umwd-components 0.1.798 → 0.1.800
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/AddIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/iro/updateIroAction.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/opo/createOpoAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/ipo/createIPOAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/ipo/updateIpoAction.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +6 -3
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +41 -35
- package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +2 -2
- package/dist/esm/src/components/logistics/ipo/AddIPOForm.js +0 -1
- package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +8 -5
- package/dist/esm/src/data/actions/e-commerce/iro/updateIroAction.js +3 -3
- package/dist/esm/src/data/actions/e-commerce/opo/createOpoAction.js +0 -1
- package/dist/esm/src/data/actions/logistics/ipo/createIPOAction.js +0 -1
- package/dist/esm/src/data/actions/logistics/ipo/updateIpoAction.js +0 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ function TextualIroItemUpdater({ item, index, handleAddReport, handleUpdateQuant
|
|
|
44
44
|
[];
|
|
45
45
|
return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsxs(Typography, { variant: "body1", children: ["Reason: ", reason, reason === "other" &&
|
|
46
46
|
other_reason !== undefined &&
|
|
47
|
-
`, ${other_reason}`] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: returned_quantity, minnewvalue: 0
|
|
47
|
+
`, ${other_reason}`] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: returned_quantity, minnewvalue: 0, maxnewvalue: returned_quantity, color: "info", handleChange: (newValue) => {
|
|
48
48
|
handleUpdateQuantity(newValue, item.documentId, "received_quantity");
|
|
49
49
|
} })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("registered") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Registered" }), jsx(TextualAmountUpdater, { label: "Registered", currentValue: registered_quantity, totalValue: returned_quantity + registered_reports_quantity, minnewvalue: 0 + released_quantity, maxnewvalue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
|
|
50
50
|
handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
|
|
@@ -274,6 +274,7 @@ revalidateCallback, handleClose, role, }) {
|
|
|
274
274
|
released_quantity: item.released_quantity,
|
|
275
275
|
reports: item.reports?.map((report) => {
|
|
276
276
|
return {
|
|
277
|
+
id: "id" in report ? report.id : undefined,
|
|
277
278
|
documentId: "documentId" in report ? report.documentId : undefined,
|
|
278
279
|
quantity: report.quantity,
|
|
279
280
|
content: report.content,
|
|
@@ -307,14 +308,15 @@ revalidateCallback, handleClose, role, }) {
|
|
|
307
308
|
const newItems = [...items];
|
|
308
309
|
const itemIndex = newItems.findIndex((item) => item.documentId === itemID);
|
|
309
310
|
const reportsOnItem = newItems[itemIndex]?.reports || [];
|
|
310
|
-
const dbReports = reportsOnItem.filter((report) => "
|
|
311
|
-
const preReports = reportsOnItem.filter((report) => !("
|
|
311
|
+
const dbReports = reportsOnItem.filter((report) => "documentId" in report);
|
|
312
|
+
const preReports = reportsOnItem.filter((report) => !("documentId" in report));
|
|
312
313
|
preReports.splice(index, 1);
|
|
313
314
|
const newReports = [...dbReports, ...preReports];
|
|
314
315
|
newItems[itemIndex].reports = newReports;
|
|
315
316
|
setItems(newItems);
|
|
316
317
|
};
|
|
317
318
|
const { handleAddMessage } = useSnackbar();
|
|
319
|
+
// Message handling
|
|
318
320
|
useEffect(() => {
|
|
319
321
|
if (formState?.message) {
|
|
320
322
|
handleAddMessage({
|
|
@@ -327,6 +329,7 @@ revalidateCallback, handleClose, role, }) {
|
|
|
327
329
|
}
|
|
328
330
|
}
|
|
329
331
|
}, [formState?.message]);
|
|
332
|
+
// Error handling
|
|
330
333
|
useEffect(() => {
|
|
331
334
|
if (formState?.strapiErrors) {
|
|
332
335
|
handleAddMessage({
|
|
@@ -335,8 +338,8 @@ revalidateCallback, handleClose, role, }) {
|
|
|
335
338
|
});
|
|
336
339
|
}
|
|
337
340
|
}, [formState?.strapiErrors]);
|
|
341
|
+
// Items state update
|
|
338
342
|
useEffect(() => {
|
|
339
|
-
console.log("data", data);
|
|
340
343
|
if (data.iro_items) {
|
|
341
344
|
setItems(data.iro_items ? data.iro_items : []);
|
|
342
345
|
}
|
|
@@ -82,41 +82,13 @@ function CancelOpoDialog({ open, handleClose, orderID, revalidateCallback, }) {
|
|
|
82
82
|
return (jsxs(Dialog, { open: open, onClose: handleClose, children: [jsx(DialogTitle, { children: "Cancel Return" }), jsx(DialogContent, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { children: "Are you sure you want to cancel this order?" }), jsxs(List, { children: [jsx(ListItem, { children: "By cancelling this order you will update it's status from ordered to cancelled" }), jsx(ListItem, { children: "Please provide a reason for the cancellation" }), jsx(ListItem, { children: "The customer will be notified about the cancellation and of the reason for the cancellation" })] }), jsx(TextField, { label: "Cancellation reason", name: "reason", multiline: true, rows: 4, fullWidth: true, variant: "outlined", value: reason, onChange: (e) => setRoason(e.target.value), placeholder: "Please provide a reason for the cancellation", error: !!reasonError, helperText: reasonError })] }) }), jsxs(DialogActions, { children: [jsx(Button, { variant: "outlined", onClick: handleClose, children: "Close" }), jsx(Button, { variant: "contained", color: "error", onClick: handleCancel, children: "Confirm Cancellation" })] })] }));
|
|
83
83
|
}
|
|
84
84
|
function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role, }) {
|
|
85
|
+
// Bind documentId to the action
|
|
85
86
|
const updateOpoWithIdAction = updateOpoAction.bind(null, opo.documentId);
|
|
86
87
|
const [formState, formAction] = useActionState(updateOpoWithIdAction, INITIAL_STATE);
|
|
87
|
-
const { handleAddMessage } = useSnackbar();
|
|
88
88
|
const [items, setItems] = useState(opo.opo_items ? opo.opo_items : []);
|
|
89
89
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
90
90
|
const [cancelDialogOpen, setCancelDialogOpen] = useState(false);
|
|
91
91
|
const [showing, setShowing] = useState(["picked", "packed", "shipped", "reports"]);
|
|
92
|
-
// Message handling
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (formState?.message) {
|
|
95
|
-
handleAddMessage({
|
|
96
|
-
message: formState.message,
|
|
97
|
-
severity: formState.severity || "info",
|
|
98
|
-
});
|
|
99
|
-
if (formState.severity === "success") {
|
|
100
|
-
revalidateCallback?.();
|
|
101
|
-
handleClose?.();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, [formState?.message]);
|
|
105
|
-
// Error handling
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
if (formState?.strapiErrors) {
|
|
108
|
-
handleAddMessage({
|
|
109
|
-
message: formState.strapiErrors.message || "Error updating OPO",
|
|
110
|
-
severity: "error",
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}, [formState?.strapiErrors]);
|
|
114
|
-
// Items state update
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
if (opo.opo_items) {
|
|
117
|
-
setItems(opo.opo_items ? opo.opo_items : []);
|
|
118
|
-
}
|
|
119
|
-
}, [opo]);
|
|
120
92
|
const parseItems = (items) => {
|
|
121
93
|
return items.map((item) => {
|
|
122
94
|
return {
|
|
@@ -161,33 +133,67 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
|
|
|
161
133
|
const newItems = [...items];
|
|
162
134
|
const itemIndex = newItems.findIndex((item) => item.documentId === itemID);
|
|
163
135
|
const reportsOnItem = newItems[itemIndex]?.reports || [];
|
|
164
|
-
const dbReports = reportsOnItem.filter((report) => "
|
|
165
|
-
const preReports = reportsOnItem.filter((report) => !("
|
|
136
|
+
const dbReports = reportsOnItem.filter((report) => "id" in report);
|
|
137
|
+
const preReports = reportsOnItem.filter((report) => !("id" in report));
|
|
166
138
|
preReports.splice(index, 1);
|
|
167
139
|
const newReports = [...dbReports, ...preReports];
|
|
168
140
|
newItems[itemIndex].reports = newReports;
|
|
169
141
|
setItems(newItems);
|
|
170
142
|
};
|
|
171
|
-
|
|
143
|
+
const { handleAddMessage } = useSnackbar();
|
|
144
|
+
// Message handling
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (formState?.message) {
|
|
147
|
+
handleAddMessage({
|
|
148
|
+
message: formState.message,
|
|
149
|
+
severity: formState.severity || "error",
|
|
150
|
+
});
|
|
151
|
+
if (formState.severity === "success") {
|
|
152
|
+
revalidateCallback && revalidateCallback();
|
|
153
|
+
handleClose && handleClose();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, [formState?.message]);
|
|
157
|
+
// Error handling
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (formState?.strapiErrors) {
|
|
160
|
+
handleAddMessage({
|
|
161
|
+
message: formState.strapiErrors.message || "Error updating OPO",
|
|
162
|
+
severity: formState.severity || "error",
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}, [formState?.strapiErrors]);
|
|
166
|
+
// Items state update
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (opo.opo_items) {
|
|
169
|
+
setItems(opo.opo_items ? opo.opo_items : []);
|
|
170
|
+
}
|
|
171
|
+
}, [opo]);
|
|
172
|
+
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Outbound Sales Order" }), jsx(Typography, { variant: "body1", children: "Manage picking, packing and shipping of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [
|
|
172
173
|
{ id: opo.documentId, __type: "api::e-commerce.opo" },
|
|
173
174
|
], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { size: 12, children: jsx(Typography, { variant: "h5", sx: { py: 1 }, children: "Details" }) }), jsx(Grid, { size: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(NumbersIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.opo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Custom reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(CalendarTodayIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: opo.customer?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(UpdateIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Status" }), jsx(OpoStatusIndicator, { status: opo.internal_status })] })] }) }) }), role === "enduser" && (jsx(Grid, { size: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [(opo.internal_status === "placed" ||
|
|
174
175
|
opo.internal_status === "external_shipping_process") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: opo.documentId, currentStatus: opo.internal_status, revalidateCallback: revalidateCallback })] })), (opo.internal_status === "placed" ||
|
|
175
176
|
opo.internal_status === "ordered") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(CancelOpoDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: opo.documentId, revalidateCallback: revalidateCallback })] }))] }) }) })), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1, children: opo.delivery_note ? (jsxs(Fragment, { children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { children: opo.delivery_note?.name }), jsx(Button, { variant: "contained", onClick: () => {
|
|
176
177
|
downloadBase64File(`api/opos/${opo.documentId}`, "delivery_note");
|
|
177
|
-
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::e-commerce.opo", refID: opo.documentId, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) }) })] }) }), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Minio Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(UploadMinioMediaForm, { reference: "api::e-commerce.opo", refID: opo.documentId, field: "minio", multiple: false, revalidateCallback: revalidateCallback }) })] }) }), opo?.notes?.length > 0 && (jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: opo.notes }), jsx(Divider, {})] }) })), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1,
|
|
178
|
+
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::e-commerce.opo", refID: opo.documentId, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) }) })] }) }), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Minio Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(UploadMinioMediaForm, { reference: "api::e-commerce.opo", refID: opo.documentId, field: "minio", multiple: false, revalidateCallback: revalidateCallback }) })] }) }), opo?.notes?.length > 0 && (jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: opo.notes }), jsx(Divider, {})] }) })), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1, sx: {
|
|
179
|
+
bgcolor: "background.default",
|
|
180
|
+
border: "1px solid",
|
|
181
|
+
borderColor: "divider",
|
|
182
|
+
boxShadow: "none",
|
|
183
|
+
}, children: [jsx(Typography, { variant: "body2", color: "text.secondary", children: "Show:" }), options.map((option) => (jsx(FormControlLabel, { control: jsx(Checkbox, { size: "small", checked: showing.includes(option), onChange: (e) => {
|
|
178
184
|
if (e.target.checked) {
|
|
179
185
|
setShowing([...showing, option]);
|
|
180
186
|
}
|
|
181
187
|
else {
|
|
182
188
|
setShowing(showing.filter((item) => item !== option));
|
|
183
189
|
}
|
|
184
|
-
} }), label: option.charAt(0).toUpperCase() + option.slice(1) }, option)))] }), opo.internal_status === "placed" && (jsx(Alert, { severity: "warning", children: "Before confirmation you cannot update the items" })), jsx(Divider, {}), jsxs("form", { action: formAction, children: [jsx("input", { type: "hidden", name: "items", value: JSON.stringify(parseItems(items)) }), items &&
|
|
190
|
+
} }), label: jsx(Typography, { variant: "body2", color: "text.secondary", children: option.charAt(0).toUpperCase() + option.slice(1) }), sx: { mr: 0 } }, option)))] }), opo.internal_status === "placed" && (jsx(Alert, { severity: "warning", children: "Before confirmation you cannot update the items" })), jsx(Divider, {}), jsxs("form", { action: formAction, children: [jsx("input", { type: "hidden", name: "items", value: JSON.stringify(parseItems(items)) }), items &&
|
|
185
191
|
items.map((item, index) => {
|
|
186
192
|
return (jsx(Paper, { sx: { p: 2, mb: 2 }, children: opo.internal_status === "placed" ||
|
|
187
193
|
opo.internal_status === "external_shipping_process" ||
|
|
188
194
|
opo.internal_status === "done" ||
|
|
189
195
|
opo.internal_status === "cancelled" ? (jsx(OpoItemDisplay, { item: item, index: index, image: item?.product?.image })) : (jsx(TextualOpoItemUpdater, { item: item, index: index, handleUpdateQuantity: handleUpdateQuantity, handleAddReport: handleAddReport, image: item?.product?.image, handleRemoveReportAtIndex: handleRemoveReportAtIndex, revalidateCallback: revalidateCallback, showing: showing })) }, index));
|
|
190
|
-
}),
|
|
196
|
+
}), jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { pt: 2 }, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Close" })), opo.internal_status !== "placed" &&
|
|
191
197
|
opo.internal_status !== "external_shipping_process" &&
|
|
192
198
|
opo.internal_status !== "done" &&
|
|
193
199
|
opo.internal_status !== "cancelled" && (jsx(SubmitButton, { text: "Update items", loadingText: "Saving...", variant: "contained" }))] })] })] }) })] }) }));
|
|
@@ -23,7 +23,7 @@ function TextualOpoItemUpdater({ item, index, handleAddReport, handleUpdateQuant
|
|
|
23
23
|
const { line_item_number, product, ordered_quantity, picked_quantity, packed_quantity, shipped_quantity, reports, } = item;
|
|
24
24
|
const [open, setOpen] = useState(false);
|
|
25
25
|
// these values where wrapped with useMemo before but that did not work well while updating values
|
|
26
|
-
Array.isArray(reports) && reports.length > 0
|
|
26
|
+
const picked_reports_quantity = Array.isArray(reports) && reports.length > 0
|
|
27
27
|
? reports
|
|
28
28
|
.filter((report) => report.type === "picked")
|
|
29
29
|
.reduce((a, b) => a + b.quantity, 0)
|
|
@@ -41,7 +41,7 @@ function TextualOpoItemUpdater({ item, index, handleAddReport, handleUpdateQuant
|
|
|
41
41
|
const dbReports = item.reports?.filter((report) => "id" in report) || [];
|
|
42
42
|
const preReports = item.reports?.filter((report) => Boolean("id" in report) === false) ||
|
|
43
43
|
[];
|
|
44
|
-
return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("picked") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Picked" }), jsx(TextualAmountUpdater, { label: "Picked", currentValue: picked_quantity, totalValue: ordered_quantity, minnewvalue: 0
|
|
44
|
+
return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("picked") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Picked" }), jsx(TextualAmountUpdater, { label: "Picked", currentValue: picked_quantity, totalValue: ordered_quantity, minnewvalue: 0, maxnewvalue: ordered_quantity + picked_reports_quantity, color: "info", handleChange: (newValue) => {
|
|
45
45
|
handleUpdateQuantity(newValue, item.documentId, "picked_quantity");
|
|
46
46
|
} })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("packed") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Packed" }), jsx(TextualAmountUpdater, { label: "Packed", currentValue: packed_quantity, totalValue: ordered_quantity + packed_reports_quantity, minnewvalue: 0 + shipped_quantity, maxnewvalue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
|
|
47
47
|
handleUpdateQuantity(newValue, item.documentId, "packed_quantity");
|
|
@@ -65,7 +65,6 @@ function AddIPOForm({ vendorNamesArr, sx, revalidateCallback, handleClose, }) {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
const vendor = await getSingleVendor(selectedVendorID);
|
|
68
|
-
console.log("vendor", vendor);
|
|
69
68
|
const vendorProducts = vendor?.products.filter((product) => !product.product_number.startsWith("r")) || [];
|
|
70
69
|
setProductsArr(vendorProducts);
|
|
71
70
|
};
|
|
@@ -42,7 +42,7 @@ function TextualIPOItemUpdater({ item, index, handleAddReport, handleUpdateQuant
|
|
|
42
42
|
[];
|
|
43
43
|
const preReports = item.reports?.filter((report) => !("documentId" in report)) ||
|
|
44
44
|
[];
|
|
45
|
-
return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: ordered_quantity, minnewvalue: 0
|
|
45
|
+
return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: ordered_quantity, minnewvalue: 0, maxnewvalue: ordered_quantity, color: "info", handleChange: (newValue) => {
|
|
46
46
|
handleUpdateQuantity(newValue, item.documentId, "received_quantity");
|
|
47
47
|
} })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("registered") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Registered" }), jsx(TextualAmountUpdater, { label: "Registered", currentValue: registered_quantity, totalValue: ordered_quantity + registered_reports_quantity, minnewvalue: 0 + released_quantity, maxnewvalue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
|
|
48
48
|
handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
|
|
@@ -140,6 +140,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
140
140
|
released_quantity: item.released_quantity,
|
|
141
141
|
reports: item.reports?.map((report) => {
|
|
142
142
|
return {
|
|
143
|
+
id: "id" in report ? report.id : undefined,
|
|
143
144
|
documentId: "documentId" in report ? report.documentId : undefined,
|
|
144
145
|
quantity: report.quantity,
|
|
145
146
|
content: report.content,
|
|
@@ -186,10 +187,12 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
186
187
|
message: "Ipo Updated",
|
|
187
188
|
severity: "success",
|
|
188
189
|
});
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
if (formState.severity === "success") {
|
|
191
|
+
revalidateCallback && revalidateCallback();
|
|
192
|
+
handleClose && handleClose();
|
|
193
|
+
}
|
|
191
194
|
}
|
|
192
|
-
}, [formState]);
|
|
195
|
+
}, [formState?.message]);
|
|
193
196
|
useEffect(() => {
|
|
194
197
|
if (formState?.strapiErrors) {
|
|
195
198
|
handleAddMessage({
|
|
@@ -223,12 +226,12 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
223
226
|
else {
|
|
224
227
|
setShowing(showing.filter((item) => item !== option));
|
|
225
228
|
}
|
|
226
|
-
} }), label: jsx(Typography, { variant: "body2", color: "text.secondary", children: option.charAt(0).toUpperCase() + option.slice(1) }), sx: { mr: 0 } }, option)))] }), data.internal_status === "placed" && (jsx(Alert, { severity: "warning", children: "Before confirmation you cannot update the items" })), jsx(Divider, {}), jsxs("form", { action: formAction, children: [items &&
|
|
229
|
+
} }), label: jsx(Typography, { variant: "body2", color: "text.secondary", children: option.charAt(0).toUpperCase() + option.slice(1) }), sx: { mr: 0 } }, option)))] }), data.internal_status === "placed" && (jsx(Alert, { severity: "warning", children: "Before confirmation you cannot update the items" })), jsx(Divider, {}), jsxs("form", { action: formAction, children: [jsx("input", { type: "hidden", name: "items", value: JSON.stringify(parseItems(items)) }), items &&
|
|
227
230
|
items.map((item, index) => {
|
|
228
231
|
return (jsx(Paper, { sx: { p: 2, mb: 2 }, children: data.internal_status === "placed" ||
|
|
229
232
|
data.internal_status === "cancelled" ||
|
|
230
233
|
data.internal_status === "done" ? (jsx(ItemDisplay, { item: item, index: index, image: item?.product?.image })) : (jsx(TextualIPOItemUpdater, { item: item, index: index, handleUpdateQuantity: handleUpdateQuantity, handleAddReport: handleAddReport, image: item?.product?.image, handleRemoveReportAtIndex: handleRemoveReportAtIndex, revalidateCallback: revalidateCallback, showing: showing })) }, index));
|
|
231
|
-
}), jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { variant: "contained", text: "Update items", loadingText: "Loading..." })] })
|
|
234
|
+
}), jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { variant: "contained", text: "Update items", loadingText: "Loading..." })] })] })] }) })] }) }));
|
|
232
235
|
}
|
|
233
236
|
|
|
234
237
|
export { TextualManageIPOForm as default };
|
|
@@ -17,24 +17,24 @@ async function updateIroAction(documentId, prevState, formData) {
|
|
|
17
17
|
if (!responseData) {
|
|
18
18
|
return {
|
|
19
19
|
...prevState,
|
|
20
|
+
severity: "error",
|
|
20
21
|
strapiErrors: null,
|
|
21
22
|
message: "Ops! Something went wrong. Please try again.",
|
|
22
|
-
severity: "error",
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
if (responseData.error) {
|
|
26
26
|
return {
|
|
27
27
|
...prevState,
|
|
28
|
+
severity: "error",
|
|
28
29
|
strapiErrors: responseData.error,
|
|
29
30
|
message: "Failed to Update Iro.",
|
|
30
|
-
severity: "error",
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
const flattenedData = flattenAttributes(responseData);
|
|
34
34
|
return {
|
|
35
35
|
...prevState,
|
|
36
|
-
message: "Iro Updated",
|
|
37
36
|
severity: "success",
|
|
37
|
+
message: "Iro Updated",
|
|
38
38
|
data: flattenedData,
|
|
39
39
|
strapiErrors: null,
|
|
40
40
|
};
|
|
@@ -16,7 +16,6 @@ import { parseFormData } from '../../../../lib/parseFormData.js';
|
|
|
16
16
|
async function createOpoAction(prevState, formData) {
|
|
17
17
|
Object.fromEntries(formData);
|
|
18
18
|
const parsedFormData = parseFormData(formData);
|
|
19
|
-
console.log("createOpoAction parsedFormData", parsedFormData);
|
|
20
19
|
const responseData = await mutateData("POST", `/api/opos/createAdmin`, parsedFormData);
|
|
21
20
|
if (!responseData) {
|
|
22
21
|
return {
|
|
@@ -12,7 +12,6 @@ import dayjs from '../../../../../node_modules/dayjs/dayjs.min.js';
|
|
|
12
12
|
|
|
13
13
|
async function createIPOAction(prevState, formData) {
|
|
14
14
|
const parsedFormData = parseFormData(formData);
|
|
15
|
-
console.log("createIPOAction parsedFormData", parsedFormData);
|
|
16
15
|
if (!parsedFormData.data.order_date) {
|
|
17
16
|
return {
|
|
18
17
|
...prevState,
|
|
@@ -11,7 +11,6 @@ import { parseFormData } from '../../../../lib/parseFormData.js';
|
|
|
11
11
|
|
|
12
12
|
async function updateIpoAction(documentId, prevState, formData) {
|
|
13
13
|
const parsedFormData = parseFormData(formData);
|
|
14
|
-
console.log("updateIpoAction", documentId, parsedFormData);
|
|
15
14
|
const responseData = await mutateData("PUT", `/api/ipos/${documentId}`, parsedFormData);
|
|
16
15
|
if (!responseData) {
|
|
17
16
|
return {
|