feat(FE-170,174): update validation messages and labels for egg product fields in RecordingForm

This commit is contained in:
rstubryan
2025-11-05 13:13:46 +07:00
parent 4454eac8af
commit fac9d5fa42
2 changed files with 61 additions and 83 deletions
@@ -109,9 +109,9 @@ const DepletionObjectSchema: Yup.ObjectSchema<DepletionSchema> = Yup.object({
const EggObjectSchema: Yup.ObjectSchema<EggSchema> = Yup.object({ const EggObjectSchema: Yup.ObjectSchema<EggSchema> = Yup.object({
product_warehouse_id: Yup.number() product_warehouse_id: Yup.number()
.required('Produk telur wajib diisi!') .required('Kondisi telur wajib diisi!')
.min(1, 'Produk telur wajib diisi!') .min(1, 'Kondisi telur wajib diisi!')
.typeError('Produk telur harus berupa angka!'), .typeError('Kondisi telur harus berupa angka!'),
qty: Yup.number() qty: Yup.number()
.required('Jumlah telur wajib diisi!') .required('Jumlah telur wajib diisi!')
.min(1, 'Jumlah telur tidak boleh 0!') .min(1, 'Jumlah telur tidak boleh 0!')
@@ -1179,86 +1179,64 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
body: 'flex flex-col gap-6', body: 'flex flex-col gap-6',
}} }}
> >
<div <div className={'grid grid-cols-3 gap-4'}>
className={ <>
type === 'detail' <SelectInput
? 'flex flex-col gap-6' key={`location-select-${selectedLocation?.value || 'default'}`}
: 'grid grid-cols-3 gap-4' required
} label='Lokasi'
> value={selectedLocation}
{(type as 'add' | 'edit' | 'detail') === 'detail' ? null : ( onChange={locationChangeHandler}
<> options={locationOptions}
<SelectInput onInputChange={setLocationSearchValue}
key={`location-select-${selectedLocation?.value || 'default'}`} isLoading={isLoadingLocations}
required placeholder='Pilih Lokasi'
label='Lokasi' isClearable
value={selectedLocation} isSearchable
onChange={locationChangeHandler} />
options={locationOptions}
onInputChange={setLocationSearchValue}
isLoading={isLoadingLocations}
placeholder='Pilih Lokasi'
isClearable
isSearchable
/>
<SelectInput <SelectInput
key={`project-flock-select-${selectedProjectFlock?.value || 'default'}`} key={`project-flock-select-${selectedProjectFlock?.value || 'default'}`}
required required
label='Project Flock' label='Project Flock'
value={selectedProjectFlock} value={selectedProjectFlock}
onChange={projectFlockChangeHandler} onChange={projectFlockChangeHandler}
options={projectFlockOptions} options={projectFlockOptions}
onInputChange={setProjectFlockSearchValue} onInputChange={setProjectFlockSearchValue}
isLoading={isLoadingProjectFlocks} isLoading={isLoadingProjectFlocks}
isDisabled={!selectedLocation} isDisabled={!selectedLocation}
placeholder={ placeholder={
selectedLocation selectedLocation
? 'Pilih Project Flock' ? 'Pilih Project Flock'
: 'Pilih Lokasi terlebih dahulu' : 'Pilih Lokasi terlebih dahulu'
} }
isClearable isClearable
isSearchable isSearchable
/> />
<SelectInput <SelectInput
key={`kandang-select-${projectFlockKandangLookup?.project_flock_kandang_id || 'default'}`} key={`kandang-select-${projectFlockKandangLookup?.project_flock_kandang_id || 'default'}`}
required required
label='Kandang' label='Kandang'
value={selectedKandang} value={selectedKandang}
onChange={kandangChangeHandler} onChange={kandangChangeHandler}
options={kandangOptions} options={kandangOptions}
isLoading={false} isLoading={false}
isDisabled={!selectedProjectFlock} isDisabled={!selectedProjectFlock}
placeholder={ placeholder={
selectedProjectFlock selectedProjectFlock
? 'Pilih Kandang' ? 'Pilih Kandang'
: 'Pilih Project Flock terlebih dahulu' : 'Pilih Project Flock terlebih dahulu'
} }
isClearable isClearable
isSearchable={false} isSearchable={false}
startAdornment={ startAdornment={
projectFlockKandangLookup projectFlockKandangLookup
? getProjectFlockBadgeAdornment() ? getProjectFlockBadgeAdornment()
: undefined : undefined
} }
/> />
</> </>
)}
{(type as 'add' | 'edit' | 'detail') === 'detail' &&
formik.values.project_flock_kandang && (
<div className='form-control'>
<label className='label'>
<span className='label-text font-semibold'>
Project Flock - Kandang
</span>
</label>
<div className='input input-bordered bg-gray-50'>
{formik.values.project_flock_kandang.label}
</div>
</div>
)}
</div> </div>
</Card> </Card>
@@ -1970,7 +1948,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
</th> </th>
)} )}
<th> <th>
Produk Telur Kondisi Telur
<span <span
className='tooltip tooltip-error tooltip-bottom z-[9999]' className='tooltip tooltip-error tooltip-bottom z-[9999]'
data-tip='required' data-tip='required'
@@ -2037,7 +2015,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
); );
}} }}
options={depletionProducts} options={depletionProducts}
placeholder='Pilih Produk Telur' placeholder='Pilih Kondisi Telur'
isLoading={isLoadingEggProducts} isLoading={isLoadingEggProducts}
isError={ isError={
isRepeaterInputError( isRepeaterInputError(