umwd-components 0.1.730 → 0.1.732

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 (114) hide show
  1. package/dist/cjs/src/components/common/csv/CsvDownloader.js +1 -1
  2. package/dist/cjs/src/components/e-commerce/cart/CartSummary.js +1 -1
  3. package/dist/cjs/src/components/e-commerce/cart/CartSummaryRow.js +1 -1
  4. package/dist/cjs/src/components/e-commerce/categories/CategorySelectorV2.js +1 -1
  5. package/dist/cjs/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
  6. package/dist/cjs/src/components/e-commerce/checkout/Step4.js +1 -1
  7. package/dist/cjs/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
  8. package/dist/cjs/src/components/e-commerce/iro/IROItemFields.js +1 -1
  9. package/dist/cjs/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
  10. package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
  11. package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
  12. package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
  13. package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
  14. package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
  15. package/dist/cjs/src/components/e-commerce/opo/OPOItemFields.js +1 -1
  16. package/dist/cjs/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
  17. package/dist/cjs/src/components/e-commerce/opo/OpoSummary.js +1 -1
  18. package/dist/cjs/src/components/e-commerce/opo/OpoSummaryRow.js +1 -1
  19. package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  20. package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
  21. package/dist/cjs/src/components/e-commerce/products/EditProductForm.js +1 -1
  22. package/dist/cjs/src/components/e-commerce/products/EditStockForm.js +1 -1
  23. package/dist/cjs/src/components/e-commerce/products/PriceFields.js +1 -1
  24. package/dist/cjs/src/components/e-commerce/products/ProductCard.js +1 -1
  25. package/dist/cjs/src/components/e-commerce/products/ProductCategoryCard.js +1 -1
  26. package/dist/cjs/src/components/e-commerce/products/ProductSelector.js +1 -1
  27. package/dist/cjs/src/components/e-commerce/products/SingleProduct.js +1 -1
  28. package/dist/cjs/src/components/logistics/ipo/IPOItemFields.js +1 -1
  29. package/dist/cjs/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
  30. package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
  31. package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
  32. package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
  33. package/dist/cjs/src/components/logistics/vendor/EditVendorForm.js +1 -1
  34. package/dist/cjs/src/components/logistics/vendor/VendorDisplay.js +1 -1
  35. package/dist/cjs/src/components/logistics/vendor/VendorSelector.js +1 -1
  36. package/dist/cjs/src/components/page-elements/CategoryBlock.js +1 -1
  37. package/dist/cjs/src/context/e-commerce/cart/CartContext.js +1 -1
  38. package/dist/cjs/src/data/actions/e-commerce/categories/updateCategoryAction.js +1 -1
  39. package/dist/cjs/src/data/actions/e-commerce/product/updateProductAction.js +1 -1
  40. package/dist/cjs/src/data/loaders/e-commerce/getSingleCustomer.js +1 -1
  41. package/dist/cjs/src/data/loaders/e-commerce/getSingleProduct.js +1 -1
  42. package/dist/cjs/src/data/loaders/logistics/getTableIpos.js +1 -1
  43. package/dist/cjs/src/lib/molliePaymentProvider.js +1 -1
  44. package/dist/cjs/src/lib/parseFormData.js +1 -1
  45. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  46. package/dist/esm/src/components/common/csv/CsvDownloader.js +3 -3
  47. package/dist/esm/src/components/e-commerce/cart/CartSummary.js +1 -1
  48. package/dist/esm/src/components/e-commerce/cart/CartSummaryRow.js +4 -4
  49. package/dist/esm/src/components/e-commerce/categories/CategorySelectorV2.js +4 -3
  50. package/dist/esm/src/components/e-commerce/categories/EditCategoryForm.js +3 -3
  51. package/dist/esm/src/components/e-commerce/checkout/Step4.js +1 -1
  52. package/dist/esm/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
  53. package/dist/esm/src/components/e-commerce/iro/IROItemFields.js +2 -2
  54. package/dist/esm/src/components/e-commerce/iro/IroItemUpdater.js +9 -4
  55. package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +4 -2
  56. package/dist/esm/src/components/e-commerce/iro/RmaForm.js +3 -3
  57. package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +4 -4
  58. package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +10 -8
  59. package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +2 -2
  60. package/dist/esm/src/components/e-commerce/opo/OPOItemFields.js +1 -1
  61. package/dist/esm/src/components/e-commerce/opo/OpoItemUpdater.js +9 -4
  62. package/dist/esm/src/components/e-commerce/opo/OpoSummary.js +1 -1
  63. package/dist/esm/src/components/e-commerce/opo/OpoSummaryRow.js +1 -1
  64. package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +7 -7
  65. package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +4 -4
  66. package/dist/esm/src/components/e-commerce/products/EditProductForm.js +19 -17
  67. package/dist/esm/src/components/e-commerce/products/EditStockForm.js +39 -16
  68. package/dist/esm/src/components/e-commerce/products/PriceFields.js +3 -2
  69. package/dist/esm/src/components/e-commerce/products/ProductCard.js +3 -3
  70. package/dist/esm/src/components/e-commerce/products/ProductCategoryCard.js +1 -1
  71. package/dist/esm/src/components/e-commerce/products/ProductSelector.js +5 -5
  72. package/dist/esm/src/components/e-commerce/products/SingleProduct.js +5 -5
  73. package/dist/esm/src/components/logistics/ipo/IPOItemFields.js +2 -2
  74. package/dist/esm/src/components/logistics/ipo/IPOItemUpdater.js +9 -4
  75. package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +7 -5
  76. package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +4 -4
  77. package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +10 -8
  78. package/dist/esm/src/components/logistics/vendor/EditVendorForm.js +7 -4
  79. package/dist/esm/src/components/logistics/vendor/VendorDisplay.js +1 -1
  80. package/dist/esm/src/components/logistics/vendor/VendorSelector.js +5 -4
  81. package/dist/esm/src/components/page-elements/CategoryBlock.js +1 -1
  82. package/dist/esm/src/context/e-commerce/cart/CartContext.js +2 -2
  83. package/dist/esm/src/data/actions/e-commerce/categories/updateCategoryAction.js +3 -3
  84. package/dist/esm/src/data/actions/e-commerce/product/updateProductAction.js +7 -6
  85. package/dist/esm/src/data/loaders/e-commerce/getAllOpos.js +8 -0
  86. package/dist/esm/src/data/loaders/e-commerce/getSingleCustomer.js +15 -6
  87. package/dist/esm/src/data/loaders/e-commerce/getSingleProduct.js +2 -2
  88. package/dist/esm/src/data/loaders/e-commerce/getSingleStock.js +2 -2
  89. package/dist/esm/src/data/loaders/logistics/getSingleVendor.js +2 -2
  90. package/dist/esm/src/data/loaders/logistics/getTableIpos.js +1 -1
  91. package/dist/esm/src/lib/molliePaymentProvider.js +7 -3
  92. package/dist/esm/src/lib/parseFormData.js +1 -0
  93. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  94. package/dist/esm/types/components/common/csv/CsvDownloader.d.ts +2 -2
  95. package/dist/esm/types/components/logistics/ipo/IPOItemFields.d.ts +1 -1
  96. package/dist/esm/types/components/logistics/report/PreReportsDisplay.d.ts +2 -2
  97. package/dist/esm/types/components/page-elements/CategoryBlock.d.ts +1 -1
  98. package/dist/esm/types/data/actions/e-commerce/categories/updateCategoryAction.d.ts +1 -1
  99. package/dist/esm/types/data/actions/e-commerce/product/updateProductAction.d.ts +1 -1
  100. package/dist/esm/types/data/loaders/e-commerce/getAllOpos.d.ts +8 -0
  101. package/dist/esm/types/data/loaders/e-commerce/getSingleProduct.d.ts +3 -2
  102. package/dist/esm/types/data/loaders/e-commerce/getSingleStock.d.ts +1 -1
  103. package/dist/esm/types/data/loaders/logistics/getSingleVendor.d.ts +1 -1
  104. package/dist/esm/types/types/e-commerce/cart/types.d.ts +2 -2
  105. package/dist/esm/types/types/e-commerce/category/types.d.ts +3 -3
  106. package/dist/esm/types/types/e-commerce/customer/types.d.ts +2 -6
  107. package/dist/esm/types/types/e-commerce/invoice/types.d.ts +6 -6
  108. package/dist/esm/types/types/e-commerce/iro/types.d.ts +2 -4
  109. package/dist/esm/types/types/e-commerce/opo/types.d.ts +2 -4
  110. package/dist/esm/types/types/e-commerce/product/types.d.ts +9 -16
  111. package/dist/esm/types/types/logistics/Ipo.d.ts +2 -4
  112. package/dist/esm/types/types/logistics/Report.d.ts +4 -4
  113. package/dist/esm/types/types/logistics/Vendor.d.ts +4 -4
  114. package/package.json +1 -1
