umwd-components 0.1.734 → 0.1.736

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 (42) hide show
  1. package/dist/cjs/src/components/ContactForm.js +1 -1
  2. package/dist/cjs/src/components/common/Contacts.js +1 -1
  3. package/dist/cjs/src/components/common/Dimensions.js +1 -1
  4. package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
  5. package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
  6. package/dist/cjs/src/components/logistics/vendor/EditVendorForm.js +1 -1
  7. package/dist/cjs/src/components/logistics/vendor/VendorDisplay.js +1 -1
  8. package/dist/cjs/src/components/public-information/PublicInformationForm.js +1 -1
  9. package/dist/cjs/src/data/actions/e-commerce/iro/requestRmaAction.js +1 -1
  10. package/dist/cjs/src/data/loaders/e-commerce/getAllOpos.js +1 -1
  11. package/dist/cjs/src/data/loaders/e-commerce/getPaginatedCategories.js +1 -1
  12. package/dist/cjs/src/data/loaders/e-commerce/getSingleOpo.js +1 -1
  13. package/dist/cjs/src/data/loaders/e-commerce/iros/getSingleIro.js +1 -1
  14. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  15. package/dist/esm/src/components/ContactForm.js +1 -0
  16. package/dist/esm/src/components/common/Contacts.js +5 -5
  17. package/dist/esm/src/components/common/Dimensions.js +2 -2
  18. package/dist/esm/src/components/e-commerce/iro/RmaForm.js +7 -11
  19. package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +6 -5
  20. package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +4 -4
  21. package/dist/esm/src/components/logistics/vendor/EditVendorForm.js +11 -8
  22. package/dist/esm/src/components/logistics/vendor/VendorDisplay.js +1 -1
  23. package/dist/esm/src/components/public-information/PublicInformationForm.js +2 -2
  24. package/dist/esm/src/data/actions/e-commerce/iro/requestRmaAction.js +3 -1
  25. package/dist/esm/src/data/loaders/e-commerce/getAllOpos.js +1 -1
  26. package/dist/esm/src/data/loaders/e-commerce/getPaginatedCategories.js +13 -3
  27. package/dist/esm/src/data/loaders/e-commerce/getSingleOpo.js +1 -3
  28. package/dist/esm/src/data/loaders/e-commerce/iros/getAllIros.js +8 -0
  29. package/dist/esm/src/data/loaders/e-commerce/iros/getSingleIro.js +5 -5
  30. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  31. package/dist/esm/types/components/e-commerce/iro/TextualIROItemUpdater.d.ts +2 -2
  32. package/dist/esm/types/components/e-commerce/iro/TextualManageIROForm.d.ts +1 -1
  33. package/dist/esm/types/data/loaders/e-commerce/getAllOpos.d.ts +1 -1
  34. package/dist/esm/types/data/loaders/e-commerce/getPaginatedCategories.d.ts +12 -1
  35. package/dist/esm/types/data/loaders/e-commerce/iros/getAllIros.d.ts +8 -0
  36. package/dist/esm/types/data/loaders/e-commerce/iros/getSingleIro.d.ts +1 -1
  37. package/dist/esm/types/types/common/Contact.d.ts +2 -2
  38. package/dist/esm/types/types/common/Dimensions.d.ts +0 -1
  39. package/dist/esm/types/types/e-commerce/iro/types.d.ts +1 -1
  40. package/dist/esm/types/types/e-commerce/product/types.d.ts +1 -1
  41. package/dist/esm/types/types/logistics/Vendor.d.ts +2 -6
  42. package/package.json +1 -1
@@ -87,6 +87,7 @@ function ContactForm({ data }) {
87
87
  },
88
88
  method: "POST",
89
89
  });
90
+ console.log("Response from sendgrid:", res);
90
91
  if (res.ok) {
91
92
  setShowSuccessMessage(true);
92
93
  setShowFailureMessage(false);
@@ -16,16 +16,16 @@ import IconButton from '@mui/material/IconButton';
16
16
  import { Delete } from '@mui/icons-material';
17
17
 
18
18
  function Contacts({ data, }) {
19
- const { id, first_name, last_name, email, phone_number, type, onClick } = data;
19
+ const { documentId, first_name, last_name, email, phone_number, type, onClick, } = data;
20
20
  return (jsx(Stack, { children: jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(AccountCircleIcon, {}), jsxs(Stack, { children: [jsxs(Typography, { children: [first_name, " ", last_name] }), jsx(Typography, { children: email }), jsx(Typography, { children: phone_number }), jsx(Typography, { children: type }), onClick && (jsx(Button, { onClick: (e) => {
21
- if (id) {
22
- onClick(e, id);
21
+ if (first_name) {
22
+ onClick(e, first_name); // TODO need fixing!!
23
23
  }
24
24
  }, children: "Edit" }))] })] }) }));
