umwd-components 0.1.823 → 0.1.825

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.
@@ -46,14 +46,19 @@ const INITIAL_STATE = {
46
46
  message: null,
47
47
  severity: null,
48
48
  };
49
- function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, revalidateCallback, }) {
49
+ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, revalidateCallback, closeMainDialog, }) {
50
50
  const [loading, setLoading] = useState(false);
51
51
  const { handleAddMessage } = useSnackbar();
52
52
  const handleConfirm = async () => {
53
53
  try {
54
54
  await confirmationService("iros", [iro.documentId], overwrites);
55
+ handleAddMessage({
56
+ message: "Return order confirmed successfully",
57
+ severity: "success",
58
+ });
55
59
  revalidateCallback && revalidateCallback();
56
60
  handleClose();
61
+ closeMainDialog && closeMainDialog();
57
62
  }
58
63
  catch (error) {
59
64
  handleAddMessage({
@@ -358,7 +363,7 @@ revalidateCallback, handleClose, role, }) {
358
363
  }, [data]);
359
364
  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 Inbound Return" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and release of returns" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: data.id, __type: "api::e-commerce.iro" }], 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: "Return Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(AssignmentReturnIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "RMA Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.rma_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer Reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.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: "Return Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_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: data.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: "Return Status" }), jsx(IroStatusIndicator, { status: data.internal_status })] })] }) }) }), (data.internal_status === "requested" ||
360
365
  data.internal_status === "finalising_process") &&