@@ -26,7 +26,7 @@ import { useState, useRef, useCallback, useEffect, Fragment as Fragment$1 } from
26
26
  import dayjs from '../../../../node_modules/dayjs/dayjs.min.js';
27
27
  import qs from '../../../../node_modules/qs/lib/index.js';
28
28
 
29
- function CSVDownloader(props) {
29
+ function CsvDownloader(props) {
30
30
  const { defaultAttributes, defaultRelations, defaultStrapiAttributes, additionalDateTypes, fetchCSVData, entityCode = "FU", } = props;
31
31
  const dateFieldOptions = [
32
32
  ...defaultStrapiAttributes.map((attr) => attr.name),
@@ -168,7 +168,7 @@ function CSVDownloader(props) {
168
168
  }, [csvData]);
169
169
  useEffect(() => {
170
170
  setCsvQuery(qs.stringify({
171
- fields: attributes,
171
+ fields: [...attributes, ...strapiAttributes],
172
172
  filters: {
173
173
  [dateType]: {
174
174
  $between: [
@@ -197,4 +197,4 @@ function CSVDownloader(props) {
197
197
  strapiAttributes.length && strapiAttributes.length > 0, sx: { "& .MuiSvgIcon-root": { fontSize: 28 } }, onChange: selectAllStrapiAttributes })] }) }), defaultStrapiAttributes.map((strapi) => (jsx(Grid, { item: true, xs: 4, children: jsxs(Stack, { spacing: 1, direction: "row", sx: { alignItems: "center" }, children: [jsx(Checkbox, { name: strapi.name, checked: strapiAttributes.includes(strapi.name), onChange: handleStrapiAttributeChange }), jsx(Typography, { children: strapi.label })] }) }, strapi.name))), jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: "Select date range" }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Autocomplete, { value: dateType, options: dateFieldOptions, multiple: false, onChange: (e, newValue) => setDateType(newValue), renderInput: (params) => (jsx(TextField, { ...params, label: "Date Type" })), sx: { width: 300 }, disableClearable: true }), jsx(DatePicker, { value: startDate, label: "start date", onChange: (value) => value && setStartDate(value) }), jsx(DatePicker, { value: endDate, label: "end date", onChange: (value) => value && setEndDate(value) })] }) })] })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", spacing: 2, sx: { justifyContent: "space-between" }, children: [jsxs(Fragment$1, { children: [jsx(Button, { variant: "contained", disabled: attributes.length === 0 && relations.length === 0, onClick: exportCSV, children: "Export CSV" }), csvData && (jsx(reactCsv.CSVLink, { data: csvData, filename: `${dayjs(startDate).format("DD-MM-YYYY")}_${dayjs(endDate).format("DD-MM-YYYY")}/${dateType}_${entityCode}-export.csv`, ref: csvLinkRef }))] }), jsx(IconButton, { "aria-label": "expand row", size: "small", onClick: () => setOpen(!open), children: open ? jsx(KeyboardArrowUpIcon, {}) : jsx(KeyboardArrowDownIcon, {}) })] }) })] }) }) }));
198
198
  }
199
199
 
200
- export { CSVDownloader as default };
200
+ export { CsvDownloader as default };
@@ -26,7 +26,7 @@ const CartSummary = () => {
26
26
  if (!isClient) {
27
27
  return jsx(CircularProgress, {});
28
28
  }
29
- return (jsx(Box, { sx: { p: { xs: 1, md: 2 } }, children: state.items.length > 0 ? (jsxs(Table, { children: [jsx(TableBody, { children: state.items.map((item) => (jsx(CartSummaryRow, { data: item }, item.id))) }), jsx(TableFooter, { children: jsxs(TableRow, { children: [!small && jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } } }), jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, colSpan: small ? 2 : 1 }), small ? (jsx(Fragment, { children: jsxs(TableCell, { colSpan: 2, align: "right", sx: { color: "#555", padding: 1 }, children: [jsx(Typography, { sx: { fontSize: 14 }, children: "Total " }), jsxs(Typography, { sx: { fontSize: 14 }, children: ["excl VAT: \u20AC ", state.totalExVAT.toFixed(2)] }), jsxs(Typography, { sx: { fontSize: 14 }, children: ["incl VAT: \u20AC ", state.totalInclVAT.toFixed(2)] })] }) })) : (jsxs(Fragment, { children: [jsxs(TableCell, { colSpan: 1, align: "right", sx: { color: "#555" }, children: ["Total excl VAT: \u20AC ", state.totalExVAT.toFixed(2)] }), jsxs(TableCell, { colSpan: 2, align: "right", sx: { color: "#555", fontSize: 16, fontWeight: 600 }, children: ["Total: \u20AC ", state.totalInclVAT.toFixed(2)] })] }))] }) })] })) : (jsx(Typography, { variant: "body1", children: "No products in cart" })) }));
29
+ return (jsx(Box, { sx: { p: { xs: 1, md: 2 } }, children: state.items.length > 0 ? (jsxs(Table, { children: [jsx(TableBody, { children: state.items.map((item) => (jsx(CartSummaryRow, { data: item }, item.documentId))) }), jsx(TableFooter, { children: jsxs(TableRow, { children: [!small && jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } } }), jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, colSpan: small ? 2 : 1 }), small ? (jsx(Fragment, { children: jsxs(TableCell, { colSpan: 2, align: "right", sx: { color: "#555", padding: 1 }, children: [jsx(Typography, { sx: { fontSize: 14 }, children: "Total " }), jsxs(Typography, { sx: { fontSize: 14 }, children: ["excl VAT: \u20AC ", state.totalExVAT.toFixed(2)] }), jsxs(Typography, { sx: { fontSize: 14 }, children: ["incl VAT: \u20AC ", state.totalInclVAT.toFixed(2)] })] }) })) : (jsxs(Fragment, { children: [jsxs(TableCell, { colSpan: 1, align: "right", sx: { color: "#555" }, children: ["Total excl VAT: \u20AC ", state.totalExVAT.toFixed(2)] }), jsxs(TableCell, { colSpan: 2, align: "right", sx: { color: "#555", fontSize: 16, fontWeight: 600 }, children: ["Total: \u20AC ", state.totalInclVAT.toFixed(2)] })] }))] }) })] })) : (jsx(Typography, { variant: "body1", children: "No products in cart" })) }));
30
30
  };
