umwd-components 0.1.645 → 0.1.647
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/package.json
CHANGED
|
@@ -25,8 +25,6 @@ import Box from "@mui/material/Box";
|
|
|
25
25
|
import Paper from "@mui/material/Paper";
|
|
26
26
|
import Stack from "@mui/material/Stack";
|
|
27
27
|
import Divider from "@mui/material/Divider";
|
|
28
|
-
import Card from "@mui/material/Card";
|
|
29
|
-
import CardContent from "@mui/material/CardContent";
|
|
30
28
|
import { confirmationService } from "../../../data/services/common/confirmation-service";
|
|
31
29
|
import { cancellationService } from "../../../data/services/common/cancellation-service";
|
|
32
30
|
// TODO this should be futher removed from client side code, reimplement via action ??
|
|
@@ -411,7 +409,6 @@ function ConfirmFormDialog({
|
|
|
411
409
|
);
|
|
412
410
|
}
|
|
413
411
|
|
|
414
|
-
// TODO
|
|
415
412
|
function CancelIroDialog({
|
|
416
413
|
open,
|
|
417
414
|
handleClose,
|
|
@@ -23,8 +23,30 @@ import Paper from "@mui/material/Paper";
|
|
|
23
23
|
import Stack from "@mui/material/Stack";
|
|
24
24
|
import Divider from "@mui/material/Divider";
|
|
25
25
|
import { confirmationService } from "../../../data/services/common/confirmation-service";
|
|
26
|
+
import { cancellationService } from "../../../data/services/common/cancellation-service";
|
|
26
27
|
import { PreReport } from "../../../types/logistics/Report";
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
FormControlLabel,
|
|
30
|
+
Checkbox,
|
|
31
|
+
List,
|
|
32
|
+
ListItem,
|
|
33
|
+
TextField,
|
|
34
|
+
DialogContentText,
|
|
35
|
+
CircularProgress,
|
|
36
|
+
} from "@mui/material";
|
|
37
|
+
import NumbersIcon from "@mui/icons-material/Numbers";
|
|
38
|
+
import AssignmentReturnIcon from "@mui/icons-material/AssignmentReturn";
|
|
39
|
+
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
|
|
40
|
+
import BusinessIcon from "@mui/icons-material/Business";
|
|
41
|
+
import DescriptionIcon from "@mui/icons-material/Description";
|
|
42
|
+
import UpdateIcon from "@mui/icons-material/Update";
|
|
43
|
+
import { IpoStatusIndicator } from "./IpoStatusIndicator";
|
|
44
|
+
import { InvoiceOverwrites } from "../../../types/e-commerce/invoice/types";
|
|
45
|
+
import { Ipo } from "../../../types/logistics/Ipo";
|
|
46
|
+
import { queryAllProducts } from "../../../data/loaders/e-commerce/queryAllProducts";
|
|
47
|
+
import qs from "qs";
|
|
48
|
+
import { Product } from "../../../types/e-commerce/product/types";
|
|
49
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
28
50
|
|
|
29
51
|
const INITIAL_STATE = {
|
|
30
52
|
zodErrors: null,
|
|
@@ -33,71 +55,6 @@ const INITIAL_STATE = {
|
|
|
33
55
|
message: null,
|
|
34
56
|
};
|
|
35
57
|
|
|
36
|
-
/* const CONFIRMATION_STATE = {
|
|
37
|
-
zodErrors: null,
|
|
38
|
-
strapiErrors: null,
|
|
39
|
-
data: null,
|
|
40
|
-
message: null,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
function ConfirmFormDialog({
|
|
44
|
-
open,
|
|
45
|
-
handleClose,
|
|
46
|
-
orderID,
|
|
47
|
-
currentStatus,
|
|
48
|
-
revalidateCallback,
|
|
49
|
-
}: {
|
|
50
|
-
open: boolean;
|
|
51
|
-
handleClose: () => void;
|
|
52
|
-
orderID: number;
|
|
53
|
-
currentStatus: "placed" | "released_on_stock";
|
|
54
|
-
revalidateCallback?: () => void;
|
|
55
|
-
}) {
|
|
56
|
-
const [formState, formAction] = useFormState(
|
|
57
|
-
updateIpoAction,
|
|
58
|
-
CONFIRMATION_STATE
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (formState?.message === "Ipo Updated") {
|
|
63
|
-
revalidateCallback && revalidateCallback();
|
|
64
|
-
handleClose();
|
|
65
|
-
}
|
|
66
|
-
}, [formState?.message]);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Dialog open={open}>
|
|
70
|
-
<form action={formAction}>
|
|
71
|
-
<input name="id" type="hidden" value={orderID} />
|
|
72
|
-
<input
|
|
73
|
-
name="status"
|
|
74
|
-
type="hidden"
|
|
75
|
-
value={currentStatus === "placed" ? "ordered" : "done"}
|
|
76
|
-
/>
|
|
77
|
-
<DialogTitle>Confirm Order</DialogTitle>
|
|
78
|
-
<DialogContent>
|
|
79
|
-
<Stack spacing={2}>
|
|
80
|
-
<Typography>
|
|
81
|
-
Are you sure you want to confirm this order?
|
|
82
|
-
</Typography>
|
|
83
|
-
<Typography>Current status: {currentStatus}</Typography>
|
|
84
|
-
</Stack>
|
|
85
|
-
</DialogContent>
|
|
86
|
-
<DialogActions>
|
|
87
|
-
<SubmitButton text="Confirm" loadingText="Loading..." />
|
|
88
|
-
<StrapiErrors error={formState?.strapiErrors} />
|
|
89
|
-
{formState?.message && (
|
|
90
|
-
<Alert severity="error">{formState?.message}</Alert>
|
|
91
|
-
)}
|
|
92
|
-
<Button variant="contained" color="secondary" onClick={handleClose}>
|
|
93
|
-
Cancel
|
|
94
|
-
</Button>
|
|
95
|
-
</DialogActions>
|
|
96
|
-
</form>
|
|
97
|
-
</Dialog>
|
|
98
|
-
);
|
|
99
|
-
} */
|
|
100
|
-
|
|
101
58
|
function ConfirmFormDialog({
|
|
102
59
|
open,
|
|
103
60
|
handleClose,
|
|
@@ -126,6 +83,7 @@ function ConfirmFormDialog({
|
|
|
126
83
|
onClick={(e) => {
|
|
127
84
|
confirmationService("ipos", [orderID]);
|
|
128
85
|
revalidateCallback && revalidateCallback();
|
|
86
|
+
handleClose();
|
|
129
87
|
}}
|
|
130
88
|
>
|
|
131
89
|
Confirm
|
|
@@ -138,6 +96,78 @@ function ConfirmFormDialog({
|
|
|
138
96
|
);
|
|
139
97
|
}
|
|
140
98
|
|
|
99
|
+
function CancelIpoDialog({
|
|
100
|
+
open,
|
|
101
|
+
handleClose,
|
|
102
|
+
orderID,
|
|
103
|
+
revalidateCallback,
|
|
104
|
+
}: {
|
|
105
|
+
open: boolean;
|
|
106
|
+
handleClose: () => void;
|
|
107
|
+
orderID: number;
|
|
108
|
+
revalidateCallback?: () => void;
|
|
109
|
+
}) {
|
|
110
|
+
const [reason, setRoason] = useState<string>("");
|
|
111
|
+
const [reasonError, setReasonError] = useState<string>("");
|
|
112
|
+
return (
|
|
113
|
+
<form>
|
|
114
|
+
<Dialog open={open}>
|
|
115
|
+
<DialogTitle>Cancel Return</DialogTitle>
|
|
116
|
+
<DialogContent>
|
|
117
|
+
<Stack spacing={2}>
|
|
118
|
+
<Typography>
|
|
119
|
+
Are you sure you want to cancel this return?
|
|
120
|
+
</Typography>
|
|
121
|
+
<List>
|
|
122
|
+
<ListItem>
|
|
123
|
+
By cancelling this return order you will update it's status from
|
|
124
|
+
requested to cancelled
|
|
125
|
+
</ListItem>
|
|
126
|
+
<ListItem>Please provide a reason for the cancellation</ListItem>
|
|
127
|
+
<ListItem>
|
|
128
|
+
The customer will be notified about the cancellation and of the
|
|
129
|
+
reason for the cancellation
|
|
130
|
+
</ListItem>
|
|
131
|
+
</List>
|
|
132
|
+
<TextField
|
|
133
|
+
label="Cancellation reason"
|
|
134
|
+
name="reason"
|
|
135
|
+
multiline
|
|
136
|
+
rows={4}
|
|
137
|
+
fullWidth
|
|
138
|
+
variant="outlined"
|
|
139
|
+
value={reason}
|
|
140
|
+
onChange={(e) => setRoason(e.target.value)}
|
|
141
|
+
placeholder="Please provide a reason for the cancellation"
|
|
142
|
+
error={!!reasonError}
|
|
143
|
+
helperText={reasonError}
|
|
144
|
+
/>
|
|
145
|
+
</Stack>
|
|
146
|
+
</DialogContent>
|
|
147
|
+
<DialogActions>
|
|
148
|
+
<Button
|
|
149
|
+
variant="contained"
|
|
150
|
+
onClick={(e) => {
|
|
151
|
+
if (reason.length < 5) {
|
|
152
|
+
setReasonError("Please provide a reason for the cancellation");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
cancellationService("ipos", orderID, reason);
|
|
156
|
+
revalidateCallback && revalidateCallback();
|
|
157
|
+
handleClose();
|
|
158
|
+
}}
|
|
159
|
+
>
|
|
160
|
+
Yes
|
|
161
|
+
</Button>
|
|
162
|
+
<Button variant="contained" onClick={handleClose}>
|
|
163
|
+
No
|
|
164
|
+
</Button>
|
|
165
|
+
</DialogActions>
|
|
166
|
+
</Dialog>
|
|
167
|
+
</form>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
141
171
|
export default function TextualManageIPOForm({
|
|
142
172
|
data,
|
|
143
173
|
sx,
|
|
@@ -154,6 +184,7 @@ export default function TextualManageIPOForm({
|
|
|
154
184
|
);
|
|
155
185
|
|
|
156
186
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
187
|
+
const [cancelDialogOpen, setCancelDialogOpen] = useState(false);
|
|
157
188
|
|
|
158
189
|
const [showing, setShowing] = useState<
|
|
159
190
|
("received" | "registered" | "released" | "reports")[]
|
|
@@ -229,13 +260,30 @@ export default function TextualManageIPOForm({
|
|
|
229
260
|
setItems(newItems);
|
|
230
261
|
};
|
|
231
262
|
|
|
263
|
+
const { handleAddMessage } = useSnackbar();
|
|
264
|
+
|
|
232
265
|
useEffect(() => {
|
|
233
266
|
if (formState?.message === "Ipo Updated") {
|
|
267
|
+
handleAddMessage({
|
|
268
|
+
message: "Ipo Updated",
|
|
269
|
+
severity: "success",
|
|
270
|
+
});
|
|
271
|
+
handleClose && handleClose();
|
|
234
272
|
revalidateCallback && revalidateCallback();
|
|
235
273
|
}
|
|
236
274
|
}, [formState]);
|
|
237
275
|
|
|
238
276
|
useEffect(() => {
|
|
277
|
+
if (formState?.strapiErrors) {
|
|
278
|
+
handleAddMessage({
|
|
279
|
+
message: formState.strapiErrors.message || "Error updating IPO",
|
|
280
|
+
severity: "error",
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}, [formState?.strapiErrors]);
|
|
284
|
+
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
console.log("data", data);
|
|
239
287
|
if (data.items?.data) {
|
|
240
288
|
setItems(data.items.data ? data.items.data : []);
|
|
241
289
|
}
|
|
@@ -273,54 +321,90 @@ export default function TextualManageIPOForm({
|
|
|
273
321
|
<Divider />
|
|
274
322
|
</Stack>
|
|
275
323
|
</Grid>
|
|
324
|
+
<Grid item xs={12}>
|
|
325
|
+
<Typography variant="h5" sx={{ py: 1 }}>
|
|
326
|
+
Details
|
|
327
|
+
</Typography>
|
|
328
|
+
</Grid>
|
|
276
329
|
<Grid item xs={6}>
|
|
277
|
-
<
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
</Stack>
|
|
330
|
+
<Paper elevation={2} sx={{ p: 2, height: "100%" }}>
|
|
331
|
+
<Stack spacing={2}>
|
|
332
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
333
|
+
<NumbersIcon color="primary" />
|
|
334
|
+
<Typography
|
|
335
|
+
variant="subtitle1"
|
|
336
|
+
color="text.secondary"
|
|
337
|
+
width="200px"
|
|
338
|
+
>
|
|
339
|
+
Purchase Order Number
|
|
340
|
+
</Typography>
|
|
341
|
+
<Typography variant="body1" fontWeight="medium">
|
|
342
|
+
{data.ipo_number}
|
|
343
|
+
</Typography>
|
|
344
|
+
</Stack>
|
|
293
345
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
346
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
347
|
+
<DescriptionIcon color="primary" />
|
|
348
|
+
<Typography
|
|
349
|
+
variant="subtitle1"
|
|
350
|
+
color="text.secondary"
|
|
351
|
+
width="200px"
|
|
352
|
+
>
|
|
353
|
+
Custom Reference
|
|
354
|
+
</Typography>
|
|
355
|
+
<Typography variant="body1" fontWeight="medium">
|
|
356
|
+
{data.customer_reference}
|
|
357
|
+
</Typography>
|
|
358
|
+
</Stack>
|
|
298
359
|
|
|
299
|
-
<
|
|
300
|
-
|
|
360
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
361
|
+
<CalendarTodayIcon color="primary" />
|
|
362
|
+
<Typography
|
|
363
|
+
variant="subtitle1"
|
|
364
|
+
color="text.secondary"
|
|
365
|
+
width="200px"
|
|
366
|
+
>
|
|
367
|
+
Order Date
|
|
368
|
+
</Typography>
|
|
369
|
+
<Typography variant="body1" fontWeight="medium">
|
|
370
|
+
{data.order_date}
|
|
371
|
+
</Typography>
|
|
372
|
+
</Stack>
|
|
301
373
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
374
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
375
|
+
<BusinessIcon color="primary" />
|
|
376
|
+
<Typography
|
|
377
|
+
variant="subtitle1"
|
|
378
|
+
color="text.secondary"
|
|
379
|
+
width="200px"
|
|
380
|
+
>
|
|
381
|
+
Supplier
|
|
382
|
+
</Typography>
|
|
383
|
+
<Typography variant="body1" fontWeight="medium">
|
|
384
|
+
{data.vendor_profile?.business_credentials?.company_name}
|
|
385
|
+
</Typography>
|
|
386
|
+
</Stack>
|
|
310
387
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
388
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
389
|
+
<UpdateIcon color="primary" />
|
|
390
|
+
<Typography
|
|
391
|
+
variant="subtitle1"
|
|
392
|
+
color="text.secondary"
|
|
393
|
+
width="200px"
|
|
394
|
+
>
|
|
395
|
+
Order Status
|
|
396
|
+
</Typography>
|
|
397
|
+
<IpoStatusIndicator status={data.status} />
|
|
398
|
+
</Stack>
|
|
318
399
|
</Stack>
|
|
400
|
+
</Paper>
|
|
401
|
+
</Grid>
|
|
319
402
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
403
|
+
{(data.status === "placed" || data.status === "released_on_stock") &&
|
|
404
|
+
role === "enduser" && (
|
|
405
|
+
<Grid item xs={6}>
|
|
406
|
+
<Paper elevation={2} sx={{ p: 2, height: "100%" }}>
|
|
407
|
+
<Stack spacing={2}>
|
|
324
408
|
<Button
|
|
325
409
|
variant="contained"
|
|
326
410
|
color="primary"
|
|
@@ -332,6 +416,13 @@ export default function TextualManageIPOForm({
|
|
|
332
416
|
Please confirm the order as soon as possible, only upon
|
|
333
417
|
confirmation this order will be available to the dispatcher
|
|
334
418
|
</Alert>
|
|
419
|
+
<Button
|
|
420
|
+
variant="contained"
|
|
421
|
+
color="error"
|
|
422
|
+
onClick={() => setCancelDialogOpen(true)}
|
|
423
|
+
>
|
|
424
|
+
Cancel order
|
|
425
|
+
</Button>
|
|
335
426
|
<ConfirmFormDialog
|
|
336
427
|
open={confirmDialogOpen}
|
|
337
428
|
handleClose={() => setConfirmDialogOpen(false)}
|
|
@@ -339,10 +430,16 @@ export default function TextualManageIPOForm({
|
|
|
339
430
|
currentStatus={data.status}
|
|
340
431
|
revalidateCallback={revalidateCallback}
|
|
341
432
|
/>
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
433
|
+
<CancelIpoDialog
|
|
434
|
+
open={cancelDialogOpen}
|
|
435
|
+
handleClose={() => setCancelDialogOpen(false)}
|
|
436
|
+
orderID={data.id}
|
|
437
|
+
revalidateCallback={revalidateCallback}
|
|
438
|
+
/>
|
|
439
|
+
</Stack>
|
|
440
|
+
</Paper>
|
|
441
|
+
</Grid>
|
|
442
|
+
)}
|
|
346
443
|
<Grid item xs={12}>
|
|
347
444
|
<Stack spacing={2}>
|
|
348
445
|
<Typography variant="h5">Documents</Typography>
|
|
@@ -492,7 +589,9 @@ export default function TextualManageIPOForm({
|
|
|
492
589
|
items.map((item: IpoItem, index: number) => {
|
|
493
590
|
return (
|
|
494
591
|
<Paper sx={{ p: 2, mb: 2 }} key={index}>
|
|
495
|
-
{data.status === "placed"
|
|
592
|
+
{data.status === "placed" ||
|
|
593
|
+
data.status === "cancelled" ||
|
|
594
|
+
data.status === "done" ? (
|
|
496
595
|
<ItemDisplay
|
|
497
596
|
item={item}
|
|
498
597
|
index={index}
|
|
@@ -516,10 +615,6 @@ export default function TextualManageIPOForm({
|
|
|
516
615
|
<Paper sx={{ p: 2 }}>
|
|
517
616
|
<Stack direction="row" spacing={2} justifyContent={"end"}>
|
|
518
617
|
<SubmitButton text="Update items" loadingText="Loading..." />
|
|
519
|
-
<StrapiErrors error={formState?.strapiErrors} />
|
|
520
|
-
{formState?.message && (
|
|
521
|
-
<Alert severity="error">{formState?.message}</Alert>
|
|
522
|
-
)}
|
|
523
618
|
</Stack>
|
|
524
619
|
</Paper>
|
|
525
620
|
<input
|