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
@@ -33,11 +33,13 @@ const INITIAL_STATE = {
33
33
  message: null,
34
34
  };
35
35
  function EditProductForm({ data, vendorArr, categoriesArray, revalidateCallback, handleClose, sx, }) {
36
- const { id, title, description, external_product_number, image, gallery, price, dimensions, categories, vendors, } = data;
37
- const initialGallery = gallery?.data || [];
38
- const initialCategories = categories?.data || [];
36
+ const { documentId, title, description, external_product_number, image, gallery, price, dimensions, categories, vendors, } = data;
37
+ console.log("price", price);
38
+ const initialGallery = gallery || [];
39
+ const initialCategories = categories || [];
40
+ console.log("initialCategories", initialCategories);
39
41
  const { handleAddMessage } = useSnackbar();
40
- const [formState, formAction] = useFormState(updateProductAction, INITIAL_STATE);
42
+ const [formState, formAction] = useFormState(updateProductAction.bind(null, documentId), INITIAL_STATE);
41
43
  useEffect(() => {
42
44
  if (formState?.message) {
43
45
  handleAddMessage({
@@ -83,19 +85,19 @@ function EditProductForm({ data, vendorArr, categoriesArray, revalidateCallback,
83
85
  setProductGallery([...productGallery, item]);
84
86
  }
85
87
  }
86
- 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: jsx(Typography, { variant: "h3", component: "h1", children: "Edit Product" }) }), 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 }), jsx(TextField, { id: "external_product_number", name: "external_product_number", label: "External Product Number", defaultValue: external_product_number })] }) }), jsxs(Grid, { item: true, xs: 6, children: [jsx(Typography, { variant: "h6", children: "Product Image" }), jsx("input", { id: "image", type: "hidden", name: "image", value: productImage?.id }), jsx(StrapiImage, { id: productImage?.id || "", url: productImage?.url || "", alternativeText: "product image", width: productImage?.width && productImage?.height
87
- ? 200 * (productImage.width / productImage.height)
88
- : 200, height: 200 }), jsx(Button, { onClick: () => setMediaDialogOpen("image"), children: "open media library" }), jsx(MediaLibraryDialog, { open: mediaDialogOpen === "image", handleClose: () => setMediaDialogOpen(null), handleCancel: () => {
89
- setProductImage(null);
90
- setMediaDialogOpen(null);
91
- }, handleSelect: handleSelectImage, selected: productImage ? [productImage] : [] })] }), jsxs(Grid, { item: true, xs: 6, children: [jsx(Typography, { variant: "h6", children: "Image Gallery" }), jsx("input", { id: "gallery", type: "hidden", name: "gallery", value: JSON.stringify(productGallery.map((item) => item.id)) }), jsx(Stack, { direction: "row", spacing: 2, children: productGallery.map((item) => {
92
- return (jsx(StrapiImage, { id: item.id, url: item.url, alternativeText: "gallery image", width: item?.width && item?.height
93
- ? 100 * (item.width / item.height)
94
- : 100, height: 100 }, item.id));
95
- }) }), jsx(Button, { onClick: () => setMediaDialogOpen("gallery"), children: "open media library" }), jsx(MediaLibraryDialog, { open: mediaDialogOpen === "gallery", handleClose: () => setMediaDialogOpen(null), handleCancel: () => {
96
- setProductGallery([]);
97
- setMediaDialogOpen(null);
98
- }, handleSelect: handleSelectGallery, selected: productGallery })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Price" }), jsx(PriceFields, { componentName: "price", componentReference: "e-commerce-elements.price", data: price })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Categories" }), jsx(CategorySelector, { categories: categoriesArray, currentValue: [...initialCategories.map((cat) => cat.id)] })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Dimensions" }), jsx(DimensionsFields, { componentName: "dimensions", componentReference: "e-commerce-elements.dimensions", data: dimensions })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Vendors" }), jsx(VendorSelector, { vendorNames: vendorArr, currentValue: vendors.data?.[0]?.id })] }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { py: 1 }, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { text: "update product", loadingText: "loading" })] }) })] })] }) }));
88
+ 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: "h3", component: "h1", children: "Edit Product" }) }), 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 }), jsx(TextField, { id: "external_product_number", name: "external_product_number", label: "External Product Number", defaultValue: external_product_number })] }) }), jsxs(Grid, { item: true, xs: 6, children: [jsx(Typography, { variant: "h6", children: "Product Image" }), jsx("input", { id: "image", type: "hidden", name: "image", value: productImage?.id }), jsx(StrapiImage, { id: productImage?.id || "", url: productImage?.url || "", alternativeText: "product image", width: productImage?.width && productImage?.height
89
+ ? 200 * (productImage.width / productImage.height)
90
+ : 200, height: 200 }), jsx(Button, { onClick: () => setMediaDialogOpen("image"), children: "open media library" }), jsx(MediaLibraryDialog, { open: mediaDialogOpen === "image", handleClose: () => setMediaDialogOpen(null), handleCancel: () => {
91
+ setProductImage(null);
92
+ setMediaDialogOpen(null);
93
+ }, handleSelect: handleSelectImage, selected: productImage ? [productImage] : [] })] }), jsxs(Grid, { item: true, xs: 6, children: [jsx(Typography, { variant: "h6", children: "Image Gallery" }), jsx("input", { id: "gallery", type: "hidden", name: "gallery", value: JSON.stringify(productGallery.map((item) => item.id)) }), jsx(Stack, { direction: "row", spacing: 2, children: productGallery.map((item) => {
94
+ return (jsx(StrapiImage, { id: item.id, url: item.url, alternativeText: "gallery image", width: item?.width && item?.height
95
+ ? 100 * (item.width / item.height)
96
+ : 100, height: 100 }, item.id));
97
+ }) }), jsx(Button, { onClick: () => setMediaDialogOpen("gallery"), children: "open media library" }), jsx(MediaLibraryDialog, { open: mediaDialogOpen === "gallery", handleClose: () => setMediaDialogOpen(null), handleCancel: () => {
98
+ setProductGallery([]);
99
+ setMediaDialogOpen(null);
100
+ }, handleSelect: handleSelectGallery, selected: productGallery })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Price" }), jsx(PriceFields, { componentName: "price", componentReference: "e-commerce-elements.price", data: price })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Categories" }), jsx(CategorySelector, { categories: categoriesArray, currentValue: [...initialCategories.map((cat) => cat.documentId)] })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Dimensions" }), jsx(DimensionsFields, { componentName: "dimensions", componentReference: "e-commerce-elements.dimensions", data: dimensions })] }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Vendors" }), jsx(VendorSelector, { vendorNames: vendorArr, currentValue: vendors[0]?.documentId })] }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { py: 1 }, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { text: "update product", loadingText: "loading" })] }) })] }) }) }));
99
101
  }
