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
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@mui/material/Paper"),a=require("@mui/material/Typography"),n=require("@mui/material/Button"),i=require("@mui/material/Stack"),r=require("@mui/material/Grid"),s=require("@mui/material/IconButton"),l=require("@mui/material/Checkbox"),c=require("@mui/material/Divider"),d=require("@mui/material/Collapse"),u=require("@mui/material/Autocomplete"),m=require("@mui/material/TextField"),o=require("../../../../node_modules/react-csv/index.js"),x=require("@mui/x-date-pickers"),h=require("@mui/x-date-pickers/AdapterDayjs"),j=require("@mui/x-date-pickers/DatePicker"),b=require("@mui/icons-material/KeyboardArrowDown"),g=require("@mui/icons-material/KeyboardArrowUp"),p=require("react"),f=require("../../../../node_modules/dayjs/dayjs.min.js"),C=require("../../../../node_modules/qs/lib/index.js");exports.default=function(k){const{defaultAttributes:y,defaultRelations:w,defaultStrapiAttributes:S,additionalDateTypes:q,fetchCSVData:v,entityCode:D="FU"}=k,Y=[...S.map(e=>e.name),...q],[A,M]=p.useState(f.default(Date.now()).startOf("day")),[I,z]=p.useState("createdAt"),[E,P]=p.useState(f.default(A).subtract(1,"month")),[$,_]=p.useState(!1),[O,T]=p.useState([]),[V,F]=p.useState([]),[R,U]=p.useState([]),[B,K]=p.useState([]),[L,G]=p.useState(null),H=p.useRef(null),[J,N]=p.useState(""),Q=p.useCallback(e=>{const{name:t}=e.target;T(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},[]),W=p.useCallback(e=>{const{name:t}=e.target;U(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},[]),X=p.useCallback(e=>{const{name:t}=e.target;F(e=>e.some(e=>e.name===t)?e.filter(e=>e.name!==t):[...e,{name:t,attributes:w.find(e=>e.name===t)?.attributes.map(e=>e.name)||[]}])},[w]),Z=p.useCallback(e=>{const[t,a]=e.target.name.split("|");F(e=>e.find(e=>e.name===a)?e.map(e=>e.name===a?{...e,attributes:e.attributes.includes(t)?e.attributes.filter(e=>e!==t):[...e.attributes,t]}:e):[...e,{name:a,attributes:[t]}])},[]),ee=p.useCallback(e=>{K(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),te=p.useCallback(e=>{const{checked:t}=e.target;T(t?y.map(e=>e.name):[])},[y]),ae=p.useCallback(e=>{const{checked:t}=e.target;U(t?S.map(e=>e.name):[])},[S]),ne=p.useCallback(e=>{const{checked:t}=e.target;F(t?w.map(e=>({name:e.name,attributes:e.attributes.map(e=>e.name)})):[])},[w]),ie=p.useCallback(async()=>{try{const e=await v(J);if(0===e.length)G(null);else{const t=e.data.map(e=>{const t={};return O.forEach(a=>{t[a]=e.attributes?.[a]??e[a]}),O.includes("id")&&(t.id=e.id),R.forEach(a=>{t[a]=e.attributes?.[a]??e[a]}),V.forEach(a=>{const n=e[a.name]?.data??e[a.name];null===n?t[a.name]=null:Array.isArray(n)?t[a.name]=n.map(e=>Object.values(e.attributes??e).join(" | ")).join(" | "):t[a.name]=Object.values(n.attributes??n).join(" | ")}),t});G(t)}}catch(e){console.error("Error fetching CSV data:",e),G(null)}},[J,O,V,R,v]);return p.useEffect(()=>{L&&H.current&&setTimeout(()=>{H.current?.link?.click(),G(null)})},[L]),p.useEffect(()=>{N(C.default.stringify({fields:O,filters:{[I]:{$between:[f.default(E).format("YYYY-MM-DD"),f.default(A).format("YYYY-MM-DD")]}},populate:V.reduce((e,t)=>(e[t.name]={fields:t.attributes},e),{})},{encodeValuesOnly:!0}))},[O,V,E,A,I]),e.jsx(t,{sx:{width:"100%",p:2},children:e.jsx(x.LocalizationProvider,{dateAdapter:h.AdapterDayjs,children:e.jsxs(r,{container:!0,spacing:2,children:[$&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{item:!0,xs:12,children:[e.jsx(i,{direction:"row",justifyContent:"flex-end",children:e.jsx(s,{"aria-label":"expand row",size:"small",onClick:()=>_(!$),children:$?e.jsx(g,{}):e.jsx(b,{})})}),e.jsx(c,{})]}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h6",children:"Attributes"}),e.jsx(l,{checked:y.length===O.length,indeterminate:y.length!==O.length&&O.length>0,sx:{"& .MuiSvgIcon-root":{fontSize:28}},onChange:te})]})}),y.map(t=>e.jsx(r,{item:!0,xs:4,children:e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:t.name,checked:O.includes(t.name),onChange:Q}),e.jsx(a,{children:t.label})]})},t.name)),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h6",children:"Relations"}),e.jsx(l,{checked:w.length===V.length,indeterminate:w.length!==V.length&&V.length>0,sx:{"& .MuiSvgIcon-root":{fontSize:28}},onChange:ne})]})}),w.map(t=>{const n=B.includes(t.name),u=V.some(e=>e.name===t.name),m=u&&V.some(e=>e.name===t.name&&e.attributes.length!==t.attributes.length);return e.jsxs(r,{item:!0,xs:12,children:[e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:t.name,checked:u,indeterminate:m,onChange:X}),e.jsx(a,{children:t.label}),e.jsx(s,{name:t.name,onClick:()=>ee(t.name),children:n?e.jsx(b,{}):e.jsx(g,{})})]}),e.jsx(c,{}),e.jsx(d,{in:n,children:e.jsx(r,{container:!0,sx:{pl:2},children:t.attributes.map(n=>e.jsx(r,{item:!0,xs:3,children:e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:`${n.name}|${t.name}`,checked:V.some(e=>e.name===t.name&&e.attributes.includes(n.name)),onChange:Z,size:"small"}),e.jsx(a,{variant:"body2",children:n.label})]})},n.name))})})]},t.name)}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h6",children:"Creation, Publication and Update"}),e.jsx(l,{checked:S.length===R.length,indeterminate:S.length!==R.length&&R.length>0,sx:{"& .MuiSvgIcon-root":{fontSize:28}},onChange:ae})]})}),S.map(t=>e.jsx(r,{item:!0,xs:4,children:e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:t.name,checked:R.includes(t.name),onChange:W}),e.jsx(a,{children:t.label})]})},t.name)),e.jsx(r,{item:!0,xs:12,children:e.jsx(a,{variant:"h6",children:"Select date range"})}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",spacing:2,children:[e.jsx(u,{value:I,options:Y,multiple:!1,onChange:(e,t)=>z(t),renderInput:t=>e.jsx(m,{...t,label:"Date Type"}),sx:{width:300},disableClearable:!0}),e.jsx(j.DatePicker,{value:E,label:"start date",onChange:e=>e&&P(e)}),e.jsx(j.DatePicker,{value:A,label:"end date",onChange:e=>e&&M(e)})]})})]}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",spacing:2,sx:{justifyContent:"space-between"},children:[e.jsxs(p.Fragment,{children:[e.jsx(n,{variant:"contained",disabled:0===O.length&&0===V.length,onClick:ie,children:"Export CSV"}),L&&e.jsx(o.reactCsv.CSVLink,{data:L,filename:`${f.default(E).format("DD-MM-YYYY")}_${f.default(A).format("DD-MM-YYYY")}/${I}_${D}-export.csv`,ref:H})]}),e.jsx(s,{"aria-label":"expand row",size:"small",onClick:()=>_(!$),children:$?e.jsx(g,{}):e.jsx(b,{})})]})})]})})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@mui/material/Paper"),a=require("@mui/material/Typography"),n=require("@mui/material/Button"),i=require("@mui/material/Stack"),r=require("@mui/material/Grid"),s=require("@mui/material/IconButton"),l=require("@mui/material/Checkbox"),c=require("@mui/material/Divider"),d=require("@mui/material/Collapse"),u=require("@mui/material/Autocomplete"),m=require("@mui/material/TextField"),o=require("../../../../node_modules/react-csv/index.js"),x=require("@mui/x-date-pickers"),h=require("@mui/x-date-pickers/AdapterDayjs"),j=require("@mui/x-date-pickers/DatePicker"),b=require("@mui/icons-material/KeyboardArrowDown"),g=require("@mui/icons-material/KeyboardArrowUp"),p=require("react"),f=require("../../../../node_modules/dayjs/dayjs.min.js"),C=require("../../../../node_modules/qs/lib/index.js");exports.default=function(k){const{defaultAttributes:y,defaultRelations:w,defaultStrapiAttributes:S,additionalDateTypes:q,fetchCSVData:v,entityCode:D="FU"}=k,Y=[...S.map(e=>e.name),...q],[A,M]=p.useState(f.default(Date.now()).startOf("day")),[I,z]=p.useState("createdAt"),[E,P]=p.useState(f.default(A).subtract(1,"month")),[$,_]=p.useState(!1),[O,T]=p.useState([]),[V,F]=p.useState([]),[R,U]=p.useState([]),[B,K]=p.useState([]),[L,G]=p.useState(null),H=p.useRef(null),[J,N]=p.useState(""),Q=p.useCallback(e=>{const{name:t}=e.target;T(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},[]),W=p.useCallback(e=>{const{name:t}=e.target;U(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},[]),X=p.useCallback(e=>{const{name:t}=e.target;F(e=>e.some(e=>e.name===t)?e.filter(e=>e.name!==t):[...e,{name:t,attributes:w.find(e=>e.name===t)?.attributes.map(e=>e.name)||[]}])},[w]),Z=p.useCallback(e=>{const[t,a]=e.target.name.split("|");F(e=>e.find(e=>e.name===a)?e.map(e=>e.name===a?{...e,attributes:e.attributes.includes(t)?e.attributes.filter(e=>e!==t):[...e.attributes,t]}:e):[...e,{name:a,attributes:[t]}])},[]),ee=p.useCallback(e=>{K(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),te=p.useCallback(e=>{const{checked:t}=e.target;T(t?y.map(e=>e.name):[])},[y]),ae=p.useCallback(e=>{const{checked:t}=e.target;U(t?S.map(e=>e.name):[])},[S]),ne=p.useCallback(e=>{const{checked:t}=e.target;F(t?w.map(e=>({name:e.name,attributes:e.attributes.map(e=>e.name)})):[])},[w]),ie=p.useCallback(async()=>{try{const e=await v(J);if(0===e.length)G(null);else{const t=e.data.map(e=>{const t={};return O.forEach(a=>{t[a]=e.attributes?.[a]??e[a]}),O.includes("id")&&(t.id=e.id),R.forEach(a=>{t[a]=e.attributes?.[a]??e[a]}),V.forEach(a=>{const n=e[a.name]?.data??e[a.name];null===n?t[a.name]=null:Array.isArray(n)?t[a.name]=n.map(e=>Object.values(e.attributes??e).join(" | ")).join(" | "):t[a.name]=Object.values(n.attributes??n).join(" | ")}),t});G(t)}}catch(e){console.error("Error fetching CSV data:",e),G(null)}},[J,O,V,R,v]);return p.useEffect(()=>{L&&H.current&&setTimeout(()=>{H.current?.link?.click(),G(null)})},[L]),p.useEffect(()=>{N(C.default.stringify({fields:[...O,...R],filters:{[I]:{$between:[f.default(E).format("YYYY-MM-DD"),f.default(A).format("YYYY-MM-DD")]}},populate:V.reduce((e,t)=>(e[t.name]={fields:t.attributes},e),{})},{encodeValuesOnly:!0}))},[O,V,E,A,I]),e.jsx(t,{sx:{width:"100%",p:2},children:e.jsx(x.LocalizationProvider,{dateAdapter:h.AdapterDayjs,children:e.jsxs(r,{container:!0,spacing:2,children:[$&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{item:!0,xs:12,children:[e.jsx(i,{direction:"row",justifyContent:"flex-end",children:e.jsx(s,{"aria-label":"expand row",size:"small",onClick:()=>_(!$),children:$?e.jsx(g,{}):e.jsx(b,{})})}),e.jsx(c,{})]}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h6",children:"Attributes"}),e.jsx(l,{checked:y.length===O.length,indeterminate:y.length!==O.length&&O.length>0,sx:{"& .MuiSvgIcon-root":{fontSize:28}},onChange:te})]})}),y.map(t=>e.jsx(r,{item:!0,xs:4,children:e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:t.name,checked:O.includes(t.name),onChange:Q}),e.jsx(a,{children:t.label})]})},t.name)),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h6",children:"Relations"}),e.jsx(l,{checked:w.length===V.length,indeterminate:w.length!==V.length&&V.length>0,sx:{"& .MuiSvgIcon-root":{fontSize:28}},onChange:ne})]})}),w.map(t=>{const n=B.includes(t.name),u=V.some(e=>e.name===t.name),m=u&&V.some(e=>e.name===t.name&&e.attributes.length!==t.attributes.length);return e.jsxs(r,{item:!0,xs:12,children:[e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:t.name,checked:u,indeterminate:m,onChange:X}),e.jsx(a,{children:t.label}),e.jsx(s,{name:t.name,onClick:()=>ee(t.name),children:n?e.jsx(b,{}):e.jsx(g,{})})]}),e.jsx(c,{}),e.jsx(d,{in:n,children:e.jsx(r,{container:!0,sx:{pl:2},children:t.attributes.map(n=>e.jsx(r,{item:!0,xs:3,children:e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:`${n.name}|${t.name}`,checked:V.some(e=>e.name===t.name&&e.attributes.includes(n.name)),onChange:Z,size:"small"}),e.jsx(a,{variant:"body2",children:n.label})]})},n.name))})})]},t.name)}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h6",children:"Creation, Publication and Update"}),e.jsx(l,{checked:S.length===R.length,indeterminate:S.length!==R.length&&R.length>0,sx:{"& .MuiSvgIcon-root":{fontSize:28}},onChange:ae})]})}),S.map(t=>e.jsx(r,{item:!0,xs:4,children:e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:t.name,checked:R.includes(t.name),onChange:W}),e.jsx(a,{children:t.label})]})},t.name)),e.jsx(r,{item:!0,xs:12,children:e.jsx(a,{variant:"h6",children:"Select date range"})}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",spacing:2,children:[e.jsx(u,{value:I,options:Y,multiple:!1,onChange:(e,t)=>z(t),renderInput:t=>e.jsx(m,{...t,label:"Date Type"}),sx:{width:300},disableClearable:!0}),e.jsx(j.DatePicker,{value:E,label:"start date",onChange:e=>e&&P(e)}),e.jsx(j.DatePicker,{value:A,label:"end date",onChange:e=>e&&M(e)})]})})]}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(i,{direction:"row",spacing:2,sx:{justifyContent:"space-between"},children:[e.jsxs(p.Fragment,{children:[e.jsx(n,{variant:"contained",disabled:0===O.length&&0===V.length,onClick:ie,children:"Export CSV"}),L&&e.jsx(o.reactCsv.CSVLink,{data:L,filename:`${f.default(E).format("DD-MM-YYYY")}_${f.default(A).format("DD-MM-YYYY")}/${I}_${D}-export.csv`,ref:H})]}),e.jsx(s,{"aria-label":"expand row",size:"small",onClick:()=>_(!$),children:$?e.jsx(g,{}):e.jsx(b,{})})]})})]})})})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Table"),s=require("@mui/material/TableBody"),t=require("@mui/material/TableRow"),l=require("@mui/material/TableCell"),a=require("@mui/material/TableFooter"),o=require("@mui/material/Typography"),n=require("@mui/material/useMediaQuery"),x=require("@mui/material/CircularProgress"),u=require("@mui/material/styles"),c=require("./CartSummaryRow.js"),d=require("./hooks.js");exports.default=()=>{const{state:m,isClient:h}=d.useClientSideCart(),j=u.useTheme(),T=n(j.breakpoints.down("sm"));return h?e.jsx(r,{sx:{p:{xs:1,md:2}},children:m.items.length>0?e.jsxs(i,{children:[e.jsx(s,{children:m.items.map(r=>e.jsx(c.default,{data:r},r.id))}),e.jsx(a,{children:e.jsxs(t,{children:[!T&&e.jsx(l,{sx:{p:{xs:1,sm:2}}}),e.jsx(l,{sx:{p:{xs:1,sm:2}},colSpan:T?2:1}),T?e.jsx(e.Fragment,{children:e.jsxs(l,{colSpan:2,align:"right",sx:{color:"#555",padding:1},children:[e.jsx(o,{sx:{fontSize:14},children:"Total "}),e.jsxs(o,{sx:{fontSize:14},children:["excl VAT: € ",m.totalExVAT.toFixed(2)]}),e.jsxs(o,{sx:{fontSize:14},children:["incl VAT: € ",m.totalInclVAT.toFixed(2)]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs(l,{colSpan:1,align:"right",sx:{color:"#555"},children:["Total excl VAT: € ",m.totalExVAT.toFixed(2)]}),e.jsxs(l,{colSpan:2,align:"right",sx:{color:"#555",fontSize:16,fontWeight:600},children:["Total: € ",m.totalInclVAT.toFixed(2)]})]})]})})]}):e.jsx(o,{variant:"body1",children:"No products in cart"})}):e.jsx(x,{})};
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Table"),t=require("@mui/material/TableBody"),s=require("@mui/material/TableRow"),l=require("@mui/material/TableCell"),a=require("@mui/material/TableFooter"),o=require("@mui/material/Typography"),n=require("@mui/material/useMediaQuery"),x=require("@mui/material/CircularProgress"),u=require("@mui/material/styles"),c=require("./CartSummaryRow.js"),d=require("./hooks.js");exports.default=()=>{const{state:m,isClient:h}=d.useClientSideCart(),j=u.useTheme(),T=n(j.breakpoints.down("sm"));return h?e.jsx(r,{sx:{p:{xs:1,md:2}},children:m.items.length>0?e.jsxs(i,{children:[e.jsx(t,{children:m.items.map(r=>e.jsx(c.default,{data:r},r.documentId))}),e.jsx(a,{children:e.jsxs(s,{children:[!T&&e.jsx(l,{sx:{p:{xs:1,sm:2}}}),e.jsx(l,{sx:{p:{xs:1,sm:2}},colSpan:T?2:1}),T?e.jsx(e.Fragment,{children:e.jsxs(l,{colSpan:2,align:"right",sx:{color:"#555",padding:1},children:[e.jsx(o,{sx:{fontSize:14},children:"Total "}),e.jsxs(o,{sx:{fontSize:14},children:["excl VAT: € ",m.totalExVAT.toFixed(2)]}),e.jsxs(o,{sx:{fontSize:14},children:["incl VAT: € ",m.totalInclVAT.toFixed(2)]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs(l,{colSpan:1,align:"right",sx:{color:"#555"},children:["Total excl VAT: € ",m.totalExVAT.toFixed(2)]}),e.jsxs(l,{colSpan:2,align:"right",sx:{color:"#555",fontSize:16,fontWeight:600},children:["Total: € ",m.totalInclVAT.toFixed(2)]})]})]})})]}):e.jsx(o,{variant:"body1",children:"No products in cart"})}):e.jsx(x,{})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/material/TableRow"),r=require("@mui/material/TableCell"),t=require("@mui/material/IconButton"),s=require("@mui/material/useMediaQuery"),a=require("@mui/material/styles"),l=require("next/image"),u=require("@mui/icons-material/Delete"),c=require("../products/Price.js"),x=require("../../../context/e-commerce/cart/CartContext.js");exports.default=function({data:n}){const{id:d,thumb:m,title:o,vat_rate:p,price_excl_vat:j,price_incl_vat:h,quantity:v}=n,q=a.useTheme(),_=s(q.breakpoints.down("sm")),{dispatch:b}=x.useCart();return e.jsxs(i,{children:[e.jsxs(r,{sx:{p:{xs:1,sm:2}},children:[v," * "]}),e.jsx(r,{sx:{p:{xs:1,sm:2}},children:e.jsx(c.default,{id:d,price:j,vat_rate:p,vat:j*(p/100),price_incl_vat:h})}),e.jsx(r,{sx:{p:{xs:1,sm:2}},children:o}),!_&&e.jsx(r,{sx:{p:{xs:1,sm:2}},children:e.jsx("div",{style:{position:"relative",width:"40px",height:"40px"},children:null!==m&&e.jsx(l,{src:m,alt:"Thumbnail of product",fill:!0,sizes:"5vw",style:{objectFit:"cover"}})})}),e.jsx(r,{sx:{p:0},children:e.jsx(t,{"aria-label":"delete",onClick:()=>{b({type:"REMOVE_ITEM",payload:{id:d}})},sx:{p:0},children:e.jsx(u,{})})})]},d)};
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/TableRow"),t=require("@mui/material/TableCell"),i=require("@mui/material/IconButton"),s=require("@mui/material/useMediaQuery"),a=require("@mui/material/styles"),l=require("next/image"),u=require("@mui/icons-material/Delete"),c=require("../products/Price.js"),n=require("../../../context/e-commerce/cart/CartContext.js");exports.default=function({data:x}){const{documentId:d,thumb:m,title:o,vat_rate:p,price_excl_vat:j,price_incl_vat:h,quantity:v}=x,q=a.useTheme(),_=s(q.breakpoints.down("sm")),{dispatch:b}=n.useCart();return e.jsxs(r,{children:[e.jsxs(t,{sx:{p:{xs:1,sm:2}},children:[v," * "]}),e.jsx(t,{sx:{p:{xs:1,sm:2}},children:e.jsx(c.default,{documentId:d,price:j,vat_rate:p,vat:j*(p/100),price_incl_vat:h})}),e.jsx(t,{sx:{p:{xs:1,sm:2}},children:o}),!_&&e.jsx(t,{sx:{p:{xs:1,sm:2}},children:e.jsx("div",{style:{position:"relative",width:"40px",height:"40px"},children:null!==m&&e.jsx(l,{src:m,alt:"Thumbnail of product",fill:!0,sizes:"5vw",style:{objectFit:"cover"}})})}),e.jsx(t,{sx:{p:0},children:e.jsx(i,{"aria-label":"delete",onClick:()=>{b({type:"REMOVE_ITEM",payload:{documentId:d}})},sx:{p:0},children:e.jsx(u,{})})})]},d)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Autocomplete"),i=require("@mui/material/TextField");exports.default=({categories:a,currentValue:u})=>{const[l,n]=t.useState(u||[]);return e.jsxs(e.Fragment,{children:[e.jsx(r,{multiple:!0,options:a,getOptionLabel:e=>e.title,filterSelectedOptions:!0,onChange:(e,t)=>{t.map(e=>e.id),n(t.map(e=>e.id))},renderInput:t=>e.jsx(i,{...t,label:"Category"}),value:a.filter(e=>l.includes(e.id))}),e.jsx("input",{type:"hidden",name:"categories",value:JSON.stringify(l)||""})]})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Autocomplete"),i=require("@mui/material/TextField");exports.default=({categories:u,currentValue:a})=>{console.log("CategorySelector props",{categories:u,currentValue:a});const[l,o]=t.useState(a||[]);return e.jsxs(e.Fragment,{children:[e.jsx(r,{multiple:!0,options:u,getOptionLabel:e=>e.title,filterSelectedOptions:!0,onChange:(e,t)=>{t.map(e=>e.documentId),o(t.map(e=>e.documentId))},renderInput:t=>e.jsx(i,{...t,label:"Category"}),value:u.filter(e=>l.includes(e.documentId))}),e.jsx("input",{type:"hidden",name:"categories",value:JSON.stringify(l)||""})]})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),t=require("@mui/material/Stack"),i=require("@mui/material/TextField"),a=require("@mui/material/Typography"),s=require("../../SubmitButton.js"),n=require("react-dom"),o=require("../../../data/actions/e-commerce/categories/updateCategoryAction.js"),c=require("@mui/material/Grid"),d=require("../products/ProductSelector.js"),u=require("../../common/markdown/MarkdownEditor.js"),l=require("react"),m=require("../../../context/common/SnackbarContext.js"),x=require("@mui/material");const p={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.EditCategoryForm=function({data:g,revalidateCallback:j,handleClose:h,productNamesArray:y,sx:v}){const{id:q,title:f,description:E,slug:C,is_archive:b,products:k}=g,S=k?.data||[],[A,w]=n.useFormState(o.updateCategoryAction,p),{handleAddMessage:B}=m.useSnackbar();return l.useEffect(()=>{A?.message&&(B({message:A.message,severity:A.severity||"error"}),"success"===A.severity&&(j&&j(),h&&h()))},[A?.message]),l.useEffect(()=>{A?.strapiErrors&&B({message:A.strapiErrors.message||"Error updating category",severity:A.severity||"error"})},[A?.strapiErrors]),e.jsx(r,{sx:[...Array.isArray(v)?v:[v]],children:e.jsxs("form",{action:w,children:[q&&e.jsx("input",{id:"id",type:"hidden",name:"id",value:q}),e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{item:!0,xs:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(a,{variant:"h3",component:"h1",children:"Edit Category"}),e.jsx(a,{variant:"body2",children:"Edit the category for your products. You can add products to this category later."})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{id:"title",name:"title",label:"Title",defaultValue:f}),e.jsx(u.default,{name:"description",label:"Description",defaultValue:E})]})}),e.jsxs(c,{item:!0,xs:12,children:[e.jsx(a,{variant:"h6",children:"Products"}),e.jsx(d.default,{productNames:y,currentValue:[...S.map(e=>e.id)]})]}),e.jsxs(c,{item:!0,xs:12,children:[" ",e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(x.Button,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(s.SubmitButton,{text:"Update category",loadingText:"Loading...",variant:"contained"})]})]})]})]})})};
7
+ "use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),t=require("@mui/material/Stack"),a=require("@mui/material/TextField"),i=require("@mui/material/Typography"),s=require("../../SubmitButton.js"),n=require("react-dom"),o=require("../../../data/actions/e-commerce/categories/updateCategoryAction.js"),c=require("@mui/material/Grid"),u=require("../products/ProductSelector.js"),d=require("../../common/markdown/MarkdownEditor.js"),l=require("react"),m=require("../../../context/common/SnackbarContext.js"),x=require("@mui/material");const p={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.EditCategoryForm=function({data:g,revalidateCallback:j,handleClose:h,productNamesArray:y,sx:q}){const{documentId:v,title:f,description:E,slug:b,is_archive:C,products:k}=g,S=k?.data||[],[A,w]=n.useFormState(o.updateCategoryAction.bind(null,v),p),{handleAddMessage:B}=m.useSnackbar();return l.useEffect(()=>{A?.message&&(B({message:A.message,severity:A.severity||"error"}),"success"===A.severity&&(j&&j(),h&&h()))},[A?.message]),l.useEffect(()=>{A?.strapiErrors&&B({message:A.strapiErrors.message||"Error updating category",severity:A.severity||"error"})},[A?.strapiErrors]),e.jsx(r,{sx:[...Array.isArray(q)?q:[q]],children:e.jsx("form",{action:w,children:e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{item:!0,xs:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"h3",component:"h1",children:"Edit Category"}),e.jsx(i,{variant:"body2",children:"Edit the category for your products. You can add products to this category later."})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(a,{id:"title",name:"title",label:"Title",defaultValue:f}),e.jsx(d.default,{name:"description",label:"Description",defaultValue:E})]})}),e.jsxs(c,{item:!0,xs:12,children:[e.jsx(i,{variant:"h6",children:"Products"}),e.jsx(u.default,{productNames:y,currentValue:[...S.map(e=>e.documentId)]})]}),e.jsxs(c,{item:!0,xs:12,children:[" ",e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(x.Button,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(s.SubmitButton,{text:"Update category",loadingText:"Loading...",variant:"contained"})]})]})]})})})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Paper"),a=require("@mui/material/Stack"),i=require("@mui/material/Alert"),s=require("@mui/material/Button"),o=require("@mui/material/Typography"),n=require("../cart/hooks.js"),u=require("../cart/CartSummary.js"),c=require("react-dom"),l=require("../../../data/actions/e-commerce/checkout-action.js"),m=require("../../StrapiErrors.js");exports.default=function({customer_reference:d}){const{state:p,isClient:y}=n.useClientSideCart(),[h,j]=c.useFormState(l.checkoutAction,{zodErrors:null,strapiErrors:null,data:null,message:null});return e.jsx(t,{sx:{p:2},children:e.jsxs(a,{spacing:2,children:[e.jsx(u.default,{}),e.jsx(m.StrapiErrors,{error:h?.strapiErrors}),h?.message&&e.jsx(i,{severity:"error",children:h?.message}),e.jsxs(o,{children:["Please double check all details prior to payment. ",d]}),e.jsx(o,{children:"Is this order compleet?"}),e.jsxs("form",{id:"paymentform",action:j,children:[p.items&&p.items.map((t,a)=>e.jsxs(r.Fragment,{children:[e.jsx("input",{type:"hidden",name:`opo_items[${a}].product`,value:t.id}),e.jsx("input",{type:"hidden",name:`opo_items[${a}].ordered_quantity`,value:t.quantity})]},a)),e.jsx("input",{type:"hidden",name:"customer_reference",value:d}),e.jsx(o,{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."}),e.jsx(s,{variant:"contained",form:"paymentform",type:"submit",children:"Proceed to payment"})]})]})})};
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Paper"),a=require("@mui/material/Stack"),i=require("@mui/material/Alert"),s=require("@mui/material/Button"),o=require("@mui/material/Typography"),n=require("../cart/hooks.js"),u=require("../cart/CartSummary.js"),c=require("react-dom"),l=require("../../../data/actions/e-commerce/checkout-action.js"),m=require("../../StrapiErrors.js");exports.default=function({customer_reference:d}){const{state:p,isClient:y}=n.useClientSideCart(),[h,j]=c.useFormState(l.checkoutAction,{zodErrors:null,strapiErrors:null,data:null,message:null});return e.jsx(t,{sx:{p:2},children:e.jsxs(a,{spacing:2,children:[e.jsx(u.default,{}),e.jsx(m.StrapiErrors,{error:h?.strapiErrors}),h?.message&&e.jsx(i,{severity:"error",children:h?.message}),e.jsxs(o,{children:["Please double check all details prior to payment. ",d]}),e.jsx(o,{children:"Is this order compleet?"}),e.jsxs("form",{id:"paymentform",action:j,children:[p.items&&p.items.map((t,a)=>e.jsxs(r.Fragment,{children:[e.jsx("input",{type:"hidden",name:`opo_items[${a}].product`,value:t.documentId}),e.jsx("input",{type:"hidden",name:`opo_items[${a}].ordered_quantity`,value:t.quantity})]},a)),e.jsx("input",{type:"hidden",name:"customer_reference",value:d}),e.jsx(o,{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."}),e.jsx(s,{variant:"contained",form:"paymentform",type:"submit",children:"Proceed to payment"})]})]})})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Paper"),i=require("@mui/material/Stack"),s=require("@mui/material/Box"),n=require("@mui/material/Typography"),a=require("@mui/material/Button"),t=require("@mui/material/Grid"),l=require("@mui/material/Table"),d=require("@mui/material/TableBody"),c=require("@mui/material/TableCell"),h=require("@mui/material/TableHead"),o=require("@mui/material/TableRow"),x=require("@mui/material/Divider"),j=require("@mui/icons-material/Person"),u=require("@mui/icons-material/Email"),m=require("@mui/icons-material/Phone"),p=require("../../common/Address.js"),g=require("./BusinessCredentials.js"),f=require("../../StyledLink.js"),v=require("@mui/material"),b=require("next/navigation");exports.default=function({data:y}){const{first_name:_,last_name:q,email:w,phone:A,company_address:S,billing_address:B,delivery_address:C,business_credentials:D,editProfileUrl:L="/user/profile/edit",completeEnough:T=!1,orders:k,returns:P}=y;if(!y)return e.jsx(i,{spacing:2,children:e.jsx(n,{children:"Customer profile not available"})});const N=b.usePathname().includes("/user/");return e.jsxs(t,{container:!0,sx:{width:"100%"},spacing:2,children:[e.jsx(t,{item:!0,xs:12,children:e.jsxs(i,{spacing:2,children:[e.jsxs(i,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(i,{spacing:2,sx:{width:"100%"},children:[e.jsx(n,{variant:"h3",component:"h1",children:N?"Your Profile":"Customer Profile"}),!N&&y.customer_number&&e.jsxs(n,{variant:"body1",children:["Customer Number: ",e.jsx("strong",{children:y.customer_number})]})]}),N&&e.jsx(e.Fragment,{children:Boolean(T)?e.jsx(i,{direction:"row",justifyContent:"flex-end",children:e.jsx(f.StyledLink,{href:L,target:"_self",children:e.jsx(a,{variant:"contained",children:"edit profile"})})}):e.jsx(v.Alert,{severity:"warning",action:e.jsx(f.StyledLink,{href:L,target:"_self",children:e.jsx(a,{variant:"contained",children:"complete profile"})}),children:"After completion of your profile you can enjoy all the benefits of your services."})})]}),e.jsx(x,{})]})}),e.jsxs(t,{item:!0,xs:12,children:[D?e.jsx(g.default,{data:D}):e.jsx(n,{children:"Business credentials not available"}),e.jsx(x,{sx:{pt:2}})]}),e.jsxs(t,{item:!0,xs:12,children:[e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(j,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[_," ",q," ",!_&&!q&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(u,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[w," ",!w&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(m,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[A," ",!A&&"N/A"]})})]}),e.jsx(x,{sx:{pt:2}})]}),S?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Company Address"}),e.jsx(p.default,{data:{...S}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Company address not available"})}),C?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Delivery Address"}),e.jsx(p.default,{data:{...C}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Delivery address not available"})}),B?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Billing Address"}),e.jsx(p.default,{data:{...B}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Billing address not available"})}),e.jsxs(t,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Orders"}),e.jsx(r,{children:k&&k.data&&k.data.length>0?e.jsxs(l,{children:[e.jsx(h,{children:e.jsxs(o,{children:[e.jsx(c,{children:"Order Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Total"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(d,{children:k.data.map((r,i)=>e.jsxs(o,{children:[e.jsx(c,{children:r.opo_number}),e.jsx(c,{children:new Date(r.order_date).toLocaleDateString()}),e.jsx(c,{children:r.internal_status}),e.jsxs(c,{align:"right",children:[r.total_incl_vat," ",r.order_currency]}),e.jsx(c,{align:"right",children:N?e.jsx(f.StyledLink,{href:`/user/orders?selectedOpoId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/opos?selectedOpoId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:N?e.jsx(n,{children:"You have no orders."}):e.jsx(n,{children:"This user has no orders."})})})]}),e.jsxs(t,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Returns"}),e.jsx(r,{children:P&&P.data&&P.data.length>0?e.jsxs(l,{children:[e.jsx(h,{children:e.jsxs(o,{children:[e.jsx(c,{children:"Return Number"}),e.jsx(c,{children:"RMA Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(d,{children:P.data.map((r,i)=>e.jsxs(o,{children:[e.jsx(c,{children:r.return_number}),e.jsx(c,{children:r.rma_number}),e.jsx(c,{children:new Date(r.return_date).toLocaleDateString()}),e.jsx(c,{children:r.internal_status}),e.jsx(c,{align:"right",children:N?e.jsx(f.StyledLink,{href:`/user/returns?selectedIroId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/iros?selectedIroId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:N?e.jsx(n,{children:"You have no returns."}):e.jsx(n,{children:"This user has no returns."})})})]})]})};
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Paper"),i=require("@mui/material/Stack"),s=require("@mui/material/Box"),n=require("@mui/material/Typography"),t=require("@mui/material/Button"),l=require("@mui/material/Grid"),d=require("@mui/material/Table"),a=require("@mui/material/TableBody"),c=require("@mui/material/TableCell"),o=require("@mui/material/TableHead"),h=require("@mui/material/TableRow"),x=require("@mui/material/Divider"),j=require("@mui/icons-material/Person"),u=require("@mui/icons-material/Email"),m=require("@mui/icons-material/Phone"),p=require("../../common/Address.js"),g=require("./BusinessCredentials.js"),f=require("../../StyledLink.js"),v=require("@mui/material"),b=require("next/navigation");exports.default=function({data:y}){const{first_name:_,last_name:q,email:w,phone:A,company_address:S,billing_address:B,delivery_address:I,business_credentials:C,editProfileUrl:D="/user/profile/edit",completeEnough:L=!1,orders:T,returns:k}=y;if(!y)return e.jsx(i,{spacing:2,children:e.jsx(n,{children:"Customer profile not available"})});const P=b.usePathname().includes("/user/");return e.jsxs(l,{container:!0,sx:{width:"100%"},spacing:2,children:[e.jsx(l,{item:!0,xs:12,children:e.jsxs(i,{spacing:2,children:[e.jsxs(i,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(i,{spacing:2,sx:{width:"100%"},children:[e.jsx(n,{variant:"h3",component:"h1",children:P?"Your Profile":"Customer Profile"}),!P&&y.customer_number&&e.jsxs(n,{variant:"body1",children:["Customer Number: ",e.jsx("strong",{children:y.customer_number})]})]}),P&&e.jsx(e.Fragment,{children:Boolean(L)?e.jsx(i,{direction:"row",justifyContent:"flex-end",children:e.jsx(f.StyledLink,{href:D,target:"_self",children:e.jsx(t,{variant:"contained",children:"edit profile"})})}):e.jsx(v.Alert,{severity:"warning",action:e.jsx(f.StyledLink,{href:D,target:"_self",children:e.jsx(t,{variant:"contained",children:"complete profile"})}),children:"After completion of your profile you can enjoy all the benefits of your services."})})]}),e.jsx(x,{})]})}),e.jsxs(l,{item:!0,xs:12,children:[C?e.jsx(g.default,{data:C}):e.jsx(n,{children:"Business credentials not available"}),e.jsx(x,{sx:{pt:2}})]}),e.jsxs(l,{item:!0,xs:12,children:[e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(j,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[_," ",q," ",!_&&!q&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(u,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[w," ",!w&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(m,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[A," ",!A&&"N/A"]})})]}),e.jsx(x,{sx:{pt:2}})]}),S?e.jsxs(l,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Company Address"}),e.jsx(p.default,{data:{...S}})]}):e.jsx(l,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Company address not available"})}),I?e.jsxs(l,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Delivery Address"}),e.jsx(p.default,{data:{...I}})]}):e.jsx(l,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Delivery address not available"})}),B?e.jsxs(l,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Billing Address"}),e.jsx(p.default,{data:{...B}})]}):e.jsx(l,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Billing address not available"})}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Orders"}),e.jsx(r,{children:T&&T.length>0?e.jsxs(d,{children:[e.jsx(o,{children:e.jsxs(h,{children:[e.jsx(c,{children:"Order Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Total"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(a,{children:T.map((r,i)=>e.jsxs(h,{children:[e.jsx(c,{children:r.opo_number}),e.jsx(c,{children:new Date(r.order_date).toLocaleDateString()}),e.jsx(c,{children:r.internal_status}),e.jsxs(c,{align:"right",children:[r.total_incl_vat," ",r.order_currency]}),e.jsx(c,{align:"right",children:P?e.jsx(f.StyledLink,{href:`/user/orders?selectedOpoId=${r.documentId}`,target:"_self",children:e.jsx(t,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/opos?selectedOpoId=${r.documentId}`,target:"_self",children:e.jsx(t,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:P?e.jsx(n,{children:"You have no orders."}):e.jsx(n,{children:"This user has no orders."})})})]}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Returns"}),e.jsx(r,{children:k&&k.length>0?e.jsxs(d,{children:[e.jsx(o,{children:e.jsxs(h,{children:[e.jsx(c,{children:"Return Number"}),e.jsx(c,{children:"RMA Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(a,{children:k.map((r,i)=>e.jsxs(h,{children:[e.jsx(c,{children:r.return_number}),e.jsx(c,{children:r.rma_number}),e.jsx(c,{children:new Date(r.return_date).toLocaleDateString()}),e.jsx(c,{children:r.internal_status}),e.jsx(c,{align:"right",children:P?e.jsx(f.StyledLink,{href:`/user/returns?selectedIroId=${r.documentId}`,target:"_self",children:e.jsx(t,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/iros?selectedIroId=${r.documentId}`,target:"_self",children:e.jsx(t,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:P?e.jsx(n,{children:"You have no returns."}):e.jsx(n,{children:"This user has no returns."})})})]})]})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Table"),i=require("@mui/material/TableHead"),a=require("@mui/material/TableBody"),n=require("@mui/material/TableCell"),s=require("@mui/material/TableRow"),u=require("@mui/material/IconButton"),l=require("@mui/icons-material/Add"),d=require("@mui/material/Typography"),o=require("@mui/material/Stack"),c=require("@mui/material/TextField"),m=require("../products/ProductSelector.js");require("../../../../node_modules/dayjs/dayjs.min.js");var h=require("@mui/icons-material/Delete"),x=require("@mui/material/styles");exports.IROItemFields=function({productsArr:j}){const[p,g]=t.useState([]),[v,q]=t.useState(null),[b,_]=t.useState(0),[w,y]=t.useState("damaged"),[f,S]=t.useState(""),[C,T]=t.useState([]),[I,N]=t.useState(!1);x.useTheme();const[A,k]=t.useState([]);return t.useEffect(()=>{k((e=>e.map((e,t)=>({line_item_number:`${t+1}.0.0`,product:e.product?.id||0,returned_quantity:e.returned_quantity,reason:w,other_reason:f})))(p))},[p]),e.jsxs(o,{spacing:2,children:[e.jsxs(r,{children:[e.jsx(i,{children:e.jsxs(s,{children:[e.jsx(n,{id:"line_item_number",sx:[{width:"15%"}],children:"Line Item Number"}),e.jsx(n,{sx:[{width:"35%"}],children:"Product Number"}),e.jsx(n,{sx:[{width:"15%"}],children:"Amount"}),e.jsx(n,{sx:[{width:"35%"}],children:"Reason"}),e.jsx(n,{sx:[]})]})}),e.jsx(a,{children:p.map((t,r)=>e.jsxs(s,{children:[e.jsxs(n,{sx:[{width:"15%"}],children:[r+1,".0.0"]}),e.jsxs(n,{sx:[{width:"35%"}],children:["object"==typeof t.product?t.product?.product_number:t.product," ","|"," ","object"==typeof t.product?t.product?.title:""]}),e.jsx(n,{sx:{width:"15%"},children:t.returned_quantity}),e.jsx(n,{sx:{width:"35%"},children:"other"===t.reason?t.other_reason:t.reason}),e.jsx(n,{align:"right",sx:{width:"5%"},children:e.jsx(u,{onClick:()=>(e=>{const t=p.filter((t,r)=>r!==e);g(t)})(r),children:e.jsx(h,{})})})]},r))})]}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(A)}),e.jsxs(o,{direction:"row",spacing:1,alignItems:"center",sx:{p:2,width:"100%"},children:[e.jsxs(d,{variant:"body1",sx:{width:"15%"},children:[p.length+1,".0.0"]}),j&&e.jsx(m.default,{productNames:j,currentValue:C,sx:{width:"70%"},multiple:!1,onChangeCallback:e=>{const t=j.find(t=>t.id===e[0]);q(t||null),T(e)}}),e.jsx(c,{id:"amount",name:"amount",type:"number",label:"Amount",value:b,onChange:e=>{""!==e.target.value?parseInt(e.target.value)<0?_(0):_(parseInt(e.target.value)):_(0)},sx:{width:"15%"}}),e.jsxs(c,{value:w,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!("other"===w),sx:{minWidth:"25%"},onChange:e=>{const t=e.target.value;N("other"===t),y(e.target.value)},children:[e.jsx("option",{value:"damaged",children:"Damaged"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]}),I&&e.jsx(c,{value:f,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const t=e.target.value;S(t)}}),e.jsx(u,{onClick:()=>{if(null===b)return void console.log("nextProductName or nextAmount is null");const e={product:v,returned_quantity:b,reason:w,other_reason:f};g([...p,e]),q(null),_(0),y("damaged"),S(""),T([])},children:e.jsx(l,{})})]})]})};
6
+ "use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Table"),i=require("@mui/material/TableHead"),n=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),s=require("@mui/material/TableRow"),u=require("@mui/material/IconButton"),l=require("@mui/icons-material/Add"),d=require("@mui/material/Typography"),o=require("@mui/material/Stack"),c=require("@mui/material/TextField"),m=require("../products/ProductSelector.js");require("../../../../node_modules/dayjs/dayjs.min.js");var h=require("@mui/icons-material/Delete"),x=require("@mui/material/styles");exports.IROItemFields=function({productsArr:j}){const[p,g]=t.useState([]),[v,q]=t.useState(null),[b,_]=t.useState(0),[w,y]=t.useState("damaged"),[f,S]=t.useState(""),[C,I]=t.useState([]),[T,N]=t.useState(!1);x.useTheme();const[A,k]=t.useState([]);return t.useEffect(()=>{k((e=>e.map((e,t)=>({line_item_number:`${t+1}.0.0`,product:e.product?.documentId||"",returned_quantity:e.returned_quantity,reason:w,other_reason:f})))(p))},[p]),e.jsxs(o,{spacing:2,children:[e.jsxs(r,{children:[e.jsx(i,{children:e.jsxs(s,{children:[e.jsx(a,{id:"line_item_number",sx:[{width:"15%"}],children:"Line Item Number"}),e.jsx(a,{sx:[{width:"35%"}],children:"Product Number"}),e.jsx(a,{sx:[{width:"15%"}],children:"Amount"}),e.jsx(a,{sx:[{width:"35%"}],children:"Reason"}),e.jsx(a,{sx:[]})]})}),e.jsx(n,{children:p.map((t,r)=>e.jsxs(s,{children:[e.jsxs(a,{sx:[{width:"15%"}],children:[r+1,".0.0"]}),e.jsxs(a,{sx:[{width:"35%"}],children:["object"==typeof t.product?t.product?.product_number:t.product," ","|"," ","object"==typeof t.product?t.product?.title:""]}),e.jsx(a,{sx:{width:"15%"},children:t.returned_quantity}),e.jsx(a,{sx:{width:"35%"},children:"other"===t.reason?t.other_reason:t.reason}),e.jsx(a,{align:"right",sx:{width:"5%"},children:e.jsx(u,{onClick:()=>(e=>{const t=p.filter((t,r)=>r!==e);g(t)})(r),children:e.jsx(h,{})})})]},r))})]}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(A)}),e.jsxs(o,{direction:"row",spacing:1,alignItems:"center",sx:{p:2,width:"100%"},children:[e.jsxs(d,{variant:"body1",sx:{width:"15%"},children:[p.length+1,".0.0"]}),j&&e.jsx(m.default,{productNames:j,currentValue:C,sx:{width:"70%"},multiple:!1,onChangeCallback:e=>{const t=j.find(t=>t.documentId===e[0]);q(t||null),I(e)}}),e.jsx(c,{id:"amount",name:"amount",type:"number",label:"Amount",value:b,onChange:e=>{""!==e.target.value?parseInt(e.target.value)<0?_(0):_(parseInt(e.target.value)):_(0)},sx:{width:"15%"}}),e.jsxs(c,{value:w,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!("other"===w),sx:{minWidth:"25%"},onChange:e=>{const t=e.target.value;N("other"===t),y(e.target.value)},children:[e.jsx("option",{value:"damaged",children:"Damaged"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]}),T&&e.jsx(c,{value:f,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const t=e.target.value;S(t)}}),e.jsx(u,{onClick:()=>{if(null===b)return void console.log("nextProductName or nextAmount is null");const e={product:v,returned_quantity:b,reason:w,other_reason:f};g([...p,e]),q(null),_(0),y("damaged"),S(""),I([])},children:e.jsx(l,{})})]})]})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),l=require("../../common/AmountUpdater.js"),s=require("@mui/icons-material/ArrowDropDown"),d=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportMakingComponent.js"),c=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:q,registered_quantity:v,released_quantity:b,returned_quantity:f,reports:_,reason:V,other_reason:w}=m,C=void 0!==_&&_.length>0?_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,N=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[k,R]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g&&g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(d.default,{image:j,label:g&&g.title})})]}),e.jsx(i,{variant:"body1",children:"Reason"}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.AmountUpdater,{currentValue:q,totalValue:f+C,minNewValue:0+v+-N,maxNewValue:f+C,color:"info",handleChange:e=>{x(e,m.id,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.AmountUpdater,{currentValue:v,totalValue:f+C,minNewValue:0+b,maxNewValue:q+N,color:"info",handleChange:e=>{x(e,m.id,"registered_quantity")},offsetEnd:N}),e.jsx(n,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>R(!k),children:e.jsx(s,{})})]})}),e.jsx(o,{in:k,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:_}),e.jsx(u.default,{content:"content",quantity:0,type:"registered",minValue:-(q+N),maxValue:q,related:[{id:m.id,__type:"api::e-commerce.iro-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.AmountUpdater,{currentValue:b||0,totalValue:f+C+N,minNewValue:0,maxNewValue:v,color:"info",handleChange:e=>{x(e,m.id,"released_quantity")}})]})},p)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),l=require("../../common/AmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),u=require("../../common/ImagePreviewTooltip.js"),s=require("../../logistics/report/ReportMakingComponent.js"),c=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:q,registered_quantity:v,released_quantity:b,returned_quantity:f,reports:_,reason:V,other_reason:w}=m,C=void 0!==_&&_.length>0?_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,I=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[N,k]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g&&g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(u.default,{image:j,label:g&&g.title})})]}),e.jsx(i,{variant:"body1",children:"Reason"}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.AmountUpdater,{currentValue:q,totalValue:f+C,minNewValue:0+v+-I,maxNewValue:f+C,color:"info",handleChange:e=>{x(e,m.documentId,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.AmountUpdater,{currentValue:v,totalValue:f+C,minNewValue:0+b,maxNewValue:q+I,color:"info",handleChange:e=>{x(e,m.documentId,"registered_quantity")},offsetEnd:I}),e.jsx(n,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>k(!N),children:e.jsx(d,{})})]})}),e.jsx(o,{in:N,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:_}),e.jsx(s.default,{content:"content",quantity:0,type:"registered",minValue:-(q+I),maxValue:q,related:[{documentId:m.documentId,__type:"api::e-commerce.iro-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.AmountUpdater,{currentValue:b||0,totalValue:f+C+I,minNewValue:0,maxNewValue:v,color:"info",handleChange:e=>{x(e,m.documentId,"released_quantity")}})]})},p)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),n=require("../../StrapiErrors.js"),d=require("../../SubmitButton.js"),o=require("@mui/material/Alert");require("@mui/material/Dialog"),require("@mui/material/DialogActions"),require("@mui/material/DialogContent"),require("@mui/material/DialogTitle");var c=require("@mui/material/Typography");require("@mui/material/Button");var l=require("@mui/material/Grid"),u=require("@mui/material/Box"),x=require("@mui/material/Paper"),m=require("@mui/material/Stack"),h=require("@mui/material/Divider");require("next/headers");const j={zodErrors:null,strapiErrors:null,data:null,message:null};exports.default=function({data:p,sx:g,revalidateCallback:q,handleClose:v,role:y}){const[b,_]=i.useFormState((e,r)=>t.updateIroAction(p.documentId,e,r),j),[w,f]=r.useState(p.iro_items?p.iro_items:[]),[S,D]=r.useState(!1);return e.jsx(u,{sx:[...Array.isArray(g)?g:[g]],children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsxs(m,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(m,{spacing:2,children:[e.jsx(c,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(c,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(a.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:q})]}),e.jsx(h,{})]})}),e.jsx(l,{item:!0,xs:6,children:e.jsxs(m,{spacing:1,children:[e.jsx(c,{variant:"h5",children:"Details"}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(c,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(c,{variant:"body2",children:p.return_number})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(c,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(c,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(c,{variant:"body2",children:p.return_date})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(c,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(c,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(c,{variant:"body2",width:"250px",children:p.internal_status})]})]})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(c,{variant:"h5",children:"Documents"}),e.jsx(x,{sx:{p:2},children:e.jsx(m,{spacing:1,children:"enduser"===y&&e.jsx(e.Fragment,{})})})]})}),p?.notes?.length>0&&e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(c,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:p.notes}),e.jsx(h,{})]})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:1,children:[e.jsx(c,{variant:"h5",children:"Items"}),e.jsx(h,{}),e.jsxs("form",{action:_,children:[p?.iro_items&&p.iro_items.map((r,i)=>(console.log("item",r),e.jsx(x,{sx:{p:2,mb:2}},i))),e.jsx(x,{sx:{p:2},children:e.jsxs(m,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(d.SubmitButton,{text:"Update items",loadingText:"Loading..."}),e.jsx(n.StrapiErrors,{error:b?.strapiErrors}),b?.message&&e.jsx(o,{severity:"error",children:b?.message})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(w))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),n=require("../../StrapiErrors.js"),d=require("../../SubmitButton.js"),o=require("@mui/material/Alert");require("@mui/material/Dialog"),require("@mui/material/DialogActions"),require("@mui/material/DialogContent"),require("@mui/material/DialogTitle");var c=require("@mui/material/Typography");require("@mui/material/Button");var l=require("@mui/material/Grid"),u=require("@mui/material/Box"),x=require("@mui/material/Paper"),m=require("@mui/material/Stack"),h=require("@mui/material/Divider");require("next/headers");const j={zodErrors:null,strapiErrors:null,data:null,message:null};exports.default=function({data:p,sx:g,revalidateCallback:q,handleClose:v,role:y}){const[b,_]=i.useFormState((e,r)=>t.updateIroAction(p.documentId,e,r),j),[w,f]=r.useState(p.iro_items?p.iro_items:[]),[S,D]=r.useState(!1);return e.jsx(u,{sx:[...Array.isArray(g)?g:[g]],children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsxs(m,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(m,{spacing:2,children:[e.jsx(c,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(c,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(a.default,{content:"",related:[{id:p.documentId,__type:"api::logistics.ipo"}],revalidateCallback:q})]}),e.jsx(h,{})]})}),e.jsx(l,{item:!0,xs:6,children:e.jsxs(m,{spacing:1,children:[e.jsx(c,{variant:"h5",children:"Details"}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(c,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(c,{variant:"body2",children:p.return_number})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(c,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(c,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(c,{variant:"body2",children:p.return_date})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(c,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(c,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(c,{variant:"body2",width:"250px",children:p.internal_status})]})]})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(c,{variant:"h5",children:"Documents"}),e.jsx(x,{sx:{p:2},children:e.jsx(m,{spacing:1,children:"enduser"===y&&e.jsx(e.Fragment,{})})})]})}),p?.notes?.length>0&&e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(c,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:p.notes}),e.jsx(h,{})]})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(m,{spacing:1,children:[e.jsx(c,{variant:"h5",children:"Items"}),e.jsx(h,{}),e.jsxs("form",{action:_,children:[p?.iro_items&&p.iro_items.map((r,i)=>(console.log("item",r),e.jsx(x,{sx:{p:2,mb:2}},i))),e.jsx(x,{sx:{p:2},children:e.jsxs(m,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(d.SubmitButton,{text:"Update items",loadingText:"Loading..."}),e.jsx(n.StrapiErrors,{error:b?.strapiErrors}),b?.message&&e.jsx(o,{severity:"error",children:b?.message})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.documentId,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(w))})]})]})})]})})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../context/common/SnackbarContext.js"),s=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),a=require("../../StrapiErrors.js"),n=require("../../SubmitButton.js"),o=require("@mui/material/Typography"),u=require("@mui/material/Grid"),l=require("@mui/material/Box"),d=require("@mui/material/TextField"),c=require("@mui/material/Checkbox"),m=require("@mui/material/Button"),h=require("@mui/material/Alert"),x=require("@mui/material/Stack"),p=require("@mui/material"),g=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),b=require("@mui/material/DialogContentText"),f=require("@mui/material/DialogTitle"),v=require("../../common/NumberInput.js");const q={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},_=({items:t,itemsToReturn:i,setItemsToReturn:s,selectedItems:a,setSelectedItems:n})=>{const[u,l]=r.useState(!1),m=(e,r,t)=>{s(i.map((i,s)=>s===e?{...i,[r]:t}:i))};r.useEffect(()=>{t&&s(t.map(e=>({line_item_number:e.line_item_number,product:e.product,ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[h,g]=r.useState([]);return r.useEffect(()=>{i&&g(i.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:"object"==typeof e.product&&"id"in e.product?e.product.id:0,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))},[i]),e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h6",children:"Items"}),e.jsx(o,{variant:"body1",children:"from the items in the original order please select the items you'd like to return"}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(h)}),e.jsx(x,{spacing:1,children:t.map((r,t)=>e.jsxs(e.Fragment,{children:[e.jsxs(x,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(c,{checked:a.includes(t),onChange:e=>{e.target.checked?n([...a,t]):n(a.filter(e=>e!==t))}}),e.jsxs(o,{variant:"body1",children:["Line Item Number: ",r.line_item_number]}),e.jsxs(o,{variant:"body1",children:["Part Number: ",r.product?.product_number]}),e.jsxs(o,{variant:"body1",children:["Quantity Ordered: ",r.ordered_quantity]})]}),a.includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs(x,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(v.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(p.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(o,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(d,{value:i[t]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;l("other"===r),m(t,"reason",r)},children:[e.jsx("option",{value:"damaged",children:"Damaged on arrival"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]})]}),u&&e.jsx(d,{value:i[t].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;m(t,"other_reason",r)}})]}),e.jsx(p.Divider,{})]}))})]})})},S=({open:t,onClose:i,items:s,formState:u,submitCallback:l})=>{const[d,x]=r.useState(!0);return e.jsxs(g,{open:t,onClose:i,children:[e.jsx(f,{children:"Confirm RMA"}),e.jsxs(y,{children:[e.jsx(b,{children:"Summary of items to be returned:"}),e.jsx(p.List,{children:s.map((r,t)=>e.jsxs(p.ListItem,{children:["object"==typeof r.product?`${r?.product?.product_number} ${r?.product?.title}`:`Product with ID ${r.product}`," ","- Quantity: ",r.returned_quantity]},t))}),e.jsx(b,{children:"Are you sure you want to request a return merchandise authorization for these items?"}),e.jsx(c,{onChange:e=>x(!e.target.checked)}),e.jsx(o,{variant:"body1",children:"I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration."})]}),e.jsxs(j,{children:[l?e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d,onClick:l}):e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d}),e.jsx(m,{onClick:i,children:"No"}),null!==u?.strapiErrors&&e.jsx(a.StrapiErrors,{error:u?.strapiErrors}),u?.message&&e.jsx(h,{severity:"error",children:u?.message})]})]})};exports.default=function({opo:n,sx:d,revalidateCallback:c,handleClose:p}){const[g,j]=t.useFormState(s.requestRmaAction,q),{handleAddMessage:y}=i.useSnackbar(),[b,f]=r.useState(!1),[v,C]=r.useState([]),[k,I]=r.useState([]);return r.useEffect(()=>{g?.message&&(y({message:g.message,severity:g.severity||"error"}),"success"===g.severity&&(c&&c(),p&&p()))},[g?.message]),r.useEffect(()=>{g?.strapiErrors&&y({message:g.strapiErrors.message||"Error requesting RMA",severity:g.severity||"error"})},[g?.strapiErrors]),e.jsx(l,{sx:[...Array.isArray(d)?d:[d]],children:e.jsx("form",{action:j,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{item:!0,xs:12,children:e.jsx(o,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:JSON.stringify([n.documentId])}),e.jsx(u,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"body1",children:"Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned."}),e.jsx(h,{severity:"warning",children:"We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items."})]})}),e.jsx(u,{item:!0,xs:12,children:n.opo_items?e.jsx(x,{spacing:1,children:n.opo_items&&e.jsx(_,{items:n.opo_items,itemsToReturn:v,setItemsToReturn:C,selectedItems:k,setSelectedItems:I})}):e.jsx(o,{variant:"body1",children:"No items"})}),e.jsx(S,{formState:g,open:b,items:v.filter(e=>e.returned_quantity>0),onClose:()=>f(!b),submitCallback:()=>{console.log("submit callback");const e=document.querySelector("form");j(e?new FormData(e):new FormData),f(!b)}}),e.jsxs(u,{item:!0,xs:12,children:[e.jsx(m,{onClick:()=>{console.log(g),f(!b)},disabled:0===k.length||0===k.reduce((e,r)=>e+v[r].returned_quantity,0),children:"Request RMA"}),null!==g?.strapiErrors&&e.jsx(a.StrapiErrors,{error:g?.strapiErrors}),g?.message&&e.jsx(h,{severity:"error",children:g?.message})]})]})})})};
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../context/common/SnackbarContext.js"),s=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),a=require("../../StrapiErrors.js"),n=require("../../SubmitButton.js"),o=require("@mui/material/Typography"),u=require("@mui/material/Grid"),l=require("@mui/material/Box"),d=require("@mui/material/TextField"),c=require("@mui/material/Checkbox"),m=require("@mui/material/Button"),h=require("@mui/material/Alert"),x=require("@mui/material/Stack"),p=require("@mui/material"),g=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),b=require("@mui/material/DialogContentText"),f=require("@mui/material/DialogTitle"),v=require("../../common/NumberInput.js");const q={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},_=({items:t,itemsToReturn:i,setItemsToReturn:s,selectedItems:a,setSelectedItems:n})=>{const[u,l]=r.useState(!1),m=(e,r,t)=>{s(i.map((i,s)=>s===e?{...i,[r]:t}:i))};r.useEffect(()=>{t&&s(t.map(e=>({line_item_number:e.line_item_number,product:e.product,ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[h,g]=r.useState([]);return r.useEffect(()=>{i&&g(i.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:"object"==typeof e.product&&"documentId"in e.product?e.product.documentId:"",returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))},[i]),e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h6",children:"Items"}),e.jsx(o,{variant:"body1",children:"from the items in the original order please select the items you'd like to return"}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(h)}),e.jsx(x,{spacing:1,children:t.map((r,t)=>e.jsxs(e.Fragment,{children:[e.jsxs(x,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(c,{checked:a.includes(t),onChange:e=>{e.target.checked?n([...a,t]):n(a.filter(e=>e!==t))}}),e.jsxs(o,{variant:"body1",children:["Line Item Number: ",r.line_item_number]}),e.jsxs(o,{variant:"body1",children:["Part Number: ",r.product?.product_number]}),e.jsxs(o,{variant:"body1",children:["Quantity Ordered: ",r.ordered_quantity]})]}),a.includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs(x,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(v.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(p.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(o,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(d,{value:i[t]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;l("other"===r),m(t,"reason",r)},children:[e.jsx("option",{value:"damaged",children:"Damaged on arrival"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]})]}),u&&e.jsx(d,{value:i[t].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;m(t,"other_reason",r)}})]}),e.jsx(p.Divider,{})]}))})]})})},S=({open:t,onClose:i,items:s,formState:u,submitCallback:l})=>{const[d,x]=r.useState(!0);return e.jsxs(g,{open:t,onClose:i,children:[e.jsx(f,{children:"Confirm RMA"}),e.jsxs(y,{children:[e.jsx(b,{children:"Summary of items to be returned:"}),e.jsx(p.List,{children:s.map((r,t)=>e.jsxs(p.ListItem,{children:["object"==typeof r.product?`${r?.product?.product_number} ${r?.product?.title}`:`Product with ID ${r.product}`," ","- Quantity: ",r.returned_quantity]},t))}),e.jsx(b,{children:"Are you sure you want to request a return merchandise authorization for these items?"}),e.jsx(c,{onChange:e=>x(!e.target.checked)}),e.jsx(o,{variant:"body1",children:"I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration."})]}),e.jsxs(j,{children:[l?e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d,onClick:l}):e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d}),e.jsx(m,{onClick:i,children:"No"}),null!==u?.strapiErrors&&e.jsx(a.StrapiErrors,{error:u?.strapiErrors}),u?.message&&e.jsx(h,{severity:"error",children:u?.message})]})]})};exports.default=function({opo:n,sx:d,revalidateCallback:c,handleClose:p}){const[g,j]=t.useFormState(s.requestRmaAction,q),{handleAddMessage:y}=i.useSnackbar(),[b,f]=r.useState(!1),[v,C]=r.useState([]),[I,k]=r.useState([]);return r.useEffect(()=>{g?.message&&(y({message:g.message,severity:g.severity||"error"}),"success"===g.severity&&(c&&c(),p&&p()))},[g?.message]),r.useEffect(()=>{g?.strapiErrors&&y({message:g.strapiErrors.message||"Error requesting RMA",severity:g.severity||"error"})},[g?.strapiErrors]),e.jsx(l,{sx:[...Array.isArray(d)?d:[d]],children:e.jsx("form",{action:j,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{item:!0,xs:12,children:e.jsx(o,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:JSON.stringify([n.documentId])}),e.jsx(u,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"body1",children:"Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned."}),e.jsx(h,{severity:"warning",children:"We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items."})]})}),e.jsx(u,{item:!0,xs:12,children:n.opo_items?e.jsx(x,{spacing:1,children:n.opo_items&&e.jsx(_,{items:n.opo_items,itemsToReturn:v,setItemsToReturn:C,selectedItems:I,setSelectedItems:k})}):e.jsx(o,{variant:"body1",children:"No items"})}),e.jsx(S,{formState:g,open:b,items:v.filter(e=>e.returned_quantity>0),onClose:()=>f(!b),submitCallback:()=>{console.log("submit callback");const e=document.querySelector("form");j(e?new FormData(e):new FormData),f(!b)}}),e.jsxs(u,{item:!0,xs:12,children:[e.jsx(m,{onClick:()=>{console.log(g),f(!b)},disabled:0===I.length||0===I.reduce((e,r)=>e+v[r].returned_quantity,0),children:"Request RMA"}),null!==g?.strapiErrors&&e.jsx(a.StrapiErrors,{error:g?.strapiErrors}),g?.message&&e.jsx(h,{severity:"error",children:g?.message})]})]})})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),o=require("@mui/icons-material/ArrowDropDown"),d=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportsDisplay.js"),c=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:v,product:f,returned_quantity:w,received_quantity:R,registered_quantity:I,released_quantity:V,reports:_,reason:C,other_reason:A}=p,[D,N]=r.useState(!1);void 0!==_&&_.length>0&&_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const T=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;void 0!==_&&_.length>0&&_.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const F=p.reports?.filter(e=>"id"in e)||[],U=p.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",v]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(d.default,{image:y,label:p.product?.title})})]}),e.jsxs(i,{variant:"body1",children:["Reason: ",C,"other"===C&&void 0!==A&&`, ${A}`]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.TextualAmountUpdater,{label:"Received",currentValue:R,totalValue:w,minNewValue:0+I,maxNewValue:w,color:"info",handleChange:e=>{g(e,p.id,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.TextualAmountUpdater,{label:"Registered",currentValue:I,totalValue:w+T,minNewValue:0+V,maxNewValue:R+T,color:"info",handleChange:e=>{g(e,p.id,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>N(!D),children:e.jsx(o,{})})]})}),e.jsx(s,{in:D,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:F}),e.jsx(c.default,{itemID:p.id,reports:U,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.id,content:"",type:"registered",minValue:-(R-I+T),handleAddReport:h})]})})]}),q&&q.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.TextualAmountUpdater,{label:"Released",currentValue:V,totalValue:w+T,minNewValue:0,maxNewValue:I,color:"info",handleChange:e=>{g(e,p.id,"released_quantity")}})]})]})},j)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),o=require("../../common/TextualAmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),d=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportsDisplay.js"),c=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:v,product:f,returned_quantity:w,received_quantity:I,registered_quantity:R,released_quantity:V,reports:_,reason:C,other_reason:A}=p,[D,N]=r.useState(!1);void 0!==_&&_.length>0&&_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const T=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;void 0!==_&&_.length>0&&_.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const F=p.reports?.filter(e=>"id"in e)||[],U=p.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",v]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(d.default,{image:y,label:p.product?.title})})]}),e.jsxs(i,{variant:"body1",children:["Reason: ",C,"other"===C&&void 0!==A&&`, ${A}`]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(o.TextualAmountUpdater,{label:"Received",currentValue:I,totalValue:w,minNewValue:0+R,maxNewValue:w,color:"info",handleChange:e=>{g(e,p.documentId,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(o.TextualAmountUpdater,{label:"Registered",currentValue:R,totalValue:w+T,minNewValue:0+V,maxNewValue:I+T,color:"info",handleChange:e=>{g(e,p.documentId,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>N(!D),children:e.jsx(l,{})})]})}),e.jsx(s,{in:D,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:F}),e.jsx(c.default,{itemID:p.documentId,reports:U,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.documentId,content:"",type:"registered",minValue:-(I-R+T),handleAddReport:h})]})})]}),q&&q.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(o.TextualAmountUpdater,{label:"Released",currentValue:V,totalValue:w+T,minNewValue:0,maxNewValue:R,color:"info",handleChange:e=>{g(e,p.documentId,"released_quantity")}})]})]})},j)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),n=require("./TextualIROItemUpdater.js"),s=require("./IroItemDisplay.js"),a=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),o=require("../../SubmitButton.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),x=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),p=require("@mui/material/Button"),j=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),_=require("@mui/material/Stack"),y=require("@mui/material/Divider"),f=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),C=require("@mui/material"),q=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),S=require("@mui/icons-material/Business"),k=require("@mui/icons-material/Description"),T=require("@mui/icons-material/Update"),A=require("./IroStatusIndicator.js"),F=require("../../../data/loaders/e-commerce/queryAllProducts.js"),D=require("../../../../node_modules/qs/lib/index.js"),R=require("../../../context/common/SnackbarContext.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{o(!0);const e=D.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.id,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(d,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(x,{children:"Check or overwrite value for the return payment"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(C.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(C.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(C.CircularProgress,{}):e.jsxs(_,{spacing:2,children:[e.jsx(C.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(C.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(C.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(_,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(h,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(h,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(h,{sx:{minWidth:200},children:r.product?.title}),e.jsx(C.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.id))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{f.confirmationService("iros",[a.documentId],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=R.useSnackbar();return e.jsxs(d,{open:r,onClose:t,children:[e.jsx(x,{children:"Confirm Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this return?"}),e.jsxs(C.List,{children:["requested"===n&&e.jsx(C.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(C.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(C.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(h,{children:["Current status: ",n]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await f.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(p,{variant:"contained",onClick:t,children:"No"})]})]})}function O({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,c]=r.useState(""),{handleAddMessage:j}=R.useSnackbar();return e.jsx("form",{children:e.jsxs(d,{open:t,onClose:i,children:[e.jsx(x,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this return?"}),e.jsxs(C.List,{children:[e.jsx(C.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(C.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(C.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(p,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:d,sx:u,revalidateCallback:m,handleClose:x,role:f}){const[b,F]=t.useFormState((e,r)=>i.updateIroAction(d.documentId,e,r),P),[D,M]=r.useState(d.iro_items?d.iro_items:[]),[B,L]=r.useState(!1),[N,z]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...D],n=i.findIndex(e=>e.id===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.id===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,M(t)},K=(e,r)=>{const t=[...D],i=t.findIndex(r=>r.id===e),n=t[i]?.reports||[],s=n.filter(e=>"id"in e),a=n.filter(e=>!("id"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,M(t)},{handleAddMessage:X}=R.useSnackbar();return r.useEffect(()=>{b?.message&&(X({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(m&&m(),x&&x()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&X({message:b.strapiErrors.message||"Error updating IRO",severity:b.severity||"error"})},[b?.strapiErrors]),r.useEffect(()=>{console.log("data",d),d.iro_items&&M(d.iro_items?d.iro_items:[])},[d]),e.jsx(v,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.rma_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_date})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(T,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(A.IroStatusIndicator,{status:d.internal_status})]})]})})}),("requested"===d.internal_status||"finalising_process"===d.internal_status)&&"enduser"===f&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.internal_status&&e.jsx(c,{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"}),"finalising_process"===d.internal_status&&e.jsx(c,{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"}),"finalising_process"===d.internal_status&&e.jsx(p,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(p,{variant:"contained",color:"error",onClick:()=>z(!0),children:"Cancel order"}),e.jsx(E,{open:B,handleClose:()=>L(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:d}),e.jsx(O,{open:N,handleClose:()=>z(!1),orderID:d.documentId,revalidateCallback:m})]})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(_,{spacing:1})})]})}),d?.notes?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(a.default,{notes:d.notes}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:g,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(C.FormControlLabel,{control:e.jsx(C.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(y,{}),e.jsxs("form",{action:F,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.internal_status||"cancelled"===d.internal_status||"done"===d.internal_status?e.jsx(s.default,{item:r,index:t,image:r?.product?.image}):e.jsx(n.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:G})},t)),e.jsxs(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[x&&e.jsx(p,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(o.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),n=require("./TextualIROItemUpdater.js"),s=require("./IroItemDisplay.js"),a=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),o=require("../../SubmitButton.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),x=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),p=require("@mui/material/Button"),j=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),_=require("@mui/material/Stack"),y=require("@mui/material/Divider"),f=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),C=require("@mui/material"),q=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),S=require("@mui/icons-material/Business"),k=require("@mui/icons-material/Description"),T=require("@mui/icons-material/Update"),A=require("./IroStatusIndicator.js"),F=require("../../../data/loaders/e-commerce/queryAllProducts.js"),D=require("../../../../node_modules/qs/lib/index.js"),R=require("../../../context/common/SnackbarContext.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{o(!0);const e=D.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(d,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(x,{children:"Check or overwrite value for the return payment"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(C.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(C.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(C.CircularProgress,{}):e.jsxs(_,{spacing:2,children:[e.jsx(C.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(C.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(C.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(_,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(h,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(h,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(h,{sx:{minWidth:200},children:r.product?.title}),e.jsx(C.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{f.confirmationService("iros",[a.documentId],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=R.useSnackbar();return e.jsxs(d,{open:r,onClose:t,children:[e.jsx(x,{children:"Confirm Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this return?"}),e.jsxs(C.List,{children:["requested"===n&&e.jsx(C.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(C.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(C.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(h,{children:["Current status: ",n]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await f.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(p,{variant:"contained",onClick:t,children:"No"})]})]})}function O({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,c]=r.useState(""),{handleAddMessage:j}=R.useSnackbar();return e.jsx("form",{children:e.jsxs(d,{open:t,onClose:i,children:[e.jsx(x,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this return?"}),e.jsxs(C.List,{children:[e.jsx(C.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(C.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(C.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(p,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:d,sx:u,revalidateCallback:m,handleClose:x,role:f}){const[b,F]=t.useFormState((e,r)=>i.updateIroAction(d.documentId,e,r),P),[D,M]=r.useState(d.iro_items?d.iro_items:[]),[B,L]=r.useState(!1),[N,z]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...D],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,M(t)},K=(e,r)=>{const t=[...D],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"id"in e),a=n.filter(e=>!("id"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,M(t)},{handleAddMessage:X}=R.useSnackbar();return r.useEffect(()=>{b?.message&&(X({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(m&&m(),x&&x()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&X({message:b.strapiErrors.message||"Error updating IRO",severity:b.severity||"error"})},[b?.strapiErrors]),r.useEffect(()=>{console.log("data",d),d.iro_items&&M(d.iro_items?d.iro_items:[])},[d]),e.jsx(v,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.documentId,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.rma_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_date})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(T,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(A.IroStatusIndicator,{status:d.internal_status})]})]})})}),("requested"===d.internal_status||"finalising_process"===d.internal_status)&&"enduser"===f&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.internal_status&&e.jsx(c,{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"}),"finalising_process"===d.internal_status&&e.jsx(c,{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"}),"finalising_process"===d.internal_status&&e.jsx(p,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(p,{variant:"contained",color:"error",onClick:()=>z(!0),children:"Cancel order"}),e.jsx(E,{open:B,handleClose:()=>L(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:d}),e.jsx(O,{open:N,handleClose:()=>z(!1),orderID:d.documentId,revalidateCallback:m})]})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(_,{spacing:1})})]})}),d?.notes?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(a.default,{notes:d.notes}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:g,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(C.FormControlLabel,{control:e.jsx(C.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(y,{}),e.jsxs("form",{action:F,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.internal_status||"cancelled"===d.internal_status||"done"===d.internal_status?e.jsx(s.default,{item:r,index:t,image:r?.product?.image}):e.jsx(n.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:G})},t)),e.jsxs(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[x&&e.jsx(p,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(o.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),m=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),j=require("@mui/material/Typography"),y=require("@mui/material/Button"),v=require("@mui/material/Grid"),g=require("@mui/material/Box"),f=require("@mui/material/Paper"),b=require("@mui/material/Stack"),_=require("@mui/material/Divider"),q=require("../../../data/services/common/confirmation-service.js"),C=require("../../../context/common/SnackbarContext.js");const w={zodErrors:null,strapiErrors:null,message:null};function k({open:i,handleClose:r,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(m,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{children:"Are you sure you want to confirm this order?"}),e.jsxs(j,{children:["Current status: ",t]})]})}),e.jsxs(p,{children:[e.jsx(y,{variant:"contained",onClick:e=>{q.confirmationService("opos",[n]),a&&a()},children:"Confirm"}),e.jsx(y,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:m,sx:p,revalidateCallback:x,handleClose:h,role:q}){const[D,O]=r.useFormState((e,i)=>n.updateOpoAction(m.documentId,e,i),w),{handleAddMessage:I}=C.useSnackbar(),[S,E]=i.useState(m.opo_items?m.opo_items:[]),[A,B]=i.useState(!1),N=(e,i,r)=>{const n=[...S],t=n.findIndex(e=>e.id===i);n[t][r]=e,E(n)};return i.useEffect(()=>{m.opo_items&&E(m.opo_items)},[m]),i.useEffect(()=>{D?.message&&(I({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(x&&x(),h&&h()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&I({message:D.strapiErrors.message||"Error updating OPO",severity:D.severity||"error"})},[D?.strapiErrors]),e.jsx(g,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(v,{container:!0,spacing:2,children:[e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h3",component:"h1",children:"Manage Outbound Purchase Order"}),e.jsx(j,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:m.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:6,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Details"}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(j,{variant:"body2",children:m.opo_number})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(j,{variant:"body2",children:m.customer_reference})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(j,{variant:"body2",children:m.order_date})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(j,{variant:"body2",children:m.customer?.business_credentials?.company_name})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(j,{variant:"body2",width:"250px",children:m.internal_status})]}),("placed"===m.internal_status||"external_shipping_process"===m.internal_status)&&"enduser"===q&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"contained",color:"primary",onClick:()=>B(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(k,{open:A,handleClose:()=>B(!1),orderID:m.documentId,currentStatus:m.internal_status,revalidateCallback:x})]})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Documents"}),e.jsx(f,{sx:{p:2},children:e.jsx(b,{spacing:1,children:m.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h6",children:"Delivery Note"}),e.jsx(j,{children:m.delivery_note?.name}),e.jsx(y,{variant:"contained",onClick:()=>{a.default(`api/opos/${m.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h5",children:"Delivery Note"}),e.jsx(j,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(t.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:m.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:x})]})})})]})}),m?.notes?.length>0&&e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:m.notes}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Items"}),"placed"===m.internal_status&&e.jsx(u,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:O,children:[e.jsx("input",{name:"id",type:"hidden",value:m.documentId}),S&&S.map((i,r)=>(console.log("item",i),e.jsx(f,{sx:{p:2,mb:2},children:"placed"===m.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:N,image:i?.product?.image,revalidateCallback:x})},r))),e.jsx(f,{sx:{p:2},children:e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(y,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(S))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),m=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),j=require("@mui/material/Typography"),y=require("@mui/material/Button"),v=require("@mui/material/Grid"),g=require("@mui/material/Box"),f=require("@mui/material/Paper"),b=require("@mui/material/Stack"),_=require("@mui/material/Divider"),q=require("../../../data/services/common/confirmation-service.js"),C=require("../../../context/common/SnackbarContext.js");const w={zodErrors:null,strapiErrors:null,message:null};function k({open:i,handleClose:r,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(m,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{children:"Are you sure you want to confirm this order?"}),e.jsxs(j,{children:["Current status: ",t]})]})}),e.jsxs(p,{children:[e.jsx(y,{variant:"contained",onClick:e=>{q.confirmationService("opos",[n]),a&&a()},children:"Confirm"}),e.jsx(y,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:m,sx:p,revalidateCallback:x,handleClose:h,role:q}){const[D,I]=r.useFormState((e,i)=>n.updateOpoAction(m.documentId,e,i),w),{handleAddMessage:O}=C.useSnackbar(),[S,E]=i.useState(m.opo_items?m.opo_items:[]),[A,B]=i.useState(!1),N=(e,i,r)=>{const n=[...S],t=n.findIndex(e=>e.documentId===i);n[t][r]=e,E(n)};return i.useEffect(()=>{m.opo_items&&E(m.opo_items)},[m]),i.useEffect(()=>{D?.message&&(O({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(x&&x(),h&&h()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&O({message:D.strapiErrors.message||"Error updating OPO",severity:D.severity||"error"})},[D?.strapiErrors]),e.jsx(g,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(v,{container:!0,spacing:2,children:[e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h3",component:"h1",children:"Manage Outbound Purchase Order"}),e.jsx(j,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:m.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:6,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Details"}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(j,{variant:"body2",children:m.opo_number})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(j,{variant:"body2",children:m.customer_reference})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(j,{variant:"body2",children:m.order_date})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(j,{variant:"body2",children:m.customer?.business_credentials?.company_name})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(j,{variant:"body2",width:"250px",children:m.internal_status})]}),("placed"===m.internal_status||"external_shipping_process"===m.internal_status)&&"enduser"===q&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"contained",color:"primary",onClick:()=>B(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(k,{open:A,handleClose:()=>B(!1),orderID:m.documentId,currentStatus:m.internal_status,revalidateCallback:x})]})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Documents"}),e.jsx(f,{sx:{p:2},children:e.jsx(b,{spacing:1,children:m.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h6",children:"Delivery Note"}),e.jsx(j,{children:m.delivery_note?.name}),e.jsx(y,{variant:"contained",onClick:()=>{a.default(`api/opos/${m.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h5",children:"Delivery Note"}),e.jsx(j,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(t.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:m.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:x})]})})})]})}),m?.notes?.length>0&&e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:m.notes}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Items"}),"placed"===m.internal_status&&e.jsx(u,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:m.documentId}),S&&S.map((i,r)=>(console.log("item",i),e.jsx(f,{sx:{p:2,mb:2},children:"placed"===m.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:N,image:i?.product?.image,revalidateCallback:x})},r))),e.jsx(f,{sx:{p:2},children:e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(y,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(S))})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Table"),i=require("@mui/material/TableHead"),u=require("@mui/material/TableBody"),n=require("@mui/material/TableCell"),s=require("@mui/material/TableRow"),a=require("@mui/material/IconButton"),l=require("@mui/icons-material/Add"),d=require("@mui/material/Typography"),m=require("@mui/material/Stack"),c=require("@mui/material/TextField"),o=require("../products/ProductSelector.js");require("../../../../node_modules/dayjs/dayjs.min.js");var x=require("@mui/icons-material/Delete"),h=require("@mui/material/styles");exports.OPOItemFields=function({productsArr:j}){const[p,q]=r.useState([]),[b,g]=r.useState(null),[w,y]=r.useState(0),[v,f]=r.useState([]);h.useTheme();const[S,T]=r.useState([]);return r.useEffect(()=>{T((e=>e.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:e.product.documentId,ordered_quantity:e.amount})))(p))},[p]),e.jsxs(m,{spacing:2,children:[e.jsxs(t,{children:[e.jsx(i,{children:e.jsxs(s,{children:[e.jsx(n,{id:"line_item_number",sx:[{width:"15%"}],children:"Line Item Number"}),e.jsx(n,{sx:[{width:"70%"}],children:"Product Number"}),e.jsx(n,{sx:[{width:"15%"}],children:"Amount"}),e.jsx(n,{sx:[]})]})}),e.jsx(u,{children:p.map((r,t)=>e.jsxs(s,{children:[e.jsxs(n,{sx:[{width:"15%"}],children:[t+1,".0.0"]}),e.jsxs(n,{sx:[{width:"70%"}],children:[r.product.product_number," | ",r.product.title]}),e.jsx(n,{sx:{width:"15%"},children:r.amount}),e.jsx(n,{align:"right",sx:{width:"5%"},children:e.jsx(a,{onClick:()=>(e=>{const r=p.filter((r,t)=>t!==e);q(r)})(t),children:e.jsx(x,{})})})]},t))})]}),e.jsx("input",{type:"hidden",name:"opo_items",value:JSON.stringify(S)}),e.jsxs(m,{direction:"row",spacing:1,alignItems:"center",sx:{p:2,width:"100%"},children:[e.jsxs(d,{variant:"body1",sx:{width:"15%"},children:[p.length+1,".0.0"]}),j&&e.jsx(o.default,{productNames:j,currentValue:v,sx:{width:"70%"},multiple:!1,onChangeCallback:e=>{const r=j.find(r=>r.id===e[0]);g(r||null),f(e)}}),e.jsx(c,{id:"amount",name:"amount",type:"number",label:"Amount",value:w,onChange:e=>{""!==e.target.value?parseInt(e.target.value)<0?y(0):y(parseInt(e.target.value)):y(0)},sx:{width:"15%"}}),e.jsx(a,{onClick:()=>{if(null===b||null===w)return void console.log("nextProductName or nextAmount is null");const e={product:b,amount:w};q([...p,e]),g(null),y(0),f([])},children:e.jsx(l,{})})]})]})};
6
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Table"),i=require("@mui/material/TableHead"),u=require("@mui/material/TableBody"),n=require("@mui/material/TableCell"),s=require("@mui/material/TableRow"),a=require("@mui/material/IconButton"),l=require("@mui/icons-material/Add"),d=require("@mui/material/Typography"),m=require("@mui/material/Stack"),c=require("@mui/material/TextField"),o=require("../products/ProductSelector.js");require("../../../../node_modules/dayjs/dayjs.min.js");var x=require("@mui/icons-material/Delete"),h=require("@mui/material/styles");exports.OPOItemFields=function({productsArr:j}){const[p,q]=r.useState([]),[b,g]=r.useState(null),[w,y]=r.useState(0),[v,f]=r.useState([]);h.useTheme();const[I,S]=r.useState([]);return r.useEffect(()=>{S((e=>e.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:e.product.documentId,ordered_quantity:e.amount})))(p))},[p]),e.jsxs(m,{spacing:2,children:[e.jsxs(t,{children:[e.jsx(i,{children:e.jsxs(s,{children:[e.jsx(n,{id:"line_item_number",sx:[{width:"15%"}],children:"Line Item Number"}),e.jsx(n,{sx:[{width:"70%"}],children:"Product Number"}),e.jsx(n,{sx:[{width:"15%"}],children:"Amount"}),e.jsx(n,{sx:[]})]})}),e.jsx(u,{children:p.map((r,t)=>e.jsxs(s,{children:[e.jsxs(n,{sx:[{width:"15%"}],children:[t+1,".0.0"]}),e.jsxs(n,{sx:[{width:"70%"}],children:[r.product.product_number," | ",r.product.title]}),e.jsx(n,{sx:{width:"15%"},children:r.amount}),e.jsx(n,{align:"right",sx:{width:"5%"},children:e.jsx(a,{onClick:()=>(e=>{const r=p.filter((r,t)=>t!==e);q(r)})(t),children:e.jsx(x,{})})})]},t))})]}),e.jsx("input",{type:"hidden",name:"opo_items",value:JSON.stringify(I)}),e.jsxs(m,{direction:"row",spacing:1,alignItems:"center",sx:{p:2,width:"100%"},children:[e.jsxs(d,{variant:"body1",sx:{width:"15%"},children:[p.length+1,".0.0"]}),j&&e.jsx(o.default,{productNames:j,currentValue:v,sx:{width:"70%"},multiple:!1,onChangeCallback:e=>{const r=j.find(r=>r.documentId===e[0]);g(r||null),f(e)}}),e.jsx(c,{id:"amount",name:"amount",type:"number",label:"Amount",value:w,onChange:e=>{""!==e.target.value?parseInt(e.target.value)<0?y(0):y(parseInt(e.target.value)):y(0)},sx:{width:"15%"}}),e.jsx(a,{onClick:()=>{if(null===b||null===w)return void console.log("nextProductName or nextAmount is null");const e={product:b,amount:w};q([...p,e]),g(null),y(0),f([])},children:e.jsx(l,{})})]})]})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),d=require("../../common/AmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),u=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportMakingComponent.js"),s=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:h,image:x,revalidateCallback:j}){const{line_item_number:y,product:g,ordered_quantity:q,picked_quantity:f,packed_quantity:b,shipped_quantity:v,reports:k}=m,[V,_]=t.useState(!1);t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"picked"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);const w=t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"packed"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);return t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"shipped"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]),e.jsx(r,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",children:[e.jsxs(r,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g?.product_number]})]}),x&&e.jsx(e.Fragment,{children:e.jsx(u.default,{image:x,label:g?.title})})]}),e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(d.AmountUpdater,{currentValue:f,totalValue:q+-w,minNewValue:0+b+-w,maxNewValue:q+-w,color:"info",handleChange:e=>{h(e,m.id,"picked_quantity")}}),e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(d.AmountUpdater,{currentValue:b,totalValue:q,minNewValue:0+v,maxNewValue:f+w,color:"info",handleChange:e=>{h(e,m.id,"packed_quantity")},offsetEnd:w}),e.jsx(n,{sx:{p:0},children:e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>_(!V),children:e.jsx(l,{})})]})}),e.jsx(o,{in:V,children:e.jsxs(r,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(s.default,{reports:k.filter(e=>"documentId"in e&&"string"==typeof e.documentId)}),e.jsx(c.default,{content:"content",quantity:0,type:"packed",minValue:-(f+w),maxValue:0,related:[{id:m.id,__type:"api::e-commerce.opo-item"}],revalidateCallback:j})]})}),e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(d.AmountUpdater,{currentValue:v,totalValue:q,minNewValue:0,maxNewValue:b,color:"info",handleChange:e=>{h(e,m.id,"shipped_quantity")}})]})},p)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),d=require("../../common/AmountUpdater.js"),u=require("@mui/icons-material/ArrowDropDown"),l=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportMakingComponent.js"),s=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:h,image:x,revalidateCallback:j}){const{line_item_number:y,product:g,ordered_quantity:q,picked_quantity:f,packed_quantity:b,shipped_quantity:v,reports:k}=m,[V,_]=t.useState(!1);t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"picked"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);const w=t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"packed"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);return t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"shipped"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]),e.jsx(r,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",children:[e.jsxs(r,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g?.product_number]})]}),x&&e.jsx(e.Fragment,{children:e.jsx(l.default,{image:x,label:g?.title})})]}),e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(d.AmountUpdater,{currentValue:f,totalValue:q+-w,minNewValue:0+b+-w,maxNewValue:q+-w,color:"info",handleChange:e=>{h(e,m.documentId,"picked_quantity")}}),e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(d.AmountUpdater,{currentValue:b,totalValue:q,minNewValue:0+v,maxNewValue:f+w,color:"info",handleChange:e=>{h(e,m.documentId,"packed_quantity")},offsetEnd:w}),e.jsx(n,{sx:{p:0},children:e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>_(!V),children:e.jsx(u,{})})]})}),e.jsx(o,{in:V,children:e.jsxs(r,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(s.default,{reports:k.filter(e=>"documentId"in e&&"string"==typeof e.documentId)}),e.jsx(c.default,{content:"content",quantity:0,type:"packed",minValue:-(f+w),maxValue:0,related:[{documentId:m.documentId,__type:"api::e-commerce.opo-item"}],revalidateCallback:j})]})}),e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(d.AmountUpdater,{currentValue:v,totalValue:q,minNewValue:0,maxNewValue:b,color:"info",handleChange:e=>{h(e,m.documentId,"shipped_quantity")}})]})},p)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Table"),l=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),n=require("@mui/material/TableHead"),c=require("@mui/material/TableFooter"),s=require("@mui/material/TableRow"),t=require("@mui/material/Typography"),o=require("./OpoSummaryRow.js");exports.OpoSummary=function({opo:u}){const{opo_items:m}=u;return m?(console.log("opo_items",m),e.jsx(r,{sx:{p:{xs:1,md:2}},children:null!=m?e.jsxs(i,{children:[e.jsx(n,{children:e.jsxs(s,{children:[e.jsx(a,{children:"Amount"}),e.jsx(a,{children:"Product Title"}),e.jsx(a,{children:"Price Excl. VAT"}),e.jsx(a,{children:"Price Incl. VAT"})]})}),e.jsx(l,{children:m&&m.map(r=>e.jsx(o.OpoSummaryRow,{data:r},r.id))}),e.jsxs(c,{children:[e.jsxs(s,{children:[e.jsx(a,{colSpan:3,align:"right",children:"Total excl VAT"}),e.jsxs(a,{colSpan:1,align:"left",children:["€ ",u.total_excl_vat]})]}),e.jsxs(s,{children:[e.jsx(a,{colSpan:3,align:"right",children:"Total incl VAT"}),e.jsxs(a,{colSpan:1,align:"left",children:["€ ",u.total_incl_vat]})]})]})]}):e.jsx(t,{children:"No products in cart"})})):e.jsx(t,{children:"Loading..."})};
6
+ "use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Table"),l=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),n=require("@mui/material/TableHead"),c=require("@mui/material/TableFooter"),s=require("@mui/material/TableRow"),t=require("@mui/material/Typography"),o=require("./OpoSummaryRow.js");exports.OpoSummary=function({opo:u}){const{opo_items:m}=u;return m?(console.log("opo_items",m),e.jsx(r,{sx:{p:{xs:1,md:2}},children:null!=m?e.jsxs(i,{children:[e.jsx(n,{children:e.jsxs(s,{children:[e.jsx(a,{children:"Amount"}),e.jsx(a,{children:"Product Title"}),e.jsx(a,{children:"Price Excl. VAT"}),e.jsx(a,{children:"Price Incl. VAT"})]})}),e.jsx(l,{children:m&&m.map(r=>e.jsx(o.OpoSummaryRow,{data:r},r.documentId))}),e.jsxs(c,{children:[e.jsxs(s,{children:[e.jsx(a,{colSpan:3,align:"right",children:"Total excl VAT"}),e.jsxs(a,{colSpan:1,align:"left",children:["€ ",u.total_excl_vat]})]}),e.jsxs(s,{children:[e.jsx(a,{colSpan:3,align:"right",children:"Total incl VAT"}),e.jsxs(a,{colSpan:1,align:"left",children:["€ ",u.total_incl_vat]})]})]})]}):e.jsx(t,{children:"No products in cart"})})):e.jsx(t,{children:"Loading..."})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";var r=require("react/jsx-runtime"),e=require("@mui/material/TableRow"),i=require("@mui/material/TableCell");exports.OpoSummaryRow=function({data:c}){const{id:t,ordered_quantity:n,product:a}=c;return r.jsxs(e,{children:[r.jsx(i,{children:n}),r.jsx(i,{children:a?.title}),r.jsx(i,{children:a?.price?.price?`€ ${a.price.price}`:"no information"}),r.jsx(i,{children:a?.price?.price_incl_vat?`€ ${a.price.price_incl_vat}`:"no information"})]})};
6
+ "use strict";var r=require("react/jsx-runtime"),e=require("@mui/material/TableRow"),i=require("@mui/material/TableCell");exports.OpoSummaryRow=function({data:c}){const{documentId:t,ordered_quantity:n,product:a}=c;return r.jsxs(e,{children:[r.jsx(i,{children:n}),r.jsx(i,{children:a?.title}),r.jsx(i,{children:a?.price?.price?`€ ${a.price.price}`:"no information"}),r.jsx(i,{children:a?.price?.price_incl_vat?`€ ${a.price.price_incl_vat}`:"no information"})]})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),l=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),k=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("opos",n,s),d({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.documentId),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items?u.opo_items:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items&&R(u.opo_items?u.opo_items:[])},[u]);const Y=(e,r,i)=>{const t=[...L],n=t.findIndex(e=>e.id===r);t[n][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),n=i[t]?.reports||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.documentId,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.documentId,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/opos/${u.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),u?.notes?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:u.notes}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),c=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),m=require("@mui/material/DialogActions"),p=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),I=require("@mui/icons-material/Numbers"),k=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(p,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(m,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[c,l]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(p,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!c,helperText:c})]})}),e.jsxs(m,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)l("Please provide a reason for the cancellation (min 5 characters)");else{l("");try{await b.cancellationService("opos",n,s),d({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:m,revalidateCallback:p,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.documentId),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items?u.opo_items:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(p?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items&&R(u.opo_items?u.opo_items:[])},[u]);const Y=(e,r,i)=>{const t=[...L],n=t.findIndex(e=>e.documentId===r);t[n][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.documentId===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.documentId===e),n=i[t]?.reports||[],a=n.filter(e=>"documentId"in e),s=n.filter(e=>!("documentId"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(m)?m:[m]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:u.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:p})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.documentId,currentStatus:u.internal_status,revalidateCallback:p})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.documentId,revalidateCallback:p})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/opos/${u.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:p})]})})})]})}),u?.notes?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:u.notes}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:p,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};