umwd-components 0.1.626 → 0.1.628
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/node_modules/base64-js/index.js +1 -1
- package/dist/node_modules/ieee754/index.js +1 -1
- package/dist/src/components/e-commerce/iro/CreateIROForm.js +1 -1
- package/dist/src/components/e-commerce/iro/IROItemFields.js +1 -1
- package/dist/src/components/e-commerce/iro/ManageIROForm.js +1 -1
- package/dist/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
- package/dist/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/src/data/actions/e-commerce/iro/createIroAction.js +1 -1
- package/dist/src/data/actions/e-commerce/iro/requestRmaAction.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/types/e-commerce/iro/types.d.ts +7 -5
- package/dist/types/types/e-commerce/opo/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/e-commerce/iro/CreateIROForm.tsx +18 -14
- package/src/components/e-commerce/iro/IROItemFields.tsx +32 -14
- package/src/components/e-commerce/iro/ManageIROForm.tsx +1 -1
- package/src/components/e-commerce/iro/RmaForm.tsx +154 -80
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +1 -1
- package/src/components/e-commerce/opo/CreateOpoForm.tsx +2 -2
- package/src/components/e-commerce/opo/ManageOpoForm.tsx +1 -1
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +1 -1
- package/src/data/actions/e-commerce/iro/createIroAction.ts +9 -0
- package/src/data/actions/e-commerce/iro/requestRmaAction.ts +12 -1
- package/src/types/e-commerce/iro/types.ts +7 -6
- package/src/types/e-commerce/opo/types.ts +1 -1
|
@@ -22,7 +22,8 @@ export interface IroItem {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
export interface NewIroItem {
|
|
25
|
-
|
|
25
|
+
line_item_number?: string;
|
|
26
|
+
product?: Product | number | ProductName;
|
|
26
27
|
reason: ReturnReason;
|
|
27
28
|
other_reason?: string;
|
|
28
29
|
returned_quantity: number;
|
|
@@ -31,19 +32,20 @@ export type IroStatus = "requested" | "returning" | "logistics_operator_process"
|
|
|
31
32
|
export interface Iro {
|
|
32
33
|
id: number;
|
|
33
34
|
uuid: string;
|
|
35
|
+
return_number: string;
|
|
34
36
|
is_archive: boolean;
|
|
35
37
|
return_date: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
confirmation_email_sent: boolean;
|
|
39
|
+
customer_internal_reference: string;
|
|
38
40
|
status: IroStatus;
|
|
39
|
-
|
|
41
|
+
iro_items: {
|
|
40
42
|
data: IroItem[];
|
|
41
43
|
};
|
|
42
44
|
notes: {
|
|
43
45
|
data: Note[];
|
|
44
46
|
};
|
|
45
47
|
customer?: CustomerProfileProps;
|
|
46
|
-
|
|
48
|
+
opos?: Opo[];
|
|
47
49
|
}
|
|
48
50
|
export interface ManageIroFormProps {
|
|
49
51
|
data: Iro;
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ export default function CreateIroForm({
|
|
|
34
34
|
customerLabels,
|
|
35
35
|
productLabels,
|
|
36
36
|
}: CreateIroFormProps) {
|
|
37
|
-
const [
|
|
37
|
+
const [returnConfirmed, setReturnConfirmed] = useState(false);
|
|
38
38
|
const [formState, formAction] = useFormState(createIroAction, INITIAL_STATE);
|
|
39
39
|
|
|
40
40
|
useEffect(() => {
|
|
@@ -55,6 +55,9 @@ export default function CreateIroForm({
|
|
|
55
55
|
<Grid item xs={12}>
|
|
56
56
|
<Stack spacing={2}>
|
|
57
57
|
<Typography variant="h6">Choose a customer</Typography>
|
|
58
|
+
<Typography variant="body2">
|
|
59
|
+
Select the customer for which you want to create a return order
|
|
60
|
+
</Typography>
|
|
58
61
|
<CustomerSelector
|
|
59
62
|
customerLabels={customerLabels}
|
|
60
63
|
// onChangeCallback={onChangeCustomer}
|
|
@@ -69,14 +72,16 @@ export default function CreateIroForm({
|
|
|
69
72
|
management it should be left here
|
|
70
73
|
</Typography>
|
|
71
74
|
<TextField
|
|
72
|
-
id="
|
|
73
|
-
name="
|
|
75
|
+
id="customer_internal_reference"
|
|
76
|
+
name="customer_internal_reference"
|
|
74
77
|
sx={{ width: "100%" }}
|
|
75
78
|
/>
|
|
76
79
|
</Stack>
|
|
77
80
|
</Grid>
|
|
78
81
|
<Grid item xs={12}>
|
|
79
|
-
<Typography variant="h6">
|
|
82
|
+
<Typography variant="h6">
|
|
83
|
+
Choose products that should be in this return order
|
|
84
|
+
</Typography>
|
|
80
85
|
<IROItemFields productsArr={productLabels} />
|
|
81
86
|
</Grid>
|
|
82
87
|
{/*
|
|
@@ -95,27 +100,26 @@ export default function CreateIroForm({
|
|
|
95
100
|
<Grid item xs={12}>
|
|
96
101
|
<Typography variant="h6">Confirm Order</Typography>
|
|
97
102
|
<Typography>
|
|
98
|
-
Are you sure you want to confirm this
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
invoices
|
|
103
|
+
Are you sure you want to confirm this return? Confirming this
|
|
104
|
+
order means you are sure the customer wants to return the products
|
|
105
|
+
and you are ready to process the return.
|
|
102
106
|
</Typography>
|
|
103
107
|
<Stack direction={"row"} spacing={1} alignItems={"center"}>
|
|
104
108
|
<Checkbox
|
|
105
|
-
value={
|
|
106
|
-
checked={
|
|
107
|
-
onChange={() =>
|
|
109
|
+
value={returnConfirmed}
|
|
110
|
+
checked={returnConfirmed}
|
|
111
|
+
onChange={() => setReturnConfirmed(!returnConfirmed)}
|
|
108
112
|
/>
|
|
109
|
-
{
|
|
113
|
+
{returnConfirmed && (
|
|
110
114
|
<Typography color={"primary"}>
|
|
111
|
-
I am sure I want to confirm this order
|
|
115
|
+
I am sure I want to confirm this return order
|
|
112
116
|
</Typography>
|
|
113
117
|
)}
|
|
114
118
|
</Stack>
|
|
115
119
|
<input
|
|
116
120
|
name={"status"}
|
|
117
121
|
type="hidden"
|
|
118
|
-
value={
|
|
122
|
+
value={returnConfirmed ? "returning" : "requested"}
|
|
119
123
|
/>
|
|
120
124
|
</Grid>
|
|
121
125
|
<Grid item xs={12}>
|
|
@@ -14,20 +14,23 @@ import { ProductName } from "../../../types/e-commerce/product/types";
|
|
|
14
14
|
import dayjs from "dayjs";
|
|
15
15
|
import DeleteIcon from "@mui/icons-material/Delete";
|
|
16
16
|
import { useTheme } from "@mui/material/styles";
|
|
17
|
+
import { NewIroItem } from "../../../types/e-commerce/iro/types";
|
|
18
|
+
import { ReturnReason } from "../../../types/e-commerce/iro/types";
|
|
17
19
|
|
|
18
20
|
const getWeek = (date: Date) => {
|
|
19
21
|
return dayjs(date).isoWeek();
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
|
|
23
|
-
const [items, setItems] = useState<
|
|
24
|
-
{ product: ProductName; amount: number }[]
|
|
25
|
-
>([]);
|
|
25
|
+
const [items, setItems] = useState<NewIroItem[]>([]);
|
|
26
26
|
|
|
27
27
|
const [nextProductName, setNextProductName] = useState<ProductName | null>(
|
|
28
28
|
null
|
|
29
29
|
);
|
|
30
30
|
const [nextAmount, setNextAmount] = useState<number>(0);
|
|
31
|
+
const [nextReason, setNextReason] = useState<ReturnReason>("damaged");
|
|
32
|
+
const [nextOtherReason, setNextOtherReason] = useState<string>("");
|
|
33
|
+
|
|
31
34
|
const [selectedProduct, setSelectedProduct] = useState<number[]>([]);
|
|
32
35
|
|
|
33
36
|
const handleAddItem = () => {
|
|
@@ -35,14 +38,18 @@ export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
|
|
|
35
38
|
console.log("nextProductName or nextAmount is null");
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
|
-
const newItem = {
|
|
39
|
-
product: nextProductName,
|
|
40
|
-
|
|
41
|
+
const newItem: NewIroItem = {
|
|
42
|
+
product: nextProductName.id,
|
|
43
|
+
returned_quantity: nextAmount,
|
|
44
|
+
reason: nextReason,
|
|
45
|
+
other_reason: nextOtherReason,
|
|
41
46
|
};
|
|
42
47
|
setItems([...items, newItem]);
|
|
43
48
|
// reset the fields
|
|
44
49
|
setNextProductName(null);
|
|
45
50
|
setNextAmount(0);
|
|
51
|
+
setNextReason("damaged");
|
|
52
|
+
setNextOtherReason("");
|
|
46
53
|
setSelectedProduct([]);
|
|
47
54
|
};
|
|
48
55
|
|
|
@@ -56,17 +63,23 @@ export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
|
|
|
56
63
|
type parsedIroItem = {
|
|
57
64
|
line_item_number: string;
|
|
58
65
|
product: number;
|
|
59
|
-
|
|
66
|
+
returned_quantity: number;
|
|
67
|
+
reason: ReturnReason;
|
|
68
|
+
other_reason: string;
|
|
60
69
|
};
|
|
61
70
|
|
|
62
|
-
const parseItems = (
|
|
63
|
-
items: { product: ProductName; amount: number }[]
|
|
64
|
-
): parsedIroItem[] => {
|
|
71
|
+
const parseItems = (items: NewIroItem[]): parsedIroItem[] => {
|
|
65
72
|
return items.map((item, index) => {
|
|
66
73
|
return {
|
|
67
74
|
line_item_number: `${index + 1}.0.0`,
|
|
68
|
-
product: item.product
|
|
69
|
-
|
|
75
|
+
product: item.product
|
|
76
|
+
? typeof item.product === "number"
|
|
77
|
+
? item.product
|
|
78
|
+
: item.product.id
|
|
79
|
+
: 0,
|
|
80
|
+
returned_quantity: item.returned_quantity,
|
|
81
|
+
reason: nextReason,
|
|
82
|
+
other_reason: nextOtherReason,
|
|
70
83
|
};
|
|
71
84
|
});
|
|
72
85
|
};
|
|
@@ -98,9 +111,14 @@ export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
|
|
|
98
111
|
<TableRow key={index}>
|
|
99
112
|
<TableCell sx={[{ width: "15%" }]}>{index + 1}.0.0</TableCell>
|
|
100
113
|
<TableCell sx={[{ width: "70%" }]}>
|
|
101
|
-
{item.product
|
|
114
|
+
{typeof item.product === "object"
|
|
115
|
+
? item.product.product_number
|
|
116
|
+
: item.product}{" "}
|
|
117
|
+
| {typeof item.product === "object" ? item.product.title : ""}
|
|
118
|
+
</TableCell>
|
|
119
|
+
<TableCell sx={{ width: "15%" }}>
|
|
120
|
+
{item.returned_quantity}
|
|
102
121
|
</TableCell>
|
|
103
|
-
<TableCell sx={{ width: "15%" }}>{item.amount}</TableCell>
|
|
104
122
|
|
|
105
123
|
<TableCell align="right" sx={{ width: "5%" }}>
|
|
106
124
|
<IconButton onClick={() => handleDeleteItem(index)}>
|
|
@@ -224,7 +224,7 @@ export default function ManageIROForm({
|
|
|
224
224
|
<Typography variant="body1" width={"250px"}>
|
|
225
225
|
Purchase Order Number
|
|
226
226
|
</Typography>
|
|
227
|
-
<Typography variant="body2">{data.
|
|
227
|
+
<Typography variant="body2">{data.return_number}</Typography>
|
|
228
228
|
</Stack>
|
|
229
229
|
|
|
230
230
|
<Stack direction="row" spacing={2}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React, { useEffect, useState } from "react";
|
|
3
|
+
import React, { Suspense, useEffect, useState } from "react";
|
|
4
4
|
import { useFormState } from "react-dom";
|
|
5
5
|
|
|
6
6
|
import { requestRmaAction } from "../../../data/actions/e-commerce/iro/requestRmaAction";
|
|
@@ -32,80 +32,159 @@ const INITIAL_STATE = {
|
|
|
32
32
|
message: null,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
interface
|
|
36
|
-
|
|
37
|
-
addToRma: (item: NewIroItem) => void;
|
|
35
|
+
interface ItemLinesProps {
|
|
36
|
+
items: OpoItem[];
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
const
|
|
39
|
+
const ItemLines: React.FC<ItemLinesProps> = ({ items }) => {
|
|
40
|
+
const [itemsToReturn, setItemsToReturn] = useState<NewIroItem[]>([]);
|
|
41
|
+
const [selectedItems, setSelectedItems] = useState<number[]>([]);
|
|
42
|
+
|
|
41
43
|
const [showCustomReason, setShowCustomReason] = useState(false);
|
|
42
44
|
|
|
43
|
-
const
|
|
45
|
+
const updateItemsToReturn = (
|
|
46
|
+
index: number,
|
|
47
|
+
name: string,
|
|
48
|
+
newValue: number | string
|
|
49
|
+
) => {
|
|
50
|
+
setItemsToReturn(
|
|
51
|
+
itemsToReturn.map((item, i) => {
|
|
52
|
+
if (i === index) {
|
|
53
|
+
return { ...item, [name]: newValue };
|
|
54
|
+
}
|
|
55
|
+
return item;
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (items) {
|
|
62
|
+
setItemsToReturn(
|
|
63
|
+
items.map((item) => {
|
|
64
|
+
return {
|
|
65
|
+
line_item_number: item.line_item_number,
|
|
66
|
+
product: item.product,
|
|
67
|
+
ordered_quantity: item.ordered_quantity,
|
|
68
|
+
returned_quantity: 0,
|
|
69
|
+
reason: "damaged",
|
|
70
|
+
other_reason: "",
|
|
71
|
+
};
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}, [items]);
|
|
76
|
+
|
|
77
|
+
const [parsedItems, setParsedItems] = useState<parsedIroItem[]>([]);
|
|
78
|
+
|
|
79
|
+
type parsedIroItem = {
|
|
80
|
+
line_item_number: string;
|
|
81
|
+
product: number;
|
|
82
|
+
returned_quantity: number;
|
|
83
|
+
reason: "damaged" | "not_as_described" | "wrong_item" | "other";
|
|
84
|
+
other_reason: string;
|
|
85
|
+
};
|
|
44
86
|
|
|
45
|
-
const [
|
|
87
|
+
const parseItems = (items: NewIroItem[]): parsedIroItem[] => {
|
|
88
|
+
return itemsToReturn.map((item, index) => {
|
|
89
|
+
return {
|
|
90
|
+
line_item_number: `${index + 1}.0.0`,
|
|
91
|
+
product:
|
|
92
|
+
typeof item.product === "object" && "id" in item.product
|
|
93
|
+
? item.product.id
|
|
94
|
+
: 0,
|
|
95
|
+
returned_quantity: item.returned_quantity,
|
|
96
|
+
reason: item.reason,
|
|
97
|
+
other_reason: item.other_reason || "",
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
};
|
|
46
101
|
|
|
47
|
-
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (itemsToReturn) {
|
|
104
|
+
setParsedItems(parseItems(itemsToReturn));
|
|
105
|
+
}
|
|
106
|
+
}, [itemsToReturn]);
|
|
48
107
|
|
|
49
108
|
return (
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
label="Quantity to return"
|
|
62
|
-
currentValue={0}
|
|
63
|
-
totalValue={item.ordered_quantity}
|
|
64
|
-
minNewValue={0}
|
|
65
|
-
maxNewValue={item.ordered_quantity}
|
|
66
|
-
handleChange={(newValue) => {
|
|
67
|
-
console.log(newValue);
|
|
68
|
-
setNewReturnQuantity(newValue);
|
|
69
|
-
}}
|
|
70
|
-
color="info"
|
|
71
|
-
/>
|
|
72
|
-
<Typography variant="body1">Reason for return:</Typography>
|
|
73
|
-
<TextField
|
|
74
|
-
select
|
|
75
|
-
SelectProps={{
|
|
76
|
-
native: true,
|
|
77
|
-
}}
|
|
78
|
-
variant="outlined"
|
|
79
|
-
fullWidth
|
|
80
|
-
onChange={(e) => {
|
|
81
|
-
const reason = e.target.value;
|
|
82
|
-
if (reason === "other") {
|
|
83
|
-
setShowCustomReason(true);
|
|
84
|
-
} else {
|
|
85
|
-
setShowCustomReason(false);
|
|
86
|
-
}
|
|
87
|
-
setNewReason(reason as ReturnReason);
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<option value="damaged">Damaged</option>
|
|
91
|
-
<option value="not_as_described">Not as described</option>
|
|
92
|
-
<option value="wrong_item">Wrong item</option>
|
|
93
|
-
<option value="other">Other</option>
|
|
94
|
-
</TextField>
|
|
95
|
-
{showCustomReason && (
|
|
96
|
-
<TextField
|
|
97
|
-
label="Custom reason"
|
|
98
|
-
variant="outlined"
|
|
99
|
-
fullWidth
|
|
100
|
-
onChange={(e) => {
|
|
101
|
-
const customReason = e.target.value;
|
|
102
|
-
console.log(customReason);
|
|
103
|
-
setNewOtherReason(customReason);
|
|
104
|
-
}}
|
|
109
|
+
<Suspense fallback={<div>Loading...</div>}>
|
|
110
|
+
<Stack spacing={2}>
|
|
111
|
+
<Typography variant="h6">Items</Typography>
|
|
112
|
+
<Typography variant="body1">
|
|
113
|
+
from the items in the original order please select the items you'd
|
|
114
|
+
like to return
|
|
115
|
+
</Typography>
|
|
116
|
+
<input
|
|
117
|
+
type="hidden"
|
|
118
|
+
name="iro_items"
|
|
119
|
+
value={JSON.stringify(parsedItems)}
|
|
105
120
|
/>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
121
|
+
<Stack spacing={1}>
|
|
122
|
+
{items.map((item, index) => (
|
|
123
|
+
<Stack spacing={1}>
|
|
124
|
+
<Typography variant="body1">
|
|
125
|
+
Line Item Number: {item.line_item_number}
|
|
126
|
+
</Typography>
|
|
127
|
+
<Typography variant="body1">
|
|
128
|
+
Part Number: {item.product?.product_number}
|
|
129
|
+
</Typography>
|
|
130
|
+
<Typography variant="body1">
|
|
131
|
+
Quantity Ordered: {item.ordered_quantity}
|
|
132
|
+
</Typography>
|
|
133
|
+
{/* */}
|
|
134
|
+
<TextualAmountUpdater
|
|
135
|
+
label="Quantity to return"
|
|
136
|
+
currentValue={item.ordered_quantity}
|
|
137
|
+
totalValue={item.ordered_quantity}
|
|
138
|
+
minNewValue={0}
|
|
139
|
+
maxNewValue={item.ordered_quantity}
|
|
140
|
+
handleChange={(newValue) => {
|
|
141
|
+
console.log(newValue);
|
|
142
|
+
updateItemsToReturn(index, "returned_quantity", newValue);
|
|
143
|
+
}}
|
|
144
|
+
color="info"
|
|
145
|
+
/>
|
|
146
|
+
<Typography variant="body1">Reason for return:</Typography>
|
|
147
|
+
<TextField
|
|
148
|
+
value={itemsToReturn[index]?.reason}
|
|
149
|
+
select
|
|
150
|
+
SelectProps={{
|
|
151
|
+
native: true,
|
|
152
|
+
}}
|
|
153
|
+
variant="outlined"
|
|
154
|
+
fullWidth
|
|
155
|
+
onChange={(e) => {
|
|
156
|
+
const reason = e.target.value;
|
|
157
|
+
if (reason === "other") {
|
|
158
|
+
setShowCustomReason(true);
|
|
159
|
+
} else {
|
|
160
|
+
setShowCustomReason(false);
|
|
161
|
+
}
|
|
162
|
+
updateItemsToReturn(index, "reason", reason as ReturnReason);
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
<option value="damaged">Damaged</option>
|
|
166
|
+
<option value="not_as_described">Not as described</option>
|
|
167
|
+
<option value="wrong_item">Wrong item</option>
|
|
168
|
+
<option value="other">Other</option>
|
|
169
|
+
</TextField>
|
|
170
|
+
{showCustomReason && (
|
|
171
|
+
<TextField
|
|
172
|
+
value={itemsToReturn[index].other_reason}
|
|
173
|
+
label="Custom reason"
|
|
174
|
+
variant="outlined"
|
|
175
|
+
fullWidth
|
|
176
|
+
onChange={(e) => {
|
|
177
|
+
const customReason = e.target.value;
|
|
178
|
+
updateItemsToReturn(index, "other_reason", customReason);
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
)}
|
|
182
|
+
<Divider />
|
|
183
|
+
</Stack>
|
|
184
|
+
))}
|
|
185
|
+
</Stack>
|
|
186
|
+
</Stack>
|
|
187
|
+
</Suspense>
|
|
109
188
|
);
|
|
110
189
|
};
|
|
111
190
|
|
|
@@ -146,12 +225,6 @@ export default function RmaForm({
|
|
|
146
225
|
}: RMAFormProps) {
|
|
147
226
|
const [formState, formAction] = useFormState(requestRmaAction, INITIAL_STATE);
|
|
148
227
|
|
|
149
|
-
const [items, setItems] = useState<NewIroItem[]>([]);
|
|
150
|
-
|
|
151
|
-
const handleAddItem = (item: NewIroItem) => {
|
|
152
|
-
setItems([...items, item]);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
228
|
/* const handleDeleteItem = (index: number) => {
|
|
156
229
|
const newItems = items.filter((_, i) => i !== index);
|
|
157
230
|
setItems(newItems);
|
|
@@ -163,7 +236,11 @@ export default function RmaForm({
|
|
|
163
236
|
}
|
|
164
237
|
}, [formState.data]);
|
|
165
238
|
|
|
166
|
-
console.log(opo);
|
|
239
|
+
console.log("opo", opo);
|
|
240
|
+
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
console.log("formState", formState);
|
|
243
|
+
}, [formState]);
|
|
167
244
|
|
|
168
245
|
return (
|
|
169
246
|
<Box
|
|
@@ -177,6 +254,7 @@ export default function RmaForm({
|
|
|
177
254
|
<Grid item xs={12}>
|
|
178
255
|
<Typography variant="h6">RMA Form</Typography>
|
|
179
256
|
</Grid>
|
|
257
|
+
<input type="hidden" name="opos" value={JSON.stringify([opo.id])} />
|
|
180
258
|
<Grid item xs={12}>
|
|
181
259
|
<Stack spacing={2}>
|
|
182
260
|
<Typography variant="body1">
|
|
@@ -195,13 +273,9 @@ export default function RmaForm({
|
|
|
195
273
|
you'd like to return
|
|
196
274
|
</Typography>
|
|
197
275
|
<Stack spacing={1}>
|
|
198
|
-
{opo.opo_items?.data
|
|
199
|
-
<
|
|
200
|
-
|
|
201
|
-
item={opoItem}
|
|
202
|
-
addToRma={handleAddItem}
|
|
203
|
-
/>
|
|
204
|
-
))}
|
|
276
|
+
{opo.opo_items?.data && (
|
|
277
|
+
<ItemLines items={opo.opo_items?.data} />
|
|
278
|
+
)}
|
|
205
279
|
</Stack>
|
|
206
280
|
</Stack>
|
|
207
281
|
) : (
|
|
@@ -283,7 +283,7 @@ export default function TextualManageIROForm({
|
|
|
283
283
|
<Typography variant="body1" width={"250px"}>
|
|
284
284
|
Purchase Order Number
|
|
285
285
|
</Typography>
|
|
286
|
-
<Typography variant="body2">{data.
|
|
286
|
+
<Typography variant="body2">{data.return_number}</Typography>
|
|
287
287
|
</Stack>
|
|
288
288
|
|
|
289
289
|
<Stack direction="row" spacing={2}>
|
|
@@ -67,8 +67,8 @@ export default function CreateOpoForm({
|
|
|
67
67
|
management it should be left here
|
|
68
68
|
</Typography>
|
|
69
69
|
<TextField
|
|
70
|
-
id="
|
|
71
|
-
name="
|
|
70
|
+
id="customer_internal_reference"
|
|
71
|
+
name="customer_internal_reference"
|
|
72
72
|
sx={{ width: "100%" }}
|
|
73
73
|
/>
|
|
74
74
|
</Stack>
|
|
@@ -13,6 +13,15 @@ export async function createIroAction(prevState: any, formData: FormData) {
|
|
|
13
13
|
|
|
14
14
|
const parsedFormData = parseFormData(formData);
|
|
15
15
|
|
|
16
|
+
console.log(parsedFormData);
|
|
17
|
+
/* if (parsedFormData.iro_items.length === 0) {
|
|
18
|
+
return {
|
|
19
|
+
...prevState,
|
|
20
|
+
strapiErrors: null,
|
|
21
|
+
message: "Ops! Something went wrong. Please try again.",
|
|
22
|
+
};
|
|
23
|
+
}} */
|
|
24
|
+
|
|
16
25
|
const responseData = await mutateData(
|
|
17
26
|
"POST",
|
|
18
27
|
`/api/iros/createAdmin`, //TODO create in CMS
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use client";
|
|
2
|
+
//"use server";
|
|
2
3
|
|
|
3
4
|
import { mutateData } from "../../../services/mutate-data";
|
|
4
5
|
import { flattenAttributes } from "../../../../lib/utils";
|
|
@@ -12,6 +13,16 @@ export async function requestRmaAction(prevState: any, formData: FormData) {
|
|
|
12
13
|
|
|
13
14
|
const parsedFormData = parseFormData(formData);
|
|
14
15
|
|
|
16
|
+
if (parsedFormData.data.iro_items) {
|
|
17
|
+
parsedFormData.data.iro_items = JSON.parse(parsedFormData.data.iro_items);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (parsedFormData.data.opos) {
|
|
21
|
+
parsedFormData.data.opos = JSON.parse(parsedFormData.data.opos);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log("parsedFormData", parsedFormData);
|
|
25
|
+
|
|
15
26
|
const responseData = await mutateData("POST", `/api/iros`, parsedFormData);
|
|
16
27
|
|
|
17
28
|
if (!responseData) {
|
|
@@ -27,7 +27,8 @@ export interface IroItem {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface NewIroItem {
|
|
30
|
-
|
|
30
|
+
line_item_number?: string;
|
|
31
|
+
product?: Product | number | ProductName;
|
|
31
32
|
reason: ReturnReason;
|
|
32
33
|
other_reason?: string;
|
|
33
34
|
returned_quantity: number;
|
|
@@ -46,18 +47,18 @@ export type IroStatus =
|
|
|
46
47
|
export interface Iro {
|
|
47
48
|
id: number;
|
|
48
49
|
uuid: string;
|
|
50
|
+
return_number: string;
|
|
49
51
|
is_archive: boolean;
|
|
50
52
|
return_date: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return_number: string;
|
|
53
|
+
confirmation_email_sent: boolean;
|
|
54
|
+
customer_internal_reference: string;
|
|
54
55
|
status: IroStatus;
|
|
55
|
-
|
|
56
|
+
iro_items: { data: IroItem[] };
|
|
56
57
|
notes: {
|
|
57
58
|
data: Note[];
|
|
58
59
|
};
|
|
59
60
|
customer?: CustomerProfileProps;
|
|
60
|
-
|
|
61
|
+
opos?: Opo[];
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export interface ManageIroFormProps {
|