100
102
 
101
103
  export { EditProductForm };
@@ -36,9 +36,11 @@ const INITIAL_STATE = {
36
36
  severity: null,
37
37
  };
38
38
  function EditStockForm({ data, revalidateCallback, handleClose, sx, }) {
39
- const { id, title, product_number, stock, ipos, opos, reports } = data;
39
+ const { documentId, title, product_number, stock, ipos, opos, reports } = data;
40
40
  const { handleAddMessage } = useSnackbar();
41
- const [formState, formAction] = useFormState(updateProductAction, INITIAL_STATE);
41
+ // Bind the documentId to the form action following form patterns
42
+ const boundAction = updateProductAction.bind(null, documentId);
43
+ const [formState, formAction] = useFormState(boundAction, INITIAL_STATE);
42
44
  useEffect(() => {
43
45
  if (formState?.message) {
44
46
  handleAddMessage({
@@ -59,27 +61,48 @@ function EditStockForm({ data, revalidateCallback, handleClose, sx, }) {
59
61
  });
60
62
  }
61
63
  }, [formState?.strapiErrors, handleAddMessage]);
62
- return (jsxs(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: [jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: title }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(TableContainer, { component: Paper, children: [jsx(Typography, { variant: "h6", sx: { pl: 2 }, children: "Incoming orders" }), jsxs(Table, { size: "small", children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Number" }), jsx(TableCell, { children: "Order Date" }), jsx(TableCell, { children: "Line Item Number" }), jsx(TableCell, { children: "Ordered Quantity" }), jsx(TableCell, { children: "Received Quantity" }), jsx(TableCell, { children: "Registered Quantity" }), jsx(TableCell, { children: "Released Quantity" })] }) }), jsx(TableBody, { children: ipos.map((ipo) => (jsx(Fragment, { children: ipo.items.map((item) => (jsxs(TableRow, { children: [jsx(TableCell, { children: ipo.ipo_number }), jsx(TableCell, { children: ipo.order_date }), jsx(TableCell, { children: item.line_item_number }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.ordered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.received_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.registered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.released_quantity, maxValue: item.ordered_quantity, color: "primary" }) })] }, ipo.id))) }))) }), jsx(TableFooter, { children: jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 6, align: "right", children: "Total added to stock:" }), jsx(TableCell, { children: ipos.reduce((total, ipo) => total +
63
- ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0) })] }) })] }), jsx(Typography, { variant: "h6", sx: { pl: 2 }, children: "Outgoing orders" }), jsxs(Table, { size: "small", children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Number" }), jsx(TableCell, { children: "Order Date" }), jsx(TableCell, { children: "Line Item Number" }), jsx(TableCell, { children: "Ordered Quantity" }), jsx(TableCell, { children: "Picked Quantity" }), jsx(TableCell, { children: "Packed Quantity" }), jsx(TableCell, { children: "Shipped Quantity" })] }) }), jsx(TableBody, { children: opos.map((opo) => (jsx(Fragment, { children: opo.opo_items.map((item) => (jsxs(TableRow, { children: [jsx(TableCell, { children: opo.opo_number }), jsx(TableCell, { children: opo.order_date }), jsx(TableCell, { children: item.line_item_number }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.ordered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.picked_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.packed_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.shipped_quantity, maxValue: item.ordered_quantity, color: "primary" }) })] }, opo.documentId))) }))) }), jsx(TableFooter, { children: jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total reduced from stock:" }), jsx(TableCell, { children: opos.reduce((total, opo) => total +
64
- opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0) })] }) })] }), jsxs(Table, { size: "small", children: [jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Total added to stock:" }), jsx(TableCell, { children: ipos.reduce((total, ipo) => total +
65
- ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0) })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Total reduced from stock:" }), jsx(TableCell, { children: opos.reduce((total, opo) => total +
66
- opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0) })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Corrections:" }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock corrections", children: jsx(Typography, { children: reports
64
+ return (jsxs(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: [jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: title }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(TableContainer, { component: Paper, children: [jsx(Typography, { variant: "h6", sx: { pl: 2 }, children: "Incoming orders" }), jsxs(Table, { size: "small", children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Number" }), jsx(TableCell, { children: "Order Date" }), jsx(TableCell, { children: "Line Item Number" }), jsx(TableCell, { children: "Ordered Quantity" }), jsx(TableCell, { children: "Received Quantity" }), jsx(TableCell, { children: "Registered Quantity" }), jsx(TableCell, { children: "Released Quantity" })] }) }), jsx(TableBody, { children: Array.isArray(ipos) ? (ipos.map((ipo) => (jsx(Fragment, { children: ipo.items.map((item) => (jsxs(TableRow, { children: [jsx(TableCell, { children: ipo.ipo_number }), jsx(TableCell, { children: ipo.order_date }), jsx(TableCell, { children: item.line_item_number }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.ordered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.received_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.registered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.released_quantity, maxValue: item.ordered_quantity, color: "primary" }) })] }, ipo.documentId))) })))) : (jsx(TableRow, { children: jsx(TableCell, { colSpan: 7, align: "center", children: "No incoming orders found." }) })) }), jsx(TableFooter, { children: jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 6, align: "right", children: "Total added to stock:" }), jsx(TableCell, { children: Array.isArray(ipos)
65
+ ? ipos.reduce((total, ipo) => total +
66
+ ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
67
+ : 0 })] }) })] }), jsx(Typography, { variant: "h6", sx: { pl: 2 }, children: "Outgoing orders" }), jsxs(Table, { size: "small", children: [jsx(TableHead, { children: jsxs(TableRow, { children: [jsx(TableCell, { children: "Number" }), jsx(TableCell, { children: "Order Date" }), jsx(TableCell, { children: "Line Item Number" }), jsx(TableCell, { children: "Ordered Quantity" }), jsx(TableCell, { children: "Picked Quantity" }), jsx(TableCell, { children: "Packed Quantity" }), jsx(TableCell, { children: "Shipped Quantity" })] }) }), jsx(TableBody, { children: Array.isArray(opos) ? (opos.map((opo) => (jsx(Fragment, { children: opo.opo_items.map((item) => (jsxs(TableRow, { children: [jsx(TableCell, { children: opo.opo_number }), jsx(TableCell, { children: opo.order_date }), jsx(TableCell, { children: item.line_item_number }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.ordered_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.picked_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.packed_quantity, maxValue: item.ordered_quantity, color: "primary" }) }), jsx(TableCell, { children: jsx(AmountIndicator, { value: item.shipped_quantity, maxValue: item.ordered_quantity, color: "primary" }) })] }, opo.documentId))) })))) : (jsx(TableRow, { children: jsx(TableCell, { colSpan: 7, align: "center", children: "No outgoing orders found" }) })) }), jsx(TableFooter, { children: jsxs(TableRow, { children: [jsx(TableCell, { colSpan: 3, align: "right", children: "Total reduced from stock:" }), jsx(TableCell, { children: Array.isArray(opos)
68
+ ? opos.reduce((total, opo) => total +
69
+ opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0)
70
+ : 0 })] }) })] }), jsxs(Table, { size: "small", children: [jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Total added to stock:" }), jsx(TableCell, { children: Array.isArray(ipos) && ipos.length > 0
71
+ ? ipos.reduce((total, ipo) => total +
72
+ ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
73
+ : 0 })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Total reduced from stock:" }), jsx(TableCell, { children: Array.isArray(opos) && opos.length > 0
74
+ ? opos.reduce((total, opo) => total +
75
+ opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0)
76
+ : 0 })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Corrections:" }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock corrections", children: jsx(Typography, { children: reports
67
77
  ? reports.reduce((total, report) => total + report.quantity, 0)
68
78
  : 0 }) }) }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock corrections after updating", children: jsx("b", { children: reports
