umwd-components 0.1.628 → 0.1.630

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.
Files changed (26) hide show
  1. package/dist/node_modules/base64-js/index.js +1 -1
  2. package/dist/node_modules/ieee754/index.js +1 -1
  3. package/dist/src/components/common/markdown/MarkdownEditor.js +1 -1
  4. package/dist/src/components/e-commerce/iro/IROItemFields.js +1 -1
  5. package/dist/src/components/e-commerce/iro/{IROItemUpdater.js → IroItemUpdater.js} +1 -1
  6. package/dist/src/components/e-commerce/iro/IroStatusIndicator.js +1 -1
  7. package/dist/src/components/e-commerce/iro/ManageIROForm.js +1 -1
  8. package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
  9. package/dist/src/data/actions/e-commerce/iro/createIroAction.js +1 -1
  10. package/dist/src/index.js +1 -1
  11. package/dist/tsconfig.build.tsbuildinfo +1 -1
  12. package/dist/types/components/e-commerce/iro/IroItemUpdater.d.ts +4 -0
  13. package/dist/types/components/e-commerce/iro/IroStatusIndicator.d.ts +2 -2
  14. package/dist/types/index.d.ts +3 -3
  15. package/dist/types/types/e-commerce/iro/types.d.ts +1 -1
  16. package/package.json +1 -1
  17. package/src/components/common/markdown/MarkdownEditor.tsx +1 -0
  18. package/src/components/e-commerce/iro/IROItemFields.tsx +62 -14
  19. package/src/components/e-commerce/iro/{IROItemUpdater.tsx → IroItemUpdater.tsx} +3 -3
  20. package/src/components/e-commerce/iro/IroStatusIndicator.tsx +15 -14
  21. package/src/components/e-commerce/iro/ManageIROForm.tsx +4 -4
  22. package/src/components/e-commerce/iro/TextualManageIROForm.tsx +15 -15
  23. package/src/data/actions/e-commerce/iro/createIroAction.ts +8 -3
  24. package/src/index.ts +3 -3
  25. package/src/types/e-commerce/iro/types.ts +1 -1
  26. package/dist/types/components/e-commerce/iro/IROItemUpdater.d.ts +0 -4
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { ItemUpdaterProps } from "../../../types/logistics/Ipo";
3
+ declare function IroItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCallback, }: ItemUpdaterProps): React.JSX.Element;
4
+ export default IroItemUpdater;
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { IpoStatus } from "../../../types/logistics/Ipo";
2
+ import { IroStatus } from "../../../types/e-commerce/iro/types";
3
3
  import { Role } from "../../../types/auth/Role";
4
4
  interface IroStatusIndicatorProps {
5
- status: IpoStatus;
5
+ status: IroStatus;
6
6
  provider_id?: string;
7
7
  role?: Role;
8
8
  }
@@ -202,10 +202,10 @@ export { createIroAction as createIroAction } from "./data/actions/e-commerce/ir
202
202
  export { updateIroAction as updateIroAction } from "./data/actions/e-commerce/iro/updateIroAction";
203
203
  export { default as IroItemDisplay } from "./components/e-commerce/iro/IroItemDisplay";
204
204
  export { IROItemFields as IROItemFields } from "./components/e-commerce/iro/IROItemFields";
205
- export { default as createIroForm } from "./components/e-commerce/iro/CreateIROForm";
206
- export { default as IROItemUpdater } from "./components/e-commerce/iro/IROItemUpdater";
205
+ export { default as CreateIroForm } from "./components/e-commerce/iro/CreateIROForm";
206
+ export { default as IROItemUpdater } from "./components/e-commerce/iro/IroItemUpdater";
207
207
  export { default as RmaForm } from "./components/e-commerce/iro/RmaForm";
208
208
  export { IroStatusIndicator } from "./components/e-commerce/iro/IroStatusIndicator";
209
209
  export { default as ManageIROForm } from "./components/e-commerce/iro/ManageIROForm";
210
210
  export { default as TextualIROItemUpdater } from "./components/e-commerce/iro/TextualIROItemUpdater";
211
- export { default as TextualManageIROForm } from "./components/e-commerce/iro/TextualManageIROForm";
211
+ export { default as TextualManageIroForm } from "./components/e-commerce/iro/TextualManageIROForm";
@@ -23,7 +23,7 @@ export interface IroItem {
23
23
  }
