mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
fix: make depletion and egg optional
This commit is contained in:
@@ -42,7 +42,7 @@ type RecordingGrowingFormSchemaType = {
|
|||||||
product_warehouse_id?: {
|
product_warehouse_id?: {
|
||||||
value: number;
|
value: number;
|
||||||
label: string;
|
label: string;
|
||||||
};
|
} | null;
|
||||||
source_product_warehouse_id?: number;
|
source_product_warehouse_id?: number;
|
||||||
qty?: number | string;
|
qty?: number | string;
|
||||||
}[];
|
}[];
|
||||||
@@ -53,7 +53,7 @@ type RecordingLayingFormSchemaType = RecordingGrowingFormSchemaType & {
|
|||||||
product_warehouse_id?: {
|
product_warehouse_id?: {
|
||||||
value: number;
|
value: number;
|
||||||
label: string;
|
label: string;
|
||||||
};
|
} | null;
|
||||||
qty?: number | string;
|
qty?: number | string;
|
||||||
weight?: number | string;
|
weight?: number | string;
|
||||||
}[];
|
}[];
|
||||||
@@ -71,7 +71,7 @@ export type DepletionSchema = {
|
|||||||
product_warehouse_id?: {
|
product_warehouse_id?: {
|
||||||
value: number;
|
value: number;
|
||||||
label: string;
|
label: string;
|
||||||
};
|
} | null;
|
||||||
source_product_warehouse_id?: number;
|
source_product_warehouse_id?: number;
|
||||||
qty?: number | string;
|
qty?: number | string;
|
||||||
};
|
};
|
||||||
@@ -80,7 +80,7 @@ export type EggSchema = {
|
|||||||
product_warehouse_id?: {
|
product_warehouse_id?: {
|
||||||
value: number;
|
value: number;
|
||||||
label: string;
|
label: string;
|
||||||
};
|
} | null;
|
||||||
qty?: number | string;
|
qty?: number | string;
|
||||||
weight?: number | string;
|
weight?: number | string;
|
||||||
};
|
};
|
||||||
@@ -104,7 +104,7 @@ const DepletionObjectSchema: Yup.ObjectSchema<DepletionSchema> = Yup.object({
|
|||||||
label: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.typeError('Depletions harus berupa angka!'),
|
.nullable(),
|
||||||
source_product_warehouse_id: Yup.number()
|
source_product_warehouse_id: Yup.number()
|
||||||
.optional()
|
.optional()
|
||||||
.typeError('Gudang sumber harus berupa angka!'),
|
.typeError('Gudang sumber harus berupa angka!'),
|
||||||
@@ -119,7 +119,7 @@ const EggObjectSchema: Yup.ObjectSchema<EggSchema> = Yup.object({
|
|||||||
label: Yup.string().required(),
|
label: Yup.string().required(),
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.typeError('Kondisi telur harus berupa angka!'),
|
.nullable(),
|
||||||
qty: Yup.number().optional().typeError('Jumlah telur harus berupa angka!'),
|
qty: Yup.number().optional().typeError('Jumlah telur harus berupa angka!'),
|
||||||
weight: Yup.number().optional().typeError('Berat telur harus berupa angka!'),
|
weight: Yup.number().optional().typeError('Berat telur harus berupa angka!'),
|
||||||
});
|
});
|
||||||
@@ -324,7 +324,7 @@ export const getRecordingLayingFormInitialValues = (
|
|||||||
weight: egg.weight,
|
weight: egg.weight,
|
||||||
})) ?? [
|
})) ?? [
|
||||||
{
|
{
|
||||||
product_warehouse_id: undefined,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
weight: '',
|
weight: '',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1472,7 +1472,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
(productWarehouseId: number) => {
|
(productWarehouseId: number) => {
|
||||||
if ((type === 'edit' || type === 'detail') && initialValues?.stocks) {
|
if ((type === 'edit' || type === 'detail') && initialValues?.stocks) {
|
||||||
const existingStock = initialValues.stocks.find(
|
const existingStock = initialValues.stocks.find(
|
||||||
(s) => s.product_warehouse_id === productWarehouseId
|
(s) => Number(s.product_warehouse_id) === Number(productWarehouseId)
|
||||||
) as RecordingStock | undefined;
|
) as RecordingStock | undefined;
|
||||||
if (existingStock) {
|
if (existingStock) {
|
||||||
return {
|
return {
|
||||||
@@ -1731,14 +1731,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
formik.setFieldTouched('stocks', false, false);
|
formik.setFieldTouched('stocks', false, false);
|
||||||
formik.setFieldValue('stocks', [
|
formik.setFieldValue('stocks', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
formik.setFieldTouched('depletions', false, false);
|
formik.setFieldTouched('depletions', false, false);
|
||||||
formik.setFieldValue('depletions', [
|
formik.setFieldValue('depletions', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -1746,7 +1746,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
formik.setFieldTouched('eggs', false, false);
|
formik.setFieldTouched('eggs', false, false);
|
||||||
formik.setFieldValue('eggs', [
|
formik.setFieldValue('eggs', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
weight: '',
|
weight: '',
|
||||||
},
|
},
|
||||||
@@ -1795,14 +1795,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
formik.setFieldTouched('stocks', false, false);
|
formik.setFieldTouched('stocks', false, false);
|
||||||
formik.setFieldValue('stocks', [
|
formik.setFieldValue('stocks', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
formik.setFieldTouched('depletions', false, false);
|
formik.setFieldTouched('depletions', false, false);
|
||||||
formik.setFieldValue('depletions', [
|
formik.setFieldValue('depletions', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -1810,7 +1810,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
formik.setFieldTouched('eggs', false, false);
|
formik.setFieldTouched('eggs', false, false);
|
||||||
formik.setFieldValue('eggs', [
|
formik.setFieldValue('eggs', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
weight: '',
|
weight: '',
|
||||||
},
|
},
|
||||||
@@ -1848,14 +1848,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
formik.setFieldTouched('stocks', false, false);
|
formik.setFieldTouched('stocks', false, false);
|
||||||
formik.setFieldValue('stocks', [
|
formik.setFieldValue('stocks', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
formik.setFieldTouched('depletions', false, false);
|
formik.setFieldTouched('depletions', false, false);
|
||||||
formik.setFieldValue('depletions', [
|
formik.setFieldValue('depletions', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -1863,7 +1863,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
formik.setFieldTouched('eggs', false, false);
|
formik.setFieldTouched('eggs', false, false);
|
||||||
formik.setFieldValue('eggs', [
|
formik.setFieldValue('eggs', [
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
weight: '',
|
weight: '',
|
||||||
},
|
},
|
||||||
@@ -2076,7 +2076,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
const newStocks = [
|
const newStocks = [
|
||||||
...(formik.values.stocks || []),
|
...(formik.values.stocks || []),
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -2108,7 +2108,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
const newDepletions = [
|
const newDepletions = [
|
||||||
...(formik.values.depletions || []),
|
...(formik.values.depletions || []),
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -2142,7 +2142,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
const newEggs = [
|
const newEggs = [
|
||||||
...((formik.values as RecordingLayingFormValues).eggs || []),
|
...((formik.values as RecordingLayingFormValues).eggs || []),
|
||||||
{
|
{
|
||||||
product_warehouse_id: 0,
|
product_warehouse_id: null,
|
||||||
qty: '',
|
qty: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -2185,7 +2185,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
if (isLayingCategory && (type as 'add' | 'edit' | 'detail') !== 'detail') {
|
if (isLayingCategory && (type as 'add' | 'edit' | 'detail') !== 'detail') {
|
||||||
const layingValues = formik.values as RecordingLayingFormValues;
|
const layingValues = formik.values as RecordingLayingFormValues;
|
||||||
if (!layingValues.eggs || layingValues.eggs.length === 0) {
|
if (!layingValues.eggs || layingValues.eggs.length === 0) {
|
||||||
setFieldValue('eggs', [{ product_warehouse_id: 0, qty: '' }]);
|
setFieldValue('eggs', [{ product_warehouse_id: null, qty: '' }]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [isLayingCategory, type, formik.values, setFieldValue]);
|
}, [isLayingCategory, type, formik.values, setFieldValue]);
|
||||||
|
|||||||
Reference in New Issue
Block a user