69
79
  ? reports.reduce((total, report) => total + report.quantity, 0)
70
- : 0 }) }) })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Stock:" }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock", children: jsx(Typography, { children: ipos.reduce((total, ipo) => total +
71
- ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0) -
72
- opos.reduce((total, opo) => total +
73
- opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0) +
80
+ : 0 }) }) })] }), jsxs(TableRow, { children: [jsx(TableCell, { align: "right", children: "Stock:" }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock", children: jsx(Typography, { children: (Array.isArray(ipos) && ipos.length > 0
81
+ ? ipos.reduce((total, ipo) => total +
82
+ ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
83
+ : 0) -
84
+ (Array.isArray(opos) && opos.length > 0
85
+ ? opos.reduce((total, opo) => total +
86
+ opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0)
87
+ : 0) +
74
88
  (reports
75
89
  ? reports.reduce((total, report) => total + report.quantity, 0)
76
- : 0) }) }) }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock after updating", children: jsx("b", { children: ipos.reduce((total, ipo) => total +
77
- ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0) -
78
- opos.reduce((total, opo) => total +
79
- opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0) +
90
+ : 0) }) }) }), jsx(TableCell, { children: jsx(Tooltip, { title: "Total stock after updating", children: jsx("b", { children: (Array.isArray(ipos) && ipos.length > 0
91
+ ? ipos.reduce((total, ipo) => total +
92
+ ipo.items.reduce((itemTotal, item) => itemTotal + item.released_quantity, 0), 0)
93
+ : 0) -
94
+ (Array.isArray(opos) && opos.length > 0
95
+ ? opos.reduce((total, opo) => total +
96
+ opo.opo_items.reduce((itemTotal, item) => itemTotal + item.ordered_quantity, 0), 0)
97
+ : 0) +
80
98
  (reports
81
99
  ? reports.reduce((total, report) => total + report.quantity, 0)
82
- : 0) }) }) })] })] })] }) })] }), jsxs("form", { action: formAction, children: [id && jsx("input", { id: "id", type: "hidden", name: "id", value: id }), jsx("input", { id: "stock_reports", type: "hidden", name: "stock_reports", value: JSON.stringify(reports) }), jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, sx: { mt: 2 }, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Stock corrections" }), 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(Stack, { direction: "row", justifyContent: "flex-end", children: jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "stock", related: [{ id: id, __type: "api::e-commerce.product" }], revalidateCallback: revalidateCallback, biggerButton: true }) })] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Stack, { direction: "row", justifyContent: "flex-end", alignItems: "center", sx: { py: 1 }, children: handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Close" })) }) })] })] })] }));
100
+ : 0) }) }) })] })] })] }) })] }), jsxs("form", { action: formAction, children: [jsx("input", { id: "stock_reports", type: "hidden", name: "stock_reports", value: JSON.stringify(reports) }), jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, sx: { mt: 2 }, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Stock corrections" }), 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(Stack, { direction: "row", justifyContent: "flex-end", children: jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "stock", related: [
101
+ {
102
+ documentId: documentId,
103
+ __type: "api::e-commerce.product",
104
+ },
105
+ ], revalidateCallback: revalidateCallback, biggerButton: true }) })] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Stack, { direction: "row", justifyContent: "flex-end", alignItems: "center", sx: { py: 1 }, children: handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Close" })) }) })] })] })] }));
83
106
  }
