diff --git a/core/app/[locale]/(default)/(auth)/register/_actions/register-customer.ts b/core/app/[locale]/(default)/(auth)/register/_actions/register-customer.ts index 920723743..20183524f 100644 --- a/core/app/[locale]/(default)/(auth)/register/_actions/register-customer.ts +++ b/core/app/[locale]/(default)/(auth)/register/_actions/register-customer.ts @@ -7,6 +7,8 @@ import { client } from '~/client'; import { graphql, VariablesOf } from '~/client/graphql'; import { parseRegisterCustomerFormData } from '~/components/form-fields/shared/parse-fields'; +import { createErrorsList } from '../../../account/(tabs)/_components/utils'; + const RegisterCustomerMutation = graphql(` mutation RegisterCustomer($input: RegisterCustomerInput!, $reCaptchaV2: ReCaptchaV2Input) { customer { @@ -84,7 +86,7 @@ export const registerCustomer = async ({ formData, reCaptchaToken }: RegisterCus return { status: 'error', - error: result.errors.map((error) => error.message).join('\n'), + error: createErrorsList(result.errors), }; } catch (error) { // eslint-disable-next-line no-console diff --git a/core/app/[locale]/(default)/(auth)/register/_components/register-customer-form.tsx b/core/app/[locale]/(default)/(auth)/register/_components/register-customer-form.tsx index 5a11dbd6e..684629f77 100644 --- a/core/app/[locale]/(default)/(auth)/register/_components/register-customer-form.tsx +++ b/core/app/[locale]/(default)/(auth)/register/_components/register-customer-form.tsx @@ -242,7 +242,7 @@ export const RegisterCustomerForm = ({ return ( <> {formStatus && ( - +

{formStatus.message}

)} diff --git a/core/app/[locale]/(default)/account/(tabs)/_components/utils.ts b/core/app/[locale]/(default)/account/(tabs)/_components/utils.ts new file mode 100644 index 000000000..1c57f3216 --- /dev/null +++ b/core/app/[locale]/(default)/account/(tabs)/_components/utils.ts @@ -0,0 +1,15 @@ +interface GenericError { + [p: string]: string | string[]; + message: string; +} + +export const createErrorsList = (submitErrors: GenericError[]) => + submitErrors + .map((error) => { + if (submitErrors.length > 1) { + return `\u2022 ${error.message}`; + } + + return error.message; + }) + .join('\n');