umwd-components 0.1.736 → 0.1.738
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.
- package/dist/cjs/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/dist/cjs/node_modules/safe-buffer/index.js +1 -1
- package/dist/cjs/src/components/common/csv/CsvDownloader.js +1 -1
- package/dist/cjs/src/components/common/media/MediaGrid.js +1 -1
- package/dist/cjs/src/components/common/media/UploadMediaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/cart/CartDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/categories/AddCategoryForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/checkout/CheckoutForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/checkout/Step3.js +1 -1
- package/dist/cjs/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/customer/CustomerProfileEditForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/customer/DenseCustomerProfileDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/enduser/EnduserProfileDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/enduser/EnduserProfileEditForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/invoice/CreateInvoiceForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/CreateIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/AddProductForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/EditProductForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/EditStockForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/ProductCategoryCard.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/SingleProduct.js +1 -1
- package/dist/cjs/src/components/layout/Footer.js +1 -1
- package/dist/cjs/src/components/layout/NavbarV2.js +1 -1
- package/dist/cjs/src/components/logistics/dispatcher/DispatcherProfileDisplay.js +1 -1
- package/dist/cjs/src/components/logistics/dispatcher/DispatcherProfileEditForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/AddIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/report/PreReportsDisplay.js +1 -1
- package/dist/cjs/src/components/logistics/report/ReportsDisplay.js +1 -1
- package/dist/cjs/src/components/logistics/vendor/AddVendorForm.js +1 -1
- package/dist/cjs/src/components/logistics/vendor/EditVendorForm.js +1 -1
- package/dist/cjs/src/components/logistics/vendor/VendorDisplay.js +1 -1
- package/dist/cjs/src/components/page-builder/ColumnsSection.js +1 -1
- package/dist/cjs/src/components/page-builder/IconSection.js +1 -1
- package/dist/cjs/src/components/page-builder/LogoBarSection.js +1 -1
- package/dist/cjs/src/components/page-builder/PBPersonaliaSection.js +1 -1
- package/dist/cjs/src/components/page-builder/PBTextImageSection.js +1 -1
- package/dist/cjs/src/components/page-builder/PictureBarSection.js +1 -1
- package/dist/cjs/src/components/page-elements/CategoryBlock.js +1 -1
- package/dist/cjs/src/components/page-elements/ColumnsSection.js +1 -1
- package/dist/cjs/src/components/page-elements/IconSection.js +1 -1
- package/dist/cjs/src/components/page-elements/LogoBarSection.js +1 -1
- package/dist/cjs/src/components/page-elements/PersonaliaSection.js +1 -1
- package/dist/cjs/src/components/page-elements/PictureBarSection.js +1 -1
- package/dist/cjs/src/components/page-elements/ProductBlock.js +1 -1
- package/dist/cjs/src/components/page-elements/TextImageSection.js +1 -1
- package/dist/cjs/src/components/public-information/PublicInformationForm.js +1 -1
- package/dist/cjs/src/data/actions/auth-actions.js +1 -1
- package/dist/cjs/src/data/services/get-token.js +1 -1
- package/dist/cjs/src/data/services/get-user-me-loader.js +1 -1
- package/dist/cjs/src/lib/parseNavigation.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/_virtual/index3.js +2 -2
- package/dist/esm/_virtual/index4.js +2 -2
- package/dist/esm/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/dist/esm/node_modules/safe-buffer/index.js +1 -1
- package/dist/esm/src/components/common/csv/CsvDownloader.js +5 -5
- package/dist/esm/src/components/common/media/MediaGrid.js +1 -1
- package/dist/esm/src/components/common/media/UploadMediaForm.js +12 -2
- package/dist/esm/src/components/e-commerce/cart/CartDisplay.js +1 -1
- package/dist/esm/src/components/e-commerce/categories/AddCategoryForm.js +1 -1
- package/dist/esm/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/esm/src/components/e-commerce/checkout/CheckoutForm.js +2 -2
- package/dist/esm/src/components/e-commerce/checkout/Step3.js +9 -3
- package/dist/esm/src/components/e-commerce/customer/CustomerProfileDisplay.js +19 -1
- package/dist/esm/src/components/e-commerce/customer/CustomerProfileEditForm.js +1 -1
- package/dist/esm/src/components/e-commerce/customer/DenseCustomerProfileDisplay.js +16 -1
- package/dist/esm/src/components/e-commerce/enduser/EnduserProfileDisplay.js +4 -1
- package/dist/esm/src/components/e-commerce/enduser/EnduserProfileEditForm.js +1 -1
- package/dist/esm/src/components/e-commerce/invoice/CreateInvoiceForm.js +3 -3
- package/dist/esm/src/components/e-commerce/iro/CreateIROForm.js +1 -1
- package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +2 -2
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +2 -2
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +3 -3
- package/dist/esm/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +4 -4
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +4 -4
- package/dist/esm/src/components/e-commerce/products/AddProductForm.js +3 -3
- package/dist/esm/src/components/e-commerce/products/EditProductForm.js +3 -3
- package/dist/esm/src/components/e-commerce/products/EditStockForm.js +3 -3
- package/dist/esm/src/components/e-commerce/products/ProductCategoryCard.js +10 -2
- package/dist/esm/src/components/e-commerce/products/SingleProduct.js +40 -4
- package/dist/esm/src/components/layout/Footer.js +24 -9
- package/dist/esm/src/components/layout/NavbarV2.js +5 -5
- package/dist/esm/src/components/logistics/dispatcher/DispatcherProfileDisplay.js +10 -1
- package/dist/esm/src/components/logistics/dispatcher/DispatcherProfileEditForm.js +1 -1
- package/dist/esm/src/components/logistics/ipo/AddIPOForm.js +4 -1
- package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +4 -4
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +4 -4
- package/dist/esm/src/components/logistics/report/PreReportsDisplay.js +1 -1
- package/dist/esm/src/components/logistics/report/ReportsDisplay.js +5 -5
- package/dist/esm/src/components/logistics/vendor/AddVendorForm.js +23 -4
- package/dist/esm/src/components/logistics/vendor/EditVendorForm.js +36 -7
- package/dist/esm/src/components/logistics/vendor/VendorDisplay.js +10 -1
- package/dist/esm/src/components/page-builder/ColumnsSection.js +4 -1
- package/dist/esm/src/components/page-builder/IconSection.js +6 -1
- package/dist/esm/src/components/page-builder/LogoBarSection.js +1 -1
- package/dist/esm/src/components/page-builder/PBPersonaliaSection.js +11 -2
- package/dist/esm/src/components/page-builder/PBTextImageSection.js +8 -2
- package/dist/esm/src/components/page-builder/PictureBarSection.js +1 -1
- package/dist/esm/src/components/page-elements/CategoryBlock.js +1 -1
- package/dist/esm/src/components/page-elements/ColumnsSection.js +4 -1
- package/dist/esm/src/components/page-elements/IconSection.js +6 -1
- package/dist/esm/src/components/page-elements/LogoBarSection.js +1 -1
- package/dist/esm/src/components/page-elements/PersonaliaSection.js +19 -4
- package/dist/esm/src/components/page-elements/PictureBarSection.js +1 -1
- package/dist/esm/src/components/page-elements/ProductBlock.js +1 -1
- package/dist/esm/src/components/page-elements/TextImageSection.js +8 -2
- package/dist/esm/src/components/public-information/PublicInformationForm.js +28 -6
- package/dist/esm/src/data/actions/auth-actions.js +6 -3
- package/dist/esm/src/data/services/get-token.js +1 -1
- package/dist/esm/src/data/services/get-user-me-loader.js +1 -1
- package/dist/esm/src/lib/parseNavigation.js +3 -3
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/types/Navigation.d.ts +2 -2
- package/package.json +12 -12
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var e,r=require("../../../../_virtual/
|
|
6
|
+
"use strict";var e,r=require("../../../../_virtual/index3.js"),i=require("./cjs/react-is.production.min.js"),s=require("./cjs/react-is.development.js");exports.__require=function(){return e||(e=1,"production"===process.env.NODE_ENV?r.__module.exports=i.__require():r.__module.exports=s.__require()),r.__module.exports};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var r,e=require("../../_virtual/
|
|
6
|
+
"use strict";var r,e=require("../../_virtual/index4.js"),n=require("buffer");exports.__require=function(){return r||(r=1,function(r,e){var o=n,t=o.Buffer;function u(r,e){for(var n in r)e[n]=r[n]}function f(r,e,n){return t(r,e,n)}t.from&&t.alloc&&t.allocUnsafe&&t.allocUnsafeSlow?r.exports=o:(u(o,e),e.Buffer=f),f.prototype=Object.create(t.prototype),u(t,f),f.from=function(r,e,n){if("number"==typeof r)throw new TypeError("Argument must not be a number");return t(r,e,n)},f.alloc=function(r,e,n){if("number"!=typeof r)throw new TypeError("Argument must be a number");var o=t(r);return void 0!==e?"string"==typeof n?o.fill(e,n):o.fill(e):o.fill(0),o},f.allocUnsafe=function(r){if("number"!=typeof r)throw new TypeError("Argument must be a number");return t(r)},f.allocUnsafeSlow=function(r){if("number"!=typeof r)throw new TypeError("Argument must be a number");return o.SlowBuffer(r)}}(e.__module,e.__module.exports)),e.__module.exports};
|
|
@@ -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"),
|
|
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"),o=require("@mui/material/TextField"),m=require("../../../../node_modules/react-csv/index.js"),h=require("@mui/x-date-pickers"),x=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,z=[...S.map(e=>e.name),...q],[Y,A]=p.useState(f.default(Date.now()).startOf("day")),[M,I]=p.useState("createdAt"),[E,P]=p.useState(f.default(Y).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:{[M]:{$between:[f.default(E).format("YYYY-MM-DD"),f.default(Y).format("YYYY-MM-DD")]}},populate:V.reduce((e,t)=>(e[t.name]={fields:t.attributes},e),{})},{encodeValuesOnly:!0}))},[O,V,E,Y,M]),e.jsx(t,{sx:{width:"100%",p:2},children:e.jsx(h.LocalizationProvider,{dateAdapter:x.AdapterDayjs,children:e.jsxs(r,{container:!0,spacing:2,children:[$&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{size: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,{size: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,{size: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,{size: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),o=u&&V.some(e=>e.name===t.name&&e.attributes.length!==t.attributes.length);return e.jsxs(r,{size:12,children:[e.jsxs(i,{spacing:1,direction:"row",sx:{alignItems:"center"},children:[e.jsx(l,{name:t.name,checked:u,indeterminate:o,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,{size: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,{size: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,{size: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,{size:12,children:e.jsx(a,{variant:"h6",children:"Select date range"})}),e.jsx(r,{size:12,children:e.jsxs(i,{direction:"row",spacing:2,children:[e.jsx(u,{value:M,options:z,multiple:!1,onChange:(e,t)=>I(t),renderInput:t=>e.jsx(o,{...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:Y,label:"end date",onChange:e=>e&&A(e)})]})})]}),e.jsx(r,{size: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(m.reactCsv.CSVLink,{data:L,filename:`${f.default(E).format("DD-MM-YYYY")}_${f.default(Y).format("DD-MM-YYYY")}/${M}_${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";var e=require("react/jsx-runtime"),i=require("react"),r=require("@mui/material/Grid"),t=require("./MediaItem.js"),a=require("./EditMediaDialog.js");exports.MediaGrid=function({mediaArray:n,selected:s=[],handleSelect:d}){const[l,u]=i.useState(!1),[c,m]=i.useState(null),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),i=require("react"),r=require("@mui/material/Grid"),t=require("./MediaItem.js"),a=require("./EditMediaDialog.js");exports.MediaGrid=function({mediaArray:n,selected:s=[],handleSelect:d}){const[l,u]=i.useState(!1),[c,m]=i.useState(null),o=()=>{u(!1),null!==c&&m(null)};return e.jsx(r,{container:!0,spacing:2,sx:{transform:"translateX(-1rem)"},children:n?.length>0&&n.map((n,x)=>e.jsxs(i.Fragment,{children:[e.jsx(a.default,{open:l&&c===x,handleClose:o,data:n}),e.jsx(r,{size:3,children:e.jsx(t.MediaItem,{mediaItem:n,isSelected:-1!==s.findIndex(e=>e.id===n.id),onClick:d?()=>d(n):()=>(async e=>{m(e),u(!0)})(x)})})]},n.id))})};
|
|
@@ -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("react"),i=require("react-dom"),t=require("../../../data/actions/media/uploadMediaAction.js"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/media/uploadMediaAction.js"),s=require("../../StrapiErrors.js"),l=require("../../ZodErrors.js"),a=require("../../SubmitButton.js"),n=require("@mui/material/Stack"),u=require("@mui/material/Typography"),c=require("@mui/material/Box"),d=require("@mui/material/Grid"),o=require("@mui/material/Alert");const m={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadMediaForm=function({reference:p,refID:x,field:j,multiple:h=!0,accept:y="image/*",revalidateCallback:f}){const[g,q]=r.useState(null),[b,E]=r.useState(null),[k,S]=i.useFormState(t.uploadMediaAction,m),v=r.useRef(null);return r.useEffect(()=>{k.data&&f?.()},[k.data]),e.jsx("form",{action:S,children:e.jsxs(n,{spacing:1,sx:{flex:1},children:[p&&e.jsx("input",{type:"text",name:"ref",value:p,style:{display:"none"},readOnly:!0}),x&&e.jsx("input",{type:"text",name:"refId",value:x,style:{display:"none"},readOnly:!0}),j&&e.jsx("input",{type:"text",name:"field",value:j,style:{display:"none"},readOnly:!0}),null!==g?e.jsx(c,{onClick:()=>v.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"},children:void 0===y||"image/*"===y?e.jsx(d,{container:!0,children:g.map((r,i)=>e.jsx(d,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx("img",{src:r.url,alt:r.name,style:{width:"100px"}},i)},i))}):e.jsx(d,{container:!0,children:g.map((r,i)=>e.jsx(d,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx(u,{children:r.name})},i))})}):e.jsx(c,{onClick:()=>v.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(u,{children:["No file",""+(h?"s":"")," selected, click here to start uploading new files"]})}),e.jsxs(n,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between",children:[e.jsx(s.StrapiErrors,{error:k.strapiErrors}),e.jsx(l.ZodErrors,{error:k.zodErrors?.image}),k?.message&&e.jsx(o,{severity:"error",children:k?.message}),e.jsxs(c,{children:[e.jsx("label",{htmlFor:"pictureInput",children:e.jsx("input",{id:"pictureInput",accept:y,multiple:h,type:"file",name:"files",ref:v,onChange:e=>{const r=e.target.files;if(null===r)return;const i=Object.keys(r).map((e,i)=>({url:URL.createObjectURL(r[i]),name:r[i].name}));E(r),q(i)},style:{display:"none"}})}),null!==b&&e.jsx(a.SubmitButton,{text:"upload",loadingText:"loading"})]})]})]})})};
|
|
@@ -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/Grid"),r=require("@mui/material/Paper"),t=require("@mui/material/Stack"),s=require("@mui/material/Button"),n=require("@mui/material/Typography"),l=require("@mui/material/CircularProgress"),c=require("next/link"),a=require("./hooks.js"),h=require("./CartSummary.js");exports.default=function({data:o}){const{shopUrl:
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/material/Grid"),r=require("@mui/material/Paper"),t=require("@mui/material/Stack"),s=require("@mui/material/Button"),n=require("@mui/material/Typography"),l=require("@mui/material/CircularProgress"),c=require("next/link"),a=require("./hooks.js"),h=require("./CartSummary.js");exports.default=function({data:o}){const{shopUrl:d="/shop",checkoutUrl:x="/shop/check-out"}=o,{state:u,isClient:j}=a.useClientSideCart();return j?e.jsxs(i,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"},children:[e.jsx(i,{size:12,children:e.jsx(n,{variant:"h4",align:"center",component:"h1",children:"My cart"})}),e.jsx(i,{size:12,children:e.jsx(r,{sx:{width:"100%",p:2},children:e.jsxs(t,{spacing:2,children:[e.jsx(h.default,{}),u.items.length>0&&e.jsxs(t,{spacing:2,children:[e.jsxs(t,{direction:"row",children:[e.jsx(n,{sx:{width:"10%"}}),e.jsx(n,{sx:{width:"60%",color:"#555"},children:"Total excl. VAT"}),e.jsxs(n,{sx:{width:"30%",color:"#555"},align:"right",children:["€ ",u.totalExVAT.toFixed(2)]})]}),e.jsxs(t,{direction:"row",children:[e.jsx(n,{sx:{width:"10%"}}),e.jsx(n,{sx:{width:"60%",color:"#555"},children:"Total VAT"}),e.jsxs(n,{sx:{width:"30%",color:"#555"},align:"right",children:["€ ",u.totalVAT.toFixed(2)]})]}),e.jsxs(t,{direction:"row",children:[e.jsx(n,{sx:{width:"10%"}}),e.jsx(n,{sx:{width:"60%",color:"#555",fontWeight:600},children:"Total"}),e.jsxs(n,{sx:{width:"30%",color:"#555",fontWeight:600},align:"right",children:["€ ",u.totalInclVAT.toFixed(2)]})]})]}),e.jsxs(t,{spacing:2,justifyContent:"space-between",children:[e.jsx(c,{href:d,legacyBehavior:!0,children:e.jsx(s,{variant:"outlined",children:"Continue shopping"})}),u.items.length>0&&e.jsx(c,{href:x,legacyBehavior:!0,children:e.jsx(s,{variant:"contained",children:"Check Out"})})]})]})})})]}):e.jsx(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("react"),t=require("@mui/material/Box"),a=require("@mui/material/Stack"),i=require("@mui/material/TextField"),s=require("@mui/material/Typography"),n=require("@mui/material"),o=require("../../SubmitButton.js"),c=require("react-dom"),l=require("../../../data/actions/e-commerce/categories/createCategoryAction.js"),u=require("@mui/material/Grid"),d=require("../products/ProductSelector.js"),m=require("../../common/markdown/MarkdownEditor.js"),x=require("../../../context/common/SnackbarContext.js");const g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.AddCategoryForm=function({productNamesArray:j,revalidateCallback:y,sx:h,handleClose:p}){const[q,v]=c.useFormState(l.createCategoryAction,g),{handleAddMessage:C}=x.useSnackbar();return r.useEffect(()=>{q?.message&&(C({message:q.message||"Error creating category",severity:q.severity||"error"}),"success"===q.severity&&(y&&y(),p&&p()))},[q?.message]),r.useEffect(()=>{q?.strapiErrors&&C({message:q.strapiErrors.message||"Error creating category",severity:q.severity||"error"})},[q?.strapiErrors]),e.jsx(t,{sx:[...Array.isArray(h)?h:[h]],children:e.jsx("form",{action:v,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Box"),a=require("@mui/material/Stack"),i=require("@mui/material/TextField"),s=require("@mui/material/Typography"),n=require("@mui/material"),o=require("../../SubmitButton.js"),c=require("react-dom"),l=require("../../../data/actions/e-commerce/categories/createCategoryAction.js"),u=require("@mui/material/Grid"),d=require("../products/ProductSelector.js"),m=require("../../common/markdown/MarkdownEditor.js"),x=require("../../../context/common/SnackbarContext.js");const g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.AddCategoryForm=function({productNamesArray:j,revalidateCallback:y,sx:h,handleClose:p}){const[q,v]=c.useFormState(l.createCategoryAction,g),{handleAddMessage:C}=x.useSnackbar();return r.useEffect(()=>{q?.message&&(C({message:q.message||"Error creating category",severity:q.severity||"error"}),"success"===q.severity&&(y&&y(),p&&p()))},[q?.message]),r.useEffect(()=>{q?.strapiErrors&&C({message:q.strapiErrors.message||"Error creating category",severity:q.severity||"error"})},[q?.strapiErrors]),e.jsx(t,{sx:[...Array.isArray(h)?h:[h]],children:e.jsx("form",{action:v,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{size:12,children:e.jsxs(a,{spacing:2,children:[e.jsx(s,{variant:"h3",component:"h1",children:"Add Category"}),e.jsx(s,{variant:"body2",children:"Create a new category for your products. You can add products to this category later."})]})}),e.jsx(u,{size:12,children:e.jsxs(a,{spacing:2,children:[e.jsx(i,{id:"title",name:"title",label:"Title"}),e.jsx(m.default,{name:"description",label:"Description"})]})}),e.jsxs(u,{size:12,children:[e.jsx(s,{variant:"h6",children:"Products"}),e.jsx(d.default,{productNames:j,currentValue:[]})]}),e.jsx(u,{size:12,children:e.jsxs(a,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(n.Button,{onClick:p,variant:"outlined",children:"Cancel"}),e.jsx(o.SubmitButton,{text:"Create category",loadingText:"Loading...",variant:"contained"})]})})]})})})};
|
|
@@ -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"),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,
|
|
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,z]=n.useFormState(o.updateCategoryAction.bind(null,v),p),{handleAddMessage:w}=m.useSnackbar();return l.useEffect(()=>{A?.message&&(w({message:A.message,severity:A.severity||"error"}),"success"===A.severity&&(j&&j(),h&&h()))},[A?.message]),l.useEffect(()=>{A?.strapiErrors&&w({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:z,children:e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{size: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,{size: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,{size:12,children:[e.jsx(i,{variant:"h6",children:"Products"}),e.jsx(u.default,{productNames:y,currentValue:[...S.map(e=>e.documentId)]})]}),e.jsxs(c,{size: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("@mui/material/Typography"),t=require("@mui/material/Container"),i=require("@mui/material/Stack"),s=require("@mui/material/Grid"),n=require("@mui/material/Paper"),l=require("@mui/material/Box"),a=require("@mui/material/Button"),o=require("@mui/material/Stepper"),c=require("@mui/material/Step"),u=require("@mui/material/StepLabel"),d=require("@mui/material/MobileStepper"),x=require("@mui/material/Alert"),m=require("@mui/material/useMediaQuery"),h=require("@mui/material/styles"),p=require("react"),j=require("next/link"),g=require("next/navigation"),b=require("../../../context/auth/SessionContext.js"),f=require("@mui/icons-material/KeyboardArrowLeft"),v=require("@mui/icons-material/KeyboardArrowRight"),y=require("./Step1.js"),k=require("./Step2.js"),q=require("./Step3.js"),B=require("./Step4.js"),C=require("./Step5.js"),S=require("../../../context/e-commerce/checkout/CheckoutContext.js"),_=require("../../../context/e-commerce/cart/CartContext.js"),
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Typography"),t=require("@mui/material/Container"),i=require("@mui/material/Stack"),s=require("@mui/material/Grid"),n=require("@mui/material/Paper"),l=require("@mui/material/Box"),a=require("@mui/material/Button"),o=require("@mui/material/Stepper"),c=require("@mui/material/Step"),u=require("@mui/material/StepLabel"),d=require("@mui/material/MobileStepper"),x=require("@mui/material/Alert"),m=require("@mui/material/useMediaQuery"),h=require("@mui/material/styles"),p=require("react"),j=require("next/link"),g=require("next/navigation"),b=require("../../../context/auth/SessionContext.js"),f=require("@mui/icons-material/KeyboardArrowLeft"),v=require("@mui/icons-material/KeyboardArrowRight"),y=require("./Step1.js"),k=require("./Step2.js"),q=require("./Step3.js"),B=require("./Step4.js"),C=require("./Step5.js"),S=require("../../../context/e-commerce/checkout/CheckoutContext.js"),_=require("../../../context/e-commerce/cart/CartContext.js"),z=require("../../../lib/isCustomerProfileCompleteEnough.js");exports.default=function({shopUrl:A="/shop"}){const E=h.useTheme(),N=m(E.breakpoints.down("sm")),{state:P,runAllChecks:D,togglePrefersBillingAddress:w,togglePrefersDeliveryAddress:I,setCustomerInternalReference:M}=S.useCheckout(),{dispatch:O}=_.useCart(),{loading:T,error:L,user:R,login:V,logout:$}=b.useSession(),[F,H]=p.useState(0),[K,G]=p.useState(null),[Q,U]=p.useState(null),J=()=>{H(e=>e+1)},W=()=>{H(e=>e-1)},X=g.useSearchParams();p.useEffect(()=>{if(null!==X){const e=X.get("order");e&&G(e);const r=X.get("message"),t=X.get("severity");r&&t&&U({message:r,severity:t})}},[X]),p.useEffect(()=>{K&&(H(4),localStorage.removeItem("cart"),O({type:"SET_ITEMS",payload:[]}))},[K]),p.useEffect(()=>{R&&(console.log("checkout change in user"),D())},[R]);const Y=!P.confirmations.itemsInCart,Z=p.useMemo(()=>null!==R?.customer_profile&&z.default(R?.customer_profile),[R?.customer_profile]),ee=p.useMemo(()=>[{label:"Login or register",children:e.jsx(y.default,{user:R,logout:$}),backButton:e.jsxs(a,{variant:N?"text":"outlined",disabled:0===F,onClick:W,sx:{mr:1},children:["Back",N&&e.jsx(f,{})]}),nextButton:e.jsxs(a,{variant:N?"text":"contained",onClick:J,sx:{ml:1},disabled:(!R||Y)&&"production"===process.env.NODE_ENV,size:N?"small":"large",children:["Next",N&&e.jsx(v,{})]})},{label:"Provide us with your address",children:e.jsx(k.default,{}),backButton:e.jsxs(a,{size:N?"small":"large",onClick:W,disabled:0===F,variant:N?"text":"outlined",children:["Back",N&&e.jsx(f,{})]}),nextButton:e.jsxs(a,{size:N?"small":"large",variant:N?"text":"contained",onClick:()=>{J()},disabled:(!R||Y||!Z)&&"production"===process.env.NODE_ENV,children:["Next",N&&e.jsx(v,{})]})},{label:"Set up mailing options",children:e.jsx(q.default,{user:R,prefersBillingAddress:P.prefersBillingAddress,prefersDeliveryAddress:P.prefersDeliveryAddress,delivery_options:P.delivery_options,payment_options:P.payment_options,togglePrefersBillingAddress:w,togglePrefersDeliveryAddress:I,setCustomerInternalReference:M}),backButton:e.jsxs(a,{size:N?"small":"large",variant:N?"text":"outlined",onClick:W,disabled:0===F,children:["Back",N&&e.jsx(f,{})]}),nextButton:e.jsxs(a,{size:N?"small":"large",variant:N?"text":"contained",onClick:()=>{J()},disabled:(!R||Y||!Z)&&"production"===process.env.NODE_ENV,children:["Next",N&&e.jsx(v,{})]})},{label:"Confirm and make a payment",children:e.jsx(B.default,{customer_reference:P.customer_reference}),nextButton:e.jsx(e.Fragment,{children:e.jsxs(a,{size:N?"small":"large",variant:N?"text":"contained",onClick:()=>{J()},disabled:!0,children:["Next",N&&e.jsx(v,{})]})}),backButton:e.jsxs(a,{size:N?"small":"large",variant:N?"text":"outlined",onClick:W,disabled:0===F,children:["Back",N&&e.jsx(f,{})]})},{label:"Done!",children:e.jsx(C.default,{})}],[R,Y,Z,P,N,F]);return e.jsx(t,{sx:{py:2,minHeight:"100vh"},children:e.jsxs(s,{container:!0,spacing:2,sx:{py:3,minHeight:"60vh"},children:[e.jsx(s,{size:12,children:e.jsx(r,{variant:"h4",align:"center",children:"Check Out"})}),Y&&4!=F&&e.jsx(s,{size:12,children:e.jsxs(x,{severity:"error",children:[e.jsx(r,{variant:"h5",children:"No products in cart"}),e.jsx(r,{variant:"body1",children:"There are no products selected to order, please visit the shop befor continuing"})]})}),null!=Q&&e.jsx(s,{size:12,children:e.jsx(x,{severity:Q.severity,children:e.jsx(r,{variant:"body1",children:Q.message})})}),e.jsx(s,{size:12,children:e.jsxs(l,{width:"100%",children:[e.jsx(n,{sx:{p:2,mb:2,display:{xs:"block",sm:"none"}},children:e.jsxs(i,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(r,{variant:"body2",children:`${F+1} / ${ee.length}`}),e.jsx(r,{children:`${ee[F].label}`})]})}),e.jsx(n,{sx:{px:2,pt:2,mb:2,display:{xs:"none",sm:"block"}},children:e.jsx(o,{activeStep:F,children:ee.map((r,t)=>e.jsx(c,{sx:{pb:"20px"},children:e.jsx(u,{children:r.label})},t))})}),!T&&e.jsxs(e.Fragment,{children:[ee[F].children,e.jsx(n,{sx:{p:2,mt:2,display:{xs:"none",sm:"block"}},children:e.jsxs(i,{direction:"row",spacing:2,children:[ee[F].backButton,e.jsx(a,{variant:"outlined",sx:{ml:1},children:e.jsx(j,{href:A,children:"continue shopping"})}),e.jsx(l,{sx:{flex:"1 1 auto"}}),ee[F].nextButton]})})]})]})}),e.jsx(s,{size:12,children:e.jsx(d,{sx:{display:{xs:"flex",sm:"none"}},variant:"text",steps:ee.length,position:"static",activeStep:F,nextButton:ee[F].nextButton,backButton:ee[F].backButton})})]})})};
|
|
@@ -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("@mui/material/Paper"),s=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/Autocomplete"),t=require("@mui/material/Grid"),a=require("@mui/material/Checkbox"),l=require("@mui/material/TextField"),d=require("../../common/Address.js");exports.default=function({user:o,prefersBillingAddress:c=!0,prefersDeliveryAddress:u=!0,delivery_options:
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Paper"),s=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/Autocomplete"),t=require("@mui/material/Grid"),a=require("@mui/material/Checkbox"),l=require("@mui/material/TextField"),d=require("../../common/Address.js");exports.default=function({user:o,prefersBillingAddress:c=!0,prefersDeliveryAddress:u=!0,delivery_options:p,payment_options:m,togglePrefersBillingAddress:x,togglePrefersDeliveryAddress:h,setCustomerInternalReference:j}){return e.jsx(r,{sx:{p:2},children:e.jsx(s,{spacing:2,children:null!==o&&e.jsx("form",{children:e.jsxs(t,{container:!0,spacing:2,children:[e.jsx(t,{size:{xs:12,md:6},children:e.jsxs(s,{spacing:2,justifyContent:"space-between",children:[e.jsx(i,{variant:"h5",children:"Delivery Options"}),e.jsx(i,{variant:"body1",children:"Your order will be delivered at this address"}),u&&o.customer_profile.delivery_address?e.jsx(d.default,{data:o.customer_profile.delivery_address}):e.jsx(d.default,{data:o.customer_profile.company_address}),null!=o?.customer_profile?.delivery_address&&e.jsxs(s,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(a,{checked:!u,onChange:h}),e.jsx(i,{children:"Use company address instead"})]}),p&&p.length>0&&e.jsx(n,{options:p,renderInput:r=>e.jsx(l,{...r,label:"Delivery Options"})})]})}),e.jsx(t,{size:{xs:12,md:6},children:e.jsxs(s,{spacing:2,justifyContent:"space-between",children:[e.jsx(i,{variant:"h5",children:"Payment Options"}),e.jsx(i,{variant:"body1",children:"Your invoice will be shipped to this address"}),c&&o.customer_profile.billing_address?e.jsx(d.default,{data:o.customer_profile.billing_address}):e.jsx(d.default,{data:o.customer_profile.company_address}),null!=o?.customer_profile?.billing_address&&e.jsxs(s,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(a,{checked:!c,onChange:x}),e.jsx(i,{children:"Use company address instead"})]}),m&&m.length>0&&e.jsx(n,{options:m,renderInput:r=>e.jsx(l,{...r,label:"Payment Options"})})]})}),e.jsx(t,{size:12,children:e.jsxs(s,{spacing:2,children:[e.jsx(i,{variant:"h5",children:"Internal Reference"}),e.jsx(i,{variant:"body1",children:"Optionaly attach an internal reference to this order"}),e.jsx(l,{id:"customer_reference",name:"customer_reference",label:"Internal Reference",onChange:e=>j(e.target.value)})]})})]})})})})};
|
|
@@ -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"),
|
|
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"),l=require("@mui/material/Button"),d=require("@mui/material/Grid"),a=require("@mui/material/Table"),t=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:z,company_address:A,billing_address:S,delivery_address:B,business_credentials:I,editProfileUrl:C="/user/profile/edit",completeEnough:D=!1,orders:L,returns:T}=y;if(!y)return e.jsx(i,{spacing:2,children:e.jsx(n,{children:"Customer profile not available"})});const k=b.usePathname().includes("/user/");return e.jsxs(d,{container:!0,sx:{width:"100%"},spacing:2,children:[e.jsx(d,{size: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:k?"Your Profile":"Customer Profile"}),!k&&y.customer_number&&e.jsxs(n,{variant:"body1",children:["Customer Number: ",e.jsx("strong",{children:y.customer_number})]})]}),k&&e.jsx(e.Fragment,{children:Boolean(D)?e.jsx(i,{direction:"row",justifyContent:"flex-end",children:e.jsx(f.StyledLink,{href:C,target:"_self",children:e.jsx(l,{variant:"contained",children:"edit profile"})})}):e.jsx(v.Alert,{severity:"warning",action:e.jsx(f.StyledLink,{href:C,target:"_self",children:e.jsx(l,{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(d,{size:12,children:[I?e.jsx(g.default,{data:I}):e.jsx(n,{children:"Business credentials not available"}),e.jsx(x,{sx:{pt:2}})]}),e.jsxs(d,{size: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:[z," ",!z&&"N/A"]})})]}),e.jsx(x,{sx:{pt:2}})]}),A?e.jsxs(d,{size:{xs:12,md:4},children:[e.jsx(n,{variant:"h6",children:"Company Address"}),e.jsx(p.default,{data:{...A}})]}):e.jsx(d,{size:{xs:12,md:4},children:e.jsx(n,{children:"Company address not available"})}),B?e.jsxs(d,{size:{xs:12,md:4},children:[e.jsx(n,{variant:"h6",children:"Delivery Address"}),e.jsx(p.default,{data:{...B}})]}):e.jsx(d,{size:{xs:12,md:4},children:e.jsx(n,{children:"Delivery address not available"})}),S?e.jsxs(d,{size:{xs:12,md:4},children:[e.jsx(n,{variant:"h6",children:"Billing Address"}),e.jsx(p.default,{data:{...S}})]}):e.jsx(d,{size:{xs:12,md:4},children:e.jsx(n,{children:"Billing address not available"})}),e.jsxs(d,{size:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Orders"}),e.jsx(r,{children:L&&L.length>0?e.jsxs(a,{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(t,{children:L.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:k?e.jsx(f.StyledLink,{href:`/user/orders?selectedOpoId=${r.documentId}`,target:"_self",children:e.jsx(l,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/opos?selectedOpoId=${r.documentId}`,target:"_self",children:e.jsx(l,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:k?e.jsx(n,{children:"You have no orders."}):e.jsx(n,{children:"This user has no orders."})})})]}),e.jsxs(d,{size:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Returns"}),e.jsx(r,{children:T&&T.length>0?e.jsxs(a,{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(t,{children:T.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:k?e.jsx(f.StyledLink,{href:`/user/returns?selectedIroId=${r.documentId}`,target:"_self",children:e.jsx(l,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/iros?selectedIroId=${r.documentId}`,target:"_self",children:e.jsx(l,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:k?e.jsx(n,{children:"You have no returns."}):e.jsx(n,{children:"This user has no returns."})})})]})]})};
|
|
@@ -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"),s=require("@mui/material/Box"),r=require("@mui/material/Stack"),i=require("@mui/material/Grid"),a=require("@mui/material/Divider"),n=require("@mui/material/TextField"),t=require("@mui/material/Typography"),d=require("@mui/material/Checkbox"),l=require("@mui/material/Button"),o=require("../../common/Address.js"),c=require("../../SubmitButton.js"),m=require("react-dom"),u=require("../../../data/actions/profile-actions.js"),x=require("./BusinessCredentials.js"),j=require("../../../context/auth/SessionContext.js"),h=require("react"),p=require("../../../context/common/SnackbarContext.js");const f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({data:g,sx:v,revalidateCallback:b,handleClose:y}){const{documentId:q,uuid:_,customer_number:C,first_name:S,last_name:A,email:E,phone:k,company_address:
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("@mui/material/Box"),r=require("@mui/material/Stack"),i=require("@mui/material/Grid"),a=require("@mui/material/Divider"),n=require("@mui/material/TextField"),t=require("@mui/material/Typography"),d=require("@mui/material/Checkbox"),l=require("@mui/material/Button"),o=require("../../common/Address.js"),c=require("../../SubmitButton.js"),m=require("react-dom"),u=require("../../../data/actions/profile-actions.js"),x=require("./BusinessCredentials.js"),j=require("../../../context/auth/SessionContext.js"),h=require("react"),p=require("../../../context/common/SnackbarContext.js");const f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({data:g,sx:v,revalidateCallback:b,handleClose:y}){const{documentId:q,uuid:_,customer_number:C,first_name:S,last_name:A,email:E,phone:k,company_address:z,delivery_address:B,billing_address:F,business_credentials:N}=g,P=u.updateCustomerProfileAction.bind(null,q),[w,I]=m.useFormState(P,f),[R,V]=h.useState(null!=B),[D,T]=h.useState(null!=F),{refreshSession:U}=j.useSession(),{handleAddMessage:M}=p.useSnackbar();return h.useEffect(()=>{w?.message&&(M({message:w.message,severity:w.severity||"error"}),"success"===w.severity&&(U(),b&&b(),y&&y()))},[w?.message]),h.useEffect(()=>{w?.strapiErrors&&M({message:w.strapiErrors.message||"Error updating profile",severity:w.severity||"error"})},[w?.strapiErrors]),e.jsx(s,{sx:[...Array.isArray(v)?v:[v]],children:e.jsx("form",{action:I,children:e.jsxs(i,{container:!0,spacing:2,children:[e.jsx(i,{size:12,children:e.jsxs(r,{spacing:2,children:[e.jsx(t,{variant:"h3",component:"h1",children:"Edit Profile"}),e.jsx(t,{variant:"body2",children:"Update your personal and business information"})]})}),e.jsxs(i,{size:12,children:[e.jsx(t,{variant:"h6",children:"Personal Details"}),e.jsx(a,{}),e.jsxs(r,{spacing:2,sx:{mt:2},children:[e.jsx(n,{id:"first_name",name:"first_name",label:"First Name",defaultValue:S}),e.jsx(n,{id:"last_name",name:"last_name",label:"Last Name",defaultValue:A}),e.jsx(n,{id:"email",name:"email",label:"Email",defaultValue:E,disabled:!0}),e.jsx(n,{id:"phone",name:"phone",label:"Phone",defaultValue:k})]})]}),e.jsxs(i,{size:12,children:[e.jsx(t,{variant:"h6",children:"Business Credentials"}),e.jsx(a,{}),e.jsx(s,{sx:{mt:2},children:e.jsx(x.BusinessCredentialsFields,{componentName:"business_credentials",componentReference:"business.credentials",data:N})})]}),e.jsxs(i,{size:12,children:[e.jsx(t,{variant:"h6",children:"Company Address"}),e.jsx(a,{}),e.jsx(s,{sx:{mt:2},children:e.jsx(o.AddressFields,{componentName:"company_address",componentReference:"common.address",data:z})})]}),e.jsxs(i,{size:12,children:[e.jsx(t,{variant:"h6",children:"Delivery Address"}),e.jsx(a,{}),e.jsxs(r,{spacing:2,sx:{mt:2},children:[e.jsxs(r,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(d,{value:R,checked:R,onChange:()=>V(!R)}),e.jsx(t,{children:"Use a different address for delivery"})]}),R&&e.jsx(o.AddressFields,{componentName:"delivery_address",componentReference:"common.address",data:B})]})]}),e.jsxs(i,{size:12,children:[e.jsx(t,{variant:"h6",children:"Billing Address"}),e.jsx(a,{}),e.jsxs(r,{spacing:2,sx:{mt:2},children:[e.jsxs(r,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(d,{value:D,checked:D,onChange:()=>T(!D)}),e.jsx(t,{children:"Use a different address for billing"})]}),D&&e.jsx(o.AddressFields,{componentName:"billing_address",componentReference:"common.address",data:F})]})]}),e.jsx(i,{size:12,children:e.jsxs(r,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[y&&e.jsx(l,{onClick:y,variant:"outlined",children:"Cancel"}),e.jsx(c.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("@mui/material/Stack"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/material/Stack"),s=require("@mui/material/Box"),r=require("@mui/material/Typography"),a=require("@mui/material/Divider"),n=require("@mui/material/Grid"),d=require("@mui/icons-material/Person"),l=require("@mui/icons-material/Email"),t=require("@mui/icons-material/Phone"),c=require("../../common/Address.js"),x=require("./BusinessCredentials.js");exports.default=function({data:o}){if(!o)return e.jsx(i,{spacing:2,children:e.jsx(r,{children:"Customer profile not available"})});const{first_name:j="",last_name:m,email:u,phone:h,company_address:p,billing_address:v,delivery_address:y,business_credentials:b}=o;return e.jsxs(i,{spacing:2,children:[b?e.jsx(x.default,{data:b}):e.jsx(r,{children:"Business credentials not available"}),e.jsx(a,{}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(d,{}),e.jsx(s,{children:e.jsxs(r,{variant:"body1",component:"p",children:[j," ",m]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(l,{}),e.jsx(s,{children:e.jsx(r,{variant:"body1",component:"p",children:u})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(t,{}),e.jsx(s,{children:e.jsx(r,{variant:"body1",component:"p",children:h})})]}),e.jsx(a,{}),e.jsxs(n,{container:!0,children:[p?e.jsxs(n,{size:{xs:12,md:4},children:[e.jsx(r,{variant:"h6",children:"Company Address"}),e.jsx(c.default,{data:{...p}})]}):e.jsx(r,{children:"Company address not available"}),y?e.jsxs(n,{size:{xs:12,md:4},children:[e.jsx(r,{variant:"h6",children:"Delivery Address"}),e.jsx(c.default,{data:{...y}})]}):e.jsx(n,{size:{xs:12,md:4},children:e.jsx(r,{children:"Delivery address not available"})}),v?e.jsxs(n,{size:{xs:12,md:4},children:[e.jsx(r,{variant:"h6",children:"Billing Address"}),e.jsx(c.default,{data:{...v}})]}):e.jsx(n,{size:{xs:12,md:4},children:e.jsx(r,{children:"Billing address not available"})})]})]})};
|
|
@@ -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/Paper"),r=require("@mui/material/Stack"),n=require("@mui/material/Typography"),t=require("@mui/material/Button"),a=require("@mui/material/Divider"),s=require("@mui/material/Grid"),l=require("@mui/material/Alert"),o=require("@mui/icons-material/Person"),c=require("@mui/icons-material/Email"),d=require("@mui/icons-material/Phone"),u=require("../../StyledLink.js"),m=require("next/navigation");exports.default=function({data:x}){const{first_name:h,last_name:j,email:f,phone:p,editProfileUrl:g="/dashboard/admin/user/profile/edit",completeEnough:q=!1}=x,y=m.usePathname().includes("admin/user/");return e.jsx(i,{sx:{p:2},children:e.jsxs(r,{spacing:2,children:[y&&e.jsx(e.Fragment,{children:Boolean(q)?e.jsx(r,{direction:"row",justifyContent:"flex-end",children:e.jsx(u.StyledLink,{href:g,target:"_self",children:e.jsx(t,{variant:"contained",children:"edit profile"})})}):e.jsx(l,{severity:"warning",action:e.jsx(u.StyledLink,{href:g,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(a,{}),e.jsx(s,{container:!0,spacing:2,sx:{width:"100%"},children:e.jsxs(s,{
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/material/Paper"),r=require("@mui/material/Stack"),n=require("@mui/material/Typography"),t=require("@mui/material/Button"),a=require("@mui/material/Divider"),s=require("@mui/material/Grid"),l=require("@mui/material/Alert"),o=require("@mui/icons-material/Person"),c=require("@mui/icons-material/Email"),d=require("@mui/icons-material/Phone"),u=require("../../StyledLink.js"),m=require("next/navigation");exports.default=function({data:x}){const{first_name:h,last_name:j,email:f,phone:p,editProfileUrl:g="/dashboard/admin/user/profile/edit",completeEnough:q=!1}=x,y=m.usePathname().includes("admin/user/");return e.jsx(i,{sx:{p:2},children:e.jsxs(r,{spacing:2,children:[y&&e.jsx(e.Fragment,{children:Boolean(q)?e.jsx(r,{direction:"row",justifyContent:"flex-end",children:e.jsx(u.StyledLink,{href:g,target:"_self",children:e.jsx(t,{variant:"contained",children:"edit profile"})})}):e.jsx(l,{severity:"warning",action:e.jsx(u.StyledLink,{href:g,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(a,{}),e.jsx(s,{container:!0,spacing:2,sx:{width:"100%"},children:e.jsxs(s,{size:{xs:12,md:4},children:[e.jsx(n,{variant:"h6",children:"Personal Information"}),e.jsxs(r,{spacing:1,sx:{mt:2},children:[e.jsxs(r,{direction:"row",alignItems:"center",children:[e.jsx(o,{}),e.jsx(n,{children:`${h} ${j}`})]}),e.jsxs(r,{direction:"row",alignItems:"center",children:[e.jsx(c,{}),e.jsx(n,{children:f})]}),e.jsxs(r,{direction:"row",alignItems:"center",children:[e.jsx(d,{}),e.jsx(n,{children:p})]})]})]})})]})})};
|
|
@@ -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/Stack"),s=require("@mui/material/Grid"),a=require("@mui/material/TextField"),
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Stack"),s=require("@mui/material/Grid"),a=require("@mui/material/TextField"),n=require("@mui/material/Typography"),t=require("@mui/material/Button"),o=require("../../SubmitButton.js"),l=require("react-dom"),c=require("../../../data/actions/e-commerce/enduser/profile-actions.js"),u=require("../../../context/auth/SessionContext.js"),m=require("../../../context/common/SnackbarContext.js"),d=require("react"),x=require("@mui/icons-material/Email"),h=require("@mui/icons-material/Phone"),j=require("@mui/icons-material/Person");const p={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({data:g,sx:f,revalidateCallback:q,handleClose:v}){const{documentId:y,first_name:E,last_name:b,email:S,phone:C}=g,P=c.updateEnduserProfileAction.bind(null,y),[I,k]=l.useFormState(P,p),{handleAddMessage:w}=m.useSnackbar(),{refreshSession:z}=u.useSession();return d.useEffect(()=>{I?.message&&(w({message:I.message,severity:I.severity||"error"}),"success"===I.severity&&(z(),q&&q(),v&&v()))},[I?.message]),d.useEffect(()=>{I?.strapiErrors&&w({message:I.strapiErrors.message||"Error performing action",severity:"error"})},[I?.strapiErrors]),e.jsx(r,{sx:[...Array.isArray(f)?f:[f]],children:e.jsx("form",{action:k,children:e.jsxs(s,{container:!0,spacing:2,children:[e.jsx(s,{size:12,children:e.jsxs(i,{spacing:2,children:[e.jsx(n,{variant:"h3",component:"h1",children:"Edit Profile"}),e.jsx(n,{variant:"body1",children:"Update your profile information"})]})}),e.jsx(s,{size:12,children:e.jsxs(i,{spacing:2,children:[e.jsx(n,{variant:"h6",children:"Personal Information"}),e.jsxs(i,{direction:"row",alignItems:"center",children:[e.jsx(j,{}),e.jsx(n,{children:`${E} ${b}`})]}),e.jsxs(i,{direction:"row",alignItems:"center",children:[e.jsx(x,{}),e.jsx(a,{id:"email",name:"email",label:"Email",type:"email",defaultValue:S})]}),e.jsxs(i,{direction:"row",alignItems:"center",children:[e.jsx(h,{}),e.jsx(a,{id:"phone",name:"phone",label:"Phone",type:"tel",defaultValue:C})]})]})}),e.jsx(s,{size:12,children:e.jsxs(i,{direction:"row",justifyContent:"space-between",spacing:2,alignItems:"center",sx:{mt:2},children:[v&&e.jsx(t,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(o.SubmitButton,{text:"Save Changes",loadingText:"Saving...",variant:"contained"})]})})]})})})};
|
|
@@ -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("react"),s=require("@mui/material/Box"),a=require("@mui/material/Stack"),n=require("@mui/material/Button"),i=require("@mui/material/TextField"),t=require("@mui/material/Typography"),l=require("../../SubmitButton.js"),d=require("react-dom"),c=require("../../../data/actions/e-commerce/invoices/createInvoiceAction.js"),o=require("@mui/material/Grid"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),s=require("@mui/material/Box"),a=require("@mui/material/Stack"),n=require("@mui/material/Button"),i=require("@mui/material/TextField"),t=require("@mui/material/Typography"),l=require("../../SubmitButton.js"),d=require("react-dom"),c=require("../../../data/actions/e-commerce/invoices/createInvoiceAction.js"),o=require("@mui/material/Grid"),u=require("../../common/Address.js"),m=require("@mui/material/Divider"),_=require("../customer/BusinessCredentials.js"),v=require("../customer/CustomerSelector.js"),x=require("../../../data/loaders/e-commerce/getSingleCustomer.js"),h=require("@mui/material/Checkbox"),b=require("./InvoiceItemFields.js"),j=require("./InvoicePDF.js"),g=require("../../../data/loaders/public-information/getPublicInformation.js"),p=require("../../common/markdown/MarkdownEditor.js"),y=require("../../../context/common/SnackbarContext.js");const C={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.CreateInvoiceForm=function({customerLabels:f,revalidateCallback:q,handleClose:k,sx:I}){const[F,A]=d.useFormState(c.createInvoiceAction,C),{handleAddMessage:S}=y.useSnackbar(),[w,E]=r.useState(!1),[N,B]=r.useState(!1),[z,R]=r.useState(null),[P,D]=r.useState(null);return r.useEffect(()=>{F?.message&&(S({message:F.message,severity:F.severity||"error"}),"success"===F.severity&&(q&&q(),k&&k()))},[F?.message]),r.useEffect(()=>{F?.strapiErrors&&S({message:F.strapiErrors.message||"Error creating invoice",severity:F.severity||"error"})},[F?.strapiErrors]),r.useEffect(()=>{!async function(){const e=await g.getPublicInformation();D(r=>({...r,seller_phone:e?.phone,seller_email:e?.email,seller_company_address:e?.address,seller_business_credentials:e?.business_credentials}))}()},[]),e.jsx(s,{sx:[...Array.isArray(I)?I:[I]],children:e.jsx("form",{action:A,children:e.jsxs(o,{container:!0,spacing:2,children:[e.jsx(o,{size:12,children:e.jsxs(a,{spacing:2,children:[e.jsx(t,{variant:"h3",component:"h1",children:"Create Invoice"}),e.jsx(t,{variant:"body2",children:"Create a new invoice by selecting a customer or filling in the details manually"})]})}),e.jsxs(o,{size:12,children:[e.jsx(t,{variant:"h6",children:"Choose a user"}),e.jsx(v.CustomerSelector,{customerLabels:f,onChangeCallback:async e=>{if(0===e.length)return void R(null);const r=await x.getSingleCustomer(e[0]);R(r)}}),e.jsx(t,{variant:"h6",children:"Set user details manually"}),e.jsxs(a,{spacing:2,direction:"row",children:[e.jsx(i,{name:"buyer_first_name",label:"First Name",value:z?.first_name||P?.buyer_first_name||"",onChange:e=>{D(r=>({...r,buyer_first_name:e.target.value}))},disabled:null!==z}),e.jsx(i,{name:"buyer_last_name",label:"Last Name",value:z?.last_name||P?.buyer_last_name||"",onChange:e=>{D(r=>({...r,buyer_last_name:e.target.value}))},disabled:null!==z})]}),e.jsx(t,{variant:"body2"}),e.jsx(t,{variant:"h6",children:"Company Address"}),e.jsx(m,{}),e.jsx(u.AddressFields,{data:z?.company_address,componentName:"buyer_company_address",componentReference:"common.address",onChangeCallback:e=>{D(r=>({...r,buyer_company_address:e}))},disabled:null!==z}),e.jsx(t,{variant:"h6",children:"Delivery Address"}),e.jsx(m,{}),null!==z?e.jsx(e.Fragment,{children:null===z.delivery_address?e.jsx(t,{variant:"body2",children:"No delivery address on file"}):e.jsx(u.AddressFields,{data:z?.delivery_address,componentName:"buyer_delivery_address",componentReference:"common.address",onChangeCallback:e=>{D(r=>({...r,buyer_delivery_address:e}))},disabled:null!==z})}):e.jsxs(e.Fragment,{children:[e.jsxs(a,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(h,{value:N,checked:N,onChange:()=>B(!N)}),e.jsx(t,{children:"Use a different address for delivery"})]}),N&&e.jsx(u.AddressFields,{componentName:"buyer_delivery_address",componentReference:"common.address",onChangeCallback:e=>{D(r=>({...r,buyer_delivery_address:e}))}})]}),e.jsx(t,{variant:"h6",children:"Billing Address"}),e.jsx(m,{}),null!==z?e.jsx(e.Fragment,{children:null===z.billing_address?e.jsx(t,{variant:"body2",children:"No billing address on file"}):e.jsx(u.AddressFields,{data:z?.billing_address,componentName:"buyer_billing_address",componentReference:"common.address",onChangeCallback:e=>{D(r=>({...r,buyer_billing_address:e}))},disabled:null!==z})}):e.jsxs(e.Fragment,{children:[e.jsxs(a,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(h,{value:w,checked:w,onChange:()=>E(!w)}),e.jsx(t,{children:"Use a different address for billing"})]}),w&&e.jsx(u.AddressFields,{componentName:"buyer_billing_address",componentReference:"common.address",onChangeCallback:e=>{D(r=>({...r,buyer_billing_address:e}))}})]}),e.jsx(t,{variant:"h6",children:"Bussiness Credentials"}),e.jsx(m,{}),e.jsx(_.BusinessCredentialsFields,{data:z?.business_credentials,componentName:"buyer_business_credentials",componentReference:"business.credentials",onChangeCallback:e=>{D(r=>({...r,buyer_business_credentials:e}))},disabled:null!==z})]}),e.jsxs(o,{size:12,children:[e.jsx(t,{variant:"h6",children:"Invoice Items"}),e.jsx(b.InvoiceItemFields,{onChangeCallback:e=>{D(r=>r?{...r,items:e.map(e=>({...e,product:"product"in e?e.product:void 0,item_description:"item_description"in e?e.item_description:void 0,price_excl_vat:"price_excl_vat"in e?e.price_excl_vat:0,vat_rate:"vat_rate"in e?e.vat_rate:0,vat:"vat"in e?e.vat:0,price_incl_vat:"price_incl_vat"in e?e.price_incl_vat:0})),VAT_total:e.reduce((e,r)=>e+r.price_excl_vat*(r.vat_rate/100),0),total_excl_vat:e.reduce((e,r)=>e+r.price_excl_vat,0),total_incl_vat:e.reduce((e,r)=>e+r.price_excl_vat+r.price_excl_vat*(r.vat_rate/100),0)}:null)}})]}),e.jsxs(o,{size:12,children:[e.jsx(t,{variant:"h6",children:"Add a Comment"}),e.jsx(p.default,{name:"comments",label:"Comments",onChangeCallback:e=>D(r=>r?{...r,comments:e}:null)})]}),e.jsxs(o,{size:12,children:[e.jsx(t,{variant:"h6",children:"Preview the Invoice"}),null!==P&&e.jsx(j.InvoicePDFViewer,{invoice:P})]})," ",e.jsx(o,{size:12,children:e.jsxs(a,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[k&&e.jsx(n,{onClick:k,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Create Invoice",loadingText:"Creating...",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"),
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),s=require("react-dom"),t=require("../../../context/common/SnackbarContext.js"),i=require("../../../data/actions/e-commerce/iro/createIroAction.js"),n=require("../../SubmitButton.js"),a=require("../customer/CustomerSelector.js"),o=require("./IROItemFields.js"),c=require("@mui/material/Typography"),u=require("@mui/material/Grid"),l=require("@mui/material/Box"),d=require("@mui/material/TextField"),m=require("@mui/material/Checkbox"),h=require("@mui/material/Stack"),x=require("@mui/material/Button");const j={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({sx:p,revalidateCallback:g,handleClose:f,customerLabels:y,productLabels:v}){const[C,q]=r.useState(!1),[b,I]=s.useFormState(i.createIroAction,j),{handleAddMessage:w}=t.useSnackbar();return r.useEffect(()=>{b?.message&&(w({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(g&&g(),f&&f()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&w({message:b.strapiErrors.message||"Error creating return order",severity:b.severity||"error"})},[b?.strapiErrors]),e.jsx(l,{sx:[...Array.isArray(p)?p:[p]],children:e.jsx("form",{action:I,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{size:12,children:e.jsx(h,{spacing:2,children:e.jsx(c,{variant:"h3",component:"h1",children:"Create new return order"})})}),e.jsx(u,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Choose a customer"}),e.jsx(c,{variant:"body2",children:"Select the customer for which you want to create a return order"}),e.jsx(a.CustomerSelector,{customerLabels:y})]})}),e.jsx(u,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Customer reference"}),e.jsx(c,{children:"If the customer utilizes a custom reference for inbound order management it should be left here"}),e.jsx(d,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}})]})}),e.jsxs(u,{size:12,children:[e.jsx(c,{variant:"h6",children:"Choose products that should be in this return order"}),e.jsx(o.IROItemFields,{productsArr:v})]}),e.jsxs(u,{size:12,children:[e.jsx(c,{variant:"h6",children:"Confirm Order"}),e.jsx(c,{children:"Are you sure you want to confirm this return? Confirming this order means you are sure the customer wants to return the products and you are ready to process the return."}),e.jsxs(h,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(m,{value:C,checked:C,onChange:()=>q(!C)}),C&&e.jsx(c,{color:"primary",children:"I am sure I want to confirm this return order"})]}),e.jsx("input",{name:"status",type:"hidden",value:C?"returning":"requested"})]})," ",e.jsx(u,{size:12,children:e.jsxs(h,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[f&&e.jsx(x,{onClick:f,variant:"outlined",children:"Cancel"}),e.jsx(n.SubmitButton,{text:"Confirm",loadingText:"Loading...",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"),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"),
|
|
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"),h=require("@mui/material/Stack"),j=require("@mui/material/Divider");require("next/headers");const m={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),m),[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,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{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(j,{})]})}),e.jsx(l,{size:6,children:e.jsxs(h,{spacing:1,children:[e.jsx(c,{variant:"h5",children:"Details"}),e.jsxs(h,{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(h,{direction:"row",spacing:2,children:e.jsx(c,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(h,{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(h,{direction:"row",spacing:2,children:e.jsx(c,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(h,{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,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h5",children:"Documents"}),e.jsx(x,{sx:{p:2},children:e.jsx(h,{spacing:1,children:"enduser"===y&&e.jsx(e.Fragment,{})})})]})}),p?.notes?.length>0&&e.jsx(l,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:p.notes}),e.jsx(j,{})]})}),e.jsx(l,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(c,{variant:"h5",children:"Items"}),e.jsx(j,{}),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(h,{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"),g=require("@mui/material"),j=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),b=require("@mui/material/DialogContentText"),v=require("@mui/material/DialogTitle"),f=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?.documentId||"",ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[h,j]=r.useState([]);return r.useEffect(()=>{i&&j((e=>e.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:e.product,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))(i))},[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(f.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(g.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(g.Divider,{})]}))})]})})},S=({open:t,onClose:i,items:s,formState:u,submitCallback:l})=>{const[d,x]=r.useState(!0);return e.jsxs(j,{open:t,onClose:i,children:[e.jsx(v,{children:"Confirm RMA"}),e.jsxs(y,{children:[e.jsx(b,{children:"Summary of items to be returned:"}),e.jsx(g.List,{children:s.map((r,t)=>e.jsx(g.ListItem,{children:`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(p,{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:g}){const[j,p]=t.useFormState(s.requestRmaAction,q),{handleAddMessage:y}=i.useSnackbar(),[b,v]=r.useState(!1),[f,C]=r.useState([]),[k,I]=r.useState([]);return r.useEffect(()=>{j?.message&&(y({message:j.message,severity:j.severity||"error"}),"success"===j.severity&&(c&&c(),g&&g()))},[j?.message]),r.useEffect(()=>{j?.strapiErrors&&y({message:j.strapiErrors.message||"Error requesting RMA",severity:j.severity||"error"})},[j?.strapiErrors]),e.jsx(l,{sx:[...Array.isArray(d)?d:[d]],children:e.jsx("form",{action:p,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{
|
|
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"),g=require("@mui/material"),j=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),b=require("@mui/material/DialogContentText"),v=require("@mui/material/DialogTitle"),f=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?.documentId||"",ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[h,j]=r.useState([]);return r.useEffect(()=>{i&&j((e=>e.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:e.product,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))(i))},[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(f.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(g.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(g.Divider,{})]}))})]})})},S=({open:t,onClose:i,items:s,formState:u,submitCallback:l})=>{const[d,x]=r.useState(!0);return e.jsxs(j,{open:t,onClose:i,children:[e.jsx(v,{children:"Confirm RMA"}),e.jsxs(y,{children:[e.jsx(b,{children:"Summary of items to be returned:"}),e.jsx(g.List,{children:s.map((r,t)=>e.jsx(g.ListItem,{children:`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(p,{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:g}){const[j,p]=t.useFormState(s.requestRmaAction,q),{handleAddMessage:y}=i.useSnackbar(),[b,v]=r.useState(!1),[f,C]=r.useState([]),[k,I]=r.useState([]);return r.useEffect(()=>{j?.message&&(y({message:j.message,severity:j.severity||"error"}),"success"===j.severity&&(c&&c(),g&&g()))},[j?.message]),r.useEffect(()=>{j?.strapiErrors&&y({message:j.strapiErrors.message||"Error requesting RMA",severity:j.severity||"error"})},[j?.strapiErrors]),e.jsx(l,{sx:[...Array.isArray(d)?d:[d]],children:e.jsx("form",{action:p,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{size:12,children:e.jsx(o,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:n.documentId}),e.jsx(u,{size: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,{size:12,children:n.opo_items?e.jsx(x,{spacing:1,children:n.opo_items&&e.jsx(_,{items:n.opo_items,itemsToReturn:f,setItemsToReturn:C,selectedItems:k,setSelectedItems:I})}):e.jsx(o,{variant:"body1",children:"No items"})}),e.jsx(S,{formState:j,open:b,items:f.filter(e=>e.returned_quantity>0),onClose:()=>v(!b),submitCallback:()=>{console.log("submit callback");const e=document.querySelector("form");p(e?new FormData(e):new FormData),v(!b)}}),e.jsxs(u,{size:12,children:[e.jsx(m,{onClick:()=>{console.log(j),v(!b)},disabled:0===k.length||0===k.reduce((e,r)=>e+f[r].returned_quantity,0),children:"Request RMA"}),null!==j?.strapiErrors&&e.jsx(a.StrapiErrors,{error:j?.strapiErrors}),j?.message&&e.jsx(h,{severity:"error",children:j?.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("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"})]})]})]})})]})})};
|
|
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 z({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 E({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,O]=r.useState(d.iro_items?d.iro_items:[]),[M,B]=r.useState(!1),[L,N]=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,O(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,O(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,O(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&&O(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,{size: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,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size: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,{size: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:()=>B(!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:()=>N(!0),children:"Cancel order"}),e.jsx(z,{open:M,handleClose:()=>B(!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(E,{open:L,handleClose:()=>N(!1),orderID:d.documentId,revalidateCallback:m})]})})}),e.jsx(j,{size: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,{size: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,{size: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"})]})]})]})})]})})};
|