umwd-components 0.1.694 → 0.1.696
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/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +87 -25
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +48 -29
- package/src/components/logistics/ipo/TextualManageIPOForm.tsx +3 -3
- package/src/data/services/common/cancellation-service.ts +0 -1
- package/src/data/services/common/confirmation-service.ts +0 -1
package/package.json
CHANGED
|
@@ -346,6 +346,15 @@ function OverwritesDialog({
|
|
|
346
346
|
);
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
+
interface ConfirmFormDialogProps {
|
|
350
|
+
open: boolean;
|
|
351
|
+
handleClose: () => void;
|
|
352
|
+
orderID: number;
|
|
353
|
+
currentStatus: "requested" | "finalising_process";
|
|
354
|
+
revalidateCallback?: () => void;
|
|
355
|
+
openOverwritesDialog?: () => void;
|
|
356
|
+
}
|
|
357
|
+
|
|
349
358
|
function ConfirmFormDialog({
|
|
350
359
|
open,
|
|
351
360
|
handleClose,
|
|
@@ -353,14 +362,50 @@ function ConfirmFormDialog({
|
|
|
353
362
|
currentStatus,
|
|
354
363
|
revalidateCallback,
|
|
355
364
|
openOverwritesDialog,
|
|
356
|
-
}: {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
365
|
+
}: ConfirmFormDialogProps): React.JSX.Element {
|
|
366
|
+
const { handleAddMessage } = useSnackbar();
|
|
367
|
+
|
|
368
|
+
const handleConfirm = async () => {
|
|
369
|
+
if (
|
|
370
|
+
currentStatus !== "requested" &&
|
|
371
|
+
currentStatus !== "finalising_process"
|
|
372
|
+
) {
|
|
373
|
+
handleAddMessage({
|
|
374
|
+
message: "Cannot confirm return order in current status",
|
|
375
|
+
severity: "error",
|
|
376
|
+
});
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (currentStatus === "finalising_process") {
|
|
381
|
+
if (!openOverwritesDialog) {
|
|
382
|
+
handleAddMessage({
|
|
383
|
+
message: "Please provide overwrites for the invoice",
|
|
384
|
+
severity: "error",
|
|
385
|
+
});
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
openOverwritesDialog();
|
|
389
|
+
handleClose();
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
try {
|
|
394
|
+
await confirmationService("iros", [orderID]);
|
|
395
|
+
handleAddMessage({
|
|
396
|
+
message: "Return order confirmed successfully",
|
|
397
|
+
severity: "success",
|
|
398
|
+
});
|
|
399
|
+
revalidateCallback && revalidateCallback();
|
|
400
|
+
handleClose();
|
|
401
|
+
} catch (error) {
|
|
402
|
+
handleAddMessage({
|
|
403
|
+
message: "Failed to confirm return order",
|
|
404
|
+
severity: "error",
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
364
409
|
return (
|
|
365
410
|
<Dialog open={open}>
|
|
366
411
|
<DialogTitle>Confirm Return</DialogTitle>
|
|
@@ -390,7 +435,8 @@ function ConfirmFormDialog({
|
|
|
390
435
|
<DialogActions>
|
|
391
436
|
<Button
|
|
392
437
|
variant="contained"
|
|
393
|
-
onClick={
|
|
438
|
+
onClick={handleConfirm}
|
|
439
|
+
/* (e) => {
|
|
394
440
|
if (currentStatus === "finalising_process") {
|
|
395
441
|
openOverwritesDialog && openOverwritesDialog();
|
|
396
442
|
handleClose();
|
|
@@ -399,7 +445,7 @@ function ConfirmFormDialog({
|
|
|
399
445
|
revalidateCallback && revalidateCallback();
|
|
400
446
|
handleClose();
|
|
401
447
|
}
|
|
402
|
-
}
|
|
448
|
+
} */
|
|
403
449
|
>
|
|
404
450
|
Yes
|
|
405
451
|
</Button>
|
|
@@ -424,6 +470,33 @@ function CancelIroDialog({
|
|
|
424
470
|
}) {
|
|
425
471
|
const [reason, setRoason] = useState<string>("");
|
|
426
472
|
const [reasonError, setReasonError] = useState<string>("");
|
|
473
|
+
|
|
474
|
+
const { handleAddMessage } = useSnackbar();
|
|
475
|
+
|
|
476
|
+
const handleCancel = async () => {
|
|
477
|
+
if (reason.length < 5) {
|
|
478
|
+
setReasonError(
|
|
479
|
+
"Please provide a reason for the cancellation (min 5 characters)"
|
|
480
|
+
);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
setReasonError("");
|
|
484
|
+
try {
|
|
485
|
+
await cancellationService("iros", orderID, reason);
|
|
486
|
+
handleAddMessage({
|
|
487
|
+
message: "Return order cancelled successfully",
|
|
488
|
+
severity: "success",
|
|
489
|
+
});
|
|
490
|
+
revalidateCallback && revalidateCallback();
|
|
491
|
+
handleClose();
|
|
492
|
+
} catch (error) {
|
|
493
|
+
handleAddMessage({
|
|
494
|
+
message: "Failed to cancel return order",
|
|
495
|
+
severity: "error",
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
|
|
427
500
|
return (
|
|
428
501
|
<form>
|
|
429
502
|
<Dialog open={open}>
|
|
@@ -460,22 +533,11 @@ function CancelIroDialog({
|
|
|
460
533
|
</Stack>
|
|
461
534
|
</DialogContent>
|
|
462
535
|
<DialogActions>
|
|
463
|
-
<Button
|
|
464
|
-
|
|
465
|
-
onClick={(e) => {
|
|
466
|
-
if (reason.length < 5) {
|
|
467
|
-
setReasonError("Please provide a reason for the cancellation");
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
cancellationService("iros", orderID, reason);
|
|
471
|
-
revalidateCallback && revalidateCallback();
|
|
472
|
-
handleClose();
|
|
473
|
-
}}
|
|
474
|
-
>
|
|
475
|
-
Yes
|
|
536
|
+
<Button variant="outlined" onClick={handleClose}>
|
|
537
|
+
Close
|
|
476
538
|
</Button>
|
|
477
|
-
<Button variant="contained" onClick={
|
|
478
|
-
|
|
539
|
+
<Button variant="contained" color="error" onClick={handleCancel}>
|
|
540
|
+
Confirm Cancellation
|
|
479
541
|
</Button>
|
|
480
542
|
</DialogActions>
|
|
481
543
|
</Dialog>
|
|
@@ -55,19 +55,21 @@ const INITIAL_STATE = {
|
|
|
55
55
|
|
|
56
56
|
const options = ["picked", "packed", "shipped", "reports"] as const;
|
|
57
57
|
|
|
58
|
+
interface ConfirmFormDialogProps {
|
|
59
|
+
open: boolean;
|
|
60
|
+
handleClose: () => void;
|
|
61
|
+
orderID: number;
|
|
62
|
+
currentStatus: "placed" | "external_shipping_process";
|
|
63
|
+
revalidateCallback?: () => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
function ConfirmFormDialog({
|
|
59
67
|
open,
|
|
60
68
|
handleClose,
|
|
61
69
|
orderID,
|
|
62
70
|
currentStatus,
|
|
63
71
|
revalidateCallback,
|
|
64
|
-
}: {
|
|
65
|
-
open: boolean;
|
|
66
|
-
handleClose: () => void;
|
|
67
|
-
orderID: number;
|
|
68
|
-
currentStatus: "placed" | "external_shipping_process";
|
|
69
|
-
revalidateCallback?: () => void;
|
|
70
|
-
}) {
|
|
72
|
+
}: ConfirmFormDialogProps): React.JSX.Element {
|
|
71
73
|
return (
|
|
72
74
|
<Dialog open={open}>
|
|
73
75
|
<DialogTitle>Confirm Order</DialogTitle>
|
|
@@ -96,19 +98,48 @@ function ConfirmFormDialog({
|
|
|
96
98
|
);
|
|
97
99
|
}
|
|
98
100
|
|
|
101
|
+
interface CancelOpoDialogProps {
|
|
102
|
+
open: boolean;
|
|
103
|
+
handleClose: () => void;
|
|
104
|
+
orderID: number;
|
|
105
|
+
revalidateCallback?: () => void;
|
|
106
|
+
}
|
|
107
|
+
|
|
99
108
|
function CancelOpoDialog({
|
|
100
109
|
open,
|
|
101
110
|
handleClose,
|
|
102
111
|
orderID,
|
|
103
112
|
revalidateCallback,
|
|
104
|
-
}: {
|
|
105
|
-
open: boolean;
|
|
106
|
-
handleClose: () => void;
|
|
107
|
-
orderID: number;
|
|
108
|
-
revalidateCallback?: () => void;
|
|
109
|
-
}) {
|
|
113
|
+
}: CancelOpoDialogProps): React.JSX.Element {
|
|
110
114
|
const [reason, setRoason] = useState<string>("");
|
|
111
115
|
const [reasonError, setReasonError] = useState<string>("");
|
|
116
|
+
|
|
117
|
+
const { handleAddMessage } = useSnackbar();
|
|
118
|
+
|
|
119
|
+
const handleCancel = async () => {
|
|
120
|
+
if (reason.length < 5) {
|
|
121
|
+
setReasonError(
|
|
122
|
+
"Please provide a reason for the cancellation (min 5 characters)"
|
|
123
|
+
);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
setReasonError("");
|
|
127
|
+
try {
|
|
128
|
+
await cancellationService("opos", orderID, reason);
|
|
129
|
+
handleAddMessage({
|
|
130
|
+
message: "Order cancelled successfully",
|
|
131
|
+
severity: "success",
|
|
132
|
+
});
|
|
133
|
+
revalidateCallback && revalidateCallback();
|
|
134
|
+
handleClose();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
handleAddMessage({
|
|
137
|
+
message: "Failed to cancel order",
|
|
138
|
+
severity: "error",
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
112
143
|
return (
|
|
113
144
|
<form>
|
|
114
145
|
<Dialog open={open}>
|
|
@@ -143,23 +174,11 @@ function CancelOpoDialog({
|
|
|
143
174
|
</Stack>
|
|
144
175
|
</DialogContent>
|
|
145
176
|
<DialogActions>
|
|
146
|
-
<Button
|
|
147
|
-
|
|
148
|
-
onClick={async (e) => {
|
|
149
|
-
if (reason.length < 5) {
|
|
150
|
-
setReasonError("Please provide a reason for the cancellation");
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const res = await cancellationService("opos", orderID, reason);
|
|
154
|
-
console.log("Cancellation response", res);
|
|
155
|
-
revalidateCallback && revalidateCallback();
|
|
156
|
-
handleClose();
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
159
|
-
Yes
|
|
177
|
+
<Button variant="outlined" onClick={handleClose}>
|
|
178
|
+
Close
|
|
160
179
|
</Button>
|
|
161
|
-
<Button variant="contained" onClick={
|
|
162
|
-
|
|
180
|
+
<Button variant="contained" color="error" onClick={handleCancel}>
|
|
181
|
+
Confirm Cancellation
|
|
163
182
|
</Button>
|
|
164
183
|
</DialogActions>
|
|
165
184
|
</Dialog>
|
|
@@ -133,14 +133,14 @@ function CancelIpoDialog({
|
|
|
133
133
|
try {
|
|
134
134
|
await cancellationService("ipos", orderID, reason);
|
|
135
135
|
handleAddMessage({
|
|
136
|
-
message: "
|
|
136
|
+
message: "Order cancelled successfully",
|
|
137
137
|
severity: "success",
|
|
138
138
|
});
|
|
139
139
|
revalidateCallback && revalidateCallback();
|
|
140
140
|
handleClose();
|
|
141
141
|
} catch (error) {
|
|
142
142
|
handleAddMessage({
|
|
143
|
-
message: "Failed to cancel
|
|
143
|
+
message: "Failed to cancel order",
|
|
144
144
|
severity: "error",
|
|
145
145
|
});
|
|
146
146
|
}
|
|
@@ -180,7 +180,7 @@ function CancelIpoDialog({
|
|
|
180
180
|
</DialogContent>
|
|
181
181
|
<DialogActions>
|
|
182
182
|
<Button variant="outlined" onClick={handleClose}>
|
|
183
|
-
|
|
183
|
+
Close
|
|
184
184
|
</Button>
|
|
185
185
|
<Button variant="contained" color="error" onClick={handleCancel}>
|
|
186
186
|
Confirm Cancellation
|
|
@@ -4,7 +4,6 @@ import { getAuthToken } from "../get-token";
|
|
|
4
4
|
import { getStrapiURL } from "../../../lib/utils"; //"@/lib/utils";
|
|
5
5
|
import { InvoiceOverwrites } from "../../../types/e-commerce/invoice/types";
|
|
6
6
|
|
|
7
|
-
// TODO move to common services
|
|
8
7
|
export async function confirmationService(
|
|
9
8
|
path: string,
|
|
10
9
|
ids: number[],
|