umwd-components 0.1.802 → 0.1.803

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 (28) hide show
  1. package/dist/cjs/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
  2. package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
  3. package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
  4. package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
  5. package/dist/cjs/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
  6. package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  7. package/dist/cjs/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
  8. package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
  9. package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
  10. package/dist/cjs/src/components/logistics/note/NoteTakingComponent.js +1 -1
  11. package/dist/cjs/src/components/logistics/report/ReportMakingComponent.js +1 -1
  12. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  13. package/dist/esm/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
  14. package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +1 -3
  15. package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +1 -3
  16. package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +1 -3
  17. package/dist/esm/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
  18. package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -3
  19. package/dist/esm/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
  20. package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +1 -3
  21. package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +1 -3
  22. package/dist/esm/src/components/logistics/note/NoteTakingComponent.js +1 -1
  23. package/dist/esm/src/components/logistics/report/ReportMakingComponent.js +1 -1
  24. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  25. package/dist/esm/types/types/e-commerce/iro/types.d.ts +2 -0
  26. package/dist/esm/types/types/e-commerce/opo/types.d.ts +2 -0
  27. package/dist/esm/types/types/logistics/Ipo.d.ts +2 -0
  28. package/package.json +1 -1
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),l=require("../../common/AmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),u=require("../../common/ImagePreviewTooltip.js"),s=require("../../logistics/report/ReportMakingComponent.js"),c=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:v,registered_quantity:q,released_quantity:b,returned_quantity:f,reports:_,reason:w,other_reason:C}=m,I=void 0!==_&&_.length>0?_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,V=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[k,R]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g&&g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(u.default,{image:j,label:g&&g.title})})]}),e.jsx(i,{variant:"body1",children:"Reason"}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.AmountUpdater,{currentValue:v,totalValue:f+I,minnewvalue:0+q+-V,maxnewvalue:f+I,color:"info",handleChange:e=>{x(e,m.documentId,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.AmountUpdater,{currentValue:q,totalValue:f+I,minnewvalue:0+b,maxnewvalue:v+V,color:"info",handleChange:e=>{x(e,m.documentId,"registered_quantity")},offsetEnd:V}),e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>R(!k),children:e.jsx(d,{})})]})}),e.jsx(o,{in:k,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:_}),e.jsx(s.default,{content:"content",quantity:0,type:"registered",minValue:-(v+V),maxValue:v,related:[{documentId:m.documentId,__type:"api::e-commerce.iro-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.AmountUpdater,{currentValue:b||0,totalValue:f+I+V,minnewvalue:0,maxnewvalue:q,color:"info",handleChange:e=>{x(e,m.documentId,"released_quantity")}})]})},p)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),l=require("../../common/AmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),s=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportMakingComponent.js"),c=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:v,registered_quantity:q,released_quantity:b,returned_quantity:f,reports:_,reason:w,other_reason:C}=m,I=void 0!==_&&_.length>0?_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,V=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[k,R]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g&&g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(s.default,{image:j,label:g&&g.title})})]}),e.jsx(i,{variant:"body1",children:"Reason"}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.AmountUpdater,{currentValue:v,totalValue:f+I,minnewvalue:0+q+-V,maxnewvalue:f+I,color:"info",handleChange:e=>{x(e,m.documentId,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.AmountUpdater,{currentValue:q,totalValue:f+I,minnewvalue:0+b,maxnewvalue:v+V,color:"info",handleChange:e=>{x(e,m.documentId,"registered_quantity")},offsetEnd:V}),e.jsx(n,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>R(!k),children:e.jsx(d,{})})]})}),e.jsx(o,{in:k,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:_}),e.jsx(u.default,{content:"content",quantity:0,type:"registered",minValue:-(v+V),maxValue:v,related:[{id:m.id,__type:"api::e-commerce.iro-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.AmountUpdater,{currentValue:b||0,totalValue:f+I+V,minnewvalue:0,maxnewvalue:q,color:"info",handleChange:e=>{x(e,m.documentId,"released_quantity")}})]})},p)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),t=require("../../logistics/note/NotesDisplay.js"),s=require("../../logistics/note/NoteTakingComponent.js"),a=require("../../StrapiErrors.js"),n=require("../../SubmitButton.js"),d=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"),l=require("@mui/material/Box"),u=require("@mui/material/Paper"),x=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:m,sx:p,revalidateCallback:g,handleClose:v,role:y}){const[q,b]=r.useActionState((e,r)=>i.updateIroAction(m.documentId,e,r),j),[_,w]=r.useState(m.iro_items?m.iro_items:[]),[f,S]=r.useState(!1);return e.jsx(l,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{size: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(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:m.documentId,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(h,{})]})}),e.jsx(c,{size:6,children:e.jsxs(x,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Details"}),e.jsxs(x,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(o,{variant:"body2",children:m.return_number})]}),e.jsx(x,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(x,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(o,{variant:"body2",children:m.return_date})]}),e.jsx(x,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(x,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(o,{variant:"body2",width:"250px",children:m.internal_status})]})]})}),e.jsx(c,{size:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Documents"}),e.jsx(u,{sx:{p:2},children:e.jsx(x,{spacing:1,children:"enduser"===y&&e.jsx(e.Fragment,{})})})]})}),m?.notes?.length>0&&e.jsx(c,{size:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Notes"}),e.jsx(t.default,{notes:m.notes}),e.jsx(h,{})]})}),e.jsx(c,{size:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Items"}),e.jsx(h,{}),e.jsxs("form",{action:b,children:[m?.iro_items&&m.iro_items.map((r,i)=>(console.log("item",r),e.jsx(u,{sx:{p:2,mb:2}},i))),e.jsx(u,{sx:{p:2},children:e.jsxs(x,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(n.SubmitButton,{text:"Update items",loadingText:"Loading..."}),e.jsx(a.StrapiErrors,{error:q?.strapiErrors}),q?.message&&e.jsx(d,{severity:"error",children:q?.message})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.documentId,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(_))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),t=require("../../logistics/note/NotesDisplay.js"),s=require("../../logistics/note/NoteTakingComponent.js"),a=require("../../StrapiErrors.js"),n=require("../../SubmitButton.js"),d=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"),l=require("@mui/material/Box"),u=require("@mui/material/Paper"),x=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:m,sx:p,revalidateCallback:g,handleClose:v,role:y}){const[q,b]=r.useActionState((e,r)=>i.updateIroAction(m.documentId,e,r),j),[_,w]=r.useState(m.iro_items?m.iro_items:[]),[f,S]=r.useState(!1);return e.jsx(l,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{size: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(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:m.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(h,{})]})}),e.jsx(c,{size:6,children:e.jsxs(x,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Details"}),e.jsxs(x,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(o,{variant:"body2",children:m.return_number})]}),e.jsx(x,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(x,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(o,{variant:"body2",children:m.return_date})]}),e.jsx(x,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(x,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(o,{variant:"body2",width:"250px",children:m.internal_status})]})]})}),e.jsx(c,{size:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Documents"}),e.jsx(u,{sx:{p:2},children:e.jsx(x,{spacing:1,children:"enduser"===y&&e.jsx(e.Fragment,{})})})]})}),m?.notes?.length>0&&e.jsx(c,{size:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Notes"}),e.jsx(t.default,{notes:m.notes}),e.jsx(h,{})]})}),e.jsx(c,{size:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Items"}),e.jsx(h,{}),e.jsxs("form",{action:b,children:[m?.iro_items&&m.iro_items.map((r,i)=>(console.log("item",r),e.jsx(u,{sx:{p:2,mb:2}},i))),e.jsx(u,{sx:{p:2},children:e.jsxs(x,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(n.SubmitButton,{text:"Update items",loadingText:"Loading..."}),e.jsx(a.StrapiErrors,{error:q?.strapiErrors}),q?.message&&e.jsx(d,{severity:"error",children:q?.message})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.documentId,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(_))})]})]})})]})})};
@@ -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("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),_=require("@mui/material/Divider"),y=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),F=require("../../../../node_modules/qs/lib/index.js"),D=require("../../../context/common/SnackbarContext.js"),R=require("../../common/media/minio/MinioItemList.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a,revalidateCallback:l}){const[o,p]=r.useState(!1),{handleAddMessage:j}=D.useSnackbar();return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{p(!0);const e=F.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),p(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),o?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{try{await y.confirmationService("iros",[a.documentId],n),l&&l(),i()}catch(e){j({message:"Failed to confirm return order",severity:"error"})}},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function z({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=D.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.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(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await y.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function M({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=D.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:y}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),P),[F,E]=r.useState(c.iro_items?c.iro_items:[]),[O,L]=r.useState(!1),[N,B]=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=[...F],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,E(i)},H=(e,r)=>{const t=[...F],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,E(t)},K=(e,r)=>{const t=[...F],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"documentId"in e),a=n.filter(e=>!("documentId"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,E(t)},{handleAddMessage:X}=D.useSnackbar();return r.useEffect(()=>{f?.message&&(X({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&X({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{c.iro_items&&E(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.documentId,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===y&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{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"===c.internal_status&&e.jsx(o,{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"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>B(!0),children:"Cancel order"}),e.jsx(z,{open:O,handleClose:()=>L(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:c}),e.jsx(M,{open:N,handleClose:()=>B(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Customer Attachements"}),e.jsx(v,{sx:{p:1},children:e.jsx(R.MinioItemList,{items:c.customer_attachment,emptyMessage:"No customer attachments found.",direction:"row",revalidateCallback:u})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(F))}),F&&F.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:u,showing:G})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.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("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),_=require("@mui/material/Divider"),y=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),F=require("../../../../node_modules/qs/lib/index.js"),D=require("../../../context/common/SnackbarContext.js"),R=require("../../common/media/minio/MinioItemList.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a,revalidateCallback:l}){const[o,p]=r.useState(!1),{handleAddMessage:j}=D.useSnackbar();return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{p(!0);const e=F.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),p(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),o?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{try{await y.confirmationService("iros",[a.documentId],n),l&&l(),i()}catch(e){j({message:"Failed to confirm return order",severity:"error"})}},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function z({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=D.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.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(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await y.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function M({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=D.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:y}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),P),[F,E]=r.useState(c.iro_items?c.iro_items:[]),[O,L]=r.useState(!1),[N,B]=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=[...F],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,E(i)},H=(e,r)=>{const t=[...F],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,E(t)},K=(e,r)=>{const t=[...F],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"documentId"in e),a=n.filter(e=>!("documentId"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,E(t)},{handleAddMessage:X}=D.useSnackbar();return r.useEffect(()=>{f?.message&&(X({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&X({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{c.iro_items&&E(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.id,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===y&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{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"===c.internal_status&&e.jsx(o,{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"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>B(!0),children:"Cancel order"}),e.jsx(z,{open:O,handleClose:()=>L(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:c}),e.jsx(M,{open:N,handleClose:()=>B(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Customer Attachements"}),e.jsx(v,{sx:{p:1},children:e.jsx(R.MinioItemList,{items:c.customer_attachment,emptyMessage:"No customer attachments found.",direction:"row",revalidateCallback:u})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(F))}),F&&F.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:u,showing:G})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.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("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./OpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),d=require("../../logistics/note/NoteTakingComponent.js"),c=require("../../SubmitButton.js"),l=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),m=require("@mui/material/DialogActions"),p=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),y=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),f=require("@mui/material/Stack"),b=require("@mui/material/Divider"),_=require("../../../data/services/common/confirmation-service.js"),q=require("../../../context/common/SnackbarContext.js");const C={zodErrors:null,strapiErrors:null,message:null};function w({open:i,handleClose:r,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(u,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(p,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",t]})]})}),e.jsxs(m,{children:[e.jsx(j,{variant:"contained",onClick:e=>{_.confirmationService("opos",[n]),a&&a()},children:"Confirm"}),e.jsx(j,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:u,sx:m,revalidateCallback:p,handleClose:h,role:_}){const[k,D]=i.useActionState((e,i)=>r.updateOpoAction(u.documentId,e,i),C),{handleAddMessage:I}=q.useSnackbar(),[O,S]=i.useState(u.opo_items?u.opo_items:[]),[A,E]=i.useState(!1),B=(e,i,r)=>{const n=[...O],t=n.findIndex(e=>e.documentId===i);n[t][r]=e,S(n)};return i.useEffect(()=>{u.opo_items&&S(u.opo_items)},[u]),i.useEffect(()=>{k?.message&&(I({message:k.message,severity:k.severity||"error"}),"success"===k.severity&&(p&&p(),h&&h()))},[k?.message]),i.useEffect(()=>{k?.strapiErrors&&I({message:k.strapiErrors.message||"Error updating OPO",severity:k.severity||"error"})},[k?.strapiErrors]),e.jsx(v,{sx:[...Array.isArray(m)?m:[m]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{size: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:"Manage Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(d.default,{content:"",related:[{id:u.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:p})]}),e.jsx(b,{})]})}),e.jsx(y,{size:6,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Details"}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body2",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(x,{variant:"body2",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(x,{variant:"body2",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(x,{variant:"body2",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(x,{variant:"body2",width:"250px",children:u.internal_status})]}),("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&"enduser"===_&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>E(!0),children:"Confirm order"}),e.jsx(l,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(w,{open:A,handleClose:()=>E(!1),orderID:u.documentId,currentStatus:u.internal_status,revalidateCallback:p})]})]})}),e.jsx(y,{size:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(g,{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:()=>{t.default(`api/opos/${u.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(b,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:p})]})})})]})}),u?.notes?.length>0&&e.jsx(y,{size:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:u.notes}),e.jsx(b,{})]})}),e.jsx(y,{size:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),"placed"===u.internal_status&&e.jsx(l,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(b,{}),e.jsxs("form",{action:D,children:[e.jsx("input",{name:"id",type:"hidden",value:u.documentId}),O&&O.map((i,r)=>(console.log("item",i),e.jsx(g,{sx:{p:2,mb:2},children:"placed"===u.internal_status?e.jsx(s.default,{item:i,index:r,image:i?.product?.image}):e.jsx(a.default,{item:i,index:r,handleUpdateQuantity:B,image:i?.product?.image,revalidateCallback:p})},r))),e.jsx(g,{sx:{p:2},children:e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(c.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(O))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),t=require("./OpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),d=require("../../logistics/note/NoteTakingComponent.js"),c=require("../../SubmitButton.js"),l=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),m=require("@mui/material/DialogActions"),p=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),y=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),f=require("@mui/material/Stack"),b=require("@mui/material/Divider"),_=require("../../../data/services/common/confirmation-service.js"),q=require("../../../context/common/SnackbarContext.js");const C={zodErrors:null,strapiErrors:null,message:null};function w({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(u,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(p,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",a]})]})}),e.jsxs(m,{children:[e.jsx(j,{variant:"contained",onClick:e=>{_.confirmationService("opos",[n]),t&&t()},children:"Confirm"}),e.jsx(j,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:u,sx:m,revalidateCallback:p,handleClose:h,role:_}){const[k,D]=i.useActionState((e,i)=>r.updateOpoAction(u.documentId,e,i),C),{handleAddMessage:I}=q.useSnackbar(),[O,S]=i.useState(u.opo_items?u.opo_items:[]),[A,E]=i.useState(!1),B=(e,i,r)=>{const n=[...O],a=n.findIndex(e=>e.documentId===i);n[a][r]=e,S(n)};return i.useEffect(()=>{u.opo_items&&S(u.opo_items)},[u]),i.useEffect(()=>{k?.message&&(I({message:k.message,severity:k.severity||"error"}),"success"===k.severity&&(p&&p(),h&&h()))},[k?.message]),i.useEffect(()=>{k?.strapiErrors&&I({message:k.strapiErrors.message||"Error updating OPO",severity:k.severity||"error"})},[k?.strapiErrors]),e.jsx(v,{sx:[...Array.isArray(m)?m:[m]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{size: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:"Manage Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(d.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:p})]}),e.jsx(b,{})]})}),e.jsx(y,{size:6,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Details"}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body2",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(x,{variant:"body2",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(x,{variant:"body2",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(x,{variant:"body2",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,children:[e.jsx(x,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(x,{variant:"body2",width:"250px",children:u.internal_status})]}),("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&"enduser"===_&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>E(!0),children:"Confirm order"}),e.jsx(l,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(w,{open:A,handleClose:()=>E(!1),orderID:u.documentId,currentStatus:u.internal_status,revalidateCallback:p})]})]})}),e.jsx(y,{size:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/opos/${u.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(b,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:p})]})})})]})}),u?.notes?.length>0&&e.jsx(y,{size:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:u.notes}),e.jsx(b,{})]})}),e.jsx(y,{size:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),"placed"===u.internal_status&&e.jsx(l,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(b,{}),e.jsxs("form",{action:D,children:[e.jsx("input",{name:"id",type:"hidden",value:u.documentId}),O&&O.map((i,r)=>(console.log("item",i),e.jsx(g,{sx:{p:2,mb:2},children:"placed"===u.internal_status?e.jsx(s.default,{item:i,index:r,image:i?.product?.image}):e.jsx(t.default,{item:i,index:r,handleUpdateQuantity:B,image:i?.product?.image,revalidateCallback:p})},r))),e.jsx(g,{sx:{p:2},children:e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(c.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(O))})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),d=require("../../common/AmountUpdater.js"),u=require("@mui/icons-material/ArrowDropDown"),l=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportMakingComponent.js"),s=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:h,image:x,revalidateCallback:j}){const{line_item_number:y,product:g,ordered_quantity:q,picked_quantity:v,packed_quantity:f,shipped_quantity:b,reports:k}=m,[_,w]=t.useState(!1);t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"picked"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);const I=t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"packed"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);return t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"shipped"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]),e.jsx(r,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",children:[e.jsxs(r,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g?.product_number]})]}),x&&e.jsx(e.Fragment,{children:e.jsx(l.default,{image:x,label:g?.title})})]}),e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(d.AmountUpdater,{currentValue:v,totalValue:q+-I,minnewvalue:0+f+-I,maxnewvalue:q+-I,color:"info",handleChange:e=>{h(e,m.documentId,"picked_quantity")}}),e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(d.AmountUpdater,{currentValue:f,totalValue:q,minnewvalue:0+b,maxnewvalue:v+I,color:"info",handleChange:e=>{h(e,m.documentId,"packed_quantity")},offsetEnd:I}),e.jsx(a,{sx:{p:0},children:e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>w(!_),children:e.jsx(u,{})})]})}),e.jsx(o,{in:_,children:e.jsxs(r,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(s.default,{reports:k.filter(e=>"documentId"in e&&"string"==typeof e.documentId)}),e.jsx(c.default,{content:"content",quantity:0,type:"packed",minValue:-(v+I),maxValue:0,related:[{documentId:m.documentId,__type:"api::e-commerce.opo-item"}],revalidateCallback:j})]})}),e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(d.AmountUpdater,{currentValue:b,totalValue:q,minnewvalue:0,maxnewvalue:f,color:"info",handleChange:e=>{h(e,m.documentId,"shipped_quantity")}})]})},p)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),d=require("../../common/AmountUpdater.js"),u=require("@mui/icons-material/ArrowDropDown"),l=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportMakingComponent.js"),s=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:h,image:x,revalidateCallback:j}){const{line_item_number:y,product:g,ordered_quantity:q,picked_quantity:v,packed_quantity:f,shipped_quantity:b,reports:k}=m,[_,w]=t.useState(!1);t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"picked"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);const C=t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"packed"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);return t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"shipped"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]),e.jsx(r,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",children:[e.jsxs(r,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g?.product_number]})]}),x&&e.jsx(e.Fragment,{children:e.jsx(l.default,{image:x,label:g?.title})})]}),e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(d.AmountUpdater,{currentValue:v,totalValue:q+-C,minnewvalue:0+f+-C,maxnewvalue:q+-C,color:"info",handleChange:e=>{h(e,m.documentId,"picked_quantity")}}),e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(d.AmountUpdater,{currentValue:f,totalValue:q,minnewvalue:0+b,maxnewvalue:v+C,color:"info",handleChange:e=>{h(e,m.documentId,"packed_quantity")},offsetEnd:C}),e.jsx(a,{sx:{p:0},children:e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>w(!_),children:e.jsx(u,{})})]})}),e.jsx(o,{in:_,children:e.jsxs(r,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(s.default,{reports:k.filter(e=>"documentId"in e&&"string"==typeof e.documentId)}),e.jsx(c.default,{content:"content",quantity:0,type:"packed",minValue:-(v+C),maxValue:0,related:[{id:m.id,__type:"api::e-commerce.opo-item"}],revalidateCallback:j})]})}),e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(d.AmountUpdater,{currentValue:b,totalValue:q,minnewvalue:0,maxnewvalue:f,color:"info",handleChange:e=>{h(e,m.documentId,"shipped_quantity")}})]})},p)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),b=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),_=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js"),F=require("../../common/media/minio/UploadMinioMediaForm.js");const M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},z=["picked","packed","shipped","reports"];function B({open:r,handleClose:i,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",t]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{b.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function N({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:n,children:[e.jsx(p,{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 order?"}),e.jsxs(_.List,{children:[e.jsx(_.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(_.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(_.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(_.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(u,{children:[e.jsx(x,{variant:"outlined",onClick:n,children:"Close"}),e.jsx(x,{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 C.cancellationService("opos",t,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),n()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:b}){const C=i.updateOpoAction.bind(null,d.documentId),[E,T]=r.useActionState(C,M),[U,P]=r.useState(d.opo_items?d.opo_items:[]),[L,R]=r.useState(!1),[W,G]=r.useState(!1),[H,J]=r.useState(["picked","packed","shipped","reports"]),Q=(e,r,i)=>{const n=[...U],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,P(n)},Y=(e,r)=>{const i=[...U],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,P(i)},$=(e,r)=>{const i=[...U],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,P(i)},{handleAddMessage:K}=O.useSnackbar();return r.useEffect(()=>{E?.message&&(K({message:E.message,severity:E.severity||"error"}),"success"===E.severity&&(m&&m(),p&&p()))},[E?.message]),r.useEffect(()=>{E?.strapiErrors&&K({message:E.strapiErrors.message||"Error updating OPO",severity:E.severity||"error"})},[E?.strapiErrors]),r.useEffect(()=>{d.opo_items&&P(d.opo_items?d.opo_items:[])},[d]),e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size: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 Outbound Sales Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:d.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{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:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_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:"Custom 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:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),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"}),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(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===b&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(B,{open:L,handleClose:()=>R(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(N,{open:W,handleClose:()=>G(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{t.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Minio Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(F.UploadMinioMediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"minio",multiple:!1,revalidateCallback:m})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size: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:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),z.map(r=>e.jsx(_.FormControlLabel,{control:e.jsx(_.Checkbox,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.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))]}),"placed"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:T,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(U))}),U&&U.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:Y,image:r?.product?.image,handleRemoveReportAtIndex:$,revalidateCallback:m,showing:H})},i)),e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.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("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),b=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),_=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js"),F=require("../../common/media/minio/UploadMinioMediaForm.js");const M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},z=["picked","packed","shipped","reports"];function B({open:r,handleClose:i,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",t]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{b.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function N({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:n,children:[e.jsx(p,{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 order?"}),e.jsxs(_.List,{children:[e.jsx(_.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(_.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(_.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(_.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(u,{children:[e.jsx(x,{variant:"outlined",onClick:n,children:"Close"}),e.jsx(x,{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 C.cancellationService("opos",t,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),n()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:b}){const C=i.updateOpoAction.bind(null,d.documentId),[E,T]=r.useActionState(C,M),[U,P]=r.useState(d.opo_items?d.opo_items:[]),[L,R]=r.useState(!1),[W,G]=r.useState(!1),[H,J]=r.useState(["picked","packed","shipped","reports"]),Q=(e,r,i)=>{const n=[...U],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,P(n)},Y=(e,r)=>{const i=[...U],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,P(i)},$=(e,r)=>{const i=[...U],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,P(i)},{handleAddMessage:K}=O.useSnackbar();return r.useEffect(()=>{E?.message&&(K({message:E.message,severity:E.severity||"error"}),"success"===E.severity&&(m&&m(),p&&p()))},[E?.message]),r.useEffect(()=>{E?.strapiErrors&&K({message:E.strapiErrors.message||"Error updating OPO",severity:E.severity||"error"})},[E?.strapiErrors]),r.useEffect(()=>{d.opo_items&&P(d.opo_items?d.opo_items:[])},[d]),e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size: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 Outbound Sales Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{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:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_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:"Custom 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:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),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"}),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(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===b&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(B,{open:L,handleClose:()=>R(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(N,{open:W,handleClose:()=>G(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{t.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Minio Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(F.UploadMinioMediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"minio",multiple:!1,revalidateCallback:m})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size: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:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),z.map(r=>e.jsx(_.FormControlLabel,{control:e.jsx(_.Checkbox,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.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))]}),"placed"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:T,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(U))}),U&&U.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:Y,image:r?.product?.image,handleRemoveReportAtIndex:$,revalidateCallback:m,showing:H})},i)),e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.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"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),d=require("../../common/AmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),u=require("../../common/ImagePreviewTooltip.js"),s=require("../report/ReportMakingComponent.js"),c=require("../report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:v,registered_quantity:q,released_quantity:b,ordered_quantity:f,reports:_}=m,w=void 0!==_&&_.length>0?_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,C=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[I,V]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(u.default,{image:j,label:m.product.title})})]}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(d.AmountUpdater,{currentValue:v,totalValue:f+w,minnewvalue:0+q+-C,maxnewvalue:f+w,color:"info",handleChange:e=>{x(e,m.documentId,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(d.AmountUpdater,{currentValue:q,totalValue:f+w,minnewvalue:0+b,maxnewvalue:v+C,color:"info",handleChange:e=>{x(e,m.documentId,"registered_quantity")},offsetEnd:C}),e.jsx(n,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>V(!I),children:e.jsx(l,{})})]})}),e.jsx(o,{in:I,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:_}),e.jsx(s.default,{content:"content",quantity:0,type:"registered",minValue:-(v+C),maxValue:v,related:[{documentId:m.documentId,__type:"api::logistics.ipo-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(d.AmountUpdater,{currentValue:b||0,totalValue:f+w+C,minnewvalue:0,maxnewvalue:q,color:"info",handleChange:e=>{x(e,m.documentId,"released_quantity")}})]})},p)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),l=require("../../common/AmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),u=require("../../common/ImagePreviewTooltip.js"),s=require("../report/ReportMakingComponent.js"),c=require("../report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:v,registered_quantity:q,released_quantity:b,ordered_quantity:f,reports:_}=m,w=void 0!==_&&_.length>0?_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,C=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[I,V]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(u.default,{image:j,label:m.product.title})})]}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.AmountUpdater,{currentValue:v,totalValue:f+w,minnewvalue:0+q+-C,maxnewvalue:f+w,color:"info",handleChange:e=>{x(e,m.documentId,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.AmountUpdater,{currentValue:q,totalValue:f+w,minnewvalue:0+b,maxnewvalue:v+C,color:"info",handleChange:e=>{x(e,m.documentId,"registered_quantity")},offsetEnd:C}),e.jsx(n,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>V(!I),children:e.jsx(d,{})})]})}),e.jsx(o,{in:I,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:_}),e.jsx(s.default,{content:"content",quantity:0,type:"registered",minValue:-(v+C),maxValue:v,related:[{id:m.id,__type:"api::logistics.ipo-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.AmountUpdater,{currentValue:b||0,totalValue:f+w+C,minnewvalue:0,maxnewvalue:q,color:"info",handleChange:e=>{x(e,m.documentId,"released_quantity")}})]})},p)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),a=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./IPOItemUpdater.js"),o=require("./ItemDisplay.js"),d=require("../note/NotesDisplay.js"),c=require("../note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),m=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),p=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),j=require("@mui/material/DialogTitle"),v=require("@mui/material/Typography"),f=require("@mui/material/Button"),g=require("@mui/material/Grid"),y=require("@mui/material/Box"),b=require("@mui/material/Paper"),_=require("@mui/material/Stack"),q=require("@mui/material/Divider");const C={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function w({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(p,{open:i,children:[e.jsx(j,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{children:"Are you sure you want to confirm this order?"}),e.jsxs(v,{children:["Current status: ",a]})]})}),e.jsxs(h,{children:[e.jsx(f,{variant:"contained",onClick:e=>{m.confirmationService("ipos",[n]),t&&t(),r()},children:"Confirm"}),e.jsx(f,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:m,sx:p,revalidateCallback:h,handleClose:x,role:j}){const[I,k]=i.useActionState((e,i)=>n.updateIpoAction(m.documentId,e,i),C),{handleAddMessage:D}=r.useSnackbar(),[S,O]=i.useState(m.items?m.items:[]),[U,A]=i.useState(!1);i.useEffect(()=>{I?.message&&(D({message:I.message,severity:I.severity||"error"}),"success"===I.severity&&(h&&h(),x&&x()))},[I?.message]),i.useEffect(()=>{I?.strapiErrors&&D({message:I.strapiErrors.message||"Error performing action",severity:"error"})},[I?.strapiErrors]);const N=(e,i,r)=>{const n=[...S],a=n.findIndex(e=>e.documentId===i);n[a][r]=e,O(n)};return e.jsx(y,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(v,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(c.default,{content:"",related:[{id:m.documentId,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(q,{})]})}),e.jsx(g,{size:6,children:e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h5",children:"Details"}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(v,{variant:"body2",children:m.ipo_number})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(v,{variant:"body2",children:m.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(v,{variant:"body2",children:m.order_date})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(v,{variant:"body2",children:m.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(v,{variant:"body2",width:"250px",children:m.internal_status})]}),("placed"===m.internal_status||"released_on_stock"===m.internal_status)&&"enduser"===j&&e.jsxs(e.Fragment,{children:[e.jsx(f,{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(w,{open:U,handleClose:()=>A(!1),orderID:m.documentId,currentStatus:m.internal_status,revalidateCallback:h})]})]})}),e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Documents"}),e.jsx(b,{sx:{p:2},children:e.jsxs(_,{spacing:1,children:["enduser"===j&&e.jsx(e.Fragment,{children:m.order_confirmation?e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(v,{children:m.order_confirmation?.name}),e.jsx(f,{variant:"contained",onClick:()=>{t.default(`api/ipos/${m.documentId}`,"order_confirmation")},children:"Download"})]}):e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(v,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(a.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:m.documentId,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})]})}),m.delivery_note?e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(v,{children:m.delivery_note?.name}),e.jsx(f,{variant:"contained",onClick:()=>{t.default(`api/ipos/${m.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(v,{variant:"body1",children:"Upload the delivery note for this order"}),e.jsx(a.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:m.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})]})})]})}),m?.notes?.length>0&&e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:m.notes}),e.jsx(q,{})]})}),e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Items"}),"placed"===m.internal_status&&e.jsx(u,{severity:"warning",children:"Items cannot be updated before order confirmation"}),e.jsxs("form",{action:k,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(S))}),e.jsxs(_,{spacing:2,children:[m?.items&&m.items.map((i,r)=>e.jsx(b,{sx:{p:2},children:"placed"===m.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:N,image:i?.product?.image,revalidateCallback:h})},r)),"placed"!==m.internal_status&&e.jsx(b,{sx:{p:2},children:e.jsxs(_,{direction:"row",justifyContent:"flex-end",spacing:2,children:[x&&e.jsx(f,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(l.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("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),a=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./IPOItemUpdater.js"),o=require("./ItemDisplay.js"),d=require("../note/NotesDisplay.js"),c=require("../note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),m=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),p=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),j=require("@mui/material/DialogTitle"),v=require("@mui/material/Typography"),f=require("@mui/material/Button"),g=require("@mui/material/Grid"),y=require("@mui/material/Box"),b=require("@mui/material/Paper"),_=require("@mui/material/Stack"),q=require("@mui/material/Divider");const C={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function w({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(p,{open:i,children:[e.jsx(j,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{children:"Are you sure you want to confirm this order?"}),e.jsxs(v,{children:["Current status: ",a]})]})}),e.jsxs(h,{children:[e.jsx(f,{variant:"contained",onClick:e=>{m.confirmationService("ipos",[n]),t&&t(),r()},children:"Confirm"}),e.jsx(f,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:m,sx:p,revalidateCallback:h,handleClose:x,role:j}){const[I,k]=i.useActionState((e,i)=>n.updateIpoAction(m.documentId,e,i),C),{handleAddMessage:D}=r.useSnackbar(),[S,O]=i.useState(m.items?m.items:[]),[U,A]=i.useState(!1);i.useEffect(()=>{I?.message&&(D({message:I.message,severity:I.severity||"error"}),"success"===I.severity&&(h&&h(),x&&x()))},[I?.message]),i.useEffect(()=>{I?.strapiErrors&&D({message:I.strapiErrors.message||"Error performing action",severity:"error"})},[I?.strapiErrors]);const N=(e,i,r)=>{const n=[...S],a=n.findIndex(e=>e.documentId===i);n[a][r]=e,O(n)};return e.jsx(y,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(v,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(c.default,{content:"",related:[{id:m.id,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(q,{})]})}),e.jsx(g,{size:6,children:e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h5",children:"Details"}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(v,{variant:"body2",children:m.ipo_number})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(v,{variant:"body2",children:m.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(v,{variant:"body2",children:m.order_date})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(v,{variant:"body2",children:m.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(_,{direction:"row",spacing:2,children:[e.jsx(v,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(v,{variant:"body2",width:"250px",children:m.internal_status})]}),("placed"===m.internal_status||"released_on_stock"===m.internal_status)&&"enduser"===j&&e.jsxs(e.Fragment,{children:[e.jsx(f,{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(w,{open:U,handleClose:()=>A(!1),orderID:m.documentId,currentStatus:m.internal_status,revalidateCallback:h})]})]})}),e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Documents"}),e.jsx(b,{sx:{p:2},children:e.jsxs(_,{spacing:1,children:["enduser"===j&&e.jsx(e.Fragment,{children:m.order_confirmation?e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(v,{children:m.order_confirmation?.name}),e.jsx(f,{variant:"contained",onClick:()=>{t.default(`api/ipos/${m.documentId}`,"order_confirmation")},children:"Download"})]}):e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(v,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(a.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:m.documentId,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})]})}),m.delivery_note?e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(v,{children:m.delivery_note?.name}),e.jsx(f,{variant:"contained",onClick:()=>{t.default(`api/ipos/${m.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(_,{spacing:1,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(v,{variant:"body1",children:"Upload the delivery note for this order"}),e.jsx(a.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:m.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})]})})]})}),m?.notes?.length>0&&e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:m.notes}),e.jsx(q,{})]})}),e.jsx(g,{size:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Items"}),"placed"===m.internal_status&&e.jsx(u,{severity:"warning",children:"Items cannot be updated before order confirmation"}),e.jsxs("form",{action:k,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(S))}),e.jsxs(_,{spacing:2,children:[m?.items&&m.items.map((i,r)=>e.jsx(b,{sx:{p:2},children:"placed"===m.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:N,image:i?.product?.image,revalidateCallback:h})},r)),"placed"!==m.internal_status&&e.jsx(b,{sx:{p:2},children:e.jsxs(_,{direction:"row",justifyContent:"flex-end",spacing:2,children:[x&&e.jsx(f,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(l.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("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),c=require("./ItemDisplay.js"),d=require("./TextualIPOItemUpdater.js"),u=require("./IpoStatusIndicator.js"),m=require("@mui/material/Box"),h=require("@mui/material/Stack"),p=require("@mui/material/Paper"),x=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),v=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),g=require("@mui/material/Typography"),f=require("@mui/material/Button"),b=require("@mui/material/Grid"),_=require("@mui/material/Divider"),C=require("@mui/material/TextField"),I=require("@mui/material/List"),q=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),w=require("@mui/material/Checkbox"),S=require("@mui/material/FormControlLabel"),D=require("@mui/icons-material/Numbers"),N=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),z=require("@mui/icons-material/Business"),A=require("@mui/icons-material/Update"),E=require("../../SubmitButton.js"),M=require("../../common/media/minio/MinioDisplay.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function T({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(x,{open:r,onClose:n,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to confirm this order?"}),e.jsxs(g,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(f,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function U({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(x,{open:n,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(q,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(q,{children:"Please provide a reason for the cancellation"}),e.jsx(q,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(f,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,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:t,sx:a,revalidateCallback:x,handleClose:j,role:v}){const[y,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:I}=i.useSnackbar(),[q,F]=r.useState(t.items?t.items:[]),[B,R]=r.useState(!1),[W,L]=r.useState(!1),[G,J]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(x&&x(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const Q=(e,r,i)=>{const n=[...q],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...q],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,F(i)},K=(e,r)=>{const i=[...q],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,F(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),"success"===y.severity&&(x&&x(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&F(t.items?t.items:[])},[t]),e.jsx(m,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(b,{container:!0,spacing:2,children:[e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(g,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(o.default,{content:"",related:[{id:t.documentId,__type:"api::logistics.ipo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(N,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(z,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===v&&e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(k,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(T,{open:B,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:x})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(U,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:x})]})]})})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",children:"Documents"})}),"enduser"===v&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(M.MinioDisplay,{fileSize:t.minio_order_confirmation?.fileSize,mimeType:t.minio_order_confirmation?.mimeType,fileName:t.minio_order_confirmation?.fileName,bucketName:t.minio_order_confirmation?.bucketName,revalidateCallback:x})]})}):e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(g,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(M.MinioDisplay,{fileSize:t.minio_delivery_note?.fileSize,mimeType:t.minio_delivery_note?.mimeType,fileName:t.minio_delivery_note?.fileName,bucketName:t.minio_delivery_note?.bucketName,revalidateCallback:x})]})}):e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(g,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})}),t?.notes?.length>0&&e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(g,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:p,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(g,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(S,{control:e.jsx(w,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(g,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(k,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:C,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(q))}),q&&q.map((r,i)=>e.jsx(p,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(c.default,{item:r,index:i,image:r?.product?.image}):e.jsx(d.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:x,showing:G})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[j&&e.jsx(f,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(E.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),c=require("./ItemDisplay.js"),d=require("./TextualIPOItemUpdater.js"),u=require("./IpoStatusIndicator.js"),m=require("@mui/material/Box"),h=require("@mui/material/Stack"),p=require("@mui/material/Paper"),x=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),v=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),g=require("@mui/material/Typography"),f=require("@mui/material/Button"),b=require("@mui/material/Grid"),_=require("@mui/material/Divider"),C=require("@mui/material/TextField"),q=require("@mui/material/List"),I=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),w=require("@mui/material/Checkbox"),S=require("@mui/material/FormControlLabel"),D=require("@mui/icons-material/Numbers"),N=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),z=require("@mui/icons-material/Business"),A=require("@mui/icons-material/Update"),E=require("../../SubmitButton.js"),M=require("../../common/media/minio/MinioDisplay.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function T({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(x,{open:r,onClose:n,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to confirm this order?"}),e.jsxs(g,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(f,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function U({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(x,{open:n,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to cancel this return?"}),e.jsxs(q,{children:[e.jsx(I,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(I,{children:"Please provide a reason for the cancellation"}),e.jsx(I,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(f,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,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:t,sx:a,revalidateCallback:x,handleClose:j,role:v}){const[y,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:q}=i.useSnackbar(),[I,F]=r.useState(t.items?t.items:[]),[B,R]=r.useState(!1),[W,L]=r.useState(!1),[G,J]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(q({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(x&&x(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&q({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const Q=(e,r,i)=>{const n=[...I],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...I],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,F(i)},K=(e,r)=>{const i=[...I],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,F(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(q({message:"Ipo Updated",severity:"success"}),"success"===y.severity&&(x&&x(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&q({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&F(t.items?t.items:[])},[t]),e.jsx(m,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(b,{container:!0,spacing:2,children:[e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(g,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(o.default,{content:"",related:[{id:t.id,__type:"api::logistics.ipo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(N,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(z,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===v&&e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(k,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(T,{open:B,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:x})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(U,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:x})]})]})})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",children:"Documents"})}),"enduser"===v&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(M.MinioDisplay,{fileSize:t.minio_order_confirmation?.fileSize,mimeType:t.minio_order_confirmation?.mimeType,fileName:t.minio_order_confirmation?.fileName,bucketName:t.minio_order_confirmation?.bucketName,revalidateCallback:x})]})}):e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(g,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(M.MinioDisplay,{fileSize:t.minio_delivery_note?.fileSize,mimeType:t.minio_delivery_note?.mimeType,fileName:t.minio_delivery_note?.fileName,bucketName:t.minio_delivery_note?.bucketName,revalidateCallback:x})]})}):e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(g,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})}),t?.notes?.length>0&&e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(g,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:p,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(g,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(S,{control:e.jsx(w,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(g,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(k,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:C,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(I))}),I&&I.map((r,i)=>e.jsx(p,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(c.default,{item:r,index:i,image:r?.product?.image}):e.jsx(d.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:x,showing:G})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[j&&e.jsx(f,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(E.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/IconButton"),i=require("@mui/material/Dialog"),a=require("@mui/material/DialogContent"),o=require("@mui/material/DialogActions"),l=require("@mui/material/Button"),n=require("@mui/material/Typography"),s=require("@mui/material/Paper"),c=require("@mui/material/Stack"),u=require("../../../../node_modules/dayjs/dayjs.min.js"),d=require("@mui/icons-material/NoteAlt"),m=require("../../SubmitButton.js"),f=require("../../../data/actions/logistics/note/createNoteAction.js"),x=require("../../common/markdown/MarkdownEditor.js"),g=require("../../../context/common/SnackbarContext.js");const h={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({content:j,related:b,revalidateCallback:p}){const[q,k]=r.useState(!1),y=f.createNoteAction.bind(null,b),[v,S]=r.useActionState(y,h),{handleAddMessage:E}=g.useSnackbar();return r.useEffect(()=>{v?.strapiErrors&&E({message:v.strapiErrors,severity:v.severity||"error"}),v?.message&&E({message:v.message,severity:v.severity||"error"}),"success"===v?.severity&&(k(!1),p&&p())},[v]),e.jsxs(e.Fragment,{children:[e.jsx(t,{onClick:()=>k(!0),sx:{width:50,height:50,color:"#ffff88"},children:e.jsx(d,{fontSize:"large"})}),e.jsx(i,{open:q,fullWidth:!0,maxWidth:"lg",onClose:()=>k(!1),children:e.jsxs("form",{action:S,children:[e.jsx(a,{sx:{p:1},children:e.jsx(s,{elevation:4,sx:{background:"linear-gradient(135deg, #ffff88 81%,#ffff88 82%,#ffff88 82%,#ffffc6 100%)",color:"black",p:1},children:e.jsxs(c,{spacing:2,children:[e.jsx(n,{variant:"body1",textAlign:"right",children:u.default(Date.now()).format("DD-MM-YYYY")}),e.jsx(x.default,{name:"content",label:"The note",defaultValue:j,sx:{color:"black",label:{color:"black"},input:{color:"black"},div:{color:"black"}},textfieldProps:{id:"content",placeholder:"Write your note here...",multiline:!0,minRows:5,maxRows:10,error:null!=v?.zodErrors?.content,helperText:v?.zodErrors?.content||""}})]})})}),e.jsxs(o,{children:[e.jsx(l,{onClick:()=>k(!1),children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Submit",loadingText:"Loading..."})]})]})})]})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/IconButton"),i=require("@mui/material/Dialog"),a=require("@mui/material/DialogContent"),o=require("@mui/material/DialogActions"),l=require("@mui/material/Button"),n=require("@mui/material/Typography"),s=require("@mui/material/Paper"),u=require("@mui/material/Stack"),c=require("../../../../node_modules/dayjs/dayjs.min.js"),d=require("@mui/icons-material/NoteAlt"),m=require("../../SubmitButton.js"),f=require("../../../data/actions/logistics/note/createNoteAction.js"),x=require("../../common/markdown/MarkdownEditor.js"),g=require("../../../context/common/SnackbarContext.js");const h={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({content:j,related:b,revalidateCallback:p}){const[q,k]=r.useState(!1),y=f.createNoteAction.bind(null,b||null),[v,S]=r.useActionState(y,h),{handleAddMessage:E}=g.useSnackbar();return r.useEffect(()=>{v?.strapiErrors&&E({message:v.strapiErrors,severity:v.severity||"error"}),v?.message&&E({message:v.message,severity:v.severity||"error"}),"success"===v?.severity&&(k(!1),p&&p())},[v]),e.jsxs(e.Fragment,{children:[e.jsx(t,{onClick:()=>k(!0),sx:{width:50,height:50,color:"#ffff88"},children:e.jsx(d,{fontSize:"large"})}),e.jsx(i,{open:q,fullWidth:!0,maxWidth:"lg",onClose:()=>k(!1),children:e.jsxs("form",{action:S,children:[e.jsx(a,{sx:{p:1},children:e.jsx(s,{elevation:4,sx:{background:"linear-gradient(135deg, #ffff88 81%,#ffff88 82%,#ffff88 82%,#ffffc6 100%)",color:"black",p:1},children:e.jsxs(u,{spacing:2,children:[e.jsx(n,{variant:"body1",textAlign:"right",children:c.default(Date.now()).format("DD-MM-YYYY")}),e.jsx(x.default,{name:"content",label:"The note",defaultValue:j,sx:{color:"black",label:{color:"black"},input:{color:"black"},div:{color:"black"}},textfieldProps:{id:"content",placeholder:"Write your note here...",multiline:!0,minRows:5,maxRows:10,error:null!=v?.zodErrors?.content,helperText:v?.zodErrors?.content||""}})]})})}),e.jsxs(o,{children:[e.jsx(l,{onClick:()=>k(!1),children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Submit",loadingText:"Loading..."})]})]})})]})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/IconButton"),i=require("@mui/material/Dialog"),a=require("@mui/material/DialogContent"),n=require("@mui/material/DialogActions"),s=require("@mui/material/Button"),o=require("@mui/material/Typography"),l=require("@mui/material/Stack"),u=require("@mui/material/TextField"),c=require("../../../../node_modules/dayjs/dayjs.min.js"),d=require("../../SubmitButton.js"),m=require("../../../data/actions/logistics/report/createReportAction.js"),x=require("../../common/markdown/MarkdownEditor.js"),g=require("@mui/icons-material/Announcement"),j=require("@mui/material"),p=require("../../../data/loaders/user/getUserMeLoader.js"),h=require("../../../context/common/SnackbarContext.js");const q={zodErrors:null,strapiErrors:null,data:null,message:null};exports.default=function({content:b,related:f,type:y,minValue:v,maxValue:k,revalidateCallback:C,biggerButton:A=!1}){const[S,E]=r.useState(!1),[M,B]=r.useState(null),D=m.createReportAction.bind(null,f,y),[T,w]=r.useActionState(D,q),{handleAddMessage:V}=h.useSnackbar();return r.useEffect(()=>{T?.message&&(V({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(C&&C(),E(!1)))},[T?.message]),r.useEffect(()=>{!async function(){const{ok:e,data:r,error:t}=await p.getUserMeLoader();e&&r?(console.log("Current User:",r),B(r)):(B(null),console.error("Error fetching current user:",t))}()},[]),e.jsxs(e.Fragment,{children:[e.jsx(j.Box,{sx:{display:"block",position:"relative"},children:A?e.jsx(s,{variant:"contained",onClick:()=>E(!0),startIcon:e.jsx(g,{}),children:"Create Report"}):e.jsx(j.Tooltip,{title:"Create a report",children:e.jsx(t,{onClick:()=>E(!0),children:e.jsx(g,{fontSize:"large"})})})}),e.jsx(i,{open:S,fullWidth:!0,maxWidth:"lg",sx:{marginX:1},onClose:()=>E(!1),children:e.jsxs("form",{action:w,children:[e.jsxs(a,{sx:{p:1},children:[" ",e.jsxs(l,{spacing:2,children:[e.jsx(o,{variant:"body1",textAlign:"right",children:c.default(Date.now()).format("DD-MM-YYYY")}),e.jsx(u,{id:"quantity",name:"quantity",type:"number",label:"Amount",size:"small",InputProps:{inputProps:{min:`${void 0!==v&&void 0!==k&&v<k?v:k}`,max:`${void 0!==v&&void 0!==k&&k>v?k:v}`,step:"1"}},defaultValue:0,helperText:v&&k&&`Enter a number between ${v} and ${k}`}),e.jsx(x.default,{name:"content",label:"The report",defaultValue:b}),null!==M&&e.jsxs(e.Fragment,{children:[e.jsx(o,{variant:"body1",textAlign:"right",children:M.username}),e.jsx(o,{variant:"body2",textAlign:"right",children:M.email})]})]})]}),e.jsxs(n,{children:[e.jsx(s,{onClick:()=>E(!1),children:"Cancel"}),e.jsx(d.SubmitButton,{text:"Submit",loadingText:"Loading..."})]})]})})]})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/IconButton"),i=require("@mui/material/Dialog"),a=require("@mui/material/DialogContent"),n=require("@mui/material/DialogActions"),s=require("@mui/material/Button"),l=require("@mui/material/Typography"),o=require("@mui/material/Stack"),u=require("@mui/material/TextField"),c=require("../../../../node_modules/dayjs/dayjs.min.js"),d=require("../../SubmitButton.js"),m=require("../../../data/actions/logistics/report/createReportAction.js"),x=require("../../common/markdown/MarkdownEditor.js"),g=require("@mui/icons-material/Announcement"),j=require("@mui/material"),p=require("../../../data/loaders/user/getUserMeLoader.js"),h=require("../../../context/common/SnackbarContext.js");const q={zodErrors:null,strapiErrors:null,data:null,message:null};exports.default=function({content:b,related:f,type:y,minValue:v,maxValue:k,revalidateCallback:C,biggerButton:A=!1}){const[S,E]=r.useState(!1),[M,B]=r.useState(null),D=m.createReportAction.bind(null,f||null,y),[T,w]=r.useActionState(D,q),{handleAddMessage:V}=h.useSnackbar();return r.useEffect(()=>{T?.message&&(V({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(C&&C(),E(!1)))},[T?.message]),r.useEffect(()=>{!async function(){const{ok:e,data:r,error:t}=await p.getUserMeLoader();e&&r?(console.log("Current User:",r),B(r)):(B(null),console.error("Error fetching current user:",t))}()},[]),e.jsxs(e.Fragment,{children:[e.jsx(j.Box,{sx:{display:"block",position:"relative"},children:A?e.jsx(s,{variant:"contained",onClick:()=>E(!0),startIcon:e.jsx(g,{}),children:"Create Report"}):e.jsx(j.Tooltip,{title:"Create a report",children:e.jsx(t,{onClick:()=>E(!0),children:e.jsx(g,{fontSize:"large"})})})}),e.jsx(i,{open:S,fullWidth:!0,maxWidth:"lg",sx:{marginX:1},onClose:()=>E(!1),children:e.jsxs("form",{action:w,children:[e.jsxs(a,{sx:{p:1},children:[" ",e.jsxs(o,{spacing:2,children:[e.jsx(l,{variant:"body1",textAlign:"right",children:c.default(Date.now()).format("DD-MM-YYYY")}),e.jsx(u,{id:"quantity",name:"quantity",type:"number",label:"Amount",size:"small",InputProps:{inputProps:{min:`${void 0!==v&&void 0!==k&&v<k?v:k}`,max:`${void 0!==v&&void 0!==k&&k>v?k:v}`,step:"1"}},defaultValue:0,helperText:v&&k&&`Enter a number between ${v} and ${k}`}),e.jsx(x.default,{name:"content",label:"The report",defaultValue:b}),null!==M&&e.jsxs(e.Fragment,{children:[e.jsx(l,{variant:"body1",textAlign:"right",children:M.username}),e.jsx(l,{variant:"body2",textAlign:"right",children:M.email})]})]})]}),e.jsxs(n,{children:[e.jsx(s,{onClick:()=>E(!1),children:"Cancel"}),e.jsx(d.SubmitButton,{text:"Submit",loadingText:"Loading..."})]})]})})]})};