fix: enable custom period

This commit is contained in:
ValdiANS
2026-04-27 10:48:42 +07:00
parent ff2ed8757f
commit 4206408db1
3 changed files with 25 additions and 3 deletions
@@ -26,6 +26,7 @@ type ProjectFlockFormSchemaType = {
label: string;
} | null;
location_id: number;
period: number | string;
kandang_ids: number[];
project_budgets: ProjectFlockBudgetsSchemaType[];
};
@@ -109,6 +110,12 @@ export const ProjectFlockFormSchema: Yup.ObjectSchema<ProjectFlockFormSchemaType
.min(1, 'Lokasi wajib diisi!')
.required('Lokasi wajib diisi!'),
// Period
period: Yup.number()
.typeError('Periode harus berupa angka!')
.min(1, 'Periode minimal 1!')
.required('Periode wajib diisi!'),
kandang_ids: Yup.array()
.of(Yup.number().required('Kandang tidak valid!'))
.min(1, 'Minimal harus ada 1 kandang!')
@@ -152,6 +152,10 @@ export const ProjectFlockFormConfirmationTable = ({
label: 'Standar Produksi',
value: projectFlockForm?.production_standard?.label ?? '-',
},
{
label: 'Periode',
value: projectFlockForm?.period ?? '-',
},
{
label: 'Informasi Kandang',
value: '',
@@ -529,6 +533,7 @@ const ProjectFlockForm = ({
kandang_ids: initialValues?.kandangs?.map(
(k: Kandang) => k.id
) as number[],
period: initialValues?.period ?? '',
project_budgets: initialValues?.project_budgets?.map((budget) => {
return {
nonstock: {
@@ -568,6 +573,7 @@ const ProjectFlockForm = ({
category: values.category as string,
production_standard_id: values.production_standard_id as number,
location_id: values.location_id as number,
period: parseInt(values.period as unknown as string),
kandang_ids: values.kandang_ids as number[],
project_budgets: values.project_budgets.flatMap((budget) => {
return {
@@ -1025,10 +1031,18 @@ const ProjectFlockForm = ({
<NumberInput
name='period'
label='Periode'
disabled
readOnly
placeholder='Periode Flock'
value={selectedLocation ? inputPeriod : ''}
value={formik.values.period}
onChange={(e) =>
formik.setFieldValue('period', e.target.value)
}
onBlur={formik.handleBlur}
allowNegative={false}
decimalScale={0}
isError={
formik.touched.period && Boolean(formik.errors.period)
}
errorMessage={formik.errors.period as string}
/>
</div>
+1
View File
@@ -51,6 +51,7 @@ export type CreateProjectFlockPayload = {
category: string;
production_standard_id: number;
location_id: number;
period: number;
kandang_ids: number[];
project_budgets?: ProjectFlockBudget[];
};