25
25
  }
26
26
  function ContactsFields({ data, componentName, componentReference, deleteCallback, }) {
27
- const { id, first_name, last_name, email, phone_number, type } = data || {};
28
- return (jsxs(Stack, { spacing: 1, children: [jsx("input", { id: `${componentName}.__component`, type: "hidden", name: `${componentName}.__component`, value: componentReference }), id && (jsx("input", { id: `${componentName}.id`, type: "hidden", name: `${componentName}.id`, value: id })), jsxs(Stack, { spacing: 1, direction: "row", children: [jsx(TextField, { id: "first_name", name: `${componentName}.first_name`, label: "First Name", defaultValue: first_name || "" }), deleteCallback && (jsx(IconButton, { onClick: deleteCallback, children: jsx(Delete, {}) }))] }), jsx(TextField, { id: "last_name", name: `${componentName}.last_name`, label: "Last Name", defaultValue: last_name || "" }), jsx(TextField, { id: "email", name: `${componentName}.email`, label: "E-mail", defaultValue: email || "" }), jsx(TextField, { id: "phone_number", name: `${componentName}.phone_number`, label: "Phone Number", defaultValue: phone_number || "" }), jsx(Autocomplete, { id: "type", options: Object.values(ContactType), defaultValue: type || Object.values(ContactType)[0], renderInput: (params) => (jsx(TextField, { ...params, name: `${componentName}.type`, label: "Type" })) })] }));
27
+ const { first_name, last_name, email, phone_number, type } = data || {};
28
+ return (jsxs(Stack, { spacing: 1, children: [jsxs(Stack, { spacing: 1, direction: "row", children: [jsx(TextField, { id: "first_name", name: `${componentName}.first_name`, label: "First Name", defaultValue: first_name || "" }), deleteCallback && (jsx(IconButton, { onClick: deleteCallback, children: jsx(Delete, {}) }))] }), jsx(TextField, { id: "last_name", name: `${componentName}.last_name`, label: "Last Name", defaultValue: last_name || "" }), jsx(TextField, { id: "email", name: `${componentName}.email`, label: "E-mail", defaultValue: email || "" }), jsx(TextField, { id: "phone_number", name: `${componentName}.phone_number`, label: "Phone Number", defaultValue: phone_number || "" }), jsx(Autocomplete, { id: "type", options: Object.values(ContactType), defaultValue: type || Object.values(ContactType)[0], renderInput: (params) => (jsx(TextField, { ...params, name: `${componentName}.type`, label: "Type" })) })] }));
29
29
  }
30
30
 
31
31
  export { ContactsFields, Contacts as default };
@@ -11,8 +11,8 @@ import '@mui/material/Typography';
11
11
  import HomeIcon from '@mui/icons-material/Home';
12
12
 
13
13
  function DimensionsFields({ data, componentName, componentReference, }) {
14
- const { id, width_mm, height_mm, depth_mm, weight_gr } = data || {};
15
- return (jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(HomeIcon, {}), jsxs(Stack, { spacing: 1, sx: { flex: 1 }, children: [jsx("input", { id: ``, type: "hidden", name: `${componentName}.__component`, value: componentReference }), id && (jsx("input", { id: ``, type: "hidden", name: `${componentName}.id`, value: id })), jsx(TextField, { id: "width_mm", type: "number", name: `${componentName}.width_mm`, label: "Width (mm)", defaultValue: width_mm || "" }), jsx(TextField, { id: "height_mm", type: "number", name: `${componentName}.height_mm`, label: "Height (mm)", defaultValue: height_mm || "" }), jsx(TextField, { id: "depth_mm", type: "number", name: `${componentName}.depth_mm`, label: "Depth (mm)", defaultValue: depth_mm || "" }), jsx(TextField, { id: "weight_gr", type: "number", name: `${componentName}.weight_gr`, label: "Weight (gr)", defaultValue: weight_gr || "" })] })] }));
14
+ const { width_mm, height_mm, depth_mm, weight_gr } = data || {};
15
+ return (jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(HomeIcon, {}), jsxs(Stack, { spacing: 1, sx: { flex: 1 }, children: [jsx(TextField, { id: "width_mm", type: "number", name: `${componentName}.width_mm`, label: "Width (mm)", defaultValue: width_mm || "" }), jsx(TextField, { id: "height_mm", type: "number", name: `${componentName}.height_mm`, label: "Height (mm)", defaultValue: height_mm || "" }), jsx(TextField, { id: "depth_mm", type: "number", name: `${componentName}.depth_mm`, label: "Depth (mm)", defaultValue: depth_mm || "" }), jsx(TextField, { id: "weight_gr", type: "number", name: `${componentName}.weight_gr`, label: "Weight (gr)", defaultValue: weight_gr || "" })] })] }));
16
16
  }
17
17
 
18
18
  export { DimensionsFields };
