-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add account settings form placeholder with translations
- Loading branch information
1 parent
3612dab
commit 49b2456
Showing
4 changed files
with
124 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@bigcommerce/catalyst-core": minor | ||
--- | ||
|
||
add change password for logged-in customer |
103 changes: 103 additions & 0 deletions
103
apps/core/app/[locale]/(default)/account/[tab]/_components/account-settings-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Button | ||
className="relative w-full items-center px-8 py-2 md:w-fit" | ||
data-button | ||
disabled={pending} | ||
variant="primary" | ||
> | ||
<> | ||
{pending && ( | ||
<> | ||
<span className="absolute z-10 flex h-full w-full items-center justify-center bg-gray-400"> | ||
<Spinner aria-hidden="true" className="animate-spin" /> | ||
</span> | ||
<span className="sr-only">{t('spinnerText')}</span> | ||
</> | ||
)} | ||
<span aria-hidden={pending}>{t('submitText')}</span> | ||
</> | ||
</Button> | ||
); | ||
}; | ||
|
||
export const AccountSettingsForm = () => { | ||
const t = useTranslations('Account.AccountSettings'); | ||
|
||
return ( | ||
<Form className="mb-14 flex w-full flex-wrap gap-y-4 md:py-4 lg:p-0"> | ||
<Field className="relative w-full space-y-2 pb-7 lg:w-1/2 lg:pe-2" name="first-name"> | ||
<FieldLabel htmlFor="first-name" isRequired={true}> | ||
{t('firstName')} | ||
</FieldLabel> | ||
<FieldControl asChild> | ||
<Input autoComplete="none" id="first-name" required type="text" /> | ||
</FieldControl> | ||
</Field> | ||
<Field className="relative w-full space-y-2 pb-7 lg:w-1/2 lg:ps-2" name="last-name"> | ||
<FieldLabel htmlFor="last-name" isRequired={true}> | ||
{t('lastName')} | ||
</FieldLabel> | ||
<FieldControl asChild> | ||
<Input autoComplete="none" id="last-name" required type="text" /> | ||
</FieldControl> | ||
</Field> | ||
<Field className="relative w-full space-y-2 pb-7 lg:w-1/2 lg:pe-2" name="company"> | ||
<FieldLabel htmlFor="company">{t('companyName')}</FieldLabel> | ||
<FieldControl asChild> | ||
<Input autoComplete="none" id="company" type="text" /> | ||
</FieldControl> | ||
</Field> | ||
<Field className="relative w-full space-y-2 pb-7 lg:w-1/2 lg:ps-2" name="phone"> | ||
<FieldLabel htmlFor="phone">{t('phone')}</FieldLabel> | ||
<FieldControl asChild> | ||
<Input autoComplete="none" id="phone" type="tel" /> | ||
</FieldControl> | ||
</Field> | ||
<Field className="relative w-full space-y-2 pb-7 lg:flex-grow" name="email"> | ||
<FieldLabel htmlFor="email" isRequired={true}> | ||
{t('email')} | ||
</FieldLabel> | ||
<FieldControl asChild> | ||
<Input autoComplete="none" id="email" required type="email" /> | ||
</FieldControl> | ||
</Field> | ||
<div className="flex w-full flex-col items-start gap-2 md:flex-row md:items-center md:justify-start md:gap-10"> | ||
<FormSubmit asChild> | ||
<SubmitButton /> | ||
</FormSubmit> | ||
<Button | ||
className="relative w-full items-center px-8 py-2 md:w-fit" | ||
data-button | ||
type="reset" | ||
variant="secondary" | ||
> | ||
{t('cancel')} | ||
</Button> | ||
<Link | ||
className="my-5 inline-flex w-full items-center justify-center text-primary hover:text-secondary md:my-0 md:ms-auto md:w-fit md:justify-start" | ||
href={{ | ||
pathname: '/account', | ||
query: { action: 'reset_password' }, | ||
}} | ||
> | ||
{t('resetPassword')} | ||
</Link> | ||
</div> | ||
</Form> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters