11import { Box , Button , Row } from '@baca/design-system'
2- import { useUpdatePasswordForm } from '@baca/hooks/forms/useUpdatePasswordForm'
2+ import { useCallback } from '@baca/hooks'
3+ import { useUpdatePasswordForm } from '@baca/hooks/forms'
4+ import { usePasswordValidation } from '@baca/hooks/usePasswordValidation'
35import { useTranslation } from 'react-i18next'
6+ import { Keyboard } from 'react-native'
47
58import { ProfileControlledInput } from './ProfileControlledInput'
69
710export const ProfilePasswordForm = ( ) => {
811 const { t } = useTranslation ( )
9- const { control, errors, submit, isSubmitting } = useUpdatePasswordForm ( )
12+ const { control, errors, submit, isSubmitting, setFocus } = useUpdatePasswordForm ( )
13+
14+ const { isPasswordError, passwordSuggestions, validationFn } = usePasswordValidation ( )
15+
16+ const focusNewPasswordInput = useCallback ( ( ) => setFocus ( 'password' ) , [ setFocus ] )
1017
1118 return (
1219 < Box borderColor = "border.secondary" borderTopWidth = { 1 } py = { 6 } >
@@ -16,14 +23,21 @@ export const ProfilePasswordForm = () => {
1623 placeholder = { t ( 'form.placeholders.old_password' ) }
1724 control = { control }
1825 errors = { errors }
26+ onSubmitEditing = { focusNewPasswordInput }
1927 />
2028 < ProfileControlledInput
2129 label = { t ( 'form.labels.new_password' ) }
2230 name = "password"
2331 placeholder = { t ( 'form.placeholders.new_password' ) }
2432 control = { control }
25- errors = { errors }
33+ errors = { { } }
34+ isInvalid = { isPasswordError }
35+ isRequired
36+ rules = { { validate : { validationFn } } }
37+ type = "password"
38+ onSubmitEditing = { Keyboard . dismiss }
2639 />
40+ { passwordSuggestions }
2741 < Row maxW = { 800 } justifyContent = "flex-end" >
2842 < Button
2943 disabled = { isSubmitting }
0 commit comments