@@ -52,8 +52,8 @@ const ItemLines = ({ items, itemsToReturn, setItemsToReturn, selectedItems, setS
52
52
  if (items) {
53
53
  setItemsToReturn(items.map((item) => {
54
54
  return {
55
- line_item_number: item.line_item_number,
56
- product: item.product,
55
+ line_item_number: item.line_item_number || "", // Handle undefined
56
+ product: item.product?.documentId || "", // Extract string ID from Product object
57
57
  ordered_quantity: item.ordered_quantity,
58
58
  returned_quantity: 0,
59
59
  reason: "damaged",
@@ -64,12 +64,10 @@ const ItemLines = ({ items, itemsToReturn, setItemsToReturn, selectedItems, setS
64
64
  }, [items]);
65
65
  const [parsedItems, setParsedItems] = useState([]);
66
66
  const parseItems = (items) => {
67
- return itemsToReturn.map((item, index) => {
67
+ return items.map((item, index) => {
68
68
  return {
69
69
  line_item_number: `${index + 1}.0.0`,
70
- product: typeof item.product === "object" && "documentId" in item.product
71
- ? item.product.documentId
72
- : "",
70
+ product: item.product,
73
71
  returned_quantity: item.returned_quantity,
74
72
  reason: item.reason,
75
73
  other_reason: item.other_reason || "",
@@ -78,7 +76,7 @@ const ItemLines = ({ items, itemsToReturn, setItemsToReturn, selectedItems, setS
78
76
  };
79
77
  useEffect(() => {
80
78
  if (itemsToReturn) {
81
- setParsedItems(parseItems());
79
+ setParsedItems(parseItems(itemsToReturn));
82
80
  }
83
81
  }, [itemsToReturn]);
84
82
  return (jsx(Suspense, { fallback: jsx("div", { children: "Loading..." }), children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Items" }), jsx(Typography, { variant: "body1", children: "from the items in the original order please select the items you'd like to return" }), jsx("input", { type: "hidden", name: "iro_items", value: JSON.stringify(parsedItems) }), jsx(Stack, { spacing: 1, children: items.map((item, index) => (jsxs(Fragment, { children: [jsxs(Stack, { spacing: 1, direction: "row", alignItems: "center", children: [jsx(Checkbox, { checked: selectedItems.includes(index), onChange: (e) => {
@@ -108,9 +106,7 @@ const ItemLines = ({ items, itemsToReturn, setItemsToReturn, selectedItems, setS
108
106
  };
109
107
  const ConfirmRMADialog = ({ open, onClose, items, formState, submitCallback, }) => {
110
108
  const [missingConfirmations, setMissingConfirmations] = useState(true);
111
- return (jsxs(Dialog, { open: open, onClose: onClose, children: [jsx(DialogTitle, { children: "Confirm RMA" }), jsxs(DialogContent, { children: [jsx(DialogContentText, { children: "Summary of items to be returned:" }), jsx(List, { children: items.map((item, index) => (jsxs(ListItem, { children: [typeof item.product === "object"
112
- ? `${item?.product?.product_number} ${item?.product?.title}`
113
- : `Product with ID ${item.product}`, " ", "- Quantity: ", item.returned_quantity] }, index))) }), jsx(DialogContentText, { children: "Are you sure you want to request a return merchandise authorization for these items?" }), jsx(Checkbox, { onChange: (e) => setMissingConfirmations(!e.target.checked) }), jsx(Typography, { variant: "body1", children: "I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration." })] }), jsxs(DialogActions, { children: [submitCallback ? (jsx(SubmitButton, { text: "Yes", loadingText: "Loading...", disabled: missingConfirmations, onClick: submitCallback })) : (jsx(SubmitButton, { text: "Yes", loadingText: "Loading...", disabled: missingConfirmations })), jsx(Button, { onClick: onClose, children: "No" }), formState?.strapiErrors !== null && (jsx(StrapiErrors, { error: formState?.strapiErrors })), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message }))] })] }));
109
+ return (jsxs(Dialog, { open: open, onClose: onClose, children: [jsx(DialogTitle, { children: "Confirm RMA" }), jsxs(DialogContent, { children: [jsx(DialogContentText, { children: "Summary of items to be returned:" }), jsx(List, { children: items.map((item, index) => (jsx(ListItem, { children: `Product with ID ${item.product} - Quantity: ${item.returned_quantity}` }, index))) }), jsx(DialogContentText, { children: "Are you sure you want to request a return merchandise authorization for these items?" }), jsx(Checkbox, { onChange: (e) => setMissingConfirmations(!e.target.checked) }), jsx(Typography, { variant: "body1", children: "I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration." })] }), jsxs(DialogActions, { children: [submitCallback ? (jsx(SubmitButton, { text: "Yes", loadingText: "Loading...", disabled: missingConfirmations, onClick: submitCallback })) : (jsx(SubmitButton, { text: "Yes", loadingText: "Loading...", disabled: missingConfirmations })), jsx(Button, { onClick: onClose, children: "No" }), formState?.strapiErrors !== null && (jsx(StrapiErrors, { error: formState?.strapiErrors })), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message }))] })] }));
114
110
  };
115
111
  /* INFO Request RMA Return Merchandise Authorization for customers*/
116
112
  function RmaForm({ opo, sx, revalidateCallback, handleClose, }) {
@@ -143,7 +139,7 @@ function RmaForm({ opo, sx, revalidateCallback, handleClose, }) {
143
139
  });
144
140
  }
145
141
  }, [formState?.strapiErrors]);
146
- return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: "RMA Form" }) }), jsx("input", { type: "hidden", name: "opos", value: JSON.stringify([opo.documentId]) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body1", children: "Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned." }), jsx(Alert, { severity: "warning", children: "We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items." })] }) }), jsx(Grid, { item: true, xs: 12, children: opo.opo_items ? (jsx(Stack, { spacing: 1, children: opo.opo_items && (jsx(ItemLines, { items: opo.opo_items, itemsToReturn: itemsToReturn, setItemsToReturn: setItemsToReturn, selectedItems: selectedItems, setSelectedItems: setSelectedItems })) })) : (jsx(Typography, { variant: "body1", children: "No items" })) }), jsx(ConfirmRMADialog, { formState: formState, open: open, items: itemsToReturn.filter((item) => item.returned_quantity > 0), onClose: () => setOpen(!open), submitCallback: () => {
142
+ return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: "RMA Form" }) }), jsx("input", { type: "hidden", name: "opos", value: opo.documentId }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body1", children: "Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned." }), jsx(Alert, { severity: "warning", children: "We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items." })] }) }), jsx(Grid, { item: true, xs: 12, children: opo.opo_items ? (jsx(Stack, { spacing: 1, children: opo.opo_items && (jsx(ItemLines, { items: opo.opo_items, itemsToReturn: itemsToReturn, setItemsToReturn: setItemsToReturn, selectedItems: selectedItems, setSelectedItems: setSelectedItems })) })) : (jsx(Typography, { variant: "body1", children: "No items" })) }), jsx(ConfirmRMADialog, { formState: formState, open: open, items: itemsToReturn.filter((item) => item.returned_quantity > 0), onClose: () => setOpen(!open), submitCallback: () => {
147
143
  console.log("submit callback");
148
144
  const formElement = document.querySelector("form");
149
145
  if (formElement) {
@@ -19,21 +19,22 @@ import PreReportsDisplay from '../../logistics/report/PreReportsDisplay.js';
19
19
  import SimpleReportFields from '../../logistics/report/SimpleReportFields.js';
20
20
  import Box from '@mui/material/Box';
21
21
 
22
- function TextualIROItemUpdater({ item, index, handleAddReport, handleUpdateQuantity, image, handleRemoveReportAtIndex, showing, }) {
22
+ function TextualIroItemUpdater({ item, index, handleAddReport, handleUpdateQuantity, image, handleRemoveReportAtIndex, showing, }) {
23
+ console.log("TextualIROItemUpdater", item);
23
24
  const { line_item_number, product, returned_quantity, received_quantity, registered_quantity, released_quantity, reports, reason, other_reason, } = item;
24
25
  const [open, setOpen] = useState(false);
25
26
  // these values where wrapped with useMemo before but that did not work well while updating values
26
- reports !== undefined && reports.length > 0
27
+ reports != null && reports.length > 0
27
28
  ? reports
28
29
  .filter((report) => report.type === "received")
29
30
  .reduce((a, b) => a + b.quantity, 0)
30
31
  : 0;
31
- const registered_reports_quantity = reports !== undefined && reports.length > 0
32
+ const registered_reports_quantity = reports != null && reports.length > 0
32
33
  ? reports
33
34
  .filter((report) => report.type === "registered")
34
35
  .reduce((a, b) => a + b.quantity, 0)
35
36
  : 0;
36
- reports !== undefined && reports.length > 0
37
+ reports != null && reports.length > 0
37
38
  ? reports
38
39
  .filter((report) => report.type === "released")
39
40
  .reduce((a, b) => a + b.quantity, 0)
@@ -54,4 +55,4 @@ function TextualIROItemUpdater({ item, index, handleAddReport, handleUpdateQuant
54
55
  } })] }))] })) }, index));