84
107
 
85
108
  export { EditStockForm };
@@ -13,7 +13,8 @@ import InputAdornment from '@mui/material/InputAdornment';
13
13
  import Stack from '@mui/material/Stack';
14
14
 
15
15
  function PriceFields({ data, componentName, componentReference, }) {
16
- const { id, vat_rate, vat, price_incl_vat, price } = data || {};
16
+ const { documentId, vat_rate, vat, price_incl_vat, price } = data || {};
17
+ console.log("documentId", documentId);
17
18
  const [priceState, setPriceState] = useState(price?.toString() || "");
18
19
  const [vatRateState, setVatRateState] = useState(() => vat_rate?.toString() || "21");
19
20
  const [vatState, setVatState] = useState(vat || 0);
@@ -28,7 +29,7 @@ function PriceFields({ data, componentName, componentReference, }) {
28
29
  setPriceInclVatState(priceInclVat);
29
30
  }
30
31
  }, [priceState, vatRateState]);
31
- return (jsxs(Stack, { spacing: 2, direction: "row", 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: "price", InputProps: {
32
+ return (jsxs(Stack, { spacing: 2, direction: "row", children: [jsx(TextField, { id: "price", InputProps: {
32
33
  startAdornment: (jsx(InputAdornment, { position: "start", children: jsx(EuroIcon, {}) })),
33
34
  }, name: `${componentName}.price`, label: "price", type: "float", value: priceState, onChange: (e) => {
34
35
  setPriceState(e.target.value);
@@ -20,7 +20,7 @@ import AddToCartButton from '../cart/AddToCartButton.client.js';
20
20
  import MarkdownDisplay from '../../common/markdown/MarkdownDisplay.js';
21
21
 
22
22
  function ProductCard({ product, sx = [] }) {
23
- const { id, uuid, product_number, title, description, slug, price, image, stock, } = product;
23
+ const { documentId, uuid, product_number, title, description, slug, price, image, stock, } = product;
24
24
  const imgURL = getStrapiMedia(image?.url);
25
25
  const thumbURL = getStrapiMedia(image?.formats?.thumbnail?.url);
26
26
  return (jsxs(Card, { sx: [
@@ -28,12 +28,12 @@ function ProductCard({ product, sx = [] }) {
28
28
  { width: "100%", height: "100%" },
29
29
  { display: "flex", flexDirection: "column" },
30
30
  ...(Array.isArray(sx) ? sx : [sx]),
31
- ], children: [jsx(CardMedia, { component: "img", height: "140", src: `${imgURL}`, alt: image.alternativeText }), jsxs(CardContent, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", sx: { pb: 2 }, children: [jsx(StyledLink, { href: `/shop/${slug}`, target: "_self", children: jsx(Typography, { variant: "h5", children: title }) }), jsx(Price, { id: id, price: price.price, vat: price.vat, vat_rate: price.vat_rate, price_incl_vat: price.price_incl_vat })] }), description && (jsx(MarkdownDisplay, { children: description.substring(0, 150) + "..." }))] }), jsx(Box, { sx: { flexGrow: 1 } }), jsxs(CardActions, { sx: {
31
+ ], children: [jsx(CardMedia, { component: "img", height: "140", src: `${imgURL}`, alt: image.alternativeText }), jsxs(CardContent, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", sx: { pb: 2 }, children: [jsx(StyledLink, { href: `/shop/${slug}`, target: "_self", children: jsx(Typography, { variant: "h5", children: title }) }), jsx(Price, { documentId: documentId, price: price.price, vat: price.vat, vat_rate: price.vat_rate, price_incl_vat: price.price_incl_vat })] }), description && (jsx(MarkdownDisplay, { children: description.substring(0, 150) + "..." }))] }), jsx(Box, { sx: { flexGrow: 1 } }), jsxs(CardActions, { sx: {
32
32
  display: "flex",
33
33
  justifyContent: "flex-end",
34
34
  alignItems: "flex-end",
35
35
  }, children: [jsx(Button, { size: "small", href: `/shop/${slug}`, children: "Learn More" }), jsx(AddToCartButton, { product: {
36
- id: id,
36
+ documentId: documentId,
37
37
  uuid: uuid,
38
38
  slug: slug,
39
39
  thumb: thumbURL,
@@ -26,7 +26,7 @@ function ProductCategoryCard({ category, sx = [] }) {
26
26
  alignItems: "center",
27
27
  gap: 2,
28
28
  flexDirection: "column",
29
- }, children: [jsx(Typography, { variant: "h4", component: "h1", align: "center", children: title }), description && (jsx(Box, { sx: { textAlign: "center", p: 2, overflow: "hidden" }, children: jsx(MarkdownDisplay, { children: description }) })), jsxs(Button, { variant: "contained", color: "primary", href: `/shop/categories/${slug}`, children: ["See all ", category.title] }), products.data.length - PRODUCTS_PER_CATEGORY > 0 && (jsxs(Typography, { variant: "body2", children: [products.data.length - PRODUCTS_PER_CATEGORY, " more..."] }))] }), products.data.slice(0, PRODUCTS_PER_CATEGORY).map((product) => (jsx(Grid, { item: true, xs: 12, sm: 6, md: 3, children: jsx(ProductCard, { product: product }, product.id) })))] }) }));
29
+ }, children: [jsx(Typography, { variant: "h4", component: "h1", align: "center", children: title }), description && (jsx(Box, { sx: { textAlign: "center", p: 2, overflow: "hidden" }, children: jsx(MarkdownDisplay, { children: description }) })), jsxs(Button, { variant: "contained", color: "primary", href: `/shop/categories/${slug}`, children: ["See all ", category.title] }), products.data.length - PRODUCTS_PER_CATEGORY > 0 && (jsxs(Typography, { variant: "body2", children: [products.data.length - PRODUCTS_PER_CATEGORY, " more..."] }))] }), products.data.slice(0, PRODUCTS_PER_CATEGORY).map((product) => (jsx(Grid, { item: true, xs: 12, sm: 6, md: 3, children: jsx(ProductCard, { product: product }, product.documentId) })))] }) }));
30
30
  }
31
31
 
32
32
  export { ProductCategoryCard as default };
@@ -14,15 +14,15 @@ const ProductSelector = ({ productNames, currentValue, sx, multiple = true, onCh
14
14
  const [selectedValues, setSelectedValues] = useState(currentValue || []);
15
15
  const handleProductChange = (event, value) => {
16
16
  if (multiple === true) {
17
- const ids = value.map((product) => product.id);
17
+ const ids = value.map((product) => product.documentId);
18
18
  setSelectedValues(ids);
19
19
  if (onChangeCallback)
20
20
  onChangeCallback(ids);
21
21
  }
22
22
  else if (value) {
23
- setSelectedValues([value.id]);
23
+ setSelectedValues([value.documentId]);
24
24
  if (onChangeCallback)
25
- onChangeCallback([value.id]);
25
+ onChangeCallback([value.documentId]);
26
26
  }
27
27
  else {
28
28
  setSelectedValues([]);
@@ -36,8 +36,8 @@ const ProductSelector = ({ productNames, currentValue, sx, multiple = true, onCh
36
36
  ], children: [jsx(Autocomplete, { multiple: multiple, options: productNames, getOptionLabel: (option) => {
37
37
  return `${option.product_number} | ${option.title}`;
38
38
  }, filterSelectedOptions: true, onChange: handleProductChange, renderInput: (params) => jsx(TextField, { ...params, label: "Products" }), defaultValue: multiple
39
- ? productNames.filter((productName) => selectedValues.includes(productName.id))
40
- : productNames.find((productName) => productName.id === selectedValues[0]) || null }), jsx("input", { type: "hidden", name: "products", value: JSON.stringify(selectedValues) })] }));
39
+ ? productNames.filter((productName) => selectedValues.includes(productName.documentId))
40
+ : productNames.find((productName) => productName.documentId === selectedValues[0]) || null }), jsx("input", { type: "hidden", name: "products", value: JSON.stringify(selectedValues) })] }));
41
41
  };
