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:
Danel Kungla
2025-08-21 21:32:03 +03:00
parent 6f67a21cc1
commit cdf1491e53
9 changed files with 13 additions and 42 deletions

View File

@@ -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'}

View File

@@ -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)}

View File

@@ -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;
};

View File

@@ -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,

View File

@@ -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
}
},
});