diff --git a/src/components/pages/master-data/production-standard/form/ProductionStandardForm.schema.ts b/src/components/pages/master-data/production-standard/form/ProductionStandardForm.schema.ts index 55e68039..13183e71 100644 --- a/src/components/pages/master-data/production-standard/form/ProductionStandardForm.schema.ts +++ b/src/components/pages/master-data/production-standard/form/ProductionStandardForm.schema.ts @@ -18,6 +18,7 @@ const LayingRepeaterFormSchema = Yup.object({ ), target_egg_weight: Yup.number().required('Berat telur wajib diisi!'), target_egg_mass: Yup.number().required('Massa telur wajib diisi!'), + standard_fcr: Yup.number().required('FCR wajib diisi!'), }).required(), }); @@ -35,6 +36,7 @@ const GrowingRepeaterFormSchema = Yup.object({ target_hen_house_production: Yup.number().optional(), target_egg_weight: Yup.number().optional(), target_egg_mass: Yup.number().optional(), + standard_fcr: Yup.number().optional(), }).optional(), }); diff --git a/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx b/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx index fe424838..640ded51 100644 --- a/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx +++ b/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx @@ -30,6 +30,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal'; import { useModal } from '@/components/Modal'; import RequirePermission from '@/components/helper/RequirePermission'; import Tooltip from '@/components/Tooltip'; +import Alert from '@/components/Alert'; type TableRowsType = { customRow: boolean; @@ -42,6 +43,7 @@ type ProductionDetailsErrors = { target_hen_house_production?: string; target_egg_weight?: string; target_egg_mass?: string; + standard_fcr?: string; }; type ProductionDetailsTouched = { @@ -49,6 +51,7 @@ type ProductionDetailsTouched = { target_hen_house_production?: boolean; target_egg_weight?: boolean; target_egg_mass?: boolean; + standard_fcr?: boolean; }; const getProductionDetailsError = ( @@ -92,6 +95,9 @@ const convertPayloadToNumberTypes = (payload: ProductionStandardFormValues) => { target_egg_mass: Number( detail.production_standard_details.target_egg_mass ), + standard_fcr: Number( + detail.production_standard_details.standard_fcr + ), } : undefined, production_standard_uniformity_details: { @@ -132,6 +138,9 @@ const convertStandardValueToFormValues = ( target_egg_mass: Number( detail.egg_production_standard_detail.target_egg_mass ), + standard_fcr: Number( + detail.egg_production_standard_detail.standard_fcr + ), } : undefined, production_standard_uniformity_details: { @@ -226,6 +235,7 @@ const ProductionStandardForm = ({ target_hen_house_production: '' as unknown as number, target_egg_weight: '' as unknown as number, target_egg_mass: '' as unknown as number, + standard_fcr: '' as unknown as number, }, production_standard_uniformity_details: { target_mean_bw: '' as unknown as number, @@ -364,6 +374,12 @@ const ProductionStandardForm = ({ row.production_standard_details?.target_egg_mass, enableSorting: false, }, + { + header: 'FCR', + accessorFn: (row) => + row.production_standard_details?.standard_fcr, + enableSorting: false, + }, ] : []; @@ -676,6 +692,7 @@ const ProductionStandardForm = ({ target_hen_house_production: 0, target_egg_weight: 0, target_egg_mass: 0, + standard_fcr: 0, }, })); } @@ -809,7 +826,7 @@ const ProductionStandardForm = ({ className={cn( 'grid gap-4 items-start', formik.values.project_category === 'LAYING' - ? 'grid-cols-9' + ? 'grid-cols-10' : 'grid-cols-5' )} > @@ -968,6 +985,41 @@ const ProductionStandardForm = ({ ) } /> + + gr + + } + errorMessage={getProductionDetailsError( + repeaterFormik.errors + .production_standard_details, + 'standard_fcr' + )} + isError={ + Boolean( + getProductionDetailsError( + repeaterFormik.errors + .production_standard_details, + 'standard_fcr' + ) + ) && + getProductionDetailsTouched( + repeaterFormik.touched + .production_standard_details, + 'standard_fcr' + ) + } + /> )} )} + {productionStandardFormErrorMessage && ( + +
+ + {productionStandardFormErrorMessage} +
+ setProductionStandardFormErrorMessage('')} + className='ms-auto' + /> +
+ )}