31
31
 
32
32
  export { CartSummary as default };
@@ -17,21 +17,21 @@ import Price from '../products/Price.js';
17
17
  import { useCart } from '../../../context/e-commerce/cart/CartContext.js';
18
18
 
19
19
  function CartSummaryRow({ data }) {
20
- const { id, thumb, title, vat_rate, price_excl_vat, price_incl_vat, quantity, } = data;
20
+ const { documentId, thumb, title, vat_rate, price_excl_vat, price_incl_vat, quantity, } = data;
21
21
  const theme = useTheme();
22
22
  const small = useMediaQuery(theme.breakpoints.down("sm"));
23
23
  const { dispatch } = useCart();
24
24
  const removeProduct = () => {
25
- dispatch({ type: "REMOVE_ITEM", payload: { id: id } });
25
+ dispatch({ type: "REMOVE_ITEM", payload: { documentId: documentId } });
26
26
  };
27
27
  // TODO should render multiple currencies
28
- return (jsxs(TableRow, { children: [jsxs(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: [quantity, " * "] }), jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: jsx(Price, { id: id, price: price_excl_vat, vat_rate: vat_rate, vat: price_excl_vat * (vat_rate / 100), price_incl_vat: price_incl_vat }) }), jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: title }), !small && (jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: jsx("div", { style: {
28
+ return (jsxs(TableRow, { children: [jsxs(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: [quantity, " * "] }), jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: jsx(Price, { documentId: documentId, price: price_excl_vat, vat_rate: vat_rate, vat: price_excl_vat * (vat_rate / 100), price_incl_vat: price_incl_vat }) }), jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: title }), !small && (jsx(TableCell, { sx: { p: { xs: 1, sm: 2 } }, children: jsx("div", { style: {
29
29
  position: "relative",
30
30
  width: "40px",
31
31
  height: "40px",
32
32
  }, children: thumb !== null && (jsx(Image, { src: thumb, alt: "Thumbnail of product", fill: true, sizes: "5vw", style: {
33
33
  objectFit: "cover",
34
- } })) }) })), jsx(TableCell, { sx: { p: 0 }, children: jsx(IconButton, { "aria-label": "delete", onClick: removeProduct, sx: { p: 0 }, children: jsx(DeleteIcon, {}) }) })] }, id));
34
+ } })) }) })), jsx(TableCell, { sx: { p: 0 }, children: jsx(IconButton, { "aria-label": "delete", onClick: removeProduct, sx: { p: 0 }, children: jsx(DeleteIcon, {}) }) })] }, documentId));
35
35
  }
36
36
 
37
37
  export { CartSummaryRow as default };
@@ -10,12 +10,13 @@ import Autocomplete from '@mui/material/Autocomplete';
10
10
  import TextField from '@mui/material/TextField';
11
11
 
12
12
  const CategorySelector = ({ categories, currentValue, }) => {
13
+ console.log("CategorySelector props", { categories, currentValue });
13
14
  const [selectedValues, setSelectedValues] = useState(currentValue || []);
14
15
  const handleCategoryChange = (event, value) => {
15
- value.map((category) => category.id);
16
- setSelectedValues(value.map((category) => category.id));
16
+ value.map((category) => category.documentId);
17
+ setSelectedValues(value.map((category) => category.documentId));
17
18
  };
18
- return (jsxs(Fragment, { children: [jsx(Autocomplete, { multiple: true, options: categories, getOptionLabel: (option) => option.title, filterSelectedOptions: true, onChange: handleCategoryChange, renderInput: (params) => jsx(TextField, { ...params, label: "Category" }), value: categories.filter((category) => selectedValues.includes(category.id)) }), jsx("input", { type: "hidden", name: "categories", value: JSON.stringify(selectedValues) || "" })] }));
19
+ return (jsxs(Fragment, { children: [jsx(Autocomplete, { multiple: true, options: categories, getOptionLabel: (option) => option.title, filterSelectedOptions: true, onChange: handleCategoryChange, renderInput: (params) => jsx(TextField, { ...params, label: "Category" }), value: categories.filter((category) => selectedValues.includes(category.documentId)) }), jsx("input", { type: "hidden", name: "categories", value: JSON.stringify(selectedValues) || "" })] }));
19
20
  };
20
21
 
21
22
  export { CategorySelector as default };
@@ -28,9 +28,9 @@ const INITIAL_STATE = {
28
28
  severity: null,
29
29
  };
30
30
  function EditCategoryForm({ data, revalidateCallback, handleClose, productNamesArray, sx, }) {
31
- const { id, title, description, slug, is_archive, products } = data;
31
+ const { documentId, title, description, slug, is_archive, products } = data;
32
32
  const initialProducts = products?.data || [];
33
- const [formState, formAction] = useFormState(updateCategoryAction, INITIAL_STATE);
33
+ const [formState, formAction] = useFormState(updateCategoryAction.bind(null, documentId), INITIAL_STATE);
34
34
  const { handleAddMessage } = useSnackbar();
35
35
  useEffect(() => {
36
36
  if (formState?.message) {
@@ -52,7 +52,7 @@ function EditCategoryForm({ data, revalidateCallback, handleClose, productNamesA
52
52
  });
53
53
  }
54
54
  }, [formState?.strapiErrors]);
55
- return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs("form", { action: formAction, children: [id && jsx("input", { id: "id", type: "hidden", name: "id", value: id }), jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Edit Category" }), jsx(Typography, { variant: "body2", children: "Edit the category for your products. You can add products to this category later." })] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(TextField, { id: "title", name: "title", label: "Title", defaultValue: title }), jsx(MarkdownEditor, { name: "description", label: "Description", defaultValue: description })] }) }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Products" }), jsx(ProductSelector, { productNames: productNamesArray, currentValue: [...initialProducts.map((prod) => prod.id)] })] }), jsxs(Grid, { item: true, xs: 12, children: [" ", 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: "Update category", loadingText: "Loading...", variant: "contained" })] })] })] })] }) }));
55
+ 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: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Edit Category" }), jsx(Typography, { variant: "body2", children: "Edit the category for your products. You can add products to this category later." })] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(TextField, { id: "title", name: "title", label: "Title", defaultValue: title }), jsx(MarkdownEditor, { name: "description", label: "Description", defaultValue: description })] }) }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Products" }), jsx(ProductSelector, { productNames: productNamesArray, currentValue: [...initialProducts.map((prod) => prod.documentId)] })] }), jsxs(Grid, { item: true, xs: 12, children: [" ", 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: "Update category", loadingText: "Loading...", variant: "contained" })] })] })] }) }) }));
56
56
  }
57
57
 
58
58
  export { EditCategoryForm };
@@ -29,7 +29,7 @@ function Step4({ customer_reference }) {
29
29
  const [formState, formAction] = useFormState(checkoutAction, INITIAL_STATE);
30
30
  return (jsx(Paper, { sx: { p: 2 }, children: jsxs(Stack, { spacing: 2, children: [jsx(CartSummary, {}), jsx(StrapiErrors, { error: formState?.strapiErrors }), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message })), jsxs(Typography, { children: ["Please double check all details prior to payment. ", customer_reference] }), jsx(Typography, { children: "Is this order compleet?" }), jsxs("form", { id: "paymentform", action: formAction, children: [state.items &&
31
31
  state.items.map((item, index) => {
32
- return (jsxs(Fragment, { children: [jsx("input", { type: "hidden", name: `opo_items[${index}].product`, value: item.id }), jsx("input", { type: "hidden", name: `opo_items[${index}].ordered_quantity`, value: item.quantity })] }, index));
32
+ return (jsxs(Fragment, { children: [jsx("input", { type: "hidden", name: `opo_items[${index}].product`, value: item.documentId }), jsx("input", { type: "hidden", name: `opo_items[${index}].ordered_quantity`, value: item.quantity })] }, index));
33
33
  }), jsx("input", { type: "hidden", name: "customer_reference", value: customer_reference }), jsx(Typography, { children: "Please click 'Proceed to payment' to proceed to the secure payment page. After completing the payment, you will automatically return to our shop. For any updates on this order, you can always access the latest information in your personal details." }), jsx(Button, { variant: "contained", form: "paymentform", type: "submit", children: "Proceed to payment" })] })] }) }));
