Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 125x 125x 125x 125x | import {
useController,
type Control,
type FieldErrors,
type UseFormRegister,
} from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import { Label } from '@/components/ui/label'
import { Textarea } from '@/components/ui/textarea'
import { fieldErrorKey } from '@/shared/utils/zod-error'
import type { MilestoneFormInput } from '../api/milestones.schemas'
import { MilestonePhotoUploadField } from './MilestonePhotoUploadField'
interface MilestoneDetailFieldsProps {
register: UseFormRegister<MilestoneFormInput>
control: Control<MilestoneFormInput>
errors: FieldErrors<MilestoneFormInput>
onFileChange?: (file: File | null, preview: string | null) => void
}
export function MilestoneDetailFields({
register,
control,
errors,
onFileChange,
}: MilestoneDetailFieldsProps) {
const { t } = useTranslation()
const photoUrlErrorKey = fieldErrorKey(errors.photoUrl)
const photoUrlField = useController({ control, name: 'photoUrl' })
return (
<div className="space-y-6">
<div>
<Label htmlFor="description">{t('milestones.editor.description')}</Label>
<Textarea
id="description"
rows={3}
placeholder={t('milestones.form.descriptionPlaceholder')}
className="mt-2"
{...register('description')}
/>
</div>
<div>
<Label htmlFor="photoUrl">{t('milestones.form.photoUrlLabel')}</Label>
<MilestonePhotoUploadField
onFileChange={onFileChange}
id="photoUrl"
className="mt-2"
value={photoUrlField.field.value}
onValueChange={photoUrlField.field.onChange}
/>
{photoUrlErrorKey && <p className="text-destructive mt-1 text-sm">{t(photoUrlErrorKey)}</p>}
</div>
</div>
)
}
|