24
24
  export interface NewIroItem {
25
25
  line_item_number?: string;
26
- product?: Product | number | ProductName;
26
+ product?: Product | number;
27
27
  reason: ReturnReason;
28
28
  other_reason?: string;
29
29
  returned_quantity: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umwd-components",
3
- "version": "0.1.628",
3
+ "version": "0.1.630",
4
4
  "description": "UMWD Component library",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/src/index.js",
@@ -52,6 +52,7 @@ export default function MarkdownEditor({
52
52
  <Paper
53
53
  sx={{
54
54
  p: 2,
55
+ background: "none",
55
56
  border: `1px solid ${theme.palette.primary.main}`,
56
57
  height: "100%",
57
58
  }}
@@ -16,30 +16,41 @@ import DeleteIcon from "@mui/icons-material/Delete";
16
16
  import { useTheme } from "@mui/material/styles";
17
17
  import { NewIroItem } from "../../../types/e-commerce/iro/types";
18
18
  import { ReturnReason } from "../../../types/e-commerce/iro/types";
19
+ import next from "next";
19
20
 
20
21
  const getWeek = (date: Date) => {
21
22
  return dayjs(date).isoWeek();
22
23
  };
23
24
 
25
+ interface newItem {
26
+ product: ProductName | null;
27
+ returned_quantity: number;
28
+ reason: ReturnReason;
29
+ other_reason: string;
30
+ }
31
+
24
32
  export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
25
- const [items, setItems] = useState<NewIroItem[]>([]);
33
+ const [items, setItems] = useState<newItem[]>([]);
26
34
 
27
35
  const [nextProductName, setNextProductName] = useState<ProductName | null>(
28
36
  null
29
37
  );
38
+
30
39
  const [nextAmount, setNextAmount] = useState<number>(0);
31
40
  const [nextReason, setNextReason] = useState<ReturnReason>("damaged");
32
41
  const [nextOtherReason, setNextOtherReason] = useState<string>("");
33
42
 
34
43
  const [selectedProduct, setSelectedProduct] = useState<number[]>([]);
35
44
 
45
+ const [showCustomReason, setShowCustomReason] = useState(false);
46
+
36
47
  const handleAddItem = () => {
37
- if (nextProductName === null || nextAmount === null) {
48
+ if (nextAmount === null) {
38
49
  console.log("nextProductName or nextAmount is null");
39
50
  return;
40
51
  }
41
- const newItem: NewIroItem = {
42
- product: nextProductName.id,
52
+ const newItem = {
53
+ product: nextProductName,
43
54
  returned_quantity: nextAmount,
44
55
  reason: nextReason,
45
56
  other_reason: nextOtherReason,
@@ -68,15 +79,11 @@ export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
68
79
  other_reason: string;
69
80
  };
70
81
 
71
- const parseItems = (items: NewIroItem[]): parsedIroItem[] => {
82
+ const parseItems = (items: newItem[]): parsedIroItem[] => {
72
83
  return items.map((item, index) => {
73
84
  return {
74
85
  line_item_number: `${index + 1}.0.0`,
75
- product: item.product
76
- ? typeof item.product === "number"
77
- ? item.product
78
- : item.product.id
79
- : 0,
86
+ product: item.product?.id || 0,
80
87
  returned_quantity: item.returned_quantity,
81
88
  reason: nextReason,
82
89
  other_reason: nextOtherReason,
@@ -99,8 +106,9 @@ export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
99
106
  Line Item Number
100
107
  </TableCell>
101
108
 
102
- <TableCell sx={[{ width: "70%" }]}>Product Number</TableCell>
109
+ <TableCell sx={[{ width: "35%" }]}>Product Number</TableCell>
103
110
  <TableCell sx={[{ width: "15%" }]}>Amount</TableCell>
111
+ <TableCell sx={[{ width: "35%" }]}>Reason</TableCell>
104
112
 
105
113
  <TableCell sx={[]}></TableCell>
106
114
  </TableRow>
@@ -110,15 +118,19 @@ export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
110
118
  return (
111
119
  <TableRow key={index}>
112
120
  <TableCell sx={[{ width: "15%" }]}>{index + 1}.0.0</TableCell>
113
- <TableCell sx={[{ width: "70%" }]}>
121
+ <TableCell sx={[{ width: "35%" }]}>
114
122
  {typeof item.product === "object"
115
- ? item.product.product_number
123
+ ? item.product?.product_number
116
124
  : item.product}{" "}
117
- | {typeof item.product === "object" ? item.product.title : ""}
125
+ |{" "}
126
+ {typeof item.product === "object" ? item.product?.title : ""}
118
127
  </TableCell>
119
128
  <TableCell sx={{ width: "15%" }}>
120
129
  {item.returned_quantity}
121
130
  </TableCell>
131
+ <TableCell sx={{ width: "35%" }}>
132
+ {item.reason === "other" ? item.other_reason : item.reason}
133
+ </TableCell>
122
134
 
123
135
  <TableCell align="right" sx={{ width: "5%" }}>
124
136
  <IconButton onClick={() => handleDeleteItem(index)}>
@@ -179,6 +191,42 @@ export function IROItemFields({ productsArr }: { productsArr: ProductName[] }) {
179
191
  helperText={formErrors.amount} */
180
192
  sx={{ width: "15%" }}
181
193
  ></TextField>
194
+ <TextField
195
+ value={nextReason}
196
+ select
197
+ SelectProps={{
198
+ native: true,
199
+ }}
200
+ variant="outlined"
201
+ fullWidth={!(nextReason === "other")}
202
+ sx={{ minWidth: "25%" }}
203
+ onChange={(e) => {
204
+ const reason = e.target.value;
205
+ if (reason === "other") {
206
+ setShowCustomReason(true);
207
+ } else {
208
+ setShowCustomReason(false);
209
+ }
210
+ setNextReason(e.target.value as ReturnReason);
211
+ }}
212
+ >
213
+ <option value="damaged">Damaged</option>
214
+ <option value="not_as_described">Not as described</option>
215
+ <option value="wrong_item">Wrong item</option>
216
+ <option value="other">Other</option>
217
+ </TextField>
218
+ {showCustomReason && (
219
+ <TextField
220
+ value={nextOtherReason}
221
+ label="Custom reason"
222
+ variant="outlined"
223
+ fullWidth
224
+ onChange={(e) => {
225
+ const customReason = e.target.value;
226
+ setNextOtherReason(customReason);
227
+ }}
228
+ />
229
+ )}
182
230
 
183
231
  <IconButton onClick={handleAddItem}>
184
232
  <AddIcon />
@@ -13,7 +13,7 @@ import { Report } from "../../../types/logistics/Report";
13
13
  import ReportMakingComponent from "../../logistics/report/ReportMakingComponent";
14
14
  import ReportsDisplay from "../../logistics/report/ReportsDisplay";
15
15
 
16
- function ItemUpdater({
16
+ function IroItemUpdater({
17
17
  item,
18
18
  index,
19
19
  handleUpdateQuantity,
@@ -112,7 +112,7 @@ function ItemUpdater({
112
112
  type="registered"
113
113
  minValue={-(received_quantity + registered_bad_quantity)}
114
114
  maxValue={received_quantity}
115
- related={[{ id: item.id, __type: "api::logistics.ipo-item" }]}
115
+ related={[{ id: item.id, __type: "api::e-commerce.iro-item" }]}
116
116
  revalidateCallback={revalidateCallback}
117
117
  />
118
118
  </Stack>
@@ -137,4 +137,4 @@ function ItemUpdater({
137
137
  );
138
138
  }
139
139
 
140
- export default ItemUpdater;
140
+ export default IroItemUpdater;
@@ -4,49 +4,50 @@ import React from "react";
4
4
 
5
5
  import Chip from "@mui/material/Chip";
6
6
 
7
- import { IpoStatus } from "../../../types/logistics/Ipo";
7
+ import { IroStatus } from "../../../types/e-commerce/iro/types";
8
8
  import { Role } from "../../../types/auth/Role";
9
9
 
10
10
  interface IroStatusIndicatorProps {
11
- status: IpoStatus;
11
+ status: IroStatus;
12
12
  provider_id?: string;
13
13
  role?: Role;
14
14
  }
15
15
 
16
+ // TODO update colors and statusses
16
17
  const statusColorArray: {
17
- status: IpoStatus;
18
+ status: IroStatus;
18
19
  color: "warning" | "info" | "success" | "error" | "default";
19
20
  }[] = [
20
- { status: "placed", color: "info" },
21
- { status: "ordered", color: "info" },
21
+ { status: "requested", color: "info" },
22
+ { status: "returning", color: "info" },
22
23
  { status: "logistics_operator_process", color: "info" },
23
- { status: "released_on_stock", color: "info" },
24
+ { status: "finalising_process", color: "info" },
24
25
  { status: "done", color: "success" },
25
26
  { status: "cancelled", color: "error" },
26
27
  { status: null, color: "default" },
27
28
  ];
28
29
 
29
30
  const enduserStatusColorArray: {
30
- status: IpoStatus;
31
+ status: IroStatus;
31
32
  color: "warning" | "info" | "success" | "error" | "default";
32
33
  }[] = [
33
- { status: "placed", color: "warning" },
34
- { status: "ordered", color: "info" },
34
+ { status: "requested", color: "warning" },
35
+ { status: "returning", color: "info" },
35
36
  { status: "logistics_operator_process", color: "info" },
36
- { status: "released_on_stock", color: "info" },
37
+ { status: "finalising_process", color: "warning" },
37
38
  { status: "done", color: "success" },
38
39
  { status: "cancelled", color: "error" },
39
40
  { status: null, color: "default" },
40
41
  ];
41
42
 
42
43
  const dispatcherStatusColorArray: {
43
- status: IpoStatus;
44
+ status: IroStatus;
44
45
  color: "warning" | "info" | "success" | "error" | "default";
45
46
  }[] = [
46
- { status: "placed", color: "info" },
47
- { status: "ordered", color: "warning" },
47
+ { status: "requested", color: "info" },
48
+ { status: "returning", color: "warning" },
48
49
  { status: "logistics_operator_process", color: "info" },
49
- { status: "released_on_stock", color: "info" },
50
+ { status: "finalising_process", color: "info" },
50
51
  { status: "done", color: "success" },
51
52
  { status: "cancelled", color: "error" },
52
53
  { status: null, color: "default" },
@@ -3,7 +3,7 @@ import { useFormState } from "react-dom";
3
3
  import { updateIpoAction } from "../../../data/actions/logistics/ipo/updateIpoAction";
4
4
  import { UploadBase64MediaForm } from "../../../components/common/media/UploadBase64MediaForm";
5
5
  import downloadBase64File from "../../../data/loaders/common/media/downloadBase64File";
6
- import ItemUpdater from "./IROItemUpdater";
6
+ import ItemUpdater from "./IroItemUpdater";
7
7
  import ItemDisplay from "./IroItemDisplay";
8
8
  import {
9
9
  IroItem,
@@ -152,7 +152,7 @@ export default function ManageIROForm({
152
152
  const [formState, formAction] = useFormState(updateIpoAction, INITIAL_STATE);
153
153
 
154
154
  const [items, setItems] = useState<IroItem[]>(
155
- data.items.data ? data.items.data : []
155
+ data.iro_items.data ? data.iro_items.data : []
156
156
  );
157
157
  const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
158
158
 
@@ -403,8 +403,8 @@ export default function ManageIROForm({
403
403
  * should be within the form, thats why the form spans two grid items
404
404
  * */}
405
405
  <input name="id" type="hidden" value={data.id} />
406
- {data?.items?.data &&
407
- data.items.data.map((item: IroItem, index: number) => {
406
+ {data?.iro_items?.data &&
407
+ data.iro_items.data.map((item: IroItem, index: number) => {
408
408
  console.log("item", item);
409
409
  return (
410
410
  <Paper sx={{ p: 2, mb: 2 }} key={index}>
@@ -155,7 +155,7 @@ export default function TextualManageIROForm({
155
155
  const [formState, formAction] = useFormState(updateIroAction, INITIAL_STATE);
156
156
 
157
157
  const [items, setItems] = useState<IroItem[]>(
158
- data.items.data ? data.items.data : []
158
+ data.iro_items.data ? data.iro_items.data : []
159
159
  );
160
160
 
161
161
  const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
@@ -238,8 +238,8 @@ export default function TextualManageIROForm({
238
238
  }, [formState]);
239
239
 
240
240
  useEffect(() => {
241
- if (data.items?.data) {
242
- setItems(data.items.data ? data.items.data : []);
241
+ if (data.iro_items?.data) {
242
+ setItems(data.iro_items.data ? data.iro_items.data : []);
243
243
  }
244
244
  }, [data]);
245
245
 
@@ -260,10 +260,10 @@ export default function TextualManageIROForm({
260
260
  >
261
261
  <Stack spacing={2}>
262
262
  <Typography variant="h3" component={"h1"}>
263
- Management Inbound Purchase Order
263
+ Management Inbound Return
264
264
  </Typography>
265
265
  <Typography variant="body1">
266
- Manage arrival, registration and recieval of purchase order
266
+ Manage arrival, registration and release of return
267
267
  </Typography>
268
268
  </Stack>
269
269
  <NoteTakingComponent
@@ -281,21 +281,21 @@ export default function TextualManageIROForm({
281
281
 
282
282
  <Stack direction="row" spacing={2}>
283
283
  <Typography variant="body1" width={"250px"}>
284
- Purchase Order Number
284
+ Return Number
285
285
  </Typography>
286
286
  <Typography variant="body2">{data.return_number}</Typography>
287
287
  </Stack>
288
288
 
289
- <Stack direction="row" spacing={2}>
289
+ {/* <Stack direction="row" spacing={2}>
290
290
  <Typography variant="body1" width={"250px"}>
291
291
  Custom reference
292
292
  </Typography>
293
- {/* <Typography variant="body2">{data.custom_reference}</Typography> */}
294
- </Stack>
293
+ <Typography variant="body2">{data.custom_reference}</Typography>
294
+ </Stack> */}
295
295
 
296
296
  <Stack direction="row" spacing={2}>
297
297
  <Typography variant="body1" width={"250px"}>
298
- Order Date
298
+ Return Date
299
299
  </Typography>
300
300
 
301
301
  <Typography variant="body2">{data.return_date}</Typography>
@@ -303,16 +303,16 @@ export default function TextualManageIROForm({
303
303
 
304
304
  <Stack direction="row" spacing={2}>
305
305
  <Typography variant="body1" width={"250px"}>
306
- Supplier
306
+ Customer
307
+ </Typography>
308
+ <Typography variant="body2">
309
+ {data.customer?.business_credentials?.company_name}
307
310
  </Typography>
308
- {/* <Typography variant="body2">
309
- {data.vendor_profile?.business_credentials?.company_name}
310
- </Typography> */}
311
311
  </Stack>
312
312
 
313
313
  <Stack direction="row" spacing={2}>
314
314
  <Typography variant="body1" width={"250px"}>
315
- Order Status
315
+ Return Status
316
316
  </Typography>
317
317
  <Typography variant="body2" width={"250px"}>
318
318
  {data.status}
@@ -13,14 +13,19 @@ export async function createIroAction(prevState: any, formData: FormData) {
13
13
 
14
14
  const parsedFormData = parseFormData(formData);
15
15
 
16
+ if (parsedFormData.data.iro_items) {
17
+ parsedFormData.data.iro_items = JSON.parse(parsedFormData.data.iro_items);
18
+ }
19
+
16
20
  console.log(parsedFormData);
17
- /* if (parsedFormData.iro_items.length === 0) {
21
+
22
+ if (parsedFormData.data.iro_items.length === 0) {
18
23
  return {
19
24
  ...prevState,
20
25
  strapiErrors: null,
21
- message: "Ops! Something went wrong. Please try again.",
26
+ message: "Please add at least one item to the Iro.",
22
27
  };
23
- }} */
28
+ }
24
29
 
25
30
  const responseData = await mutateData(
26
31
  "POST",
package/src/index.ts CHANGED
@@ -313,10 +313,10 @@ export { createIroAction as createIroAction } from "./data/actions/e-commerce/ir
313
313
  export { updateIroAction as updateIroAction } from "./data/actions/e-commerce/iro/updateIroAction";
314
314
  export { default as IroItemDisplay } from "./components/e-commerce/iro/IroItemDisplay";
315
315
  export { IROItemFields as IROItemFields } from "./components/e-commerce/iro/IROItemFields";
316
- export { default as createIroForm } from "./components/e-commerce/iro/CreateIROForm";
317
- export { default as IROItemUpdater } from "./components/e-commerce/iro/IROItemUpdater";
316
+ export { default as CreateIroForm } from "./components/e-commerce/iro/CreateIROForm";
317
+ export { default as IROItemUpdater } from "./components/e-commerce/iro/IroItemUpdater";
318
318
  export { default as RmaForm } from "./components/e-commerce/iro/RmaForm";
319
319
  export { IroStatusIndicator } from "./components/e-commerce/iro/IroStatusIndicator";
320
320
  export { default as ManageIROForm } from "./components/e-commerce/iro/ManageIROForm";
321
321
  export { default as TextualIROItemUpdater } from "./components/e-commerce/iro/TextualIROItemUpdater";
322
- export { default as TextualManageIROForm } from "./components/e-commerce/iro/TextualManageIROForm";
322
+ export { default as TextualManageIroForm } from "./components/e-commerce/iro/TextualManageIROForm";
@@ -28,7 +28,7 @@ export interface IroItem {
28
28
 
29
29
  export interface NewIroItem {
30
30
  line_item_number?: string;
31
- product?: Product | number | ProductName;
31
+ product?: Product | number;
32
32
  reason: ReturnReason;
33
33
  other_reason?: string;
34
34
  returned_quantity: number;
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import { ItemUpdaterProps } from "../../../types/logistics/Ipo";
3
- declare function ItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCallback, }: ItemUpdaterProps): React.JSX.Element;
4
- export default ItemUpdater;