42
42
 
43
43
  export { ProductSelector as default };
@@ -19,7 +19,7 @@ import AddToCartButton from '../cart/AddToCartButton.client.js';
19
19
  import MarkdownDisplay from '../../common/markdown/MarkdownDisplay.js';
20
20
 
21
21
  function SingleProduct({ product, sx = [] }) {
22
- const { id, uuid, product_number, title, description, slug, price, image, gallery, categories, stock, } = product;
22
+ const { documentId, uuid, product_number, title, description, slug, price, image, gallery, categories, stock, } = product;
23
23
  const imgURL = image?.url ? getStrapiMedia(image.url) : null;
24
24
  const thumbURL = image?.formats?.thumbnail?.url
25
25
  ? getStrapiMedia(image.formats.thumbnail.url)
@@ -28,7 +28,7 @@ function SingleProduct({ product, sx = [] }) {
28
28
  fontWeight: 600,
29
29
  color: stock === 0 ? "red" : "white",
30
30
  }, align: "right", children: [stock, " items in stock"] }), jsx(AddToCartButton, { product: {
31
- id: id,
31
+ documentId: documentId,
32
32
  uuid: uuid,
33
33
  slug: slug,
34
34
  thumb: thumbURL,
@@ -39,15 +39,15 @@ function SingleProduct({ product, sx = [] }) {
39
39
  price_incl_vat: price.price_incl_vat,
40
40
  product_number: product_number,
41
41
  stock: stock,
42
- } })] }) })) }), jsx(Grid, { item: true, xs: 12, sm: 12, md: 6, lg: 5, xl: 5, children: imgURL !== null && (jsx(Box, { sx: { height: "400px", width: "100%", position: "relative" }, children: jsx(Suspense, { fallback: jsx("div", { children: "Loading..." }), children: jsx(StrapiImage, { id: image.id, url: imgURL, alternativeText: image.alternativeText, fill: true, style: { objectFit: "contain" } }) }) })) }), jsx(Grid, { item: true, xs: 12, sm: 12, md: 6, lg: 7, xl: 7, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: "Image gallery" }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Suspense, { fallback: jsx("div", { children: "Loading..." }), children: jsx(Stack, { spacing: 1, direction: "row", children: product?.gallery?.data &&
43
- product.gallery.data.map((img) => {
42
+ } })] }) })) }), jsx(Grid, { item: true, xs: 12, sm: 12, md: 6, lg: 5, xl: 5, children: imgURL !== null && (jsx(Box, { sx: { height: "400px", width: "100%", position: "relative" }, children: jsx(Suspense, { fallback: jsx("div", { children: "Loading..." }), children: jsx(StrapiImage, { id: image.id, url: imgURL, alternativeText: image.alternativeText, fill: true, style: { objectFit: "contain" } }) }) })) }), jsx(Grid, { item: true, xs: 12, sm: 12, md: 6, lg: 7, xl: 7, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h6", children: "Image gallery" }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Suspense, { fallback: jsx("div", { children: "Loading..." }), children: jsx(Stack, { spacing: 1, direction: "row", children: product?.gallery &&
43
+ product.gallery.map((img) => {
44
44
  const imgUrl = img?.url ? getStrapiMedia(img.url) : null;
45
45
  return (jsx(Box, { sx: {
46
46
  width: " 150px",
47
47
  height: "150px",
48
48
  position: "relative",
49
49
  }, children: imgUrl !== null && (jsx(StrapiImage, { id: img.id, url: imgUrl, alternativeText: img.alternativeText, fill: true, style: { objectFit: "contain" } })) }, img.id));
50
- }) }) }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: categories?.data && (jsxs(Stack, { justifyContent: "center", alignItems: "center", direction: categories.data.length === 1 ? "row" : "column", children: [categories.data.length === 1 ? (jsx(Typography, { children: "Category:" })) : (jsx(Typography, { children: "Categories:" })), categories.data?.map((categorie) => {
50
+ }) }) }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: categories && (jsxs(Stack, { justifyContent: "center", alignItems: "center", direction: categories.length === 1 ? "row" : "column", children: [categories.length === 1 ? (jsx(Typography, { children: "Category:" })) : (jsx(Typography, { children: "Categories:" })), categories.map((categorie) => {
51
51
  return (jsx(Link, { href: `/shop/categories/${categorie.slug}`, legacyBehavior: true, children: jsx(Button, { variant: "text", children: categorie.slug }) }, categorie.id));
52
52
  })] })) }), jsx(Grid, { item: true, xs: 12, md: 6, children: jsx(Stack, { children: jsx(Link, { href: "/shop", legacyBehavior: true, children: jsx(Button, { variant: "outlined", children: "continue shopping" }) }) }) })] }) })] }) }));
