mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
refactor(FE-208,212): rename product_warehouse to warehouse and update related schema and form handling
This commit is contained in:
@@ -18,18 +18,13 @@ type PurchaseRequestFormSchemaType = {
|
||||
label: string;
|
||||
} | null;
|
||||
location_id: number;
|
||||
warehouse?: {
|
||||
value: number;
|
||||
label: string;
|
||||
} | null;
|
||||
warehouse_id: number;
|
||||
notes: string | null;
|
||||
items: {
|
||||
product_warehouse?: {
|
||||
warehouse?: {
|
||||
value: number;
|
||||
label: string;
|
||||
} | null;
|
||||
product_warehouse_id: number;
|
||||
warehouse_id: number;
|
||||
product?: {
|
||||
value: number;
|
||||
label: string;
|
||||
@@ -40,11 +35,11 @@ type PurchaseRequestFormSchemaType = {
|
||||
};
|
||||
|
||||
export type PurchaseItemSchema = {
|
||||
product_warehouse?: {
|
||||
warehouse?: {
|
||||
value: number;
|
||||
label: string;
|
||||
} | null;
|
||||
product_warehouse_id: number;
|
||||
warehouse_id: number;
|
||||
product?: {
|
||||
value: number;
|
||||
label: string;
|
||||
@@ -55,14 +50,14 @@ export type PurchaseItemSchema = {
|
||||
|
||||
const PurchaseItemObjectSchema: Yup.ObjectSchema<PurchaseItemSchema> =
|
||||
Yup.object({
|
||||
product_warehouse: Yup.object({
|
||||
warehouse: Yup.object({
|
||||
value: Yup.number().min(1).required(),
|
||||
label: Yup.string().required(),
|
||||
}).nullable(),
|
||||
product_warehouse_id: Yup.number()
|
||||
.required('Produk wajib dipilih!')
|
||||
.min(1, 'Produk wajib dipilih!')
|
||||
.typeError('Produk wajib dipilih!'),
|
||||
warehouse_id: Yup.number()
|
||||
.required('Gudang wajib dipilih!')
|
||||
.min(1, 'Gudang wajib dipilih!')
|
||||
.typeError('Gudang wajib dipilih!'),
|
||||
product: Yup.object({
|
||||
value: Yup.number().min(1).required(),
|
||||
label: Yup.string().required(),
|
||||
@@ -107,14 +102,6 @@ export const PurchaseRequestFormSchema: Yup.ObjectSchema<PurchaseRequestFormSche
|
||||
.required('Lokasi wajib dipilih!')
|
||||
.min(1, 'Lokasi wajib dipilih!')
|
||||
.typeError('Lokasi wajib dipilih!'),
|
||||
warehouse: Yup.object({
|
||||
value: Yup.number().min(1).required(),
|
||||
label: Yup.string().required(),
|
||||
}),
|
||||
warehouse_id: Yup.number()
|
||||
.required('Gudang wajib dipilih!')
|
||||
.min(1, 'Gudang wajib dipilih!')
|
||||
.typeError('Gudang wajib dipilih!'),
|
||||
notes: Yup.string().nullable().default(null),
|
||||
items: Yup.array()
|
||||
.of(PurchaseItemObjectSchema)
|
||||
@@ -154,13 +141,6 @@ export const getPurchaseRequestFormInitialValues = (
|
||||
}
|
||||
: null,
|
||||
location_id: initialValues?.location?.id ?? 0,
|
||||
warehouse: initialValues?.warehouse
|
||||
? {
|
||||
value: initialValues.warehouse.id,
|
||||
label: initialValues.warehouse.name,
|
||||
}
|
||||
: undefined,
|
||||
warehouse_id: initialValues?.warehouse?.id ?? 0,
|
||||
notes: initialValues?.notes ?? null,
|
||||
items: [],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user