55
56
  }
56
57
 
57
- export { TextualIROItemUpdater as default };
58
+ export { TextualIroItemUpdater as default };
@@ -8,7 +8,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
8
  import { useState, useEffect } from 'react';
9
9
  import { useFormState } from 'react-dom';
10
10
  import { updateIroAction } from '../../../data/actions/e-commerce/iro/updateIroAction.js';
11
- import TextualIROItemUpdater from './TextualIROItemUpdater.js';
11
+ import TextualIroItemUpdater from './TextualIROItemUpdater.js';
12
12
  import IroItemDisplay from './IroItemDisplay.js';
13
13
  import NotesDisplay from '../../logistics/note/NotesDisplay.js';
14
14
  import NoteTakingComponent from '../../logistics/note/NoteTakingComponent.js';
@@ -241,7 +241,7 @@ function CancelIroDialog({ open, handleClose, orderID, revalidateCallback, }) {
241
241
  };
242
242
  return (jsx("form", { children: jsxs(Dialog, { open: open, onClose: handleClose, children: [jsx(DialogTitle, { children: "Cancel Return" }), jsx(DialogContent, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { children: "Are you sure you want to cancel this return?" }), jsxs(List, { children: [jsx(ListItem, { children: "By cancelling this return order you will update it's status from requested to cancelled" }), jsx(ListItem, { children: "Please provide a reason for the cancellation" }), jsx(ListItem, { children: "The customer will be notified about the cancellation and of the reason for the cancellation" })] }), jsx(TextField, { label: "Cancellation reason", name: "reason", multiline: true, rows: 4, fullWidth: true, variant: "outlined", value: reason, onChange: (e) => setRoason(e.target.value), placeholder: "Please provide a reason for the cancellation", error: !!reasonError, helperText: reasonError })] }) }), jsxs(DialogActions, { children: [jsx(Button, { variant: "outlined", onClick: handleClose, children: "Close" }), jsx(Button, { variant: "contained", color: "error", onClick: handleCancel, children: "Confirm Cancellation" })] })] }) }));