53
53
  }
@@ -60,7 +60,7 @@ function IPOItemFields({ productsArr, vendorID = null, }) {
60
60
  return items.map((item, index) => {
61
61
  return {
62
62
  line_item_number: `${index + 1}.0.0`,
63
- product: item.product.id,
63
+ product: item.product.documentId,
64
64
  ordered_quantity: item.amount,
65
65
  expected_delivery_date: item.pdw,
66
66
  };
@@ -103,7 +103,7 @@ function IPOItemFields({ productsArr, vendorID = null, }) {
103
103
  vendorID === null && { color: theme.palette.text.disabled },
104
104
  ], children: [item.product.product_number, " | ", item.product.title] }), jsx(TableCell, { sx: { width: "15%" }, children: item.amount }), jsx(TableCell, { sx: { width: "10%" }, children: getWeek(item.pdw) }), jsx(TableCell, { align: "right", sx: { width: "5%" }, children: jsx(IconButton, { onClick: () => handleDeleteItem(index), children: jsx(DeleteIcon, {}) }) })] }, index));
105
105
  }) })] }), jsx("input", { type: "hidden", name: "ipo_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: "55%" }, multiple: false, onChangeCallback: (ids) => {
106
- const product = productsArr.find((p) => p.id === ids[0]);
106
+ const product = productsArr.find((p) => p.documentId === ids[0]);
107
107
  setNextProductName(product || null);
108
108
  setSelectedProduct(ids);
109
109
  } })), jsx(TextField, { id: "amount", name: "amount", type: "number", label: "Amount", value: nextAmount, onChange: (e) => {
@@ -31,11 +31,16 @@ function ItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCallb
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_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product.title }) }))] }), jsx(Typography, { variant: "body2", children: "Received" }), jsx(AmountUpdater, { currentValue: received_quantity, totalValue: ordered_quantity + received_bad_quantity, minNewValue: 0 + registered_quantity + -registered_bad_quantity, maxNewValue: ordered_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: ordered_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::logistics.ipo-item" }], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: ordered_quantity + received_bad_quantity + registered_bad_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
38
- handleUpdateQuantity(newValue, item.id, "released_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::logistics.ipo-item",
41
+ },
42
+ ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: ordered_quantity + received_bad_quantity + registered_bad_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
43
+ handleUpdateQuantity(newValue, item.documentId, "released_quantity");
39
44
  } })] })) }, index));
40
45
  }
41
46
 
@@ -72,7 +72,7 @@ function ManageIPOForm({ data, sx, revalidateCallback, handleClose, role, }) {
72
72
  const parseItems = (items) => {
73
73
  return items.map((item) => {
74
74
  return {
75
- id: item.id,
75
+ documentId: item.documentId,
76
76
  received_quantity: item.received_quantity,
77
77
  registered_quantity: item.registered_quantity,
78
78
  released_quantity: item.released_quantity,
@@ -81,16 +81,18 @@ function ManageIPOForm({ data, sx, revalidateCallback, handleClose, role, }) {
81
81
  };
82
82
  const handleUpdateQuantity = (value, itemID, type) => {
83
83
  const newItems = [...items];
84
- const index = newItems.findIndex((item) => item.id === itemID);
84
+ const index = newItems.findIndex((item) => item.documentId === itemID);
85
85
  newItems[index][type] = value;
86
86
  setItems(newItems);
87
87
  };
88
- 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: "Manage Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Update the incoming purchase order details" })] }), 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.ipo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }), jsx(Typography, { variant: "body2", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: data.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Supplier" }), jsx(Typography, { variant: "body2", children: data.vendor_profile?.business_credentials?.company_name })] }), 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 })] }), (data.internal_status === "placed" ||
88
+ 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: "Manage Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Update the incoming purchase order details" })] }), jsx(NoteTakingComponent, { content: "", related: [
89
+ { id: data.documentId, __type: "api::logistics.ipo" },
90
+ ], 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.ipo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Custom reference" }), jsx(Typography, { variant: "body2", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Order Date" }), jsx(Typography, { variant: "body2", children: data.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, children: [jsx(Typography, { variant: "body1", width: "250px", children: "Supplier" }), jsx(Typography, { variant: "body2", children: data.vendor_profile?.business_credentials?.company_name })] }), 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 })] }), (data.internal_status === "placed" ||
89
91
  data.internal_status === "released_on_stock") &&
