|
1 | | -import { Box, Spacer, Button } from '@baca/design-system' |
2 | | -import { useTranslation } from '@baca/hooks' |
| 1 | +import { AuthUpdateDto } from '@baca/api/types' |
| 2 | +import { Box, Button, Row } from '@baca/design-system' |
3 | 3 | import { useUpdatePasswordForm } from '@baca/hooks/forms/useUpdatePasswordForm' |
| 4 | +import React from 'react' |
| 5 | +import { useTranslation } from 'react-i18next' |
4 | 6 |
|
5 | 7 | import { ProfileControlledInput } from './ProfileControlledInput' |
6 | 8 |
|
7 | | -// interface ProfilePasswordFormProps { |
8 | | -// onSubmit: (data: any) => void |
9 | | -// } |
| 9 | +interface ProfilePasswordFormProps { |
| 10 | + onSubmit: (data: AuthUpdateDto) => void |
| 11 | +} |
10 | 12 |
|
11 | 13 | export const ProfilePasswordForm = ({ onSubmit }: ProfilePasswordFormProps) => { |
12 | | - const { control, errors, isSubmitting, submit } = useUpdatePasswordForm() |
13 | 14 | const { t } = useTranslation() |
| 15 | + const { control, errors, submit, isSubmitting } = useUpdatePasswordForm() |
14 | 16 |
|
15 | 17 | 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> |
| 18 | + <Box> |
| 19 | + <Box borderColor="border.secondary" borderTopWidth={1} py={6}> |
| 20 | + <ProfileControlledInput |
| 21 | + label={t('form.labels.old_password')} |
| 22 | + name="oldPassword" |
| 23 | + placeholder={t('form.placeholders.old_password')} |
| 24 | + control={control} |
| 25 | + errors={errors} |
| 26 | + // secureTextEntry |
| 27 | + /> |
| 28 | + <ProfileControlledInput |
| 29 | + label={t('form.labels.new_password')} |
| 30 | + name="password" |
| 31 | + placeholder={t('form.placeholders.new_password')} |
| 32 | + control={control} |
| 33 | + errors={errors} |
| 34 | + // secureTextEntry |
| 35 | + /> |
| 36 | + <Row maxW={800} justifyContent="flex-end"> |
| 37 | + <Button |
| 38 | + disabled={isSubmitting} |
| 39 | + loading={isSubmitting} |
| 40 | + onPress={submit} |
| 41 | + testID="changePasswordButton" |
| 42 | + > |
| 43 | + {t('common.change')} |
| 44 | + </Button> |
| 45 | + </Row> |
| 46 | + </Box> |
38 | 47 | </Box> |
39 | 48 | ) |
40 | 49 | } |
41 | 50 |
|
| 51 | +// import { Box, Button } from '@baca/design-system' |
| 52 | +// import { useTranslation } from '@baca/hooks' |
| 53 | +// import { useUpdatePasswordForm } from '@baca/hooks/forms/useUpdatePasswordForm' |
| 54 | +// import { ProfileControlledInput } from './ProfileControlledInput' |
| 55 | +// import { AuthUpdateDto } from '@baca/api/types' |
| 56 | + |
| 57 | +// interface ProfilePasswordFormProps { |
| 58 | +// onSubmit: (data: AuthUpdateDto) => void |
| 59 | +// } |
| 60 | + |
| 61 | +// export const ProfilePasswordForm = ({ onSubmit }: ProfilePasswordFormProps) => { |
| 62 | +// const { t } = useTranslation() |
| 63 | +// const { control, errors, isSubmitting, submit } = useUpdatePasswordForm() |
| 64 | + |
| 65 | +// return ( |
| 66 | +// <Box |
| 67 | +// /* as="form" onSubmit={submit} */ borderColor="border.secondary" |
| 68 | +// borderTopWidth={1} |
| 69 | +// py={6} |
| 70 | +// > |
| 71 | +// <ProfileControlledInput |
| 72 | +// label={t('form.labels.old_password')} |
| 73 | +// name="oldPassword" |
| 74 | +// placeholder={t('form.placeholders.old_password')} |
| 75 | +// control={control} |
| 76 | +// errors={errors} |
| 77 | +// // isPassword |
| 78 | +// /> |
| 79 | +// <ProfileControlledInput |
| 80 | +// label={t('form.labels.new_password')} |
| 81 | +// name="password" |
| 82 | +// placeholder={t('form.placeholders.new_password')} |
| 83 | +// control={control} |
| 84 | +// errors={errors} |
| 85 | +// // isPassword |
| 86 | +// /> |
| 87 | +// <Button type="submit" isLoading={isSubmitting}> |
| 88 | +// {t('common.change')} |
| 89 | +// </Button> |
| 90 | +// </Box> |
| 91 | +// ) |
| 92 | +// } |
| 93 | + |
42 | 94 | // import { Box, Spacer, Button } from '@baca/design-system' |
43 | 95 | // import { useForm, Controller } from 'react-hook-form' |
44 | 96 | // import { ProfileControlledInput } from './ProfileControlledInput' |
|
0 commit comments