243
243
  }
244
- function TextualManageIROForm({ data, sx,
244
+ function TextualManageIroForm({ data, sx,
245
245
  // revalidates the selectedOpo from the database
246
246
  revalidateCallback, handleClose, role, }) {
247
247
  // Bind documentId to the action
@@ -361,8 +361,8 @@ revalidateCallback, handleClose, role, }) {
361
361
  items.map((item, index) => {
362
362
  return (jsx(Paper, { sx: { p: 2, mb: 2 }, children: data.internal_status === "requested" ||
363
363
  data.internal_status === "cancelled" ||
364
- data.internal_status === "done" ? (jsx(IroItemDisplay, { item: item, index: index, image: item?.product?.image })) : (jsx(TextualIROItemUpdater, { item: item, index: index, handleUpdateQuantity: handleUpdateQuantity, handleAddReport: handleAddReport, image: item?.product?.image, handleRemoveReportAtIndex: handleRemoveReportAtIndex, revalidateCallback: revalidateCallback, showing: showing })) }, index));
364
+ data.internal_status === "done" ? (jsx(IroItemDisplay, { item: item, index: index, image: item?.product?.image })) : (jsx(TextualIroItemUpdater, { item: item, index: index, handleUpdateQuantity: handleUpdateQuantity, handleAddReport: handleAddReport, image: item?.product?.image, handleRemoveReportAtIndex: handleRemoveReportAtIndex, revalidateCallback: revalidateCallback, showing: showing })) }, index));
365
365
  }), jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { pt: 2 }, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { text: "Save changes", loadingText: "Saving...", variant: "contained" })] })] })] }) })] }) }));
366
366
  }
367
367
 
368
- export { TextualManageIROForm as default };
368
+ export { TextualManageIroForm as default };
@@ -59,7 +59,8 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
59
59
  });
60
60
  }
61
61
  }, [formState?.strapiErrors]);
62
- const initialProducts = products?.data || [];
62
+ const initialProducts = products || [];
63
+ console.log("initialProducts", initialProducts);
63
64
  const [open, setOpen] = useState([]);
64
65
  const onClickHandler = (event, id) => {
65
66
  if (open.includes(id)) {
@@ -86,8 +87,9 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
86
87
  __type: "api::logistics.vendor-profile",
87
88
  },
88
89
  ], revalidateCallback: revalidateCallback })] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(ExplanatoryFoldOut, { title: "Vendor", description: "Vendors are businesses that you purchase products from." }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: jsx(BusinessCredentialsFields, { data: business_credentials, componentName: "business_credentials", componentReference: "common.business-credentials" }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: jsxs(Stack, { spacing: 2, children: [jsx(TextField, { id: "website_url", name: "website_url", label: "Website Url", defaultValue: website_url }), jsx(TextField, { id: "phone_number", name: "phone_number", label: "Phone Number", defaultValue: phone_number }), jsx(TextField, { id: "email", name: "email", label: "Email", defaultValue: email })] }) }), jsxs(Grid, { item: true, xs: 12, md: 6, children: [jsx(Typography, { variant: "h6", children: "Address" }), jsx(AddressFields, { data: address, componentName: "address", componentReference: "common.address" })] }), jsxs(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: [jsx(Typography, { variant: "h6", children: "Products" }), jsx(ProductSelector, { productNames: productNamesArr, currentValue: initialProducts.map((prod) => prod.documentId) })] }), jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: jsx(Typography, { variant: "h6", children: "Contacts" }) }), oldContacts?.map((contact, index) => {
89
- if (contact.data?.id) {
90
- if (open.includes(contact.data?.id)) {
90
+ console.log("contact", contact);
91
+ if (contact.data?.first_name) {
92
+ if (open.includes(contact.data?.first_name)) {
91
93
  return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
92
94
  justifyContent: "center",
93
95
  display: "flex",
@@ -104,21 +106,21 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
104
106
  /* setOpen(
105
107
  open.filter((openId) => openId !== contact.data?.id)
106
108
  ); */
107
- } }) }) }, contact.data.id));
109
+ } }) }) }, contact.data?.documentId || index));
108
110
  }