90
92
  role === "enduser" && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher." }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, 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: jsxs(Stack, { spacing: 1, children: [role === "enduser" && (jsx(Fragment, { children: data.order_confirmation ? (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { children: data.order_confirmation?.name }), jsx(Button, { variant: "contained", onClick: () => {
91
- downloadBase64File(`api/ipos/${data.id}`, "order_confirmation");
93
+ downloadBase64File(`api/ipos/${data.documentId}`, "order_confirmation");
92
94
  }, children: "Download" })] })) : (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { variant: "body1", children: "Upload the order confirmation for this order" }), jsx(UploadBase64MediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "order_confirmation", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "order_confirmation", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) })), data.delivery_note ? (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { children: data.delivery_note?.name }), jsx(Button, { variant: "contained", onClick: () => {
93
- downloadBase64File(`api/ipos/${data.id}`, "delivery_note");
95
+ downloadBase64File(`api/ipos/${data.documentId}`, "delivery_note");
94
96
  }, children: "Download" })] })) : (jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Upload the delivery note for this order" }), jsx(UploadBase64MediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] }))] }) })] }) }), 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: 2, children: [jsx(Typography, { variant: "h5", children: "Items" }), data.internal_status === "placed" && (jsx(Alert, { severity: "warning", children: "Items cannot be updated before order confirmation" })), jsxs("form", { action: formAction, children: [jsx("input", { type: "hidden", name: "items", value: JSON.stringify(parseItems(items)) }), jsxs(Stack, { spacing: 2, children: [data?.items &&
95
97
  data.items.map((item, index) => (jsx(Paper, { sx: { p: 2 }, children: data.internal_status === "placed" ? (jsx(ItemDisplay, { item: item, index: index, image: item?.product?.image })) : (jsx(ItemUpdater, { item: item, index: index, handleUpdateQuantity: handleUpdateQuantity, image: item?.product?.image,
96
98
  // handleRemoveReportAtIndex={handleRemoveReportAtIndex}
@@ -42,13 +42,13 @@ function TextualIPOItemUpdater({ 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: item.product?.title }) }))] }), 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: ordered_quantity, minNewValue: 0 + registered_quantity, maxNewValue: ordered_quantity, color: "info", handleChange: (newValue) => {
45
- handleUpdateQuantity(newValue, item.id, "received_quantity");
45
+ handleUpdateQuantity(newValue, item.documentId, "received_quantity");
46
46
  } })] }), 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: ordered_quantity + registered_reports_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
47
- handleUpdateQuantity(newValue, item.id, "registered_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: "registered", minValue: -(received_quantity -
47
+ handleUpdateQuantity(newValue, item.documentId, "registered_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: "registered", minValue: -(received_quantity -
49
49
  registered_quantity +
50
50
  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: ordered_quantity + registered_reports_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
51
- handleUpdateQuantity(newValue, item.id, "released_quantity");
51
+ handleUpdateQuantity(newValue, item.documentId, "released_quantity");
52
52
  } })] }))] })) }, index));
53
53
  }
54
54
 
