umwd-components 0.1.721 → 0.1.722

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 (45) hide show
  1. package/dist/cjs/src/components/e-commerce/iro/IroItemDisplay.js +1 -1
  2. package/dist/cjs/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
  3. package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
  4. package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
  5. package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
  6. package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
  7. package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
  8. package/dist/cjs/src/components/e-commerce/opo/OpoItemDisplay.js +1 -1
  9. package/dist/cjs/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
  10. package/dist/cjs/src/components/e-commerce/opo/OpoSummary.js +1 -1
  11. package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  12. package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
  13. package/dist/cjs/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
  14. package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
  15. package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
  16. package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
  17. package/dist/cjs/src/data/loaders/e-commerce/getAllOpos.js +1 -1
  18. package/dist/cjs/src/data/loaders/e-commerce-loaders.js +1 -1
  19. package/dist/cjs/src/lib/isEORIValid.js +1 -1
  20. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  21. package/dist/esm/src/components/e-commerce/iro/IroItemDisplay.js +1 -1
  22. package/dist/esm/src/components/e-commerce/iro/IroItemUpdater.js +5 -5
  23. package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +3 -3
  24. package/dist/esm/src/components/e-commerce/iro/RmaForm.js +1 -1
  25. package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +8 -8
  26. package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +14 -14
  27. package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +4 -4
  28. package/dist/esm/src/components/e-commerce/opo/OpoItemDisplay.js +1 -1
  29. package/dist/esm/src/components/e-commerce/opo/OpoItemUpdater.js +8 -7
  30. package/dist/esm/src/components/e-commerce/opo/OpoSummary.js +2 -2
  31. package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +10 -10
  32. package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +8 -8
  33. package/dist/esm/src/components/logistics/ipo/IPOItemUpdater.js +5 -5
  34. package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +3 -3
  35. package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +8 -8
  36. package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +10 -10
  37. package/dist/esm/src/data/loaders/e-commerce/getAllOpos.js +1 -1
  38. package/dist/esm/src/data/loaders/e-commerce-loaders.js +0 -1
  39. package/dist/esm/src/lib/isEORIValid.js +0 -1
  40. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  41. package/dist/esm/types/data/services/archive-service.d.ts +2 -2
  42. package/dist/esm/types/types/e-commerce/iro/types.d.ts +3 -9
  43. package/dist/esm/types/types/e-commerce/opo/types.d.ts +3 -9
  44. package/dist/esm/types/types/logistics/Ipo.d.ts +3 -9
  45. 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"),i=require("react-dom"),a=require("../../../context/common/SnackbarContext.js"),t=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),l=require("../../common/media/UploadBase64MediaForm.js"),d=require("../note/NoteTakingComponent.js"),c=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),_=require("@mui/material/Divider"),w=require("@mui/material/TextField"),I=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:t,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=a.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[t]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:t,orderID:n,revalidateCallback:o}){const[l,d]=r.useState(""),[c,u]=r.useState(""),{handleAddMessage:m}=a.useSnackbar();return e.jsxs(g,{open:i,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(w,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>d(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!c,helperText:c})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,w]=i.useFormState((e,r)=>t.updateIpoAction(n.id,e,r),N),{handleAddMessage:I}=a.useSnackbar(),[k,R]=r.useState(n.items.data?n.items.data:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const a=[...k],t=a.findIndex(e=>e.id===r);a[t][i]=e,R(a)},Q=(e,r)=>{const i=[...k],a=i.findIndex(e=>e.id===r),t=[...i[a]?.reports?.data||[],e];null==i[a]?.reports&&(i[a]={...i[a],reports:{data:[]}}),i[a].reports.data=t,R(i)},K=(e,r)=>{const i=[...k],a=i.findIndex(r=>r.id===e),t=i[a]?.reports?.data||[],n=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[a].reports.data=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items?.data&&R(n.items.data?n.items.data:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(d.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.internal_status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.internal_status||"released_on_stock"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.id,currentStatus:n.internal_status,revalidateCallback:g})]}),("placed"===n.internal_status||"ordered"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.id,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})]})})]})}),n?.notes?.data?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:n.notes.data}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:w,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.internal_status||"cancelled"===n.internal_status||"done"===n.internal_status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),a=require("../../../context/common/SnackbarContext.js"),t=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),l=require("../../common/media/UploadBase64MediaForm.js"),c=require("../note/NoteTakingComponent.js"),d=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),_=require("@mui/material/Divider"),w=require("@mui/material/TextField"),I=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:t,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=a.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[t]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:t,orderID:n,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=a.useSnackbar();return e.jsxs(g,{open:i,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(w,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,w]=i.useFormState((e,r)=>t.updateIpoAction(n.id,e,r),N),{handleAddMessage:I}=a.useSnackbar(),[k,R]=r.useState(n.items?n.items:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const a=[...k],t=a.findIndex(e=>e.id===r);a[t][i]=e,R(a)},Q=(e,r)=>{const i=[...k],a=i.findIndex(e=>e.id===r),t=[...i[a]?.reports||[],e];null==i[a]?.reports&&(i[a]={...i[a],reports:[]}),i[a].reports=t,R(i)},K=(e,r)=>{const i=[...k],a=i.findIndex(r=>r.id===e),t=i[a]?.reports||[],n=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[a].reports=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items&&R(n.items?n.items:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.internal_status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.internal_status||"released_on_stock"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.id,currentStatus:n.internal_status,revalidateCallback:g})]}),("placed"===n.internal_status||"ordered"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.id,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})]})})]})}),n?.notes?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:n.notes}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:w,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.internal_status||"cancelled"===n.internal_status||"done"===n.internal_status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("../../../../node_modules/qs/lib/index.js"),s=require("../loaders.js"),r=require("../../../lib/utils.js"),i=require("next/cache"),t=require("../../services/get-user-me-loader.js"),a=require("../../../lib/processFilters.js");const l=r.getStrapiURL();exports.getAllOpos=async function(r,d,o,u,n=[!1],p={}){i.unstable_noStore();const c=await t.getUserRole(),_=c?.data?.role?.type,b="enduser"===_,y=new URL("/api/opos",l),m=a.processFilters(p);return y.search=e.default.stringify({filters:{is_archive:{$in:n},...m},sort:`${u||"createdAt"}:${o||"desc"}`,populate:{opo_items:{populate:{product:{populate:{price:!0}},reports:!0}},customer:!!b&&{populate:{company_address:!0,delivery_address:!0,billing_address:!0,business_credentials:!0}},payments:!0,invoice:{populate:{seller_business_credentials:!0,seller_company_address:!0,buyer_company_address:!0,buyer_delivery_address:!0,buyer_billing_address:!0,buyer_business_credentials:!0,items:!0,admin_items:!0}},iros:{fields:["id","uuid","status"]}},pagination:{pageSize:d||10,page:r?r+1:1}}),await s.fetchData(y.href)};