109
111
  else {
110
112
  return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
111
113
  justifyContent: "center",
112
114
  display: "flex",
113
115
  alignItems: "center",
114
- }, children: jsxs(Paper, { sx: {
116
+ }, children: jsx(Paper, { sx: {
115
117
  p: 2,
116
118
  width: "100%",
117
119
  display: "flex",
118
120
  justifyContent: "center",
119
121
  alignItems: "center",
120
122
  height: "100%",
121
- }, children: [jsx("input", { type: "hidden", name: `contacts[${index}].id`, value: contact.data.id }), jsx("input", { type: "hidden", name: `contacts[${index}].__component`, value: "logistics-elements.contact" }), jsx(Contacts, { data: { ...contact.data, onClick: onClickHandler } })] }) }, contact.data.id));
123
+ }, children: jsx(Contacts, { data: { ...contact.data, onClick: onClickHandler } }) }) }, contact.data?.documentId || index));
122
124
  }
123
125
  }
124
126
  return null;
@@ -143,7 +145,7 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
143
145
  componentName: `contacts[${i + oldContacts.length}]`,
144
146
  };
145
147
  }));
146
- } }) }) }, contact.data?.id || index));
148
+ } }) }) }, contact.data?.documentId || index));
147
149
  }), jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
148
150
  justifyContent: "center",
149
151
  display: "flex",
@@ -162,6 +164,7 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
162
164
  componentName: `contacts[${oldContacts.length + newContacts.length}]`,
163
165
  componentReference: "logistics-elements.contact",
164
166
  data: {
167
+ documentId: "",
165
168
  uuid: Math.random(),
166
169
  first_name: "",
167
170
  last_name: "",
@@ -171,7 +174,7 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
171
174
  },
172
175
  },
173
176
  ]);
174
- }, size: "large", children: "Add contact" }) }) }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Notes" }), notes?.data !== undefined ? (jsx(NotesDisplay, { notes: notes.data })) : (jsx(Typography, { children: "No notes to display" }))] }), " ", jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", alignItems: "center", sx: { mt: 2 }, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { text: "Update Vendor", loadingText: "Updating..." })] }) })] }) }) }));
177
+ }, size: "large", children: "Add contact" }) }) }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Notes" }), Array.isArray(notes) && notes.length > 0 ? (jsx(NotesDisplay, { notes: notes })) : (jsx(Typography, { children: "No notes to display" }))] }), " ", jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", alignItems: "center", sx: { mt: 2 }, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { text: "Update Vendor", loadingText: "Updating..." })] }) })] }) }) }));
175
178
  }
176
179
 
177
180
  export { EditVendorForm };
