Skip to content

Commit bf817cb

Browse files
committed
ProfileControlledInputs improved
1 parent c9f6149 commit bf817cb

3 files changed

Lines changed: 25 additions & 26 deletions

File tree

src/components/screens/profile/ProfileControlledInput.tsx

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,19 @@
11
import { ControlledField } from '@baca/components'
22
import { isWeb } from '@baca/constants'
33
import { Text, Box } from '@baca/design-system'
4-
import { useTranslation, useWeb } from '@baca/hooks'
5-
import { I18nKeys } from '@baca/types/i18next'
6-
import { Control, FieldErrors } from 'react-hook-form'
7-
8-
interface ProfileControlledInputProps {
9-
labelTx: I18nKeys
10-
name: string
11-
placeholderTx: I18nKeys
12-
control: Control
13-
errors: FieldErrors
14-
isDisabled?: boolean
15-
onFocus?: () => void
16-
onSubmitEditing?: () => void
17-
}
4+
import { useWeb } from '@baca/hooks'
5+
import { ProfileControlledInputProps } from '@baca/types/ProfileInputProps'
186

197
export const ProfileControlledInput = ({
20-
labelTx,
8+
label,
219
name,
22-
placeholderTx,
10+
placeholder,
2311
control,
2412
errors,
2513
isDisabled = false,
2614
onFocus,
2715
onSubmitEditing,
2816
}: ProfileControlledInputProps) => {
29-
const { t } = useTranslation()
3017
const { shouldApplyMobileStyles } = useWeb()
3118

3219
return (
@@ -36,20 +23,20 @@ export const ProfileControlledInput = ({
3623
mb={isWeb ? 10 : 0}
3724
maxW={800}
3825
>
39-
<Text.SmBold flex={1}>{t(labelTx)}</Text.SmBold>
26+
<Text.SmBold flex={1}>{label}</Text.SmBold>
4027
<Box flex={isWeb ? 2 : 0}>
4128
<ControlledField.Input
4229
control={control}
4330
errors={errors}
4431
autoCapitalize="none"
4532
inputMode={name === 'email' ? 'email' : 'text'}
4633
name={name}
47-
placeholder={t(placeholderTx)}
34+
placeholder={placeholder}
4835
testID={`${name}Input`}
4936
isDisabled={isDisabled}
5037
onFocus={onFocus}
5138
onSubmitEditing={onSubmitEditing}
52-
{...(!isWeb && { label: t(labelTx) })}
39+
{...(!isWeb && { label })}
5340
/>
5441
</Box>
5542
</Box>

src/components/screens/profile/ProfileDetailsForm.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ export const ProfileDetailsForm = () => {
1717
<Box>
1818
<Box borderColor="border.secondary" borderTopWidth={1} py={6}>
1919
<ProfileControlledInput
20-
labelTx="form.labels.first_name"
20+
label={t('form.labels.first_name')}
2121
name="firstName"
22-
placeholderTx="form.placeholders.first_name"
22+
placeholder={t('form.placeholders.first_name')}
2323
control={control}
2424
errors={errors}
2525
onFocus={focusLastNameInput}
2626
/>
2727
<ProfileControlledInput
28-
labelTx="form.labels.last_name"
28+
label={t('form.labels.last_name')}
2929
name="lastName"
30-
placeholderTx="form.placeholders.last_name"
30+
placeholder={t('form.placeholders.last_name')}
3131
control={control}
3232
errors={errors}
3333
/>
3434
<ProfileControlledInput
35-
labelTx="form.labels.email"
35+
label={t('form.labels.email')}
3636
name="email"
37-
placeholderTx="form.placeholders.email"
37+
placeholder={t('form.placeholders.email')}
3838
control={control}
3939
errors={errors}
4040
isDisabled

src/types/ProfileInputProps.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Control, FieldErrors } from 'react-hook-form'
2+
3+
export type ProfileControlledInputProps = {
4+
label: string
5+
name: string
6+
placeholder: string
7+
control: Control
8+
errors: FieldErrors
9+
isDisabled?: boolean
10+
onFocus?: () => void
11+
onSubmitEditing?: () => void
12+
}

0 commit comments

Comments
 (0)