@@ -133,14 +133,14 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
133
133
  const parseItems = (items) => {
134
134
  return items.map((item) => {
135
135
  return {
136
- id: item.id,
136
+ id: item.documentId,
137
137
  ordered_quantity: item.ordered_quantity,
138
138
  received_quantity: item.received_quantity,
139
139
  registered_quantity: item.registered_quantity,
140
140
  released_quantity: item.released_quantity,
141
141
  reports: item.reports?.map((report) => {
142
142
  return {
143
- id: "id" in report ? report.id : undefined,
143
+ documentId: "documentId" in report ? report.documentId : undefined,
144
144
  quantity: report.quantity,
145
145
  content: report.content,
146
146
  type: report.type,
@@ -151,7 +151,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
151
151
  };
152
152
  const handleUpdateQuantity = (value, itemID, type) => {
153
153
  const newItems = [...items];
154
- const index = newItems.findIndex((item) => item.id === itemID);
154
+ const index = newItems.findIndex((item) => item.documentId === itemID);
155
155
  newItems[index][type] = value;
156
156
  setItems(newItems);
157
157
  };
@@ -160,7 +160,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
160
160
  * - only used with Textual form */
161
161
  const handleAddReport = (report, itemID) => {
162
162
  const newItems = [...items];
163
- const index = newItems.findIndex((item) => item.id === itemID);
163
+ const index = newItems.findIndex((item) => item.documentId === itemID);
164
164
  const reportsOnItem = newItems[index]?.reports || [];
165
165
  const newReports = [...reportsOnItem, report];
166
166
  if (newItems[index]?.reports == undefined) {
@@ -171,7 +171,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
171
171
  };
172
172
  const handleRemoveReportAtIndex = (itemID, index) => {
173
173
  const newItems = [...items];
174
- const itemIndex = newItems.findIndex((item) => item.id === itemID);
174
+ const itemIndex = newItems.findIndex((item) => item.documentId === itemID);
175
175
  const reportsOnItem = newItems[itemIndex]?.reports || [];
176
176
  const dbReports = reportsOnItem.filter((report) => "id" in report);
177
177
  const preReports = reportsOnItem.filter((report) => !("id" in report));
@@ -207,12 +207,14 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
207
207
  return (jsx(Box, { sx: [
208
208
  // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
209
209
  ...(Array.isArray(sx) ? sx : [sx]),
210
- ], 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: 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: "Purchase Order Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.ipo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Custom 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: "Order Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Supplier" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.vendor_profile?.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: "Order Status" }), jsx(IpoStatusIndicator, { status: data.internal_status })] })] }) }) }), role === "enduser" && (jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [(data.internal_status === "placed" ||
210
+ ], 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: [
211
+ { id: data.documentId, __type: "api::logistics.ipo" },
212
+ ], 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: "Purchase Order Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.ipo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Custom 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: "Order Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Supplier" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.vendor_profile?.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: "Order Status" }), jsx(IpoStatusIndicator, { status: data.internal_status })] })] }) }) }), role === "enduser" && (jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [(data.internal_status === "placed" ||
211
213
  data.internal_status === "released_on_stock") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback })] })), (data.internal_status === "placed" ||
212
214
  data.internal_status === "ordered") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(CancelIpoDialog, { 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: jsxs(Stack, { spacing: 1, children: [role === "enduser" && (jsx(Fragment, { children: data.order_confirmation ? (jsxs(Fragment, { children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { children: data.order_confirmation?.name }), jsx(Button, { variant: "contained", onClick: () => {
213
- downloadBase64File(`api/ipos/${data.id}`, "order_confirmation");
215
+ downloadBase64File(`api/ipos/${data.documentId}`, "order_confirmation");
214
216
  }, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Order Confirmation" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the order confirmation for this order" }), jsx(Typography, { variant: "body1", children: "FileUpload" }), jsx(Divider, {}), jsx(UploadBase64MediaForm /* This form manages it's own state internally */, { reference: "api::logistics.ipo", refID: data.documentId, field: "order_confirmation", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "order_confirmation", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) })), data.delivery_note ? (jsxs(Fragment, { children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { children: data.delivery_note?.name }), jsx(Button, { variant: "contained", onClick: () => {
215
- downloadBase64File(`api/ipos/${data.id}`, "delivery_note");
217
+ downloadBase64File(`api/ipos/${data.documentId}`, "delivery_note");
216
218
  }, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] }))] }) })] }) }), 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: {
217
219
  bgcolor: "background.default",
218
220
  border: "1px solid",
@@ -36,7 +36,7 @@ const INITIAL_STATE = {
36
36
  severity: null,
37
37
  };
38
38
  function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose, sx, }) {
39
- const { id, website_url, phone_number, email, business_credentials, address, products, contacts, notes, } = data;
39
+ const { documentId, website_url, phone_number, email, business_credentials, address, products, contacts, notes, } = data;
40
40
  console.log("data", data);
41
41
  const [formState, formAction] = useFormState(updateVendorAction, INITIAL_STATE);
42
42
  const { handleAddMessage } = useSnackbar();
@@ -81,9 +81,12 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
81
81
  // INFO must utilize the uuid to ensure that the new contacts are unique
82
82
  // this is important to use both the deleteCallback and still not have problems with the key
83
83
  const [newContacts, setNewContacts] = useState([]);
84
- 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, { direction: "row", justifyContent: "space-between", children: [jsx(Typography, { variant: "h5", children: "Edit Vendor" }), jsx(NoteTakingComponent, { content: "", related: [
85
- { id: data.id, __type: "api::logistics.vendor-profile" },
86
- ], 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.id) })] }), jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: jsx(Typography, { variant: "h6", children: "Contacts" }) }), oldContacts?.map((contact, index) => {
84
+ return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsxs("form", { action: formAction, children: [documentId && (jsx("input", { id: "id", type: "hidden", name: "id", value: documentId })), jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsx(Typography, { variant: "h5", children: "Edit Vendor" }), jsx(NoteTakingComponent, { content: "", related: [
85
+ {
86
+ id: data.documentId,
87
+ __type: "api::logistics.vendor-profile",
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) => {
87
90
  if (contact.data?.id) {
88
91
  if (open.includes(contact.data?.id)) {
89
92
  return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
@@ -18,7 +18,7 @@ import { ExplanatoryFoldOut } from '../../ExplanatoryFoldOut.js';
18
18
  import Contacts from '../../common/Contacts.js';
19
19
 
20
20
  function VendorDisplay({ data, sx }) {
21
- const { id, website_url, phone_number, email, business_credentials, address, products, contacts, } = data;
21
+ const { documentId, website_url, phone_number, email, business_credentials, address, products, contacts, } = data;
22
22
  console.log(contacts);
23
23
  return (jsxs(Box, { sx: [
24
24
  // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
@@ -18,12 +18,13 @@ const VendorSelector = ({ vendorNames, currentValue, onSelectVendor, }) => {
18
18
  const [selectedValue, setSelectedValue] = useState(currentValue || null);
19
19
  const handleVendorChange = (event, value) => {
20
20
  // if (!value) return;
21
- const id = value?.id || null;
22
- setSelectedValue(id);
21
+ const documentId = value?.documentId || null;
22
+ setSelectedValue(documentId);
23
23
  if (onSelectVendor)
24
- onSelectVendor(id);
24
+ onSelectVendor(documentId);
25
25
  };
26
- return (jsxs(Fragment, { children: [jsx(Autocomplete, { options: vendorNames, getOptionLabel: (option) => option?.business_credentials?.company_name, filterSelectedOptions: true, onChange: handleVendorChange, renderInput: (params) => jsx(TextField, { ...params, label: "Vendors" }), value: vendorNames?.find((vendor) => vendor.id === selectedValue) || null }), jsx("input", { type: "hidden", name: "vendors", value: selectedValue ? JSON.stringify(selectedValue) : "" })] }));
26
+ return (jsxs(Fragment, { children: [jsx(Autocomplete, { options: vendorNames, getOptionLabel: (option) => option?.business_credentials?.company_name, filterSelectedOptions: true, onChange: handleVendorChange, renderInput: (params) => jsx(TextField, { ...params, label: "Vendors" }), value: vendorNames?.find((vendor) => vendor.documentId === selectedValue) ||
27
+ null }), jsx("input", { type: "hidden", name: "vendors", value: selectedValue ? selectedValue : "" })] }));
27
28
  };
28
29
 
29
30
  export { VendorSelector as default };