@@ -24,7 +24,7 @@ function VendorDisplay({ data, sx }) {
24
24
  // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
25
25
  { p: 2 },
26
26
  ...(Array.isArray(sx) ? sx : [sx]),
27
- ], component: Paper, children: [jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", children: "Vendor" }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: jsx(BusinessCredentials, { data: business_credentials }) }), jsxs(Grid, { item: true, xs: 12, md: 6, children: [jsxs(Typography, { variant: "body1", children: ["Website Url: ", website_url] }), jsxs(Typography, { variant: "body1", children: ["Phone Number: ", phone_number] }), jsxs(Typography, { variant: "body1", children: ["Email: ", email] })] }), jsxs(Grid, { item: true, xs: 12, md: 6, children: [jsx(Typography, { variant: "h6", children: "Address" }), jsx(Address, { data: address })] })] }), jsxs(Grid, { item: true, xs: 12, sx: { mt: 3 }, children: [jsx(Typography, { variant: "h6", children: "Products" }), jsx(ExplanatoryFoldOut, { title: "Products", sx: { mt: 1 }, children: jsx(Stack, { spacing: 1, children: products.data.map((product, index) => (jsx(Paper, { sx: { p: 1 }, children: jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Typography, { variant: "h6", children: ["Product: ", product.title, " ", product.product_number] }), jsx(Price, { ...product.price })] }) }, index))) }) })] }), jsxs(Grid, { item: true, xs: 12, sx: { mt: 3 }, children: [jsx(Typography, { variant: "h6", children: "Contacts" }), jsx(ExplanatoryFoldOut, { title: "Contacts", sx: { mt: 1 }, children: jsx(Stack, { spacing: 1, children: contacts.map((contact, index) => (jsx(Paper, { sx: { p: 1 }, children: jsx(Contacts, { data: contact }) }, index))) }) })] })] }));
27
+ ], component: Paper, children: [jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", children: "Vendor" }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: jsx(BusinessCredentials, { data: business_credentials }) }), jsxs(Grid, { item: true, xs: 12, md: 6, children: [jsxs(Typography, { variant: "body1", children: ["Website Url: ", website_url] }), jsxs(Typography, { variant: "body1", children: ["Phone Number: ", phone_number] }), jsxs(Typography, { variant: "body1", children: ["Email: ", email] })] }), jsxs(Grid, { item: true, xs: 12, md: 6, children: [jsx(Typography, { variant: "h6", children: "Address" }), jsx(Address, { data: address })] })] }), jsxs(Grid, { item: true, xs: 12, sx: { mt: 3 }, children: [jsx(Typography, { variant: "h6", children: "Products" }), jsx(ExplanatoryFoldOut, { title: "Products", sx: { mt: 1 }, children: jsx(Stack, { spacing: 1, children: products.map((product, index) => (jsx(Paper, { sx: { p: 1 }, children: jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Typography, { variant: "h6", children: ["Product: ", product.title, " ", product.product_number] }), jsx(Price, { ...product.price })] }) }, index))) }) })] }), jsxs(Grid, { item: true, xs: 12, sx: { mt: 3 }, children: [jsx(Typography, { variant: "h6", children: "Contacts" }), jsx(ExplanatoryFoldOut, { title: "Contacts", sx: { mt: 1 }, children: jsx(Stack, { spacing: 1, children: contacts.map((contact, index) => (jsx(Paper, { sx: { p: 1 }, children: jsx(Contacts, { data: contact }) }, index))) }) })] })] }));
28
28
  }
29
29
 
30
30
  export { VendorDisplay };
