From 49b245617c67de73dd902cf1b25ca0e4fb19f532 Mon Sep 17 00:00:00 2001 From: Alexander Saiannyi Date: Mon, 25 Mar 2024 15:12:57 +0100 Subject: [PATCH] feat(core): add account settings form placeholder with translations --- .changeset/happy-eggs-buy.md | 5 + .../_components/account-settings-form.tsx | 103 ++++++++++++++++++ .../[locale]/(default)/account/[tab]/page.tsx | 69 +----------- apps/core/messages/en.json | 13 +++ 4 files changed, 124 insertions(+), 66 deletions(-) create mode 100644 .changeset/happy-eggs-buy.md create mode 100644 apps/core/app/[locale]/(default)/account/[tab]/_components/account-settings-form.tsx diff --git a/.changeset/happy-eggs-buy.md b/.changeset/happy-eggs-buy.md new file mode 100644 index 000000000..c498c1553 --- /dev/null +++ b/.changeset/happy-eggs-buy.md @@ -0,0 +1,5 @@ +--- +"@bigcommerce/catalyst-core": minor +--- + +add change password for logged-in customer diff --git a/apps/core/app/[locale]/(default)/account/[tab]/_components/account-settings-form.tsx b/apps/core/app/[locale]/(default)/account/[tab]/_components/account-settings-form.tsx new file mode 100644 index 000000000..e080e78df --- /dev/null +++ b/apps/core/app/[locale]/(default)/account/[tab]/_components/account-settings-form.tsx @@ -0,0 +1,103 @@ +'use client'; + +import { Button } from '@bigcommerce/components/button'; +import { Field, FieldControl, FieldLabel, Form, FormSubmit } from '@bigcommerce/components/form'; +import { Input } from '@bigcommerce/components/input'; +import { Loader2 as Spinner } from 'lucide-react'; +import { useTranslations } from 'next-intl'; +import { useFormStatus } from 'react-dom'; + +import { Link } from '~/components/link'; + +const SubmitButton = () => { + const { pending } = useFormStatus(); + const t = useTranslations('SubmitAccountSettings'); + + return ( + + ); +}; + +export const AccountSettingsForm = () => { + const t = useTranslations('Account.AccountSettings'); + + return ( +
+ + + {t('firstName')} + + + + + + + + {t('lastName')} + + + + + + + {t('companyName')} + + + + + + {t('phone')} + + + + + + + {t('email')} + + + + + +
+ + + + + + {t('resetPassword')} + +
+
+ ); +}; diff --git a/apps/core/app/[locale]/(default)/account/[tab]/page.tsx b/apps/core/app/[locale]/(default)/account/[tab]/page.tsx index 42224cbe0..47b1121e3 100644 --- a/apps/core/app/[locale]/(default)/account/[tab]/page.tsx +++ b/apps/core/app/[locale]/(default)/account/[tab]/page.tsx @@ -3,9 +3,10 @@ import { notFound } from 'next/navigation'; import { NextIntlClientProvider } from 'next-intl'; import { getMessages, getTranslations } from 'next-intl/server'; -import { Link } from '~/components/link'; import { LocaleType } from '~/i18n'; +import { AccountSettingsForm as FormPlaceholder } from './_components/account-settings-form'; + interface Props { params: { tab: 'orders' | 'messages' | 'addresses' | 'wishlists' | 'recently-viewed' | 'settings'; @@ -19,59 +20,6 @@ export function generateMetadata({ params: { tab } }: Props): Metadata { }; } -const FormPlaceholder = () => ( -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-); - export default async function AccountTabPage({ params: { tab, locale } }: Props) { const messages = await getMessages({ locale }); const Account = messages.Account ?? {}; @@ -82,18 +30,7 @@ export default async function AccountTabPage({ params: { tab, locale } }: Props)

{t('accountSettings')}

- <> - - - {t('resetPasswordHeading')} - - +
); diff --git a/apps/core/messages/en.json b/apps/core/messages/en.json index 875168851..679c40beb 100644 --- a/apps/core/messages/en.json +++ b/apps/core/messages/en.json @@ -184,6 +184,19 @@ "createLink": "Create Account " } }, + "AccountSettings": { + "firstName": "First Name", + "lastName": "Last Name", + "companyName": "Company Name", + "phone": "Phone", + "email": "Email", + "cancel": "Cancel", + "resetPassword": "Reset Password" + }, + "SubmitAccountSettings": { + "spinnerText": "Submitting...", + "submitText": "Update settings" + }, "ChangePassword": { "currentPasswordLabel": "Current password", "newPasswordLabel": "New password",