361
- role === "enduser" && (jsx(Grid, { size: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), data.internal_status === "requested" && (jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning" })), data.internal_status === "finalising_process" && (jsx(Alert, { severity: "warning", children: "Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done" })), data.internal_status === "finalising_process" && (jsx(Button, { variant: "contained", sx: { color: "yellow" }, children: "// TODO RE-PAYMENT PROCESS" })), jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback, openOverwritesDialog: () => setOverwritesDialogOpen(true) }), jsx(OverwritesDialog, { open: overwritesDialogOpen, handleClose: () => setOverwritesDialogOpen(false), overwrites: overwrites, setOverwrites: setOverwrites, iro: data }), jsx(CancelIroDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: data.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 }) })] }) }), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Customer Attachements" }), jsx(Paper, { sx: { p: 1 }, children: jsx(MinioItemList, { items: data.customer_attachment, emptyMessage: "No customer attachments found.", direction: "row", revalidateCallback: revalidateCallback }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.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: {
366
+ role === "enduser" && (jsx(Grid, { size: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), data.internal_status === "requested" && (jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning" })), data.internal_status === "finalising_process" && (jsx(Alert, { severity: "warning", children: "Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done" })), data.internal_status === "finalising_process" && (jsx(Button, { variant: "contained", sx: { color: "yellow" }, children: "// TODO RE-PAYMENT PROCESS" })), jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback, openOverwritesDialog: () => setOverwritesDialogOpen(true) }), jsx(OverwritesDialog, { open: overwritesDialogOpen, handleClose: () => setOverwritesDialogOpen(false), overwrites: overwrites, setOverwrites: setOverwrites, iro: data, revalidateCallback: revalidateCallback, closeMainDialog: handleClose }), jsx(CancelIroDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: data.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 }) })] }) }), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Customer Attachements" }), jsx(Paper, { sx: { p: 1 }, children: jsx(MinioItemList, { items: data.customer_attachment, emptyMessage: "No customer attachments found.", direction: "row", revalidateCallback: revalidateCallback }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.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: {
362
367
  bgcolor: "background.default",
363
368
  border: "1px solid",
364
369
  borderColor: "divider",
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+
8
+ import { jsxs, jsx } from 'react/jsx-runtime';
9
+ import { useActionState, useEffect } from 'react';
10
+ import Paper from '@mui/material/Paper';
11
+ import Box from '@mui/material/Box';
12
+ import Stack from '@mui/material/Stack';
13
+ import Typography from '@mui/material/Typography';
14
+ import { updateProductAction } from '../../../data/actions/e-commerce/product/updateProductAction.js';
15
+ import Grid from '@mui/material/Grid';
16
+ import ReportsDisplay from '../../logistics/report/ReportsDisplay.js';
17
+ import ReportMakingComponent from '../../logistics/report/ReportMakingComponent.js';
18
+ import { useSnackbar } from '../../../context/common/SnackbarContext.js';
19
+ import Table from '@mui/material/Table';
20
+ import TableBody from '@mui/material/TableBody';
21
+ import TableCell from '@mui/material/TableCell';
22
+ import TableContainer from '@mui/material/TableContainer';
23
+ import TableFooter from '@mui/material/TableFooter';
24
+ import TableHead from '@mui/material/TableHead';
25
+ import TableRow from '@mui/material/TableRow';
26
+ import Tooltip from '@mui/material/Tooltip';
27
+ import Button from '@mui/material/Button';
28
+ import { AmountIndicator } from '../../common/AmountIndicator.js';
29
+
30
+ const INITIAL_STATE = {
31
+ zodErrors: null,
32
+ strapiErrors: null,
33
+ data: null,
34
+ message: null,
35
+ severity: null,
36
+ };
37
+ function EditReturnStockForm({ data, revalidateCallback, handleClose, sx, }) {
38
+ const { id, documentId, title, product_number, stock, iros, opoItems, reports, } = data;
39
+ const { handleAddMessage } = useSnackbar();
40
+ // Bind the documentId to the form action following form patterns
41
+ const boundAction = updateProductAction.bind(null, documentId);
42
+ const [formState, formAction] = useActionState(boundAction, INITIAL_STATE);
43
+ useEffect(() => {
44
+ if (formState?.message) {
45
+ handleAddMessage({
46
+ message: formState.message,
47
+ severity: formState.severity || "error",
48
+ });
49
+ if (formState.severity === "success") {
50
+ revalidateCallback && revalidateCallback();
51
+ handleClose && handleClose();
52
+ }
53
+ }
54
+ }, [formState?.message, handleAddMessage, revalidateCallback, handleClose]);
55
+ useEffect(() => {
56
+ if (formState?.strapiErrors) {
57
+ handleAddMessage({
58
+ message: formState.strapiErrors.message || "Error updating stock",
59
+ severity: "error",
60
+ });
61
+ }
62
+ }, [formState?.strapiErrors, handleAddMessage]);
63
+ return (jsxs(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: [jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { size: 12, children: jsx(Typography, { variant: "h6", children: title }) }), jsx(Grid, { size: 12, children: jsxs(TableContainer, { component: Paper, children: [jsx(Typography, { variant: "h6", sx: { pl: 2 }, children: "Incoming return orders" }), jsxs(Table, { size: "small", children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Number" }), jsx(TableCell, { children: "Order Date" }), jsx(TableCell, { children: "Line Item Number" }), jsx(TableCell, { children: "Ordered Quantity" }), jsx(TableCell, { children: "Received Quantity" }), jsx(TableCell, { children: "Registered Quantity" }), jsx(TableCell, { children: "Released Quantity" })] }) }), jsx(TableBody, { children: Array.isArray(iros) ? (iros.map((iro) => iro.items.map((item) => (jsxs(TableRow, { children: [jsx(TableCell, { children: iro.ipo_number }), jsx(TableCell, { children: iro.order_date }), jsx(TableCell, { children: item.line_item_number }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.ordered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.received_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.registered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.released_quantity, maxValue: item.ordered_quantity, color: "primary" }) })] }, iro.documentId))))) : (jsx(TableRow, { children: jsx(TableCell, { colSpan: 7, align: "center", children: "No incoming orders found." }) })) }), jsx(TableFooter, { children: jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 6, align: "right", children: "Total added to stock:" }), jsx(TableCell, { children: Array.isArray(iros)
64
+ ? iros.reduce((total, iro) => total +
65
+ iro.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
66
+ : 0 })] }) })] }), jsx(Table, { size: "small", children: jsxs(TableBody, { children: [jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Total added to stock:" }), jsx(TableCell, { children: Array.isArray(iros) && iros.length > 0
67
+ ? iros.reduce((total, iro) => total +
68
+ iro.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
69
+ : 0 })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Corrections:" }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock corrections", children: jsx(Typography, { children: reports
70
+ ? reports.reduce((total, report) => total + report.quantity, 0)
71
+ : 0 }) }) }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock corrections after updating", children: jsx("b", { children: reports
72
+ ? reports.reduce((total, report) => total + report.quantity, 0)
73
+ : 0 }) }) })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Stock:" }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock", children: jsx(Typography, { children: (Array.isArray(iros) && iros.length > 0
74
+ ? iros.reduce((total, iro) => total +
75
+ iro.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
76
+ : 0) +
77
+ (reports
78
+ ? reports.reduce((total, report) => total + report.quantity, 0)
79
+ : 0) }) }) }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock after updating", children: jsx("b", { children: (Array.isArray(iros) && iros.length > 0
80
+ ? iros.reduce((total, iro) => total +
81
+ iro.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
82
+ : 0) +
83
+ (reports
84
+ ? reports.reduce((total, report) => total + report.quantity, 0)
85
+ : 0) }) }) })] })] }) })] }) })] }), jsxs("form", { action: formAction, children: [jsx("input", { id: "stock_reports", type: "hidden", name: "stock_reports", value: JSON.stringify(reports) }), jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { size: 12, sx: { mt: 2 }, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Stock corrections" }), jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports }), jsx(Stack, { direction: "row", justifyContent: "flex-end", children: jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "stock", related: [
86
+ {
87
+ id: id,
88
+ __type: "api::e-commerce.product",
89
+ },
90
+ ], revalidateCallback: revalidateCallback, biggerButton: true }) })] }) }), jsx(Grid, { size: 12, children: jsx(Stack, { direction: "row", justifyContent: "flex-end", alignItems: "center", sx: { py: 1 }, children: handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Close" })) }) })] })] })] }));
91
+ }
92
+
93
+ export { EditReturnStockForm };
@@ -153,6 +153,7 @@ export { OPOItemFields } from './components/e-commerce/opo/OPOItemFields.js';
153
153
  export { default as OpoItemUpdater } from './components/e-commerce/opo/OpoItemUpdater.js';
154
154
  export { createOpoAction } from './data/actions/e-commerce/opo/createOpoAction.js';
155
155
  export { EditStockForm } from './components/e-commerce/products/EditStockForm.js';
156
+ export { EditReturnStockForm } from './components/e-commerce/products/EditReturnStockForm.js';
156
157
  export { getSingleStock } from './data/loaders/e-commerce/getSingleStock.js';
157
158
  export { default as CsvDownloader } from './components/common/csv/CsvDownloader.js';
158
159
  export { getProductModel } from './data/loaders/e-commerce/getProductModel.js';