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({
product_warehouse_id: Yup.number()
.required('Produk telur wajib diisi!')
.min(1, 'Produk telur wajib diisi!')
.typeError('Produk telur harus berupa angka!'),
.required('Kondisi telur wajib diisi!')
.min(1, 'Kondisi telur wajib diisi!')
.typeError('Kondisi telur harus berupa angka!'),
qty: Yup.number()
.required('Jumlah telur wajib diisi!')
.min(1, 'Jumlah telur tidak boleh 0!')
@@ -1179,86 +1179,64 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
body: 'flex flex-col gap-6',
}}
>
<div
className={
type === 'detail'
? 'flex flex-col gap-6'
: 'grid grid-cols-3 gap-4'
}
>
{(type as 'add' | 'edit' | 'detail') === 'detail' ? null : (
<>
<SelectInput
key={`location-select-${selectedLocation?.value || 'default'}`}
required
label='Lokasi'
value={selectedLocation}
onChange={locationChangeHandler}
options={locationOptions}
onInputChange={setLocationSearchValue}
isLoading={isLoadingLocations}
placeholder='Pilih Lokasi'
isClearable
isSearchable
/>
<div className={'grid grid-cols-3 gap-4'}>
<>
<SelectInput
key={`location-select-${selectedLocation?.value || 'default'}`}
required
label='Lokasi'
value={selectedLocation}
onChange={locationChangeHandler}
options={locationOptions}
onInputChange={setLocationSearchValue}
isLoading={isLoadingLocations}
placeholder='Pilih Lokasi'
isClearable
isSearchable
/>
<SelectInput
key={`project-flock-select-${selectedProjectFlock?.value || 'default'}`}
required
label='Project Flock'
value={selectedProjectFlock}
onChange={projectFlockChangeHandler}
options={projectFlockOptions}
onInputChange={setProjectFlockSearchValue}
isLoading={isLoadingProjectFlocks}
isDisabled={!selectedLocation}
placeholder={
selectedLocation
? 'Pilih Project Flock'
: 'Pilih Lokasi terlebih dahulu'
}
isClearable
isSearchable
/>
<SelectInput
key={`project-flock-select-${selectedProjectFlock?.value || 'default'}`}
required
label='Project Flock'
value={selectedProjectFlock}
onChange={projectFlockChangeHandler}
options={projectFlockOptions}
onInputChange={setProjectFlockSearchValue}
isLoading={isLoadingProjectFlocks}
isDisabled={!selectedLocation}
placeholder={
selectedLocation
? 'Pilih Project Flock'
: 'Pilih Lokasi terlebih dahulu'
}
isClearable
isSearchable
/>
<SelectInput
key={`kandang-select-${projectFlockKandangLookup?.project_flock_kandang_id || 'default'}`}
required
label='Kandang'
value={selectedKandang}
onChange={kandangChangeHandler}
options={kandangOptions}
isLoading={false}
isDisabled={!selectedProjectFlock}
placeholder={
selectedProjectFlock
? 'Pilih Kandang'
: 'Pilih Project Flock terlebih dahulu'
}
isClearable
isSearchable={false}
startAdornment={
projectFlockKandangLookup
? getProjectFlockBadgeAdornment()
: 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>
)}
<SelectInput
key={`kandang-select-${projectFlockKandangLookup?.project_flock_kandang_id || 'default'}`}
required
label='Kandang'
value={selectedKandang}
onChange={kandangChangeHandler}
options={kandangOptions}
isLoading={false}
isDisabled={!selectedProjectFlock}
placeholder={
selectedProjectFlock
? 'Pilih Kandang'
: 'Pilih Project Flock terlebih dahulu'
}
isClearable
isSearchable={false}
startAdornment={
projectFlockKandangLookup
? getProjectFlockBadgeAdornment()
: undefined
}
/>
</>
</div>
</Card>
@@ -1970,7 +1948,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
</th>
)}
<th>
Produk Telur
Kondisi Telur
<span
className='tooltip tooltip-error tooltip-bottom z-[9999]'
data-tip='required'
@@ -2037,7 +2015,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
);
}}
options={depletionProducts}
placeholder='Pilih Produk Telur'
placeholder='Pilih Kondisi Telur'
isLoading={isLoadingEggProducts}
isError={
isRepeaterInputError(