umwd-components 0.1.692 → 0.1.694

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.
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as r}from"../../_virtual/index7.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
6
+ import{__exports as r}from"../../_virtual/index8.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
@@ -3,5 +3,5 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as a}from"../../_virtual/index8.js";
6
+ import{__exports as a}from"../../_virtual/index7.js";
7
7
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var t;function o(){return t||(t=1,a.read=function(a,t,o,r,h){var M,e,i=8*h-r-1,p=(1<<i)-1,f=p>>1,n=-7,w=o?h-1:0,s=o?-1:1,u=a[t+w];for(w+=s,M=u&(1<<-n)-1,u>>=-n,n+=i;n>0;M=256*M+a[t+w],w+=s,n-=8);for(e=M&(1<<-n)-1,M>>=-n,n+=r;n>0;e=256*e+a[t+w],w+=s,n-=8);if(0===M)M=1-f;else{if(M===p)return e?NaN:1/0*(u?-1:1);e+=Math.pow(2,r),M-=f}return(u?-1:1)*e*Math.pow(2,M-r)},a.write=function(a,t,o,r,h,M){var e,i,p,f=8*M-h-1,n=(1<<f)-1,w=n>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,N=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,e=n):(e=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-e))<1&&(e--,p*=2),(t+=e+w>=1?s/p:s*Math.pow(2,1-w))*p>=2&&(e++,p/=2),e+w>=n?(i=0,e=n):e+w>=1?(i=(t*p-1)*Math.pow(2,h),e+=w):(i=t*Math.pow(2,w-1)*Math.pow(2,h),e=0));h>=8;a[o+u]=255&i,u+=N,i/=256,h-=8);for(e=e<<h|i,f+=h;f>0;a[o+u]=255&e,u+=N,e/=256,f-=8);a[o+u-N]|=128*_}),a}export{o as __require};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as a,useEffect as i}from"react";import{useFormState as o}from"react-dom";import{updateOpoAction as l}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import s from"./TextualOpoItemUpdater.js";import d from"./OpoItemDisplay.js";import u from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import v from"@mui/material/Alert";import E from"@mui/material/Dialog";import f from"@mui/material/DialogActions";import g from"@mui/material/DialogContent";import h from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import x from"@mui/material/Button";import b from"@mui/material/Grid";import C from"@mui/material/Box";import k from"@mui/material/Paper";import _ from"@mui/material/Stack";import w from"@mui/material/Divider";import{confirmationService as I}from"../../../data/services/common/confirmation-service.js";import{cancellationService as D}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as j,Checkbox as O,List as A,ListItem as N,TextField as q}from"@mui/material";import S from"@mui/icons-material/Numbers";import B from"@mui/icons-material/CalendarToday";import P from"@mui/icons-material/Business";import T from"@mui/icons-material/Description";import F from"@mui/icons-material/Update";import{OpoStatusIndicator as U}from"./OpoStatusIndicator.js";import{useSnackbar as R}from"../../../context/common/SnackbarContext.js";import{SubmitButton as W}from"../../SubmitButton.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},Y=["picked","packed","shipped","reports"];function z(e){var t=e.open,n=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return r.createElement(E,{open:t},r.createElement(h,null,"Confirm Order"),r.createElement(g,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to confirm this order?"),r.createElement(y,null,"Current status: ",i))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){I("opos",[a]),o&&o(),n()}},"Yes"),r.createElement(x,{variant:"contained",onClick:n},"No")))}function G(t){var n=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],s=c[1],d=e(a(""),2),u=d[0],p=d[1];return r.createElement("form",null,r.createElement(E,{open:n},r.createElement(h,null,"Cancel Return"),r.createElement(g,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(A,null,r.createElement(N,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(N,null,"Please provide a reason for the cancellation"),r.createElement(N,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(q,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!u,helperText:u}))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(D("opos",o,m),l&&l(),i())}},"Yes"),r.createElement(x,{variant:"contained",onClick:i},"No"))))}function H(E){var f,g,h,I,D,A=E.opo,N=E.sx,q=E.revalidateCallback,H=E.handleClose,J=E.role,Q=l.bind(null,A.id),K=e(o(Q,M),2),L=K[0],V=K[1],X=R().handleAddMessage,Z=e(a(A.opo_items.data?A.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(a(!1),2),ne=te[0],re=te[1],ae=e(a(!1),2),ie=ae[0],oe=ae[1],le=e(a(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];i((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==q||q(),null==H||H()))}),[null==L?void 0:L.message]),i((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),i((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&ee(A.opo_items.data?A.opo_items.data:[])}),[A]);var se=function(n,r,a){var i=t([],e($),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,ee(i)},de=function(r,a){var i,o,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[r],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=d,ee(c)},ue=function(n,r){var a,i,o=t([],e($),!1),l=o.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,ee(o)};return r.createElement(C,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},r.createElement(b,{container:!0,spacing:2},r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),r.createElement(y,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),r.createElement(p,{content:"",related:[{id:A.id,__type:"api::e-commerce.opo"}],revalidateCallback:q})),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(y,{variant:"h5",sx:{py:1}},"Details")),r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(g=null===(f=A.customer)||void 0===f?void 0:f.business_credentials)||void 0===g?void 0:g.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(F,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(U,{status:A.status}))))),"enduser"===J&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===A.status||"external_shipping_process"===A.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return re(!0)}},"Confirm order"),r.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(z,{open:ne,handleClose:function(){return re(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:q})),("placed"===A.status||"ordered"===A.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return oe(!0)}},"Cancel order"),r.createElement(G,{open:ie,handleClose:function(){return oe(!1)},orderID:A.id,revalidateCallback:q}))))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Documents"),r.createElement(k,{sx:{p:2}},r.createElement(_,{spacing:1},A.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(h=A.delivery_note)||void 0===h?void 0:h.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(A.id),"delivery_note")}},"Download")):r.createElement(r.Fragment,null,r.createElement(y,{variant:"h5"},"Delivery Note"),r.createElement(y,{variant:"body1"},"Here you can upload the the delivery note for this order"),r.createElement(w,null),r.createElement(c,{reference:"api::e-commerce.opo",refID:A.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:q})))))),(null===(D=null===(I=null==A?void 0:A.notes)||void 0===I?void 0:I.data)||void 0===D?void 0:D.length)>0&&r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Notes"),r.createElement(u,{notes:A.notes.data}),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:1},r.createElement(y,{variant:"h5"},"Items"),r.createElement(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:k,p:1},r.createElement(y,{variant:"body1"},"Show:"),Y.map((function(n){return r.createElement(j,{key:n,control:r.createElement(O,{checked:ce.includes(n),onChange:function(r){r.target.checked?me(t(t([],e(ce),!1),[n],!1)):me(ce.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===A.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:V},r.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}($))}),$&&$.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===A.status||"external_shipping_process"===A.status||"done"===A.status||"cancelled"===A.status?r.createElement(d,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(s,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ue,revalidateCallback:q,showing:ce}))}))," ",r.createElement(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},H&&r.createElement(x,{onClick:H,variant:"outlined"},"Cancel"),r.createElement(W,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{H as default};
6
+ import{__read as e,__spreadArray as t,__awaiter as n,__generator as r,__assign as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{updateOpoAction as m}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as s}from"../../common/media/UploadBase64MediaForm.js";import d from"../../../data/loaders/common/media/downloadBase64File.js";import u from"./TextualOpoItemUpdater.js";import p from"./OpoItemDisplay.js";import v from"../../logistics/note/NotesDisplay.js";import f from"../../logistics/note/NoteTakingComponent.js";import E from"@mui/material/Alert";import g from"@mui/material/Dialog";import h from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import x from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import C from"@mui/material/Button";import k from"@mui/material/Grid";import w from"@mui/material/Box";import _ from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as O}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as A,Checkbox as N,List as q,ListItem as S,TextField as B}from"@mui/material";import P from"@mui/icons-material/Numbers";import T from"@mui/icons-material/CalendarToday";import F from"@mui/icons-material/Business";import U from"@mui/icons-material/Description";import R from"@mui/icons-material/Update";import{OpoStatusIndicator as W}from"./OpoStatusIndicator.js";import{useSnackbar as M}from"../../../context/common/SnackbarContext.js";import{SubmitButton as Y}from"../../SubmitButton.js";var z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},G=["picked","packed","shipped","reports"];function H(e){var t=e.open,n=e.handleClose,r=e.orderID,a=e.currentStatus,o=e.revalidateCallback;return i.createElement(g,{open:t},i.createElement(x,null,"Confirm Order"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to confirm this order?"),i.createElement(b,null,"Current status: ",a))),i.createElement(h,null,i.createElement(C,{variant:"contained",onClick:function(e){j("opos",[r]),o&&o(),n()}},"Yes"),i.createElement(C,{variant:"contained",onClick:n},"No")))}function J(t){var a=this,l=t.open,c=t.handleClose,m=t.orderID,s=t.revalidateCallback,d=e(o(""),2),u=d[0],p=d[1],v=e(o(""),2),f=v[0],E=v[1];return i.createElement("form",null,i.createElement(g,{open:l},i.createElement(x,null,"Cancel Return"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to cancel this order?"),i.createElement(q,null,i.createElement(S,null,"By cancelling this order you will update it's status from ordered to cancelled"),i.createElement(S,null,"Please provide a reason for the cancellation"),i.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(B,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:u,onChange:function(e){return p(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!f,helperText:f}))),i.createElement(h,null,i.createElement(C,{variant:"contained",onClick:function(e){return n(a,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return u.length<5?(E("Please provide a reason for the cancellation"),[2]):[4,O("opos",m,u)];case 1:return e=t.sent(),console.log("Cancellation response",e),s&&s(),c(),[2]}}))}))}},"Yes"),i.createElement(C,{variant:"contained",onClick:c},"No"))))}function Q(n){var r,g,h,y,x,j=n.opo,O=n.sx,q=n.revalidateCallback,S=n.handleClose,B=n.role,Q=m.bind(null,j.id),K=e(c(Q,z),2),L=K[0],V=K[1],X=M().handleAddMessage,Z=e(o(j.opo_items.data?j.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(o(!1),2),ne=te[0],re=te[1],ae=e(o(!1),2),ie=ae[0],oe=ae[1],le=e(o(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];l((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==q||q(),null==S||S()))}),[null==L?void 0:L.message]),l((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),l((function(){var e;(null===(e=j.opo_items)||void 0===e?void 0:e.data)&&ee(j.opo_items.data?j.opo_items.data:[])}),[j]);var se=function(n,r,a){var i=t([],e($),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,ee(i)},de=function(n,r){var i,o,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===r})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[n],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=a(a({},c[m]),{reports:{data:[]}})),c[m].reports.data=d,ee(c)},ue=function(n,r){var a,i,o=t([],e($),!1),l=o.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,ee(o)};return i.createElement(w,{sx:t([],e(Array.isArray(O)?O:[O]),!1)},i.createElement(k,{container:!0,spacing:2},i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),i.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),i.createElement(f,{content:"",related:[{id:j.id,__type:"api::e-commerce.opo"}],revalidateCallback:q})),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(b,{variant:"h5",sx:{py:1}},"Details")),i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.opo_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(T,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.order_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(b,{variant:"body1",fontWeight:"medium"},null===(g=null===(r=j.customer)||void 0===r?void 0:r.business_credentials)||void 0===g?void 0:g.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(R,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(W,{status:j.status}))))),"enduser"===B&&i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},("placed"===j.status||"external_shipping_process"===j.status)&&i.createElement(i.Fragment,null,i.createElement(C,{variant:"contained",color:"primary",onClick:function(){return re(!0)}},"Confirm order"),i.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(H,{open:ne,handleClose:function(){return re(!1)},orderID:j.id,currentStatus:j.status,revalidateCallback:q})),("placed"===j.status||"ordered"===j.status)&&i.createElement(i.Fragment,null,i.createElement(C,{variant:"contained",color:"error",onClick:function(){return oe(!0)}},"Cancel order"),i.createElement(J,{open:ie,handleClose:function(){return oe(!1)},orderID:j.id,revalidateCallback:q}))))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Documents"),i.createElement(_,{sx:{p:2}},i.createElement(I,{spacing:1},j.delivery_note?i.createElement(i.Fragment,null,i.createElement(b,{variant:"h6"},"Delivery Note"),i.createElement(b,null,null===(h=j.delivery_note)||void 0===h?void 0:h.name),i.createElement(C,{variant:"contained",onClick:function(){d("api/ipos/".concat(j.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(b,{variant:"h5"},"Delivery Note"),i.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(D,null),i.createElement(s,{reference:"api::e-commerce.opo",refID:j.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:q})))))),(null===(x=null===(y=null==j?void 0:j.notes)||void 0===y?void 0:y.data)||void 0===x?void 0:x.length)>0&&i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Notes"),i.createElement(v,{notes:j.notes.data}),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(b,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1},i.createElement(b,{variant:"body1"},"Show:"),G.map((function(n){return i.createElement(A,{key:n,control:i.createElement(N,{checked:ce.includes(n),onChange:function(r){r.target.checked?me(t(t([],e(ce),!1),[n],!1)):me(ce.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===j.status&&i.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(D,null),i.createElement("form",{action:V},i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}($))}),$&&$.map((function(e,t){var n,r;return i.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===j.status||"external_shipping_process"===j.status||"done"===j.status||"cancelled"===j.status?i.createElement(p,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):i.createElement(u,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image,handleRemoveReportAtIndex:ue,revalidateCallback:q,showing:ce}))}))," ",i.createElement(I,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},S&&i.createElement(C,{onClick:S,variant:"outlined"},"Cancel"),i.createElement(Y,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{Q as default};