umwd-components 0.1.718 → 0.1.720

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
  2. package/dist/cjs/src/components/e-commerce/customer/CustomerSelector.js +1 -1
  3. package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
  4. package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
  5. package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
  6. package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  7. package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
  8. package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
  9. package/dist/cjs/src/data/services/get-user-me-loader.js +1 -1
  10. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  11. package/dist/esm/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
  12. package/dist/esm/src/components/e-commerce/customer/CustomerSelector.js +4 -4
  13. package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +1 -1
  14. package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +7 -7
  15. package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +5 -5
  16. package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +12 -11
  17. package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +6 -6
  18. package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +7 -6
  19. package/dist/esm/src/data/loaders/e-commerce/getSingleCustomer.js +2 -2
  20. package/dist/esm/src/data/loaders/e-commerce/getSingleOpo.js +2 -2
  21. package/dist/esm/src/data/loaders/e-commerce/iros/getSingleIro.js +2 -2
  22. package/dist/esm/src/data/loaders/logistics/getSingleIpo.js +2 -2
  23. package/dist/esm/src/data/services/get-user-me-loader.js +41 -40
  24. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  25. package/dist/esm/types/data/loaders/e-commerce/getSingleCustomer.d.ts +1 -1
  26. package/dist/esm/types/data/loaders/e-commerce/getSingleOpo.d.ts +1 -1
  27. package/dist/esm/types/data/loaders/e-commerce/iros/getSingleIro.d.ts +1 -1
  28. package/dist/esm/types/data/loaders/logistics/getSingleIpo.d.ts +1 -1
  29. package/dist/esm/types/types/e-commerce/customer/types.d.ts +3 -2
  30. package/dist/esm/types/types/e-commerce/iro/types.d.ts +1 -1
  31. package/dist/esm/types/types/e-commerce/opo/types.d.ts +1 -1
  32. package/dist/esm/types/types/logistics/Ipo.d.ts +1 -1
  33. package/package.json +1 -1
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Paper"),i=require("@mui/material/Stack"),s=require("@mui/material/Box"),n=require("@mui/material/Typography"),a=require("@mui/material/Button"),t=require("@mui/material/Grid"),l=require("@mui/material/Table"),d=require("@mui/material/TableBody"),c=require("@mui/material/TableCell"),h=require("@mui/material/TableHead"),o=require("@mui/material/TableRow"),x=require("@mui/material/Divider"),j=require("@mui/icons-material/Person"),u=require("@mui/icons-material/Email"),m=require("@mui/icons-material/Phone"),p=require("../../common/Address.js"),g=require("./BusinessCredentials.js"),f=require("../../StyledLink.js"),v=require("@mui/material"),b=require("next/navigation");exports.default=function({data:y}){const{first_name:_,last_name:q,email:w,phone:A,company_address:S,billing_address:B,delivery_address:C,business_credentials:D,editProfileUrl:L="/user/profile/edit",completeEnough:T=!1,orders:k,returns:P}=y;if(!y)return e.jsx(i,{spacing:2,children:e.jsx(n,{children:"Customer profile not available"})});const N=b.usePathname().includes("/user/");return e.jsxs(t,{container:!0,sx:{width:"100%"},spacing:2,children:[e.jsx(t,{item:!0,xs:12,children:e.jsxs(i,{spacing:2,children:[e.jsxs(i,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(i,{spacing:2,sx:{width:"100%"},children:[e.jsx(n,{variant:"h3",component:"h1",children:N?"Your Profile":"Customer Profile"}),!N&&y.customer_number&&e.jsxs(n,{variant:"body1",children:["Customer Number: ",e.jsx("strong",{children:y.customer_number})]})]}),N&&e.jsx(e.Fragment,{children:Boolean(T)?e.jsx(i,{direction:"row",justifyContent:"flex-end",children:e.jsx(f.StyledLink,{href:L,target:"_self",children:e.jsx(a,{variant:"contained",children:"edit profile"})})}):e.jsx(v.Alert,{severity:"warning",action:e.jsx(f.StyledLink,{href:L,target:"_self",children:e.jsx(a,{variant:"contained",children:"complete profile"})}),children:"After completion of your profile you can enjoy all the benefits of your services."})})]}),e.jsx(x,{})]})}),e.jsxs(t,{item:!0,xs:12,children:[D?e.jsx(g.default,{data:D}):e.jsx(n,{children:"Business credentials not available"}),e.jsx(x,{sx:{pt:2}})]}),e.jsxs(t,{item:!0,xs:12,children:[e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(j,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[_," ",q," ",!_&&!q&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(u,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[w," ",!w&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(m,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[A," ",!A&&"N/A"]})})]}),e.jsx(x,{sx:{pt:2}})]}),S?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Company Address"}),e.jsx(p.default,{data:{...S}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Company address not available"})}),C?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Delivery Address"}),e.jsx(p.default,{data:{...C}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Delivery address not available"})}),B?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Billing Address"}),e.jsx(p.default,{data:{...B}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Billing address not available"})}),e.jsxs(t,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Orders"}),e.jsx(r,{children:k&&k.data&&k.data.length>0?e.jsxs(l,{children:[e.jsx(h,{children:e.jsxs(o,{children:[e.jsx(c,{children:"Order Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Total"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(d,{children:k.data.map((r,i)=>e.jsxs(o,{children:[e.jsx(c,{children:r.opo_number}),e.jsx(c,{children:new Date(r.order_date).toLocaleDateString()}),e.jsx(c,{children:r.status}),e.jsxs(c,{align:"right",children:[r.total_incl_vat," ",r.order_currency]}),e.jsx(c,{align:"right",children:N?e.jsx(f.StyledLink,{href:`/user/orders?selectedOpoId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/opos?selectedOpoId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:N?e.jsx(n,{children:"You have no orders."}):e.jsx(n,{children:"This user has no orders."})})})]}),e.jsxs(t,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Returns"}),e.jsx(r,{children:P&&P.data&&P.data.length>0?e.jsxs(l,{children:[e.jsx(h,{children:e.jsxs(o,{children:[e.jsx(c,{children:"Return Number"}),e.jsx(c,{children:"RMA Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(d,{children:P.data.map((r,i)=>e.jsxs(o,{children:[e.jsx(c,{children:r.return_number}),e.jsx(c,{children:r.rma_number}),e.jsx(c,{children:new Date(r.return_date).toLocaleDateString()}),e.jsx(c,{children:r.status}),e.jsx(c,{align:"right",children:N?e.jsx(f.StyledLink,{href:`/user/returns?selectedIroId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/iros?selectedIroId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:N?e.jsx(n,{children:"You have no returns."}):e.jsx(n,{children:"This user has no returns."})})})]})]})};
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Paper"),i=require("@mui/material/Stack"),s=require("@mui/material/Box"),n=require("@mui/material/Typography"),a=require("@mui/material/Button"),t=require("@mui/material/Grid"),l=require("@mui/material/Table"),d=require("@mui/material/TableBody"),c=require("@mui/material/TableCell"),h=require("@mui/material/TableHead"),o=require("@mui/material/TableRow"),x=require("@mui/material/Divider"),j=require("@mui/icons-material/Person"),u=require("@mui/icons-material/Email"),m=require("@mui/icons-material/Phone"),p=require("../../common/Address.js"),g=require("./BusinessCredentials.js"),f=require("../../StyledLink.js"),v=require("@mui/material"),b=require("next/navigation");exports.default=function({data:y}){const{first_name:_,last_name:q,email:w,phone:A,company_address:S,billing_address:B,delivery_address:C,business_credentials:D,editProfileUrl:L="/user/profile/edit",completeEnough:T=!1,orders:k,returns:P}=y;if(!y)return e.jsx(i,{spacing:2,children:e.jsx(n,{children:"Customer profile not available"})});const N=b.usePathname().includes("/user/");return e.jsxs(t,{container:!0,sx:{width:"100%"},spacing:2,children:[e.jsx(t,{item:!0,xs:12,children:e.jsxs(i,{spacing:2,children:[e.jsxs(i,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(i,{spacing:2,sx:{width:"100%"},children:[e.jsx(n,{variant:"h3",component:"h1",children:N?"Your Profile":"Customer Profile"}),!N&&y.customer_number&&e.jsxs(n,{variant:"body1",children:["Customer Number: ",e.jsx("strong",{children:y.customer_number})]})]}),N&&e.jsx(e.Fragment,{children:Boolean(T)?e.jsx(i,{direction:"row",justifyContent:"flex-end",children:e.jsx(f.StyledLink,{href:L,target:"_self",children:e.jsx(a,{variant:"contained",children:"edit profile"})})}):e.jsx(v.Alert,{severity:"warning",action:e.jsx(f.StyledLink,{href:L,target:"_self",children:e.jsx(a,{variant:"contained",children:"complete profile"})}),children:"After completion of your profile you can enjoy all the benefits of your services."})})]}),e.jsx(x,{})]})}),e.jsxs(t,{item:!0,xs:12,children:[D?e.jsx(g.default,{data:D}):e.jsx(n,{children:"Business credentials not available"}),e.jsx(x,{sx:{pt:2}})]}),e.jsxs(t,{item:!0,xs:12,children:[e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(j,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[_," ",q," ",!_&&!q&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(u,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[w," ",!w&&"N/A"]})})]}),e.jsxs(i,{spacing:2,direction:"row",children:[e.jsx(m,{}),e.jsx(s,{children:e.jsxs(n,{variant:"body1",component:"p",children:[A," ",!A&&"N/A"]})})]}),e.jsx(x,{sx:{pt:2}})]}),S?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Company Address"}),e.jsx(p.default,{data:{...S}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Company address not available"})}),C?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Delivery Address"}),e.jsx(p.default,{data:{...C}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Delivery address not available"})}),B?e.jsxs(t,{item:!0,xs:12,md:4,children:[e.jsx(n,{variant:"h6",children:"Billing Address"}),e.jsx(p.default,{data:{...B}})]}):e.jsx(t,{item:!0,xs:12,md:4,children:e.jsx(n,{children:"Billing address not available"})}),e.jsxs(t,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Orders"}),e.jsx(r,{children:k&&k.data&&k.data.length>0?e.jsxs(l,{children:[e.jsx(h,{children:e.jsxs(o,{children:[e.jsx(c,{children:"Order Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Total"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(d,{children:k.data.map((r,i)=>e.jsxs(o,{children:[e.jsx(c,{children:r.opo_number}),e.jsx(c,{children:new Date(r.order_date).toLocaleDateString()}),e.jsx(c,{children:r.internal_status}),e.jsxs(c,{align:"right",children:[r.total_incl_vat," ",r.order_currency]}),e.jsx(c,{align:"right",children:N?e.jsx(f.StyledLink,{href:`/user/orders?selectedOpoId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/opos?selectedOpoId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:N?e.jsx(n,{children:"You have no orders."}):e.jsx(n,{children:"This user has no orders."})})})]}),e.jsxs(t,{item:!0,xs:12,children:[e.jsx(n,{variant:"h6",gutterBottom:!0,children:"Returns"}),e.jsx(r,{children:P&&P.data&&P.data.length>0?e.jsxs(l,{children:[e.jsx(h,{children:e.jsxs(o,{children:[e.jsx(c,{children:"Return Number"}),e.jsx(c,{children:"RMA Number"}),e.jsx(c,{children:"Date"}),e.jsx(c,{children:"Status"}),e.jsx(c,{align:"right",children:"Actions"})]})}),e.jsx(d,{children:P.data.map((r,i)=>e.jsxs(o,{children:[e.jsx(c,{children:r.return_number}),e.jsx(c,{children:r.rma_number}),e.jsx(c,{children:new Date(r.return_date).toLocaleDateString()}),e.jsx(c,{children:r.internal_status}),e.jsx(c,{align:"right",children:N?e.jsx(f.StyledLink,{href:`/user/returns?selectedIroId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})}):e.jsx(f.StyledLink,{href:`/dashboard/admin/e-commerce/iros?selectedIroId=${r.id}`,target:"_self",children:e.jsx(a,{variant:"contained",size:"small",children:"View"})})})]},i))})]}):e.jsx(s,{p:2,children:N?e.jsx(n,{children:"You have no returns."}):e.jsx(n,{children:"This user has no returns."})})})]})]})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Autocomplete"),i=require("@mui/material/TextField");const l=({customerLabels:l,currentValue:u,multiple:n=!1,onChangeCallback:s})=>{const[a,o]=t.useState(u||[]);return e.jsxs(e.Fragment,{children:[e.jsx(r,{multiple:n,options:l,getOptionLabel:e=>e.title,filterSelectedOptions:!0,onChange:(e,t,r,i)=>{if(Array.isArray(t)){const e=t.map(e=>e.id);o(e),s&&s(e)}else t?(o([t.id]),s&&s([t.id])):(o([]),s&&s([]))},renderOption:(e,r)=>t.createElement("li",{...e,key:r.id},r.title),renderInput:t=>e.jsx(i,{...t,label:"Customer"}),value:l.filter(e=>a.includes(e.id))[0]||null}),e.jsx("input",{type:"hidden",name:"customer",value:n?JSON.stringify(a)||"":a[0]||""})]})};exports.CustomerSelector=l,exports.default=l;
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Autocomplete"),l=require("@mui/material/TextField");const i=({customerLabels:i,currentValue:u,multiple:n=!1,onChangeCallback:s})=>{const[a,o]=t.useState(u||[]);return e.jsxs(e.Fragment,{children:[e.jsx(r,{multiple:n,options:i,getOptionLabel:e=>e.title,filterSelectedOptions:!0,onChange:(e,t,r,l)=>{if(Array.isArray(t)){const e=t.map(e=>e.documentId);o(e),s&&s(e)}else t?(o([t.documentId]),s&&s([t.documentId])):(o([]),s&&s([]))},renderOption:(e,r)=>t.createElement("li",{...e,key:r.id},r.title),renderInput:t=>e.jsx(l,{...t,label:"Customer"}),value:i.filter(e=>a.includes(e.documentId))[0]||null}),e.jsx("input",{type:"hidden",name:"customer",value:n?JSON.stringify(a)||"":a[0]||""})]})};exports.CustomerSelector=i,exports.default=i;
@@ -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"),a=require("../../logistics/note/NotesDisplay.js"),s=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 l=require("@mui/material/Typography");require("@mui/material/Button");var c=require("@mui/material/Grid"),u=require("@mui/material/Box"),x=require("@mui/material/Paper"),m=require("@mui/material/Stack"),h=require("@mui/material/Divider");require("next/headers");const j={zodErrors:null,strapiErrors:null,data:null,message:null};exports.default=function({data:p,sx:g,revalidateCallback:v,handleClose:y,role:q}){const[b,_]=i.useFormState(t.updateIroAction,j),[w,f]=r.useState(p.iro_items.data?p.iro_items.data:[]),[S,D]=r.useState(!1);return e.jsx(u,{sx:[...Array.isArray(g)?g:[g]],children:e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsxs(m,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(m,{spacing:2,children:[e.jsx(l,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(l,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(s.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:v})]}),e.jsx(h,{})]})}),e.jsx(c,{item:!0,xs:6,children:e.jsxs(m,{spacing:1,children:[e.jsx(l,{variant:"h5",children:"Details"}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(l,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(l,{variant:"body2",children:p.return_number})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(l,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(l,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(l,{variant:"body2",children:p.return_date})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(l,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(l,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(l,{variant:"body2",width:"250px",children:p.status})]})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(l,{variant:"h5",children:"Documents"}),e.jsx(x,{sx:{p:2},children:e.jsx(m,{spacing:1,children:"enduser"===q&&e.jsx(e.Fragment,{})})})]})}),p?.notes?.data?.length>0&&e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(l,{variant:"h5",children:"Notes"}),e.jsx(a.default,{notes:p.notes.data}),e.jsx(h,{})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:1,children:[e.jsx(l,{variant:"h5",children:"Items"}),e.jsx(h,{}),e.jsxs("form",{action:_,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),p?.iro_items?.data&&p.iro_items.data.map((r,i)=>(console.log("item",r),e.jsx(x,{sx:{p:2,mb:2}},i))),e.jsx(x,{sx:{p:2},children:e.jsxs(m,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(d.SubmitButton,{text:"Update items",loadingText:"Loading..."}),e.jsx(n.StrapiErrors,{error:b?.strapiErrors}),b?.message&&e.jsx(o,{severity:"error",children:b?.message})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(w))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),a=require("../../logistics/note/NotesDisplay.js"),s=require("../../logistics/note/NoteTakingComponent.js"),n=require("../../StrapiErrors.js"),d=require("../../SubmitButton.js"),l=require("@mui/material/Alert");require("@mui/material/Dialog"),require("@mui/material/DialogActions"),require("@mui/material/DialogContent"),require("@mui/material/DialogTitle");var o=require("@mui/material/Typography");require("@mui/material/Button");var c=require("@mui/material/Grid"),u=require("@mui/material/Box"),x=require("@mui/material/Paper"),m=require("@mui/material/Stack"),h=require("@mui/material/Divider");require("next/headers");const j={zodErrors:null,strapiErrors:null,data:null,message:null};exports.default=function({data:p,sx:g,revalidateCallback:v,handleClose:y,role:q}){const[b,_]=i.useFormState(t.updateIroAction,j),[w,f]=r.useState(p.iro_items.data?p.iro_items.data:[]),[S,D]=r.useState(!1);return e.jsx(u,{sx:[...Array.isArray(g)?g:[g]],children:e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsxs(m,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(m,{spacing:2,children:[e.jsx(o,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(o,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(s.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:v})]}),e.jsx(h,{})]})}),e.jsx(c,{item:!0,xs:6,children:e.jsxs(m,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Details"}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(o,{variant:"body2",children:p.return_number})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(o,{variant:"body2",children:p.return_date})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(o,{variant:"body2",width:"250px",children:p.internal_status})]})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Documents"}),e.jsx(x,{sx:{p:2},children:e.jsx(m,{spacing:1,children:"enduser"===q&&e.jsx(e.Fragment,{})})})]})}),p?.notes?.data?.length>0&&e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Notes"}),e.jsx(a.default,{notes:p.notes.data}),e.jsx(h,{})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Items"}),e.jsx(h,{}),e.jsxs("form",{action:_,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),p?.iro_items?.data&&p.iro_items.data.map((r,i)=>(console.log("item",r),e.jsx(x,{sx:{p:2,mb:2}},i))),e.jsx(x,{sx:{p:2},children:e.jsxs(m,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(d.SubmitButton,{text:"Update items",loadingText:"Loading..."}),e.jsx(n.StrapiErrors,{error:b?.strapiErrors}),b?.message&&e.jsx(l,{severity:"error",children:b?.message})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(w))})]})]})})]})})};
@@ -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"),a=require("./IroItemDisplay.js"),s=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"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),_=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:a,iro:s}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&s?.iro_items?.data?.length>0&&(async()=>{o(!0);const e=D.default.stringify({filters:{product_number:{$in:s.iro_items.data.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.id,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=s.iro_items.data.map((e,n)=>{const a=e.product,s=r.find(e=>e.product_number===a?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(s&&s.price){l=s.price.price||0,o=s.price.price_incl_vat||0,c=s.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}});a({customer_internal_reference:s.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,s]),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(y,{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(y,{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=>a({...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=>a({...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=>a({...n,total_incl_vat:parseFloat(e.target.value)})})]}),s?.iro_items?.data?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C.DialogContentText,{variant:"h5",children:"Items"}),s.iro_items.data.map((r,t)=>e.jsxs(y,{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)},a({...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)},a({...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)},a({...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)},a({...n,lines:r})}})]},r.id))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{_.confirmationService("iros",[s.id],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:a,openOverwritesDialog:s}){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(y,{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 s?(s(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await _.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),a&&a(),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:a}){const[s,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(y,{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:s,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(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("iros",n,s),j({message:"Return order cancelled successfully",severity:"success"}),a&&a(),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:_}){const[b,F]=t.useFormState(i.updateIroAction,P),[D,M]=r.useState(d.iro_items.data?d.iro_items.data:[]),[B,L]=r.useState(!1),[N,z]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...D],n=i.findIndex(e=>e.id===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.id===r),n=[...t[i]?.reports?.data||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:{data:[]}}),t[i].reports.data=n,M(t)},K=(e,r)=>{const t=[...D],i=t.findIndex(r=>r.id===e),n=t[i]?.reports?.data||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const l=[...a,...s];t[i].reports.data=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?.data&&M(d.iro_items.data?d.iro_items.data:[])},[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(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),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(y,{spacing:2,children:[e.jsxs(y,{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(y,{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(y,{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(y,{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(y,{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(y,{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.status})]})]})})}),("requested"===d.status||"finalising_process"===d.status)&&"enduser"===_&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.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.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.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.id,currentStatus:d.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.id,revalidateCallback:m})]})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(y,{spacing:1})})]})}),d?.notes?.data?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:d.notes.data}),e.jsx(f,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(y,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(y,{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.status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:F,children:[e.jsx("input",{name:"id",type:"hidden",value:d.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.status||"cancelled"===d.status||"done"===d.status?e.jsx(a.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(y,{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"),a=require("./IroItemDisplay.js"),s=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:a,iro:s}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&s?.iro_items?.data?.length>0&&(async()=>{o(!0);const e=D.default.stringify({filters:{product_number:{$in:s.iro_items.data.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.id,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=s.iro_items.data.map((e,n)=>{const a=e.product,s=r.find(e=>e.product_number===a?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(s&&s.price){l=s.price.price||0,o=s.price.price_incl_vat||0,c=s.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}});a({customer_internal_reference:s.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,s]),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=>a({...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=>a({...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=>a({...n,total_incl_vat:parseFloat(e.target.value)})})]}),s?.iro_items?.data?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C.DialogContentText,{variant:"h5",children:"Items"}),s.iro_items.data.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)},a({...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)},a({...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)},a({...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)},a({...n,lines:r})}})]},r.id))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{f.confirmationService("iros",[s.id],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:a,openOverwritesDialog:s}){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 s?(s(),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"}),a&&a(),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:a}){const[s,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:s,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(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("iros",n,s),j({message:"Return order cancelled successfully",severity:"success"}),a&&a(),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(i.updateIroAction,P),[D,M]=r.useState(d.iro_items.data?d.iro_items.data:[]),[B,L]=r.useState(!1),[N,z]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...D],n=i.findIndex(e=>e.id===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.id===r),n=[...t[i]?.reports?.data||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:{data:[]}}),t[i].reports.data=n,M(t)},K=(e,r)=>{const t=[...D],i=t.findIndex(r=>r.id===e),n=t[i]?.reports?.data||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const l=[...a,...s];t[i].reports.data=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?.data&&M(d.iro_items.data?d.iro_items.data:[])},[d]),e.jsx(v,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.rma_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_date})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(T,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(A.IroStatusIndicator,{status:d.internal_status})]})]})})}),("requested"===d.internal_status||"finalising_process"===d.internal_status)&&"enduser"===f&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===d.internal_status&&e.jsx(p,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(p,{variant:"contained",color:"error",onClick:()=>z(!0),children:"Cancel order"}),e.jsx(E,{open:B,handleClose:()=>L(!1),orderID:d.id,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.id,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?.data?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:d.notes.data}),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",{name:"id",type:"hidden",value:d.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.internal_status||"cancelled"===d.internal_status||"done"===d.internal_status?e.jsx(a.default,{item:r,index:t,image:r?.product?.image}):e.jsx(n.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:G})},t)),e.jsxs(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[x&&e.jsx(p,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(o.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),a=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),n=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),p=require("@mui/material/Dialog"),m=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),j=require("@mui/material/Typography"),y=require("@mui/material/Button"),v=require("@mui/material/Grid"),g=require("@mui/material/Box"),f=require("@mui/material/Paper"),b=require("@mui/material/Stack"),q=require("@mui/material/Divider"),_=require("../../../data/services/common/confirmation-service.js"),C=require("../../../context/common/SnackbarContext.js");const w={zodErrors:null,strapiErrors:null,message:null};function k({open:i,handleClose:r,orderID:a,currentStatus:t,revalidateCallback:n}){return e.jsxs(p,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{children:"Are you sure you want to confirm this order?"}),e.jsxs(j,{children:["Current status: ",t]})]})}),e.jsxs(m,{children:[e.jsx(y,{variant:"contained",onClick:e=>{_.confirmationService("opos",[a]),n&&n()},children:"Confirm"}),e.jsx(y,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:p,sx:m,revalidateCallback:x,handleClose:h,role:_}){const[D,O]=r.useFormState((e,i)=>a.updateOpoAction(p.id,e,i),w),{handleAddMessage:S}=C.useSnackbar(),[E,A]=i.useState(p.opo_items.data?p.opo_items.data:[]),[B,N]=i.useState(!1),F=(e,i,r)=>{const a=[...E],t=a.findIndex(e=>e.id===i);a[t][r]=e,A(a)};return i.useEffect(()=>{p.opo_items?.data&&A(p.opo_items.data)},[p]),i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(x&&x(),h&&h()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error updating OPO",severity:D.severity||"error"})},[D?.strapiErrors]),e.jsx(g,{sx:[...Array.isArray(m)?m:[m]],children:e.jsxs(v,{container:!0,spacing:2,children:[e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h3",component:"h1",children:"Manage Outbound Purchase Order"}),e.jsx(j,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:p.id,__type:"api::e-commerce.opo"}],revalidateCallback:x})]}),e.jsx(q,{})]})}),e.jsx(v,{item:!0,xs:6,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Details"}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(j,{variant:"body2",children:p.opo_number})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(j,{variant:"body2",children:p.customer_reference})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(j,{variant:"body2",children:p.order_date})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(j,{variant:"body2",children:p.customer?.business_credentials?.company_name})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(j,{variant:"body2",width:"250px",children:p.status})]}),("placed"===p.status||"external_shipping_process"===p.status)&&"enduser"===_&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"contained",color:"primary",onClick:()=>N(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(k,{open:B,handleClose:()=>N(!1),orderID:p.id,currentStatus:p.status,revalidateCallback:x})]})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Documents"}),e.jsx(f,{sx:{p:2},children:e.jsx(b,{spacing:1,children:p.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h6",children:"Delivery Note"}),e.jsx(j,{children:p.delivery_note?.name}),e.jsx(y,{variant:"contained",onClick:()=>{n.default(`api/opos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h5",children:"Delivery Note"}),e.jsx(j,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(q,{}),e.jsx(t.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:p.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:x})]})})})]})}),p?.notes?.data?.length>0&&e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:p.notes.data}),e.jsx(q,{})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Items"}),"placed"===p.status&&e.jsx(u,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(q,{}),e.jsxs("form",{action:O,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),E&&E.map((i,r)=>(console.log("item",i),e.jsx(f,{sx:{p:2,mb:2},children:"placed"===p.status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:F,image:i?.product?.image,revalidateCallback:x})},r))),e.jsx(f,{sx:{p:2},children:e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(y,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(E))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),a=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),p=require("@mui/material/Dialog"),m=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),j=require("@mui/material/Typography"),y=require("@mui/material/Button"),v=require("@mui/material/Grid"),g=require("@mui/material/Box"),f=require("@mui/material/Paper"),b=require("@mui/material/Stack"),_=require("@mui/material/Divider"),q=require("../../../data/services/common/confirmation-service.js"),C=require("../../../context/common/SnackbarContext.js");const w={zodErrors:null,strapiErrors:null,message:null};function k({open:i,handleClose:r,orderID:a,currentStatus:n,revalidateCallback:t}){return e.jsxs(p,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{children:"Are you sure you want to confirm this order?"}),e.jsxs(j,{children:["Current status: ",n]})]})}),e.jsxs(m,{children:[e.jsx(y,{variant:"contained",onClick:e=>{q.confirmationService("opos",[a]),t&&t()},children:"Confirm"}),e.jsx(y,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:p,sx:m,revalidateCallback:x,handleClose:h,role:q}){const[D,O]=r.useFormState((e,i)=>a.updateOpoAction(p.id,e,i),w),{handleAddMessage:S}=C.useSnackbar(),[E,A]=i.useState(p.opo_items.data?p.opo_items.data:[]),[B,N]=i.useState(!1),F=(e,i,r)=>{const a=[...E],n=a.findIndex(e=>e.id===i);a[n][r]=e,A(a)};return i.useEffect(()=>{p.opo_items?.data&&A(p.opo_items.data)},[p]),i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(x&&x(),h&&h()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error updating OPO",severity:D.severity||"error"})},[D?.strapiErrors]),e.jsx(g,{sx:[...Array.isArray(m)?m:[m]],children:e.jsxs(v,{container:!0,spacing:2,children:[e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h3",component:"h1",children:"Manage Outbound Purchase Order"}),e.jsx(j,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:p.id,__type:"api::e-commerce.opo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:6,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Details"}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(j,{variant:"body2",children:p.opo_number})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(j,{variant:"body2",children:p.customer_reference})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(j,{variant:"body2",children:p.order_date})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(j,{variant:"body2",children:p.customer?.business_credentials?.company_name})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(j,{variant:"body2",width:"250px",children:p.internal_status})]}),("placed"===p.internal_status||"external_shipping_process"===p.internal_status)&&"enduser"===q&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"contained",color:"primary",onClick:()=>N(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(k,{open:B,handleClose:()=>N(!1),orderID:p.id,currentStatus:p.internal_status,revalidateCallback:x})]})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Documents"}),e.jsx(f,{sx:{p:2},children:e.jsx(b,{spacing:1,children:p.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h6",children:"Delivery Note"}),e.jsx(j,{children:p.delivery_note?.name}),e.jsx(y,{variant:"contained",onClick:()=>{t.default(`api/opos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h5",children:"Delivery Note"}),e.jsx(j,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:p.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:x})]})})})]})}),p?.notes?.data?.length>0&&e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:p.notes.data}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Items"}),"placed"===p.internal_status&&e.jsx(u,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:O,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),E&&E.map((i,r)=>(console.log("item",i),e.jsx(f,{sx:{p:2,mb:2},children:"placed"===p.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:F,image:i?.product?.image,revalidateCallback:x})},r))),e.jsx(f,{sx:{p:2},children:e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(y,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(E))})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),a=require("../../common/media/UploadBase64MediaForm.js"),n=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),c=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),C=require("@mui/material/Divider"),b=require("../../../data/services/common/confirmation-service.js"),q=require("../../../data/services/common/cancellation-service.js"),k=require("@mui/material"),_=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:a,revalidateCallback:n}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",a]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{b.confirmationService("opos",[t]),n&&n(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:a,revalidateCallback:n}){const[s,o]=r.useState(""),[c,l]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(k.List,{children:[e.jsx(k.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(k.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(k.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(k.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!c,helperText:c})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)l("Please provide a reason for the cancellation (min 5 characters)");else{l("");try{await q.cancellationService("opos",a,s),d({message:"Order cancelled successfully",severity:"success"}),n&&n(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:b}){const q=t.updateOpoAction.bind(null,u.id),[T,M]=i.useFormState(q,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items.data?u.opo_items.data:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items?.data&&R(u.opo_items.data?u.opo_items.data:[])},[u]);const Y=(e,r,i)=>{const t=[...L],a=t.findIndex(e=>e.id===r);t[a][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),a=[...i[t]?.reports?.data||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:{data:[]}}),i[t].reports.data=a,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),a=i[t]?.reports?.data||[],n=a.filter(e=>"id"in e),s=a.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[t].reports.data=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(C,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(_,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.status})]})]})})}),"enduser"===b&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.status||"external_shipping_process"===u.status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.id,currentStatus:u.status,revalidateCallback:m})]}),("placed"===u.status||"ordered"===u.status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.id,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{n.default(`api/ipos/${u.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(C,{}),e.jsx(a.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),u?.notes?.data?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:u.notes.data}),e.jsx(C,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(k.FormControlLabel,{control:e.jsx(k.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===u.status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(C,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.status||"external_shipping_process"===u.status||"done"===u.status||"cancelled"===u.status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.status&&"external_shipping_process"!==u.status&&"done"!==u.status&&"cancelled"!==u.status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),a=require("../../common/media/UploadBase64MediaForm.js"),n=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),l=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),k=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:a,revalidateCallback:n}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",a]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),n&&n(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:a,revalidateCallback:n}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("opos",a,s),d({message:"Order cancelled successfully",severity:"success"}),n&&n(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.id),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items.data?u.opo_items.data:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items?.data&&R(u.opo_items.data?u.opo_items.data:[])},[u]);const Y=(e,r,i)=>{const t=[...L],a=t.findIndex(e=>e.id===r);t[a][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),a=[...i[t]?.reports?.data||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:{data:[]}}),i[t].reports.data=a,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),a=i[t]?.reports?.data||[],n=a.filter(e=>"id"in e),s=a.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[t].reports.data=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.id,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.id,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{n.default(`api/ipos/${u.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(a.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),u?.notes?.data?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:u.notes.data}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),a=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),s=require("../../../data/loaders/common/media/downloadBase64File.js"),d=require("./IPOItemUpdater.js"),o=require("./ItemDisplay.js"),c=require("../note/NotesDisplay.js"),l=require("../note/NoteTakingComponent.js"),m=require("../../SubmitButton.js"),p=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),x=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),j=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),f=require("@mui/material/Typography"),g=require("@mui/material/Button"),y=require("@mui/material/Grid"),b=require("@mui/material/Box"),q=require("@mui/material/Paper"),C=require("@mui/material/Stack"),_=require("@mui/material/Divider");const w={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k({open:i,handleClose:r,orderID:a,currentStatus:n,revalidateCallback:t}){return e.jsxs(x,{open:i,children:[e.jsx(v,{children:"Confirm Order"}),e.jsx(j,{children:e.jsxs(C,{spacing:2,children:[e.jsx(f,{children:"Are you sure you want to confirm this order?"}),e.jsxs(f,{children:["Current status: ",n]})]})}),e.jsxs(h,{children:[e.jsx(g,{variant:"contained",onClick:e=>{p.confirmationService("ipos",[a]),t&&t(),r()},children:"Confirm"}),e.jsx(g,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:p,sx:x,revalidateCallback:h,handleClose:j,role:v}){const[D,I]=r.useFormState((e,i)=>n.updateIpoAction(p.id,e,i),w),{handleAddMessage:S}=a.useSnackbar(),[O,U]=i.useState(p.items.data?p.items.data:[]),[N,A]=i.useState(!1);i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(h&&h(),j&&j()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error performing action",severity:"error"})},[D?.strapiErrors]);const B=(e,i,r)=>{const a=[...O],n=a.findIndex(e=>e.id===i);a[n][r]=e,U(a)};return e.jsx(b,{sx:[...Array.isArray(x)?x:[x]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{item:!0,xs:12,children:e.jsxs(C,{spacing:2,children:[e.jsxs(C,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(C,{spacing:2,children:[e.jsx(f,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(f,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(l.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(_,{})]})}),e.jsx(y,{item:!0,xs:6,children:e.jsxs(C,{spacing:1,children:[e.jsx(f,{variant:"h5",children:"Details"}),e.jsxs(C,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(f,{variant:"body2",children:p.ipo_number})]}),e.jsxs(C,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(f,{variant:"body2",children:p.customer_reference})]}),e.jsxs(C,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(f,{variant:"body2",children:p.order_date})]}),e.jsxs(C,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(f,{variant:"body2",children:p.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(C,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(f,{variant:"body2",width:"250px",children:p.status})]}),("placed"===p.status||"released_on_stock"===p.status)&&"enduser"===v&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"contained",color:"primary",onClick:()=>A(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher."}),e.jsx(k,{open:N,handleClose:()=>A(!1),orderID:p.id,currentStatus:p.status,revalidateCallback:h})]})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(C,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Documents"}),e.jsx(q,{sx:{p:2},children:e.jsxs(C,{spacing:1,children:["enduser"===v&&e.jsx(e.Fragment,{children:p.order_confirmation?e.jsxs(C,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{children:p.order_confirmation?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(C,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})}),p.delivery_note?e.jsxs(C,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{children:p.delivery_note?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(C,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{variant:"body1",children:"Upload the delivery note for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})]})})]})}),p?.notes?.data?.length>0&&e.jsx(y,{item:!0,xs:12,children:e.jsxs(C,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:p.notes.data}),e.jsx(_,{})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(C,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Items"}),"placed"===p.status&&e.jsx(u,{severity:"warning",children:"Items cannot be updated before order confirmation"}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(O))}),e.jsxs(C,{spacing:2,children:[p?.items?.data&&p.items.data.map((i,r)=>e.jsx(q,{sx:{p:2},children:"placed"===p.status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(d.default,{item:i,index:r,handleUpdateQuantity:B,image:i?.product?.image,revalidateCallback:h})},r)),"placed"!==p.status&&e.jsx(q,{sx:{p:2},children:e.jsxs(C,{direction:"row",justifyContent:"flex-end",spacing:2,children:[j&&e.jsx(g,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Update Items",loadingText:"Updating...",variant:"contained"})]})})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),a=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),s=require("../../../data/loaders/common/media/downloadBase64File.js"),d=require("./IPOItemUpdater.js"),o=require("./ItemDisplay.js"),c=require("../note/NotesDisplay.js"),l=require("../note/NoteTakingComponent.js"),m=require("../../SubmitButton.js"),p=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),x=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),j=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),f=require("@mui/material/Typography"),g=require("@mui/material/Button"),y=require("@mui/material/Grid"),b=require("@mui/material/Box"),_=require("@mui/material/Paper"),q=require("@mui/material/Stack"),C=require("@mui/material/Divider");const w={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k({open:i,handleClose:r,orderID:a,currentStatus:n,revalidateCallback:t}){return e.jsxs(x,{open:i,children:[e.jsx(v,{children:"Confirm Order"}),e.jsx(j,{children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{children:"Are you sure you want to confirm this order?"}),e.jsxs(f,{children:["Current status: ",n]})]})}),e.jsxs(h,{children:[e.jsx(g,{variant:"contained",onClick:e=>{p.confirmationService("ipos",[a]),t&&t(),r()},children:"Confirm"}),e.jsx(g,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:p,sx:x,revalidateCallback:h,handleClose:j,role:v}){const[D,I]=r.useFormState((e,i)=>n.updateIpoAction(p.id,e,i),w),{handleAddMessage:S}=a.useSnackbar(),[O,U]=i.useState(p.items.data?p.items.data:[]),[N,A]=i.useState(!1);i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(h&&h(),j&&j()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error performing action",severity:"error"})},[D?.strapiErrors]);const B=(e,i,r)=>{const a=[...O],n=a.findIndex(e=>e.id===i);a[n][r]=e,U(a)};return e.jsx(b,{sx:[...Array.isArray(x)?x:[x]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsxs(q,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(f,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(l.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:6,children:e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h5",children:"Details"}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(f,{variant:"body2",children:p.ipo_number})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(f,{variant:"body2",children:p.customer_reference})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(f,{variant:"body2",children:p.order_date})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(f,{variant:"body2",children:p.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(f,{variant:"body2",width:"250px",children:p.internal_status})]}),("placed"===p.internal_status||"released_on_stock"===p.internal_status)&&"enduser"===v&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"contained",color:"primary",onClick:()=>A(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher."}),e.jsx(k,{open:N,handleClose:()=>A(!1),orderID:p.id,currentStatus:p.internal_status,revalidateCallback:h})]})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Documents"}),e.jsx(_,{sx:{p:2},children:e.jsxs(q,{spacing:1,children:["enduser"===v&&e.jsx(e.Fragment,{children:p.order_confirmation?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{children:p.order_confirmation?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})}),p.delivery_note?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{children:p.delivery_note?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{variant:"body1",children:"Upload the delivery note for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})]})})]})}),p?.notes?.data?.length>0&&e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:p.notes.data}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Items"}),"placed"===p.internal_status&&e.jsx(u,{severity:"warning",children:"Items cannot be updated before order confirmation"}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(O))}),e.jsxs(q,{spacing:2,children:[p?.items?.data&&p.items.data.map((i,r)=>e.jsx(_,{sx:{p:2},children:"placed"===p.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(d.default,{item:i,index:r,handleUpdateQuantity:B,image:i?.product?.image,revalidateCallback:h})},r)),"placed"!==p.internal_status&&e.jsx(_,{sx:{p:2},children:e.jsxs(q,{direction:"row",justifyContent:"flex-end",spacing:2,children:[j&&e.jsx(g,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Update Items",loadingText:"Updating...",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"),a=require("../../../context/common/SnackbarContext.js"),t=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),d=require("../../common/media/UploadBase64MediaForm.js"),l=require("../note/NoteTakingComponent.js"),c=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),w=require("@mui/material/Divider"),I=require("@mui/material/TextField"),_=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:t,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:d}=a.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[t]),d({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){d({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:t,orderID:n,revalidateCallback:o}){const[d,l]=r.useState(""),[c,u]=r.useState(""),{handleAddMessage:m}=a.useSnackbar();return e.jsxs(g,{open:i,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(_,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(I,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:d,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!c,helperText:c})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(d.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,d),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,I]=i.useFormState((e,r)=>t.updateIpoAction(n.id,e,r),N),{handleAddMessage:_}=a.useSnackbar(),[k,R]=r.useState(n.items.data?n.items.data:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(_({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&_({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const a=[...k],t=a.findIndex(e=>e.id===r);a[t][i]=e,R(a)},Q=(e,r)=>{const i=[...k],a=i.findIndex(e=>e.id===r),t=[...i[a]?.reports?.data||[],e];null==i[a]?.reports&&(i[a]={...i[a],reports:{data:[]}}),i[a].reports.data=t,R(i)},K=(e,r)=>{const i=[...k],a=i.findIndex(r=>r.id===e),t=i[a]?.reports?.data||[],n=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[a].reports.data=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(_({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&_({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items?.data&&R(n.items.data?n.items.data:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(w,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.status||"released_on_stock"===n.status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.id,currentStatus:n.status,revalidateCallback:g})]}),("placed"===n.status||"ordered"===n.status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.id,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(w,{}),e.jsx(d.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(w,{}),e.jsx(d.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})]})})]})}),n?.notes?.data?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:n.notes.data}),e.jsx(w,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(w,{}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.status||"cancelled"===n.status||"done"===n.status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),a=require("../../../context/common/SnackbarContext.js"),t=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),l=require("../../common/media/UploadBase64MediaForm.js"),d=require("../note/NoteTakingComponent.js"),c=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),_=require("@mui/material/Divider"),w=require("@mui/material/TextField"),I=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:t,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=a.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[t]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:t,orderID:n,revalidateCallback:o}){const[l,d]=r.useState(""),[c,u]=r.useState(""),{handleAddMessage:m}=a.useSnackbar();return e.jsxs(g,{open:i,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(w,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>d(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!c,helperText:c})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,w]=i.useFormState((e,r)=>t.updateIpoAction(n.id,e,r),N),{handleAddMessage:I}=a.useSnackbar(),[k,R]=r.useState(n.items.data?n.items.data:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const a=[...k],t=a.findIndex(e=>e.id===r);a[t][i]=e,R(a)},Q=(e,r)=>{const i=[...k],a=i.findIndex(e=>e.id===r),t=[...i[a]?.reports?.data||[],e];null==i[a]?.reports&&(i[a]={...i[a],reports:{data:[]}}),i[a].reports.data=t,R(i)},K=(e,r)=>{const i=[...k],a=i.findIndex(r=>r.id===e),t=i[a]?.reports?.data||[],n=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[a].reports.data=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items?.data&&R(n.items.data?n.items.data:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(d.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.internal_status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.internal_status||"released_on_stock"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.id,currentStatus:n.internal_status,revalidateCallback:g})]}),("placed"===n.internal_status||"ordered"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.id,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})]})})]})}),n?.notes?.data?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:n.notes.data}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:w,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.internal_status||"cancelled"===n.internal_status||"done"===n.internal_status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("./get-token.js"),r=require("../../../node_modules/qs/lib/index.js"),t=require("../../lib/utils.js"),o=require("next/cache");const a=t.getStrapiURL(),n=r.default.stringify({populate:{customer_profile:{populate:{company_address:!0,delivery_address:!0,billing_address:!0,business_credentials:{populate:{vat_validate_response:!0,eori_validate_response:!0}},orders:{populate:{opo_items:{populate:{product:{populate:{price:!0,image:!0}}}}}},returns:{populate:{iro_items:{populate:{product:{populate:{price:!0,image:!0}}}}}}}}}}),s=r.default.stringify({populate:"role"});exports.getExtendedUserMeLoader=async function(){o.unstable_noStore();const r=new URL("/api/users/me",a);r.search=n;const t=await e.getAuthToken();if(!t)return{ok:!1,data:null,error:null};try{const e=await fetch(r.href,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},cache:"no-cache"});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const o=await e.json();return o.error?{ok:!1,data:null,error:o.error}:{ok:!0,data:o,error:null}}catch(e){return console.error("getExtendedUserMeLoader Error:",e),{ok:!1,data:null,error:e}}},exports.getUserMeLoader=async function(e){const r=new URL("/api/users/me",a);r.search=n;try{const t=await fetch(r,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);if(t.ok)return t.json();throw new Error("Failed to fetch user details")}catch(e){return console.error("getUserMeLoader Error:",e),null}},exports.getUserRole=async function(){const r=new URL("/api/users/me",a);r.search=s;const t=await e.getAuthToken();if(!t)return{ok:!1,data:null,error:null};try{const e=await fetch(r.href,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},cache:"no-cache"});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const o=await e.json();return o.error?{ok:!1,data:null,error:o.error}:{ok:!0,data:o,error:null}}catch(e){return console.error("getUserRole Error:",e),{ok:!1,data:null,error:e}}};
7
+ "use strict";var r=require("./get-token.js"),e=require("../../../node_modules/qs/lib/index.js"),t=require("../../lib/utils.js"),o=require("next/cache");const n=t.getStrapiURL(),a=e.default.stringify({}),s=e.default.stringify({populate:"role"});exports.getExtendedUserMeLoader=async function(){o.unstable_noStore();const e=new URL("/api/users/me",n);e.search=a;const t=await r.getAuthToken();if(!t)return{ok:!1,data:null,error:null};try{const r=await fetch(e.href,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},cache:"no-cache"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const o=await r.json();return o.error?{ok:!1,data:null,error:o.error}:{ok:!0,data:o,error:null}}catch(r){return console.error("getExtendedUserMeLoader Error:",r),{ok:!1,data:null,error:r}}},exports.getUserMeLoader=async function(r){const e=new URL("/api/users/me",n);e.search=a;try{const t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);if(t.ok)return t.json();throw new Error("Failed to fetch user details")}catch(r){return console.error("getUserMeLoader Error:",r),null}},exports.getUserRole=async function(){const e=new URL("/api/users/me",n);e.search=s;const t=await r.getAuthToken();if(!t)return{ok:!1,data:null,error:null};try{const r=await fetch(e.href,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},cache:"no-cache"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const o=await r.json();return o.error?{ok:!1,data:null,error:o.error}:{ok:!0,data:o,error:null}}catch(r){return console.error("getUserRole Error:",r),{ok:!1,data:null,error:r}}};