mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-208,213): streamline PurchaseOrderAcceptApprovalForm by removing hardcoded warehouse options and utilizing initialValues for dynamic data
This commit is contained in:
@@ -220,77 +220,32 @@ const PurchaseOrderAcceptApprovalForm = ({
|
||||
}));
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
value: 1,
|
||||
label: 'SEALYTE SPARK 1 x 87 gr (14 SACHET)',
|
||||
id: 1,
|
||||
quantity: 14,
|
||||
product: {
|
||||
name: 'SEALYTE SPARK 1 x 87 gr',
|
||||
product_category: 'Bahan Baku',
|
||||
uom: {
|
||||
name: 'SACHET',
|
||||
},
|
||||
},
|
||||
warehouse: {
|
||||
name: 'GUDANG CIANGSANA 1 (ARCA P15)',
|
||||
},
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: 'CID-2000 @ 5 KG (2 KILOGRAM)',
|
||||
id: 2,
|
||||
quantity: 2,
|
||||
product: {
|
||||
name: 'CID-2000 @ 5 KG',
|
||||
product_category: 'Bahan Baku',
|
||||
uom: {
|
||||
name: 'Kilogram',
|
||||
},
|
||||
},
|
||||
warehouse: {
|
||||
name: 'GUDANG CIANGSANA 2 (ARCA P15)',
|
||||
},
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
label: 'VITAMIN AYAM (10 DOSIS)',
|
||||
id: 3,
|
||||
quantity: 10,
|
||||
product: {
|
||||
name: 'VITAMIN AYAM',
|
||||
product_category: 'Bahan Baku',
|
||||
uom: {
|
||||
name: 'DOSIS',
|
||||
},
|
||||
},
|
||||
warehouse: {
|
||||
name: 'GUDANG CIANGSANA 3 (ARCA P15)',
|
||||
},
|
||||
},
|
||||
];
|
||||
}, [initialValues?.items, searchParams]);
|
||||
return [];
|
||||
}, [initialValues?.items]);
|
||||
|
||||
const warehouses: WarehouseOptionType[] = useMemo(
|
||||
() => [
|
||||
{ value: 1, label: 'GUDANG CIANGSANA 1 (ARCA P15)', id: 1 },
|
||||
{ value: 2, label: 'GUDANG CIANGSANA 2 (ARCA P15)', id: 2 },
|
||||
{ value: 3, label: 'GUDANG CIANGSANA 3 (ARCA P15)', id: 3 },
|
||||
{ value: 7, label: 'GUDANG UTAMA', id: 7 },
|
||||
],
|
||||
[]
|
||||
);
|
||||
const warehouses: WarehouseOptionType[] = useMemo(() => {
|
||||
if (initialValues?.items) {
|
||||
const uniqueWarehouses = new Map();
|
||||
|
||||
const expeditionVendors: ExpeditionVendorOptionType[] = useMemo(
|
||||
() => [
|
||||
{ value: 1, label: 'JNE Express', id: 1 },
|
||||
{ value: 2, label: 'J&T Express', id: 2 },
|
||||
{ value: 3, label: 'SiCepat Express', id: 3 },
|
||||
{ value: 4, label: 'Anteraja', id: 4 },
|
||||
],
|
||||
[]
|
||||
);
|
||||
initialValues.items.forEach((item) => {
|
||||
if (item.warehouse && !uniqueWarehouses.has(item.warehouse.id)) {
|
||||
uniqueWarehouses.set(item.warehouse.id, {
|
||||
value: item.warehouse.id,
|
||||
label: item.warehouse.name,
|
||||
id: item.warehouse.id,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return Array.from(uniqueWarehouses.values());
|
||||
}
|
||||
|
||||
return [];
|
||||
}, [initialValues?.items]);
|
||||
|
||||
const expeditionVendors: ExpeditionVendorOptionType[] = useMemo(() => {
|
||||
return [];
|
||||
}, []);
|
||||
|
||||
const getPurchaseItemOptions = useCallback(() => {
|
||||
return purchaseItems;
|
||||
|
||||
@@ -773,6 +773,7 @@ const PurchaseOrderDetail = ({
|
||||
>
|
||||
<PurchaseOrderAcceptApprovalForm
|
||||
type='add'
|
||||
initialValues={purchaseData}
|
||||
onCancel={acceptApprovalModal.closeModal}
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
@@ -41,7 +41,7 @@ const pdfStyles = StyleSheet.create({
|
||||
fontSize: 12,
|
||||
fontWeight: 'bold',
|
||||
marginBottom: 4,
|
||||
color: '#1f74bf', // Primary color from globals.css
|
||||
color: '#1f74bf',
|
||||
},
|
||||
address: {
|
||||
fontSize: 8,
|
||||
@@ -65,7 +65,7 @@ const pdfStyles = StyleSheet.create({
|
||||
fontSize: 18,
|
||||
fontWeight: 'bold',
|
||||
flex: 3,
|
||||
color: '#1f74bf', // Primary color
|
||||
color: '#1f74bf',
|
||||
},
|
||||
poInfo: {
|
||||
flex: 1,
|
||||
@@ -76,7 +76,7 @@ const pdfStyles = StyleSheet.create({
|
||||
fontSize: 12,
|
||||
fontWeight: 'bold',
|
||||
marginBottom: 8,
|
||||
color: '#1f74bf', // Primary color
|
||||
color: '#1f74bf',
|
||||
},
|
||||
table: {
|
||||
borderWidth: 1,
|
||||
|
||||
Reference in New Issue
Block a user