umwd-components 0.1.644 → 0.1.646
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/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/src/data/loaders/e-commerce/iros/getAllIros.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +0 -3
- package/src/components/logistics/ipo/TextualManageIPOForm.tsx +193 -109
- package/src/data/loaders/e-commerce/iros/getAllIros.ts +12 -0
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,
|
|
@@ -138,6 +95,78 @@ function ConfirmFormDialog({
|
|
|
138
95
|
);
|
|
139
96
|
}
|
|
140
97
|
|
|
98
|
+
function CancelIpoDialog({
|
|
99
|
+
open,
|
|
100
|
+
handleClose,
|
|
101
|
+
orderID,
|
|
102
|
+
revalidateCallback,
|
|
103
|
+
}: {
|
|
104
|
+
open: boolean;
|
|
105
|
+
handleClose: () => void;
|
|
106
|
+
orderID: number;
|
|
107
|
+
revalidateCallback?: () => void;
|
|
108
|
+
}) {
|
|
109
|
+
const [reason, setRoason] = useState<string>("");
|
|
110
|
+
const [reasonError, setReasonError] = useState<string>("");
|
|
111
|
+
return (
|
|
112
|
+
<form>
|
|
113
|
+
<Dialog open={open}>
|
|
114
|
+
<DialogTitle>Cancel Return</DialogTitle>
|
|
115
|
+
<DialogContent>
|
|
116
|
+
<Stack spacing={2}>
|
|
117
|
+
<Typography>
|
|
118
|
+
Are you sure you want to cancel this return?
|
|
119
|
+
</Typography>
|
|
120
|
+
<List>
|
|
121
|
+
<ListItem>
|
|
122
|
+
By cancelling this return order you will update it's status from
|
|
123
|
+
requested to cancelled
|
|
124
|
+
</ListItem>
|
|
125
|
+
<ListItem>Please provide a reason for the cancellation</ListItem>
|
|
126
|
+
<ListItem>
|
|
127
|
+
The customer will be notified about the cancellation and of the
|
|
128
|
+
reason for the cancellation
|
|
129
|
+
</ListItem>
|
|
130
|
+
</List>
|
|
131
|
+
<TextField
|
|
132
|
+
label="Cancellation reason"
|
|
133
|
+
name="reason"
|
|
134
|
+
multiline
|
|
135
|
+
rows={4}
|
|
136
|
+
fullWidth
|
|
137
|
+
variant="outlined"
|
|
138
|
+
value={reason}
|
|
139
|
+
onChange={(e) => setRoason(e.target.value)}
|
|
140
|
+
placeholder="Please provide a reason for the cancellation"
|
|
141
|
+
error={!!reasonError}
|
|
142
|
+
helperText={reasonError}
|
|
143
|
+
/>
|
|
144
|
+
</Stack>
|
|
145
|
+
</DialogContent>
|
|
146
|
+
<DialogActions>
|
|
147
|
+
<Button
|
|
148
|
+
variant="contained"
|
|
149
|
+
onClick={(e) => {
|
|
150
|
+
if (reason.length < 5) {
|
|
151
|
+
setReasonError("Please provide a reason for the cancellation");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
cancellationService("ipos", orderID, reason);
|
|
155
|
+
revalidateCallback && revalidateCallback();
|
|
156
|
+
handleClose();
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
Yes
|
|
160
|
+
</Button>
|
|
161
|
+
<Button variant="contained" onClick={handleClose}>
|
|
162
|
+
No
|
|
163
|
+
</Button>
|
|
164
|
+
</DialogActions>
|
|
165
|
+
</Dialog>
|
|
166
|
+
</form>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
141
170
|
export default function TextualManageIPOForm({
|
|
142
171
|
data,
|
|
143
172
|
sx,
|
|
@@ -154,6 +183,7 @@ export default function TextualManageIPOForm({
|
|
|
154
183
|
);
|
|
155
184
|
|
|
156
185
|
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
|
186
|
+
const [cancelDialogOpen, setCancelDialogOpen] = useState(false);
|
|
157
187
|
|
|
158
188
|
const [showing, setShowing] = useState<
|
|
159
189
|
("received" | "registered" | "released" | "reports")[]
|
|
@@ -229,13 +259,30 @@ export default function TextualManageIPOForm({
|
|
|
229
259
|
setItems(newItems);
|
|
230
260
|
};
|
|
231
261
|
|
|
262
|
+
const { handleAddMessage } = useSnackbar();
|
|
263
|
+
|
|
232
264
|
useEffect(() => {
|
|
233
265
|
if (formState?.message === "Ipo Updated") {
|
|
266
|
+
handleAddMessage({
|
|
267
|
+
message: "Ipo Updated",
|
|
268
|
+
severity: "success",
|
|
269
|
+
});
|
|
270
|
+
handleClose && handleClose();
|
|
234
271
|
revalidateCallback && revalidateCallback();
|
|
235
272
|
}
|
|
236
273
|
}, [formState]);
|
|
237
274
|
|
|
238
275
|
useEffect(() => {
|
|
276
|
+
if (formState?.strapiErrors) {
|
|
277
|
+
handleAddMessage({
|
|
278
|
+
message: formState.strapiErrors.message || "Error updating IPO",
|
|
279
|
+
severity: "error",
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}, [formState?.strapiErrors]);
|
|
283
|
+
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
console.log("data", data);
|
|
239
286
|
if (data.items?.data) {
|
|
240
287
|
setItems(data.items.data ? data.items.data : []);
|
|
241
288
|
}
|
|
@@ -273,48 +320,81 @@ export default function TextualManageIPOForm({
|
|
|
273
320
|
<Divider />
|
|
274
321
|
</Stack>
|
|
275
322
|
</Grid>
|
|
323
|
+
<Grid item xs={12}>
|
|
324
|
+
<Typography variant="h5" sx={{ py: 1 }}>
|
|
325
|
+
Details
|
|
326
|
+
</Typography>
|
|
327
|
+
</Grid>
|
|
276
328
|
<Grid item xs={6}>
|
|
277
|
-
<
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
</Stack>
|
|
329
|
+
<Paper elevation={2} sx={{ p: 2, height: "100%" }}>
|
|
330
|
+
<Stack spacing={2}>
|
|
331
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
332
|
+
<NumbersIcon color="primary" />
|
|
333
|
+
<Typography
|
|
334
|
+
variant="subtitle1"
|
|
335
|
+
color="text.secondary"
|
|
336
|
+
width="200px"
|
|
337
|
+
>
|
|
338
|
+
Purchase Order Number
|
|
339
|
+
</Typography>
|
|
340
|
+
<Typography variant="body1" fontWeight="medium">
|
|
341
|
+
{data.ipo_number}
|
|
342
|
+
</Typography>
|
|
343
|
+
</Stack>
|
|
293
344
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
345
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
346
|
+
<DescriptionIcon color="primary" />
|
|
347
|
+
<Typography
|
|
348
|
+
variant="subtitle1"
|
|
349
|
+
color="text.secondary"
|
|
350
|
+
width="200px"
|
|
351
|
+
>
|
|
352
|
+
Custom Reference
|
|
353
|
+
</Typography>
|
|
354
|
+
<Typography variant="body1" fontWeight="medium">
|
|
355
|
+
{data.customer_reference}
|
|
356
|
+
</Typography>
|
|
357
|
+
</Stack>
|
|
298
358
|
|
|
299
|
-
<
|
|
300
|
-
|
|
359
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
360
|
+
<CalendarTodayIcon color="primary" />
|
|
361
|
+
<Typography
|
|
362
|
+
variant="subtitle1"
|
|
363
|
+
color="text.secondary"
|
|
364
|
+
width="200px"
|
|
365
|
+
>
|
|
366
|
+
Order Date
|
|
367
|
+
</Typography>
|
|
368
|
+
<Typography variant="body1" fontWeight="medium">
|
|
369
|
+
{data.order_date}
|
|
370
|
+
</Typography>
|
|
371
|
+
</Stack>
|
|
301
372
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
373
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
374
|
+
<BusinessIcon color="primary" />
|
|
375
|
+
<Typography
|
|
376
|
+
variant="subtitle1"
|
|
377
|
+
color="text.secondary"
|
|
378
|
+
width="200px"
|
|
379
|
+
>
|
|
380
|
+
Supplier
|
|
381
|
+
</Typography>
|
|
382
|
+
<Typography variant="body1" fontWeight="medium">
|
|
383
|
+
{data.vendor_profile?.business_credentials?.company_name}
|
|
384
|
+
</Typography>
|
|
385
|
+
</Stack>
|
|
310
386
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
387
|
+
<Stack direction="row" spacing={2} alignItems="center">
|
|
388
|
+
<UpdateIcon color="primary" />
|
|
389
|
+
<Typography
|
|
390
|
+
variant="subtitle1"
|
|
391
|
+
color="text.secondary"
|
|
392
|
+
width="200px"
|
|
393
|
+
>
|
|
394
|
+
Order Status
|
|
395
|
+
</Typography>
|
|
396
|
+
<IpoStatusIndicator status={data.status} />
|
|
397
|
+
</Stack>
|
|
318
398
|
</Stack>
|
|
319
399
|
|
|
320
400
|
{(data.status === "placed" ||
|
|
@@ -339,9 +419,15 @@ export default function TextualManageIPOForm({
|
|
|
339
419
|
currentStatus={data.status}
|
|
340
420
|
revalidateCallback={revalidateCallback}
|
|
341
421
|
/>
|
|
422
|
+
<CancelIpoDialog
|
|
423
|
+
open={cancelDialogOpen}
|
|
424
|
+
handleClose={() => setCancelDialogOpen(false)}
|
|
425
|
+
orderID={data.id}
|
|
426
|
+
revalidateCallback={revalidateCallback}
|
|
427
|
+
/>
|
|
342
428
|
</>
|
|
343
429
|
)}
|
|
344
|
-
</
|
|
430
|
+
</Paper>
|
|
345
431
|
</Grid>
|
|
346
432
|
<Grid item xs={12}>
|
|
347
433
|
<Stack spacing={2}>
|
|
@@ -492,7 +578,9 @@ export default function TextualManageIPOForm({
|
|
|
492
578
|
items.map((item: IpoItem, index: number) => {
|
|
493
579
|
return (
|
|
494
580
|
<Paper sx={{ p: 2, mb: 2 }} key={index}>
|
|
495
|
-
{data.status === "placed"
|
|
581
|
+
{data.status === "placed" ||
|
|
582
|
+
data.status === "cancelled" ||
|
|
583
|
+
data.status === "done" ? (
|
|
496
584
|
<ItemDisplay
|
|
497
585
|
item={item}
|
|
498
586
|
index={index}
|
|
@@ -516,10 +604,6 @@ export default function TextualManageIPOForm({
|
|
|
516
604
|
<Paper sx={{ p: 2 }}>
|
|
517
605
|
<Stack direction="row" spacing={2} justifyContent={"end"}>
|
|
518
606
|
<SubmitButton text="Update items" loadingText="Loading..." />
|
|
519
|
-
<StrapiErrors error={formState?.strapiErrors} />
|
|
520
|
-
{formState?.message && (
|
|
521
|
-
<Alert severity="error">{formState?.message}</Alert>
|
|
522
|
-
)}
|
|
523
607
|
</Stack>
|
|
524
608
|
</Paper>
|
|
525
609
|
<input
|
|
@@ -51,6 +51,18 @@ async function getAllIros(
|
|
|
51
51
|
},
|
|
52
52
|
}
|
|
53
53
|
: false,
|
|
54
|
+
invoice: {
|
|
55
|
+
populate: {
|
|
56
|
+
seller_business_credentials: true,
|
|
57
|
+
seller_company_address: true,
|
|
58
|
+
buyer_company_address: true,
|
|
59
|
+
buyer_delivery_address: true,
|
|
60
|
+
buyer_billing_address: true,
|
|
61
|
+
buyer_business_credentials: true,
|
|
62
|
+
items: true,
|
|
63
|
+
admin_items: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
54
66
|
},
|
|
55
67
|
pagination: {
|
|
56
68
|
pageSize: rowsPerPage || 10,
|