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 { ServerDataLoader } from '@makerkit/data-loader-supabase-nextjs';
|
||||||
|
import { Trans } from 'react-i18next';
|
||||||
|
|
||||||
import { AdminAccountsTable } from '@kit/admin/components/admin-accounts-table';
|
import { AdminAccountsTable } from '@kit/admin/components/admin-accounts-table';
|
||||||
import { AdminCreateCompanyDialog } from '@kit/admin/components/admin-create-company-dialog';
|
import { AdminCreateCompanyDialog } from '@kit/admin/components/admin-create-company-dialog';
|
||||||
@@ -38,7 +39,9 @@ async function AccountsPage(props: AdminAccountsPageProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
</AdminCreateUserDialog>
|
</AdminCreateUserDialog>
|
||||||
<AdminCreateCompanyDialog>
|
<AdminCreateCompanyDialog>
|
||||||
<Button>Create Company Account</Button>
|
<Button>
|
||||||
|
<Trans i18nKey="account:createCompanyAccount" />
|
||||||
|
</Button>
|
||||||
</AdminCreateCompanyDialog>
|
</AdminCreateCompanyDialog>
|
||||||
</div>
|
</div>
|
||||||
</PageHeader>
|
</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 { createTeamAccountsApi } from '@/packages/features/team-accounts/src/server/api';
|
||||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ interface PasswordSignUpFormProps {
|
|||||||
displayTermsCheckbox?: boolean;
|
displayTermsCheckbox?: boolean;
|
||||||
|
|
||||||
onSubmit: (params: {
|
onSubmit: (params: {
|
||||||
personalCode: string;
|
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
repeatPassword: string;
|
repeatPassword: string;
|
||||||
@@ -49,7 +48,6 @@ export function PasswordSignUpForm({
|
|||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(PasswordSignUpSchema),
|
resolver: zodResolver(PasswordSignUpSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
personalCode: '',
|
|
||||||
email: defaultValues?.email ?? '',
|
email: defaultValues?.email ?? '',
|
||||||
password: '',
|
password: '',
|
||||||
repeatPassword: '',
|
repeatPassword: '',
|
||||||
@@ -62,28 +60,6 @@ export function PasswordSignUpForm({
|
|||||||
className={'flex w-full flex-col gap-y-4'}
|
className={'flex w-full flex-col gap-y-4'}
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
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
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name={'email'}
|
name={'email'}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
import type { Provider } from '@supabase/supabase-js';
|
import type { Provider } from '@supabase/supabase-js';
|
||||||
|
|
||||||
import { isBrowser } from '@kit/shared/utils';
|
import { isBrowser } from '@kit/shared/utils';
|
||||||
@@ -11,7 +13,6 @@ import { Trans } from '@kit/ui/trans';
|
|||||||
import { MagicLinkAuthContainer } from './magic-link-auth-container';
|
import { MagicLinkAuthContainer } from './magic-link-auth-container';
|
||||||
import { OauthProviders } from './oauth-providers';
|
import { OauthProviders } from './oauth-providers';
|
||||||
import { EmailPasswordSignUpContainer } from './password-sign-up-container';
|
import { EmailPasswordSignUpContainer } from './password-sign-up-container';
|
||||||
import { redirect } from 'next/navigation';
|
|
||||||
|
|
||||||
export function SignUpMethodsContainer(props: {
|
export function SignUpMethodsContainer(props: {
|
||||||
paths: {
|
paths: {
|
||||||
@@ -40,7 +41,7 @@ export function SignUpMethodsContainer(props: {
|
|||||||
|
|
||||||
<If condition={props.providers.password}>
|
<If condition={props.providers.password}>
|
||||||
<EmailPasswordSignUpContainer
|
<EmailPasswordSignUpContainer
|
||||||
emailRedirectTo={redirectUrl}
|
emailRedirectTo={props.paths.callback}
|
||||||
defaultValues={defaultValues}
|
defaultValues={defaultValues}
|
||||||
displayTermsCheckbox={props.displayTermsCheckbox}
|
displayTermsCheckbox={props.displayTermsCheckbox}
|
||||||
onSignUp={() => redirect(redirectUrl)}
|
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';
|
import { useSignUpWithEmailAndPassword } from '@kit/supabase/hooks/use-sign-up-with-email-password';
|
||||||
|
|
||||||
type SignUpCredentials = {
|
type SignUpCredentials = {
|
||||||
personalCode: string;
|
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import { RefinedPasswordSchema, refineRepeatPassword } from './password.schema';
|
|||||||
|
|
||||||
export const PasswordSignUpSchema = z
|
export const PasswordSignUpSchema = z
|
||||||
.object({
|
.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(),
|
email: z.string().email(),
|
||||||
password: RefinedPasswordSchema,
|
password: RefinedPasswordSchema,
|
||||||
repeatPassword: RefinedPasswordSchema,
|
repeatPassword: RefinedPasswordSchema,
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { useSupabase } from './use-supabase';
|
|
||||||
import { medusaLoginOrRegister } from '../../../features/medusa-storefront/src/lib/data/customer';
|
import { medusaLoginOrRegister } from '../../../features/medusa-storefront/src/lib/data/customer';
|
||||||
|
import { useSupabase } from './use-supabase';
|
||||||
|
|
||||||
interface Credentials {
|
interface Credentials {
|
||||||
personalCode: string;
|
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
emailRedirectTo: string;
|
emailRedirectTo: string;
|
||||||
@@ -16,7 +15,7 @@ export function useSignUpWithEmailAndPassword() {
|
|||||||
const mutationKey = ['auth', 'sign-up-with-email-password'];
|
const mutationKey = ['auth', 'sign-up-with-email-password'];
|
||||||
|
|
||||||
const mutationFn = async (params: Credentials) => {
|
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
|
// TODO?: should be a validation of unique personal code before registration
|
||||||
const response = await client.auth.signUp({
|
const response = await client.auth.signUp({
|
||||||
@@ -24,9 +23,6 @@ export function useSignUpWithEmailAndPassword() {
|
|||||||
options: {
|
options: {
|
||||||
emailRedirectTo,
|
emailRedirectTo,
|
||||||
captchaToken,
|
captchaToken,
|
||||||
data: {
|
|
||||||
personalCode
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
"noTeamsYet": "You don't have any teams yet.",
|
"noTeamsYet": "You don't have any teams yet.",
|
||||||
"createTeam": "Create a team to get started.",
|
"createTeam": "Create a team to get started.",
|
||||||
"createTeamButtonLabel": "Create a Team",
|
"createTeamButtonLabel": "Create a Team",
|
||||||
"createCompanyAccount": "Create Company Account",
|
"createCompanyAccount": "Loo ettevõtte konto",
|
||||||
"requestCompanyAccount": {
|
"requestCompanyAccount": {
|
||||||
"title": "Ettevõtte andmed",
|
"title": "Ettevõtte andmed",
|
||||||
"description": "Pakkumise saamiseks palun sisesta ettevõtte andmed millega MedReport kasutada kavatsed.",
|
"description": "Pakkumise saamiseks palun sisesta ettevõtte andmed millega MedReport kasutada kavatsed.",
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
"expandSidebar": "Expand Sidebar",
|
"expandSidebar": "Expand Sidebar",
|
||||||
"collapseSidebar": "Collapse Sidebar",
|
"collapseSidebar": "Collapse Sidebar",
|
||||||
"documentation": "Documentation",
|
"documentation": "Documentation",
|
||||||
"getStarted": "Get Started",
|
"getStarted": "Alusta!",
|
||||||
"getStartedWithPlan": "Get Started with {{plan}}",
|
"getStartedWithPlan": "Get Started with {{plan}}",
|
||||||
"retry": "Retry",
|
"retry": "Retry",
|
||||||
"contactUs": "Contact Us",
|
"contactUs": "Contact Us",
|
||||||
|
|||||||
Reference in New Issue
Block a user