@@ -60,8 +60,8 @@ function PublicInformationForm({ publicInformation, sx, }) {
60
60
  { p: 2 },
61
61
  ...(Array.isArray(sx) ? sx : [sx]),
62
62
  ], component: Paper, children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", children: "Edit Public Information" }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(TextField, { id: "title", name: "title", label: "Title", defaultValue: title }), jsx(TextField, { id: "description", name: "description", label: "Description", defaultValue: description }), jsx(TextField, { id: "email", name: "email", label: "email", defaultValue: email }), jsx(TextField, { id: "phone_number", name: "phone_number", label: "phone_number", defaultValue: phone_number })] }) }), jsx(Grid, { item: true, xs: 12, lg: 6, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Company Address" }), jsx(Divider, {}), jsx(AddressFields, { componentName: "address", componentReference: "common.address", data: address })] }) }), jsx(Grid, { item: true, xs: 12, lg: 6, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Business Credentials" }), jsx(Divider, {}), jsx(BusinessCredentialsFields, { componentName: "business_credentials", componentReference: "business.credentials", data: business_credentials })] }) }), jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: jsx(Typography, { variant: "h6", children: "Socials" }) }), oldSocials.map((social, index) => {
63
- if (social.data?.documentId) {
64
- if (open.includes(social.data.documentId)) {
63
+ if (social.data?.name) {
64
+ if (open.includes(social.data.name)) {
65
65
  return (jsx(Grid, { item: true, xs: 12, md: 6, lg: 4, children: jsx(SocialsFields, { data: social.data, componentName: `socials[${index}]`, componentReference: "common.social", deleteCallback: () => {
66
66
  setOldSocials(oldSocials.filter((_, i) => i !== index));
67
67
  /* setOpen(
@@ -16,10 +16,12 @@ async function requestRmaAction(prevState, formData) {
16
16
  Object.fromEntries(formData);
17
17
  const parsedFormData = parseFormData(formData);
18
18
  if (parsedFormData.data.iro_items) {
19
+ console.log("parsedFormData.data.iro_items", parsedFormData.data.iro_items);
19
20
  parsedFormData.data.iro_items = JSON.parse(parsedFormData.data.iro_items);
20
21
  }
21
22
  if (parsedFormData.data.opos) {
22
- parsedFormData.data.opos = JSON.parse(parsedFormData.data.opos);
23
+ console.log("parsedFormData.data.opos", parsedFormData.data.opos);
24
+ parsedFormData.data.opos = parsedFormData.data.opos;
23
25
  }
24
26
  const responseData = await mutateData("POST", `/api/iros`, parsedFormData);
25
27
  if (!responseData) {
@@ -25,7 +25,7 @@ const baseUrl = getStrapiURL();
25
25
  * @return A promise that resolves to the fetched OPO data
26
26
  * * @throws Will throw an error if the fetch fails
27
27
  */
28
- async function getAllOpos(currentPage, rowsPerPage, order, orderBy, is_archive = [false], // default to only non-archived OPOs
28
+ async function getAllOpos(currentPage, rowsPerPage, order, orderBy = "createdAt", is_archive = [false], // default to only non-archived OPOs
29
29
  filters = {}) {
30
30
  unstable_noStore();
31
31
  const user = await getUserRole();
@@ -10,6 +10,16 @@ import { fetchData } from '../loaders.js';
10
10
  import { getStrapiURL } from '../../../lib/utils.js';
11
11
 
12
12
  const baseUrl = getStrapiURL();
13
+ /**
14
+ * Fetch paginated product categories from the Strapi API.
15
+ *
16
+ * @param currentPage - The current page number for pagination.
17
+ * @param rowsPerPage - The number of rows per page for pagination.
18
+ * @param order - The sort order (asc or desc).
19
+ * @param orderBy - The field to order by, defaults to "createdAt".
20
+ * @param is_archive - An array of booleans to filter by archived status, defaulting to both archived and non-archived categories.
21
+ * @returns A promise that resolves to the fetched categories data.
22
+ */
13
23
  async function getPaginatedCategories(currentPage, rowsPerPage, order, orderBy, is_archive = [false] // default to both archived and non-archived categories
14
24
  ) {
15
25
  const url = new URL(`/api/product-categories`, baseUrl);
@@ -28,10 +38,10 @@ async function getPaginatedCategories(currentPage, rowsPerPage, order, orderBy,
28
38
  },
29
39
  },
30
40
  },
31
- sort: `${orderBy || "id"}:${order || "desc"}`,
41
+ sort: `${orderBy || "createdAt"}:${order || "desc"}`,
32
42
  pagination: {
33
- pageSize: rowsPerPage || 4,
34
- page: currentPage ? currentPage : 1, // because table pagination starts at 0 but strapi starts at 1
43
+ pageSize: rowsPerPage || 5,
44
+ page: currentPage ? currentPage + 1 : 1, // because table pagination starts at 0 but strapi starts at 1
35
45
  },
36
46
  });
37
47
  return await fetchData(url.href);
@@ -32,9 +32,7 @@ async function getSingleOpo(documentId, filters = {}) {
32
32
  },
33
33
  },
34
34
  customer: {
35
- populate: {
36
- business_credentials: true,
37
- },
35
+ populate: ["business_credentials"],
38
36
  },
39
37
  notes: {
40
38
  populate: {
@@ -16,6 +16,14 @@ const baseUrl = getStrapiURL();
16
16
  /**
17
17
  * INFO Fetch all IROs
18
18
  * used by the IROs table in the admin panel
19
+ * @param currentPage - The current page number for pagination
20
+ * @param rowsPerPage - The number of rows per page for pagination
21
+ * @param order - The sort order (asc or desc)
22
+ * @param orderBy - The field to order by, defaults to "createdAt"
23
+ * @param is_archive - An array of booleans to filter by archived status, defaulting to only non-archived IROs
24
+ * @param filters - An object containing additional filters to apply
25
+ * @return A promise that resolves to the fetched IRO data
26
+ * * @throws Will throw an error if the fetch fails
19
27
  */
20
28
  async function getAllIros(currentPage, rowsPerPage, order, orderBy = "createdAt", is_archive = [false], // default to only non-archived OPOs
21
29
  filters = {}) {
@@ -8,10 +8,11 @@
8
8
  import qs from '../../../../../node_modules/qs/lib/index.js';
9
9
  import { fetchData } from '../../loaders.js';
10
10
  import { getStrapiURL } from '../../../../lib/utils.js';
11
+ import { unstable_noStore } from 'next/cache';
11
12
 
12
13
  const baseUrl = getStrapiURL();
13
- async function getSingleIro(documentId) {
14
- // noStore();
14
+ async function getSingleIro(documentId, filters = {}) {
15
+ unstable_noStore();
15
16
  const url = new URL(`/api/iros/${documentId}`, baseUrl);
16
17
  url.search = qs.stringify({
17
18
  populate: {
@@ -35,12 +36,11 @@ async function getSingleIro(documentId) {
35
36
  notes: {
36
37
  // should only be available to enduser and dispatcher
37
38
  populate: {
38
- author: {
39
- populate: true,
40
- },
39
+ author: true,
41
40
  },
42
41
  },
43
42
  },
43
+ filters: { ...filters },
44
44
  });
45
45
  return await fetchData(url.href);
46
46
  }