refactor(auth): remove personal code from sign-up flow and update related components
feat(i18n): update translations for company account creation and get started
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { ServerDataLoader } from '@makerkit/data-loader-supabase-nextjs';
|
||||
import { Trans } from 'react-i18next';
|
||||
|
||||
import { AdminAccountsTable } from '@kit/admin/components/admin-accounts-table';
|
||||
import { AdminCreateCompanyDialog } from '@kit/admin/components/admin-create-company-dialog';
|
||||
@@ -38,7 +39,9 @@ async function AccountsPage(props: AdminAccountsPageProps) {
|
||||
</Button>
|
||||
</AdminCreateUserDialog>
|
||||
<AdminCreateCompanyDialog>
|
||||
<Button>Create Company Account</Button>
|
||||
<Button>
|
||||
<Trans i18nKey="account:createCompanyAccount" />
|
||||
</Button>
|
||||
</AdminCreateCompanyDialog>
|
||||
</div>
|
||||
</PageHeader>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createAccountsApi } from '@/packages/features/accounts/src/server/api';
|
||||
import { createTeamAccountsApi } from '@/packages/features/team-accounts/src/server/api';
|
||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ interface PasswordSignUpFormProps {
|
||||
displayTermsCheckbox?: boolean;
|
||||
|
||||
onSubmit: (params: {
|
||||
personalCode: string;
|
||||
email: string;
|
||||
password: string;
|
||||
repeatPassword: string;
|
||||
@@ -49,7 +48,6 @@ export function PasswordSignUpForm({
|
||||
const form = useForm({
|
||||
resolver: zodResolver(PasswordSignUpSchema),
|
||||
defaultValues: {
|
||||
personalCode: '',
|
||||
email: defaultValues?.email ?? '',
|
||||
password: '',
|
||||
repeatPassword: '',
|
||||
@@ -62,28 +60,6 @@ export function PasswordSignUpForm({
|
||||
className={'flex w-full flex-col gap-y-4'}
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={'personalCode'}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
<Trans i18nKey={'common:personalCode'} />
|
||||
</FormLabel>
|
||||
|
||||
<FormControl>
|
||||
<Input
|
||||
data-test={'personal-code-input'}
|
||||
required
|
||||
type="text"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={'email'}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import type { Provider } from '@supabase/supabase-js';
|
||||
|
||||
import { isBrowser } from '@kit/shared/utils';
|
||||
@@ -11,7 +13,6 @@ import { Trans } from '@kit/ui/trans';
|
||||
import { MagicLinkAuthContainer } from './magic-link-auth-container';
|
||||
import { OauthProviders } from './oauth-providers';
|
||||
import { EmailPasswordSignUpContainer } from './password-sign-up-container';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export function SignUpMethodsContainer(props: {
|
||||
paths: {
|
||||
@@ -40,7 +41,7 @@ export function SignUpMethodsContainer(props: {
|
||||
|
||||
<If condition={props.providers.password}>
|
||||
<EmailPasswordSignUpContainer
|
||||
emailRedirectTo={redirectUrl}
|
||||
emailRedirectTo={props.paths.callback}
|
||||
defaultValues={defaultValues}
|
||||
displayTermsCheckbox={props.displayTermsCheckbox}
|
||||
onSignUp={() => redirect(redirectUrl)}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { useAppEvents } from '@kit/shared/events';
|
||||
import { useSignUpWithEmailAndPassword } from '@kit/supabase/hooks/use-sign-up-with-email-password';
|
||||
|
||||
type SignUpCredentials = {
|
||||
personalCode: string;
|
||||
email: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
@@ -4,9 +4,6 @@ import { RefinedPasswordSchema, refineRepeatPassword } from './password.schema';
|
||||
|
||||
export const PasswordSignUpSchema = z
|
||||
.object({
|
||||
personalCode: z.string().regex(/^[1-6]\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}\d$/, {
|
||||
message: 'Invalid Estonian personal code format',
|
||||
}),
|
||||
email: z.string().email(),
|
||||
password: RefinedPasswordSchema,
|
||||
repeatPassword: RefinedPasswordSchema,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
|
||||
import { useSupabase } from './use-supabase';
|
||||
import { medusaLoginOrRegister } from '../../../features/medusa-storefront/src/lib/data/customer';
|
||||
import { useSupabase } from './use-supabase';
|
||||
|
||||
interface Credentials {
|
||||
personalCode: string;
|
||||
email: string;
|
||||
password: string;
|
||||
emailRedirectTo: string;
|
||||
@@ -16,17 +15,14 @@ export function useSignUpWithEmailAndPassword() {
|
||||
const mutationKey = ['auth', 'sign-up-with-email-password'];
|
||||
|
||||
const mutationFn = async (params: Credentials) => {
|
||||
const { emailRedirectTo, captchaToken, personalCode, ...credentials } = params;
|
||||
|
||||
const { emailRedirectTo, captchaToken, ...credentials } = params;
|
||||
|
||||
// TODO?: should be a validation of unique personal code before registration
|
||||
const response = await client.auth.signUp({
|
||||
...credentials,
|
||||
options: {
|
||||
emailRedirectTo,
|
||||
captchaToken,
|
||||
data: {
|
||||
personalCode
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
"noTeamsYet": "You don't have any teams yet.",
|
||||
"createTeam": "Create a team to get started.",
|
||||
"createTeamButtonLabel": "Create a Team",
|
||||
"createCompanyAccount": "Create Company Account",
|
||||
"createCompanyAccount": "Loo ettevõtte konto",
|
||||
"requestCompanyAccount": {
|
||||
"title": "Ettevõtte andmed",
|
||||
"description": "Pakkumise saamiseks palun sisesta ettevõtte andmed millega MedReport kasutada kavatsed.",
|
||||
@@ -149,4 +149,4 @@
|
||||
"updateRoleSuccess": "Roll uuendatud",
|
||||
"updateRoleError": "Midagi läks valesti. Palun proovi uuesti",
|
||||
"updateRoleLoading": "Rolli uuendatakse..."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"expandSidebar": "Expand Sidebar",
|
||||
"collapseSidebar": "Collapse Sidebar",
|
||||
"documentation": "Documentation",
|
||||
"getStarted": "Get Started",
|
||||
"getStarted": "Alusta!",
|
||||
"getStartedWithPlan": "Get Started with {{plan}}",
|
||||
"retry": "Retry",
|
||||
"contactUs": "Contact Us",
|
||||
|
||||
Reference in New Issue
Block a user