7
+ "use strict";var e=require("../../../../node_modules/qs/lib/index.js"),s=require("../loaders.js"),r=require("../../../lib/utils.js"),i=require("next/cache"),t=require("../../services/get-user-me-loader.js"),a=require("../../../lib/processFilters.js");const l=r.getStrapiURL();exports.getAllOpos=async function(r,d,o,n,u=[!1],p={}){i.unstable_noStore();const c=await t.getUserRole(),_=c?.data?.role?.type,b="enduser"===_,y=new URL("/api/opos",l),m=a.processFilters(p);return y.search=e.default.stringify({filters:{is_archive:{$in:u},...m},sort:`${n||"createdAt"}:${o||"desc"}`,populate:{opo_items:{populate:{product:{populate:{price:!0}},reports:!0}},customer:!!b&&{populate:{company_address:!0,delivery_address:!0,billing_address:!0,business_credentials:!0}},payments:!0,invoice:{populate:{seller_business_credentials:!0,seller_company_address:!0,buyer_company_address:!0,buyer_delivery_address:!0,buyer_billing_address:!0,buyer_business_credentials:!0,items:!0,admin_items:!0}},iros:{fields:["id","uuid","internal_status"]}},pagination:{pageSize:d||10,page:r?r+1:1}}),await s.fetchData(y.href)};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("../../../node_modules/qs/lib/index.js"),r=require("./loaders.js"),t=require("../../lib/utils.js"),s=require("next/cache");require("../services/get-user-me-loader.js");const i=t.getStrapiURL();exports.getCustomerProfile=async function(){s.unstable_noStore();const t=new URL("/api/users/me",i);return t.search=e.default.stringify({populate:{customer_profile:!0}}),await r.fetchData(t.href)},exports.getSingleOrderByUuid=async function(e){console.log("getSingleOrderByUuid",e),s.unstable_noStore();const t=new URL(`/api/opos/uuid/${e}`,i);return await r.fetchData(t.href)};
7
+ "use strict";var e=require("../../../node_modules/qs/lib/index.js"),r=require("./loaders.js"),t=require("../../lib/utils.js"),s=require("next/cache");const i=t.getStrapiURL();exports.getCustomerProfile=async function(){s.unstable_noStore();const t=new URL("/api/users/me",i);return t.search=e.default.stringify({populate:{customer_profile:!0}}),await r.fetchData(t.href)},exports.getSingleOrderByUuid=async function(e){console.log("getSingleOrderByUuid",e),s.unstable_noStore();const t=new URL(`/api/opos/uuid/${e}`,i);return await r.fetchData(t.href)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e){if(e?.eori_number){const s=e?.eori_validate_response||{status:"1",statusDescr:"Valid"},t=Boolean("0"===s.status&&"Valid"===s.statusDescr);return console.log("isEORIValid",t),t}return!1};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e){if(e?.eori_number){const t=e?.eori_validate_response||{status:"1",statusDescr:"Valid"};return Boolean("0"===t.status&&"Valid"===t.statusDescr)}return!1};