|
| 1 | +import { Box, Spacer, Button } from '@baca/design-system' |
| 2 | +import { useTranslation } from '@baca/hooks' |
| 3 | +import { useUpdatePasswordForm } from '@baca/hooks/forms/useUpdatePasswordForm' |
| 4 | + |
| 5 | +import { ProfileControlledInput } from './ProfileControlledInput' |
| 6 | + |
| 7 | +// interface ProfilePasswordFormProps { |
| 8 | +// onSubmit: (data: any) => void |
| 9 | +// } |
| 10 | + |
| 11 | +export const ProfilePasswordForm = ({ onSubmit }: ProfilePasswordFormProps) => { |
| 12 | + const { control, errors, isSubmitting, submit } = useUpdatePasswordForm() |
| 13 | + const { t } = useTranslation() |
| 14 | + |
| 15 | + return ( |
| 16 | + <Box as="form" onSubmit={submit}> |
| 17 | + <ProfileControlledInput |
| 18 | + label={t('form.labels.old_password')} |
| 19 | + name="oldPassword" |
| 20 | + placeholder={t('form.placeholders.old_password')} |
| 21 | + control={control} |
| 22 | + errors={errors} |
| 23 | + isPassword |
| 24 | + /> |
| 25 | + <Spacer y={4} /> |
| 26 | + <ProfileControlledInput |
| 27 | + label={t('form.labels.new_password')} |
| 28 | + name="password" |
| 29 | + placeholder={t('form.placeholders.new_password')} |
| 30 | + control={control} |
| 31 | + errors={errors} |
| 32 | + isPassword |
| 33 | + /> |
| 34 | + <Spacer y={4} /> |
| 35 | + <Button type="submit" isLoading={isSubmitting}> |
| 36 | + {t('common.change')} |
| 37 | + </Button> |
| 38 | + </Box> |
| 39 | + ) |
| 40 | +} |
| 41 | + |
| 42 | +// import { Box, Spacer, Button } from '@baca/design-system' |
| 43 | +// import { useForm, Controller } from 'react-hook-form' |
| 44 | +// import { ProfileControlledInput } from './ProfileControlledInput' |
| 45 | +// import { useTranslation } from '@baca/hooks' |
| 46 | +// import { AuthUpdateDto } from '@baca/api/types' |
| 47 | + |
| 48 | +// interface ProfilePasswordFormProps { |
| 49 | +// onSubmit: (data: AuthUpdateDto) => void |
| 50 | +// } |
| 51 | + |
| 52 | +// export const ProfilePasswordForm = ({ onSubmit }: ProfilePasswordFormProps) => { |
| 53 | +// const { |
| 54 | +// control, |
| 55 | +// handleSubmit, |
| 56 | +// formState: { errors }, |
| 57 | +// } = useForm<AuthUpdateDto>() |
| 58 | +// const { t } = useTranslation() |
| 59 | + |
| 60 | +// return ( |
| 61 | +// <Box as="form" onSubmit={handleSubmit(onSubmit)}> |
| 62 | +// <ProfileControlledInput |
| 63 | +// label={t('form.labels.old_password')} |
| 64 | +// name="oldPassword" |
| 65 | +// placeholder={t('form.placeholders.old_password')} |
| 66 | +// control={control} |
| 67 | +// errors={errors} |
| 68 | +// isPassword |
| 69 | +// /> |
| 70 | +// <Spacer y={4} /> |
| 71 | +// <ProfileControlledInput |
| 72 | +// label={t('form.labels.new_password')} |
| 73 | +// name="password" |
| 74 | +// placeholder={t('form.placeholders.new_password')} |
| 75 | +// control={control} |
| 76 | +// errors={errors} |
| 77 | +// isPassword |
| 78 | +// /> |
| 79 | +// <Spacer y={4} /> |
| 80 | +// <Button type="submit">{t('form.buttons.update_password')}</Button> |
| 81 | +// </Box> |
| 82 | +// ) |
| 83 | +// } |
0 commit comments