34
34
  }
35
35
 
@@ -40,7 +40,7 @@ function CustomerProfileDisplay({ data, }) {
40
40
  }
41
41
  const pathname = usePathname();
42
42
  const isCustomer = pathname.includes("/user/");
43
- return (jsxs(Grid, { container: true, sx: { width: "100%" }, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, sx: { width: "100%" }, children: [jsx(Typography, { variant: "h3", component: "h1", children: isCustomer ? "Your Profile" : "Customer Profile" }), !isCustomer && data.customer_number && (jsxs(Typography, { variant: "body1", children: ["Customer Number: ", jsx("strong", { children: data.customer_number })] }))] }), isCustomer && (jsx(Fragment, { children: !Boolean(completeEnough) ? (jsx(Alert, { severity: "warning", action: jsx(StyledLink, { href: editProfileUrl, target: "_self", children: jsx(Button, { variant: "contained", children: "complete profile" }) }), children: "After completion of your profile you can enjoy all the benefits of your services." })) : (jsx(Stack, { direction: "row", justifyContent: "flex-end", children: jsx(StyledLink, { href: editProfileUrl, target: "_self", children: jsx(Button, { variant: "contained", children: "edit profile" }) }) })) }))] }), jsx(Divider, {})] }) }), jsxs(Grid, { item: true, xs: 12, children: [business_credentials ? (jsx(BusinessCredentials, { data: business_credentials })) : (jsx(Typography, { children: "Business credentials not available" })), jsx(Divider, { sx: { pt: 2 } })] }), jsxs(Grid, { item: true, xs: 12, children: [jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(PersonIcon, {}), jsx(Box, { children: jsxs(Typography, { variant: "body1", component: "p", children: [first_name, " ", last_name, " ", !first_name && !last_name && "N/A"] }) })] }), jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(EmailIcon, {}), jsx(Box, { children: jsxs(Typography, { variant: "body1", component: "p", children: [email, " ", !email && "N/A"] }) })] }), jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(PhoneIcon, {}), jsx(Box, { children: jsxs(Typography, { variant: "body1", component: "p", children: [phone, " ", !phone && "N/A"] }) })] }), jsx(Divider, { sx: { pt: 2 } })] }), company_address ? (jsxs(Grid, { item: true, xs: 12, md: 4, children: [jsx(Typography, { variant: "h6", children: "Company Address" }), jsx(Address, { data: { ...company_address } })] })) : (jsx(Grid, { item: true, xs: 12, md: 4, children: jsx(Typography, { children: "Company address not available" }) })), delivery_address ? (jsxs(Grid, { item: true, xs: 12, md: 4, children: [jsx(Typography, { variant: "h6", children: "Delivery Address" }), jsx(Address, { data: { ...delivery_address } })] })) : (jsx(Grid, { item: true, xs: 12, md: 4, children: jsx(Typography, { children: "Delivery address not available" }) })), billing_address ? (jsxs(Grid, { item: true, xs: 12, md: 4, children: [jsx(Typography, { variant: "h6", children: "Billing Address" }), jsx(Address, { data: { ...billing_address } })] })) : (jsx(Grid, { item: true, xs: 12, md: 4, children: jsx(Typography, { children: "Billing address not available" }) })), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", gutterBottom: true, children: "Orders" }), jsx(Paper, { children: orders && orders.data && orders.data.length > 0 ? (jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Order Number" }), jsx(TableCell, { children: "Date" }), jsx(TableCell, { children: "Status" }), jsx(TableCell, { align: "right", children: "Total" }), jsx(TableCell, { align: "right", children: "Actions" })] }) }), jsx(TableBody, { children: orders.data.map((order, index) => (jsxs(TableRow, { children: [jsx(TableCell, { children: order.opo_number }), jsx(TableCell, { children: new Date(order.order_date).toLocaleDateString() }), jsx(TableCell, { children: order.internal_status }), jsxs(TableCell, { align: "right", children: [order.total_incl_vat, " ", order.order_currency] }), jsx(TableCell, { align: "right", children: isCustomer ? (jsx(StyledLink, { href: `/user/orders?selectedOpoId=${order.id}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) : (jsx(StyledLink, { href: `/dashboard/admin/e-commerce/opos?selectedOpoId=${order.id}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) })] }, index))) })] })) : (jsx(Box, { p: 2, children: isCustomer ? (jsx(Typography, { children: "You have no orders." })) : (jsx(Typography, { children: "This user has no orders." })) })) })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", gutterBottom: true, children: "Returns" }), jsx(Paper, { children: returns && returns.data && returns.data.length > 0 ? (jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Return Number" }), jsx(TableCell, { children: "RMA Number" }), jsx(TableCell, { children: "Date" }), jsx(TableCell, { children: "Status" }), jsx(TableCell, { align: "right", children: "Actions" })] }) }), jsx(TableBody, { children: returns.data.map((iro, index) => (jsxs(TableRow, { children: [jsx(TableCell, { children: iro.return_number }), jsx(TableCell, { children: iro.rma_number }), jsx(TableCell, { children: new Date(iro.return_date).toLocaleDateString() }), jsx(TableCell, { children: iro.internal_status }), jsx(TableCell, { align: "right", children: isCustomer ? (jsx(StyledLink, { href: `/user/returns?selectedIroId=${iro.id}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) : (jsx(StyledLink, { href: `/dashboard/admin/e-commerce/iros?selectedIroId=${iro.id}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) })] }, index))) })] })) : (jsx(Box, { p: 2, children: isCustomer ? (jsx(Typography, { children: "You have no returns." })) : (jsx(Typography, { children: "This user has no returns." })) })) })] })] }));
43
+ return (jsxs(Grid, { container: true, sx: { width: "100%" }, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, sx: { width: "100%" }, children: [jsx(Typography, { variant: "h3", component: "h1", children: isCustomer ? "Your Profile" : "Customer Profile" }), !isCustomer && data.customer_number && (jsxs(Typography, { variant: "body1", children: ["Customer Number: ", jsx("strong", { children: data.customer_number })] }))] }), isCustomer && (jsx(Fragment, { children: !Boolean(completeEnough) ? (jsx(Alert, { severity: "warning", action: jsx(StyledLink, { href: editProfileUrl, target: "_self", children: jsx(Button, { variant: "contained", children: "complete profile" }) }), children: "After completion of your profile you can enjoy all the benefits of your services." })) : (jsx(Stack, { direction: "row", justifyContent: "flex-end", children: jsx(StyledLink, { href: editProfileUrl, target: "_self", children: jsx(Button, { variant: "contained", children: "edit profile" }) }) })) }))] }), jsx(Divider, {})] }) }), jsxs(Grid, { item: true, xs: 12, children: [business_credentials ? (jsx(BusinessCredentials, { data: business_credentials })) : (jsx(Typography, { children: "Business credentials not available" })), jsx(Divider, { sx: { pt: 2 } })] }), jsxs(Grid, { item: true, xs: 12, children: [jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(PersonIcon, {}), jsx(Box, { children: jsxs(Typography, { variant: "body1", component: "p", children: [first_name, " ", last_name, " ", !first_name && !last_name && "N/A"] }) })] }), jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(EmailIcon, {}), jsx(Box, { children: jsxs(Typography, { variant: "body1", component: "p", children: [email, " ", !email && "N/A"] }) })] }), jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(PhoneIcon, {}), jsx(Box, { children: jsxs(Typography, { variant: "body1", component: "p", children: [phone, " ", !phone && "N/A"] }) })] }), jsx(Divider, { sx: { pt: 2 } })] }), company_address ? (jsxs(Grid, { item: true, xs: 12, md: 4, children: [jsx(Typography, { variant: "h6", children: "Company Address" }), jsx(Address, { data: { ...company_address } })] })) : (jsx(Grid, { item: true, xs: 12, md: 4, children: jsx(Typography, { children: "Company address not available" }) })), delivery_address ? (jsxs(Grid, { item: true, xs: 12, md: 4, children: [jsx(Typography, { variant: "h6", children: "Delivery Address" }), jsx(Address, { data: { ...delivery_address } })] })) : (jsx(Grid, { item: true, xs: 12, md: 4, children: jsx(Typography, { children: "Delivery address not available" }) })), billing_address ? (jsxs(Grid, { item: true, xs: 12, md: 4, children: [jsx(Typography, { variant: "h6", children: "Billing Address" }), jsx(Address, { data: { ...billing_address } })] })) : (jsx(Grid, { item: true, xs: 12, md: 4, children: jsx(Typography, { children: "Billing address not available" }) })), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", gutterBottom: true, children: "Orders" }), jsx(Paper, { children: orders && orders.length > 0 ? (jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Order Number" }), jsx(TableCell, { children: "Date" }), jsx(TableCell, { children: "Status" }), jsx(TableCell, { align: "right", children: "Total" }), jsx(TableCell, { align: "right", children: "Actions" })] }) }), jsx(TableBody, { children: orders.map((order, index) => (jsxs(TableRow, { children: [jsx(TableCell, { children: order.opo_number }), jsx(TableCell, { children: new Date(order.order_date).toLocaleDateString() }), jsx(TableCell, { children: order.internal_status }), jsxs(TableCell, { align: "right", children: [order.total_incl_vat, " ", order.order_currency] }), jsx(TableCell, { align: "right", children: isCustomer ? (jsx(StyledLink, { href: `/user/orders?selectedOpoId=${order.documentId}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) : (jsx(StyledLink, { href: `/dashboard/admin/e-commerce/opos?selectedOpoId=${order.documentId}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) })] }, index))) })] })) : (jsx(Box, { p: 2, children: isCustomer ? (jsx(Typography, { children: "You have no orders." })) : (jsx(Typography, { children: "This user has no orders." })) })) })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", gutterBottom: true, children: "Returns" }), jsx(Paper, { children: returns && returns.length > 0 ? (jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Return Number" }), jsx(TableCell, { children: "RMA Number" }), jsx(TableCell, { children: "Date" }), jsx(TableCell, { children: "Status" }), jsx(TableCell, { align: "right", children: "Actions" })] }) }), jsx(TableBody, { children: returns.map((iro, index) => (jsxs(TableRow, { children: [jsx(TableCell, { children: iro.return_number }), jsx(TableCell, { children: iro.rma_number }), jsx(TableCell, { children: new Date(iro.return_date).toLocaleDateString() }), jsx(TableCell, { children: iro.internal_status }), jsx(TableCell, { align: "right", children: isCustomer ? (jsx(StyledLink, { href: `/user/returns?selectedIroId=${iro.documentId}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) : (jsx(StyledLink, { href: `/dashboard/admin/e-commerce/iros?selectedIroId=${iro.documentId}`, target: "_self", children: jsx(Button, { variant: "contained", size: "small", children: "View" }) })) })] }, index))) })] })) : (jsx(Box, { p: 2, children: isCustomer ? (jsx(Typography, { children: "You have no returns." })) : (jsx(Typography, { children: "This user has no returns." })) })) })] })] }));
44
44
  }
45
45
 
46
46
  export { CustomerProfileDisplay as default };
@@ -57,7 +57,7 @@ function IROItemFields({ productsArr }) {
57
57
  return items.map((item, index) => {
58
58
  return {
59
59
  line_item_number: `${index + 1}.0.0`,
60
- product: item.product?.id || 0,
60
+ product: item.product?.documentId || "",
61
61
  returned_quantity: item.returned_quantity,
62
62
  reason: nextReason,
63
63
  other_reason: nextOtherReason,
@@ -73,7 +73,7 @@ function IROItemFields({ productsArr }) {
73
73
  ? item.product?.product_number
74
74
  : item.product, " ", "|", " ", typeof item.product === "object" ? item.product?.title : ""] }), jsx(TableCell, { sx: { width: "15%" }, children: item.returned_quantity }), jsx(TableCell, { sx: { width: "35%" }, children: item.reason === "other" ? item.other_reason : item.reason }), jsx(TableCell, { align: "right", sx: { width: "5%" }, children: jsx(IconButton, { onClick: () => handleDeleteItem(index), children: jsx(DeleteIcon, {}) }) })] }, index));
75
75
  }) })] }), jsx("input", { type: "hidden", name: "iro_items", value: JSON.stringify(parsedItems) }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", sx: { p: 2, width: "100%" }, children: [jsxs(Typography, { variant: "body1", sx: { width: "15%" }, children: [items.length + 1, ".0.0"] }), productsArr && (jsx(ProductSelector, { productNames: productsArr, currentValue: selectedProduct, sx: { width: "70%" }, multiple: false, onChangeCallback: (ids) => {
76
- const product = productsArr.find((p) => p.id === ids[0]);
76
+ const product = productsArr.find((p) => p.documentId === ids[0]);
77
77
  setNextProductName(product || null);
78
78
  setSelectedProduct(ids);
79
79
  } })), jsx(TextField, { id: "amount", name: "amount", type: "number", label: "Amount", value: nextAmount, onChange: (e) => {
@@ -31,13 +31,18 @@ function IroItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCa
31
31
  : 0;
32
32
  const [open, setOpen] = useState(false);
33
33
  return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product && product.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product && product.title }) }))] }), jsx(Typography, { variant: "body1", children: "Reason" }), jsx(Typography, { variant: "body2", children: "Received" }), jsx(AmountUpdater, { currentValue: received_quantity, totalValue: returned_quantity + received_bad_quantity, minNewValue: 0 + registered_quantity + -registered_bad_quantity, maxNewValue: returned_quantity + received_bad_quantity, color: "info", handleChange: (newValue) => {
34
- handleUpdateQuantity(newValue, item.id, "received_quantity");
34
+ handleUpdateQuantity(newValue, item.documentId, "received_quantity");
35
35
  } }), jsx(Typography, { variant: "body2", children: "Registered" }), jsx(AmountUpdater, { currentValue: registered_quantity, totalValue: returned_quantity + received_bad_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_bad_quantity, color: "info", handleChange: (newValue) => {
36
- handleUpdateQuantity(newValue, item.id, "registered_quantity");
37
- }, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "registered", minValue: -(received_quantity + registered_bad_quantity), maxValue: received_quantity, related: [{ id: item.id, __type: "api::e-commerce.iro-item" }], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: returned_quantity +
36
+ handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
37
+ }, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "registered", minValue: -(received_quantity + registered_bad_quantity), maxValue: received_quantity, related: [
38
+ {
39
+ documentId: item.documentId,
40
+ __type: "api::e-commerce.iro-item",
41
+ },
42
+ ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: returned_quantity +
38
43
  received_bad_quantity +
39
44
  registered_bad_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
40
- handleUpdateQuantity(newValue, item.id, "released_quantity");
45
+ handleUpdateQuantity(newValue, item.documentId, "released_quantity");
41
46
  } })] })) }, index));
42
47
  }
43
48
 
@@ -41,7 +41,7 @@ function ManageIROForm({ data, sx, revalidateCallback, handleClose, role, }) {
41
41
  const parseItems = (items) => {
42
42
  return items.map((item) => {
43
43
  return {
44
- id: item.id,
44
+ id: item.documentId,
45
45
  received_quantity: item.received_quantity,
46
46
  registered_quantity: item.registered_quantity,
47
47
  released_quantity: item.released_quantity,
@@ -51,7 +51,9 @@ function ManageIROForm({ data, sx, revalidateCallback, handleClose, role, }) {
51
51
  return (jsx(Box, { sx: [
52
52
  // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
53
53
  ...(Array.isArray(sx) ? sx : [sx]),
54
- ], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and recieval of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: data.id, __type: "api::logistics.ipo" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 6, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Details" }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body2", children: data.return_number })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: data.return_date })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Supplier" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Status" }), jsx(Typography, { variant: "body2", width: "250px", children: data.internal_status })] })] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1, children: role === "enduser" && (jsx(Fragment, {})) }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsx(Divider, {}), jsxs("form", { action: formAction, children: [data?.iro_items &&
54
+ ], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and recieval of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [
55
+ { id: data.documentId, __type: "api::logistics.ipo" },
56
+ ], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 6, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Details" }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body2", children: data.return_number })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: data.return_date })] }), jsx(Stack, { direction: "row", spacing: 2, children: jsx(Typography, { variant: "body1", width: "250px", children: "Supplier" }) }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Status" }), jsx(Typography, { variant: "body2", width: "250px", children: data.internal_status })] })] }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1, children: role === "enduser" && (jsx(Fragment, {})) }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsx(Divider, {}), jsxs("form", { action: formAction, children: [data?.iro_items &&
55
57
  data.iro_items.map((item, index) => {
56
58
  console.log("item", item);
57
59
  return (jsx(Paper, { sx: { p: 2, mb: 2 } }, index));
@@ -67,9 +67,9 @@ const ItemLines = ({ items, itemsToReturn, setItemsToReturn, selectedItems, setS
67
67
  return itemsToReturn.map((item, index) => {
68
68
  return {
69
69
  line_item_number: `${index + 1}.0.0`,
70
- product: typeof item.product === "object" && "id" in item.product
71
- ? item.product.id
72
- : 0,
70
+ product: typeof item.product === "object" && "documentId" in item.product
71
+ ? item.product.documentId
72
+ : "",
73
73
  returned_quantity: item.returned_quantity,
74
74
  reason: item.reason,
75
75
  other_reason: item.other_reason || "",
@@ -44,13 +44,13 @@ function TextualIROItemUpdater({ item, index, handleAddReport, handleUpdateQuant
44
44
  return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsxs(Typography, { variant: "body1", children: ["Reason: ", reason, reason === "other" &&
45
45
  other_reason !== undefined &&
46
46
  `, ${other_reason}`] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: returned_quantity, minNewValue: 0 + registered_quantity, maxNewValue: returned_quantity, color: "info", handleChange: (newValue) => {
47
- handleUpdateQuantity(newValue, item.id, "received_quantity");
47
+ handleUpdateQuantity(newValue, item.documentId, "received_quantity");
48
48
  } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("registered") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Registered" }), jsx(TextualAmountUpdater, { label: "Registered", currentValue: registered_quantity, totalValue: returned_quantity + registered_reports_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
49
- handleUpdateQuantity(newValue, item.id, "registered_quantity");
50
- } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("reports") && (jsxs(Box, { sx: { mb: 2 }, children: [jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: dbReports }), jsx(PreReportsDisplay, { itemID: item.id, reports: preReports, handleRemoveReportAtIndex: handleRemoveReportAtIndex }), jsx(SimpleReportFields, { itemID: item.id, content: "", type: "registered", minValue: -(received_quantity -
49
+ handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
50
+ } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("reports") && (jsxs(Box, { sx: { mb: 2 }, children: [jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: dbReports }), jsx(PreReportsDisplay, { itemID: item.documentId, reports: preReports, handleRemoveReportAtIndex: handleRemoveReportAtIndex }), jsx(SimpleReportFields, { itemID: item.documentId, content: "", type: "registered", minValue: -(received_quantity -
51
51
  registered_quantity +
52
52
  registered_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("released") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Released" }), jsx(TextualAmountUpdater, { label: "Released", currentValue: released_quantity, totalValue: returned_quantity + registered_reports_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
53
- handleUpdateQuantity(newValue, item.id, "released_quantity");
53
+ handleUpdateQuantity(newValue, item.documentId, "released_quantity");
54
54
  } })] }))] })) }, index));
55
55
  }
56
56
 
@@ -65,7 +65,7 @@ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, }
65
65
  const correspondingProductsData = await queryAllProducts(query);
66
66
  const correspondingProducts = correspondingProductsData.data.map((product) => {
67
67
  return {
68
- id: product.id,
68
+ id: product.documentId,
69
69
  product_number: product.product_number,
70
70
  price: product.price,
71
71
  };
@@ -164,7 +164,7 @@ function OverwritesDialog({ open, handleClose, overwrites, setOverwrites, iro, }
164
164
  ...overwrites,
165
165
  lines: newLines,
166
166
  });
167
- } })] }, item.id));
167
+ } })] }, item.documentId));
168
168
  })] }))] }) }), jsxs(DialogActions, { children: [jsx(Button, { variant: "contained", onClick: (e) => {
169
169
  confirmationService("iros", [iro.documentId], overwrites);
170
170
  handleClose();
@@ -267,14 +267,14 @@ revalidateCallback, handleClose, role, }) {
267
267
  const parseItems = (items) => {
268
268
  return items.map((item) => {
269
269
  return {
270
- id: item.id,
270
+ documentId: item.documentId,
271
271
  returned_quantity: item.returned_quantity,
272
272
  received_quantity: item.received_quantity,
273
273
  registered_quantity: item.registered_quantity,
274
274
  released_quantity: item.released_quantity,
275
275
  reports: item.reports?.map((report) => {
276
276
  return {
277
- id: "id" in report ? report.id : undefined,
277
+ documentId: "documentId" in report ? report.documentId : undefined,
278
278
  quantity: report.quantity,
279
279
  content: report.content,
280
280
  type: report.type,
@@ -285,7 +285,7 @@ revalidateCallback, handleClose, role, }) {
285
285
  };
286
286
  const handleUpdateQuantity = (value, itemID, type) => {
287
287
  const newItems = [...items];
288
- const index = newItems.findIndex((item) => item.id === itemID);
288
+ const index = newItems.findIndex((item) => item.documentId === itemID);
289
289
  newItems[index][type] = value;
290
290
  setItems(newItems);
291
291
  };
@@ -294,7 +294,7 @@ revalidateCallback, handleClose, role, }) {
294
294
  * - only used with Textual form */
295
295
  const handleAddReport = (report, itemID) => {
296
296
  const newItems = [...items];
297
- const index = newItems.findIndex((item) => item.id === itemID);
297
+ const index = newItems.findIndex((item) => item.documentId === itemID);
298
298
  const reportsOnItem = newItems[index]?.reports || [];
299
299
  const newReports = [...reportsOnItem, report];
300
300
  if (newItems[index]?.reports == undefined) {
@@ -305,7 +305,7 @@ revalidateCallback, handleClose, role, }) {
305
305
  };
306
306
  const handleRemoveReportAtIndex = (itemID, index) => {
307
307
  const newItems = [...items];
308
- const itemIndex = newItems.findIndex((item) => item.id === itemID);
308
+ const itemIndex = newItems.findIndex((item) => item.documentId === itemID);
309
309
  const reportsOnItem = newItems[itemIndex]?.reports || [];
310
310
  const dbReports = reportsOnItem.filter((report) => "id" in report);
311
311
  const preReports = reportsOnItem.filter((report) => !("id" in report));
@@ -341,7 +341,9 @@ revalidateCallback, handleClose, role, }) {
341
341
  setItems(data.iro_items ? data.iro_items : []);
342
342
  }
343
343
  }, [data]);
344
- return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Return" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and release of returns" })] }), jsx(NoteTakingComponent, { content: "", related: [{ id: data.id, __type: "api::e-commerce.iro" }], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", sx: { py: 1 }, children: "Details" }) }), jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(NumbersIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(AssignmentReturnIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "RMA Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.rma_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer Reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(CalendarTodayIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(UpdateIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Status" }), jsx(IroStatusIndicator, { status: data.internal_status })] })] }) }) }), (data.internal_status === "requested" ||
344
+ return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Return" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and release of returns" })] }), jsx(NoteTakingComponent, { content: "", related: [
345
+ { id: data.documentId, __type: "api::e-commerce.iro" },
346
+ ], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", sx: { py: 1 }, children: "Details" }) }), jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(NumbersIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(AssignmentReturnIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "RMA Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.rma_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer Reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(CalendarTodayIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.return_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Customer" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(UpdateIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Return Status" }), jsx(IroStatusIndicator, { status: data.internal_status })] })] }) }) }), (data.internal_status === "requested" ||
345
347
  data.internal_status === "finalising_process") &&
346
348
  role === "enduser" && (jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), data.internal_status === "requested" && (jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning" })), data.internal_status === "finalising_process" && (jsx(Alert, { severity: "warning", children: "Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done" })), data.internal_status === "finalising_process" && (jsx(Button, { variant: "contained", sx: { color: "yellow" }, children: "// TODO RE-PAYMENT PROCESS" })), jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback, openOverwritesDialog: () => setOverwritesDialogOpen(true) }), jsx(OverwritesDialog, { open: overwritesDialogOpen, handleClose: () => setOverwritesDialogOpen(false), overwrites: overwrites, setOverwrites: setOverwrites, iro: data }), jsx(CancelIroDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: data.documentId, revalidateCallback: revalidateCallback })] }) }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsx(Stack, { spacing: 1 }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1, sx: {
347
349
  bgcolor: "background.default",
@@ -125,7 +125,7 @@ revalidateCallback, handleClose, role, }) {
125
125
  const parseItems = (items) => {
126
126
  return items.map((item) => {
127
127
  return {
128
- id: item.id,
128
+ documentId: item.documentId,
129
129
  ordered_quantity: item.ordered_quantity,
130
130
  picked_quantity: item.picked_quantity,
131
131
  packed_quantity: item.packed_quantity,
@@ -135,7 +135,7 @@ revalidateCallback, handleClose, role, }) {
135
135
  };
136
136
  const handleUpdateQuantity = (value, itemID, type) => {
137
137
  const newItems = [...items];
138
- const index = newItems.findIndex((item) => item.id === itemID);
138
+ const index = newItems.findIndex((item) => item.documentId === itemID);
139
139
  newItems[index][type] = value;
140
140
  setItems(newItems);
141
141
  };
@@ -62,7 +62,7 @@ function OPOItemFields({ productsArr }) {
62
62
  return (jsxs(Stack, { spacing: 2, children: [jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { id: "line_item_number", sx: [{ width: "15%" }], children: "Line Item Number" }), jsx(TableCell, { sx: [{ width: "70%" }], children: "Product Number" }), jsx(TableCell, { sx: [{ width: "15%" }], children: "Amount" }), jsx(TableCell, { sx: [] })] }) }), jsx(TableBody, { children: items.map((item, index) => {
63
63
  return (jsxs(TableRow, { children: [jsxs(TableCell, { sx: [{ width: "15%" }], children: [index + 1, ".0.0"] }), jsxs(TableCell, { sx: [{ width: "70%" }], children: [item.product.product_number, " | ", item.product.title] }), jsx(TableCell, { sx: { width: "15%" }, children: item.amount }), jsx(TableCell, { align: "right", sx: { width: "5%" }, children: jsx(IconButton, { onClick: () => handleDeleteItem(index), children: jsx(DeleteIcon, {}) }) })] }, index));
64
64
  }) })] }), jsx("input", { type: "hidden", name: "opo_items", value: JSON.stringify(parsedItems) }), jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", sx: { p: 2, width: "100%" }, children: [jsxs(Typography, { variant: "body1", sx: { width: "15%" }, children: [items.length + 1, ".0.0"] }), productsArr && (jsx(ProductSelector, { productNames: productsArr, currentValue: selectedProduct, sx: { width: "70%" }, multiple: false, onChangeCallback: (ids) => {
65
- const product = productsArr.find((p) => p.id === ids[0]);
65
+ const product = productsArr.find((p) => p.documentId === ids[0]);
66
66
  setNextProductName(product || null);
67
67
  setSelectedProduct(ids);
68
68
  } })), jsx(TextField, { id: "amount", name: "amount", type: "number", label: "Amount", value: nextAmount, onChange: (e) => {
@@ -44,12 +44,17 @@ revalidateCallback, }) {
44
44
  : 0;
45
45
  }, [reports]);
46
46
  return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Typography, { variant: "body2", children: "Picked" }), jsx(AmountUpdater, { currentValue: picked_quantity, totalValue: ordered_quantity + -packed_reports_quantity, minNewValue: 0 + packed_quantity + -packed_reports_quantity, maxNewValue: ordered_quantity + -packed_reports_quantity, color: "info", handleChange: (newValue) => {
47
- handleUpdateQuantity(newValue, item.id, "picked_quantity");
47
+ handleUpdateQuantity(newValue, item.documentId, "picked_quantity");
48
48
  } }), jsx(Typography, { variant: "body2", children: "Packed" }), jsx(AmountUpdater, { currentValue: packed_quantity, totalValue: ordered_quantity, minNewValue: 0 + shipped_quantity, maxNewValue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
49
- handleUpdateQuantity(newValue, item.id, "packed_quantity");
49
+ handleUpdateQuantity(newValue, item.documentId, "packed_quantity");
50
50
  }, offsetEnd: packed_reports_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports.filter((report) => "documentId" in report &&
51
- typeof report.documentId === "string") }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "packed", minValue: -(picked_quantity + packed_reports_quantity), maxValue: 0, related: [{ id: item.id, __type: "api::e-commerce.opo-item" }], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(AmountUpdater, { currentValue: shipped_quantity, totalValue: ordered_quantity, minNewValue: 0, maxNewValue: packed_quantity, color: "info", handleChange: (newValue) => {
52
- handleUpdateQuantity(newValue, item.id, "shipped_quantity");
51
+ typeof report.documentId === "string") }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "packed", minValue: -(picked_quantity + packed_reports_quantity), maxValue: 0, related: [
52
+ {
53
+ documentId: item.documentId,
54
+ __type: "api::e-commerce.opo-item",
55
+ },
56
+ ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(AmountUpdater, { currentValue: shipped_quantity, totalValue: ordered_quantity, minNewValue: 0, maxNewValue: packed_quantity, color: "info", handleChange: (newValue) => {
57
+ handleUpdateQuantity(newValue, item.documentId, "shipped_quantity");
53
58
  } })] })) }, index));
54
59
  }
55
60
 
@@ -24,7 +24,7 @@ function OpoSummary({ opo }) {
24
24
  }
25
25
  console.log("opo_items", opo_items);
26
26
  return (jsx(Box, { sx: { p: { xs: 1, md: 2 } }, children: opo_items != null ? (jsxs(Table, { children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Amount" }), jsx(TableCell, { children: "Product Title" }), jsx(TableCell, { children: "Price Excl. VAT" }), jsx(TableCell, { children: "Price Incl. VAT" })] }) }), jsx(TableBody, { children: opo_items &&
27
- opo_items.map((item) => (jsx(OpoSummaryRow, { data: item }, item.id))) }), jsxs(TableFooter, { children: [jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total excl VAT" }), jsxs(TableCell, { colSpan: 1, align: "left", children: ["\u20AC ", opo.total_excl_vat] })] }), jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total incl VAT" }), jsxs(TableCell, { colSpan: 1, align: "left", children: ["\u20AC ", opo.total_incl_vat] })] })] })] })) : (jsx(Typography, { children: "No products in cart" })) }));
27
+ opo_items.map((item) => (jsx(OpoSummaryRow, { data: item }, item.documentId))) }), jsxs(TableFooter, { children: [jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total excl VAT" }), jsxs(TableCell, { colSpan: 1, align: "left", children: ["\u20AC ", opo.total_excl_vat] })] }), jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total incl VAT" }), jsxs(TableCell, { colSpan: 1, align: "left", children: ["\u20AC ", opo.total_incl_vat] })] })] })] })) : (jsx(Typography, { children: "No products in cart" })) }));
28
28
  }
29
29
 
30
30
  export { OpoSummary };
@@ -9,7 +9,7 @@ import TableRow from '@mui/material/TableRow';
9
9
  import TableCell from '@mui/material/TableCell';
10
10
 
11
11
  function OpoSummaryRow({ data }) {
12
- const { id, ordered_quantity, product } = data;
12
+ const { documentId, ordered_quantity, product } = data;
13
13
  return (jsxs(TableRow, { children: [jsx(TableCell, { children: ordered_quantity }), jsx(TableCell, { children: product?.title }), jsx(TableCell, { children: product?.price?.price ? `€ ${product.price.price}` : "no information" }), jsx(TableCell, { children: product?.price?.price_incl_vat
14
14
  ? `€ ${product.price.price_incl_vat}`
15
15
  : "no information" })] }));
@@ -120,14 +120,14 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
120
120
  const parseItems = (items) => {
121
121
  return items.map((item) => {
122
122
  return {
123
- id: item.id,
123
+ documentId: item.documentId,
124
124
  ordered_quantity: item.ordered_quantity,
125
125
  picked_quantity: item.picked_quantity,
126
126
  packed_quantity: item.packed_quantity,
127
127
  shipped_quantity: item.shipped_quantity,
128
128
  reports: item.reports?.map((report) => {
129
129
  return {
130
- id: "id" in report ? report.id : undefined,
130
+ documentId: "documentId" in report ? report.documentId : undefined,
131
131
  quantity: report.quantity,
132
132
  content: report.content,
133
133
  type: report.type,
@@ -138,7 +138,7 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
138
138
  };
139
139
  const handleUpdateQuantity = (value, itemID, type) => {
140
140
  const newItems = [...items];
141
- const index = newItems.findIndex((item) => item.id === itemID);
141
+ const index = newItems.findIndex((item) => item.documentId === itemID);
142
142
  newItems[index][type] = value;
143
143
  setItems(newItems);
144
144
  };
@@ -147,7 +147,7 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
147
147
  * - only used with Textual form */
148
148
  const handleAddReport = (report, itemID) => {
149
149
  const newItems = [...items];
150
- const index = newItems.findIndex((item) => item.id === itemID);
150
+ const index = newItems.findIndex((item) => item.documentId === itemID);
151
151
  const reportsOnItem = newItems[index]?.reports || [];
152
152
  const newReports = [...reportsOnItem, report];
153
153
  if (newItems[index]?.reports == undefined) {
@@ -158,10 +158,10 @@ function TextualManageOPOForm({ opo, sx, revalidateCallback, handleClose, role,
158
158
  };
159
159
  const handleRemoveReportAtIndex = (itemID, index) => {
160
160
  const newItems = [...items];
161
- const itemIndex = newItems.findIndex((item) => item.id === itemID);
161
+ const itemIndex = newItems.findIndex((item) => item.documentId === itemID);
162
162
  const reportsOnItem = newItems[itemIndex]?.reports || [];
163
- const dbReports = reportsOnItem.filter((report) => "id" in report);
164
- const preReports = reportsOnItem.filter((report) => !("id" in report));
163
+ const dbReports = reportsOnItem.filter((report) => "documentId" in report);
164
+ const preReports = reportsOnItem.filter((report) => !("documentId" in report));
165
165
  preReports.splice(index, 1);
166
166
  const newReports = [...dbReports, ...preReports];
167
167
  newItems[itemIndex].reports = newReports;
@@ -42,13 +42,13 @@ function TextualOpoItemUpdater({ item, index, handleAddReport, handleUpdateQuant
42
42
  const preReports = item.reports?.filter((report) => Boolean("id" in report) === false) ||
43
43
  [];
44
44
  return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("picked") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Picked" }), jsx(TextualAmountUpdater, { label: "Picked", currentValue: picked_quantity, totalValue: ordered_quantity, minNewValue: 0 + packed_quantity, maxNewValue: ordered_quantity, color: "info", handleChange: (newValue) => {
45
- handleUpdateQuantity(newValue, item.id, "picked_quantity");
45
+ handleUpdateQuantity(newValue, item.documentId, "picked_quantity");
46
46
  } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("packed") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Packed" }), jsx(TextualAmountUpdater, { label: "Packed", currentValue: packed_quantity, totalValue: ordered_quantity + packed_reports_quantity, minNewValue: 0 + shipped_quantity, maxNewValue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
47
- handleUpdateQuantity(newValue, item.id, "packed_quantity");
48
- } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("reports") && (jsxs(Box, { sx: { mb: 2 }, children: [jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: dbReports }), jsx(PreReportsDisplay, { itemID: item.id, reports: preReports, handleRemoveReportAtIndex: handleRemoveReportAtIndex }), jsx(SimpleReportFields, { itemID: item.id, content: "", type: "packed", minValue: -(picked_quantity -
47
+ handleUpdateQuantity(newValue, item.documentId, "packed_quantity");
48
+ } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("reports") && (jsxs(Box, { sx: { mb: 2 }, children: [jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: dbReports }), jsx(PreReportsDisplay, { itemID: item.documentId, reports: preReports, handleRemoveReportAtIndex: handleRemoveReportAtIndex }), jsx(SimpleReportFields, { itemID: item.documentId, content: "", type: "packed", minValue: -(picked_quantity -
49
49
  packed_quantity +
50
50
  packed_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("shipped") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(TextualAmountUpdater, { label: "Shipped", currentValue: shipped_quantity, totalValue: ordered_quantity + packed_reports_quantity, minNewValue: 0, maxNewValue: packed_quantity, color: "info", handleChange: (newValue) => {
51
- handleUpdateQuantity(newValue, item.id, "shipped_quantity");
51
+ handleUpdateQuantity(newValue, item.documentId, "shipped_quantity");
52
52
  } })] }))] })) }, index));
53
53
  }
54
54