umwd-components 0.1.648 → 0.1.649

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/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};
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};
@@ -3,5 +3,5 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as a}from"../../_virtual/index7.js";
6
+ import{__exports as a}from"../../_virtual/index8.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 r}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useState as a,useEffect as i}from"react";import{useFormState as o}from"react-dom";import{updateIpoAction as l}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualIPOItemUpdater.js";import s from"./ItemDisplay.js";import u from"../note/NotesDisplay.js";import p from"../note/NoteTakingComponent.js";import{SubmitButton as v}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import h from"@mui/material/DialogTitle";import x from"@mui/material/Typography";import b from"@mui/material/Button";import C from"@mui/material/Grid";import w from"@mui/material/Box";import _ from"@mui/material/Paper";import I from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as D}from"../../../data/services/common/confirmation-service.js";import{cancellationService as j}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as q,Checkbox as A,List as N,ListItem as S,TextField as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import U from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import F from"@mui/icons-material/Description";import T from"@mui/icons-material/Update";import{IpoStatusIndicator as R}from"./IpoStatusIndicator.js";import{useSnackbar as W}from"../../../context/common/SnackbarContext.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null};function z(e){var t=e.open,r=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return n.createElement(E,{open:t},n.createElement(h,null,"Confirm Order"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(x,null,"Are you sure you want to confirm this order?"),n.createElement(x,null,"Current status: ",i))),n.createElement(g,null,n.createElement(b,{variant:"contained",onClick:function(e){D("ipos",[a]),o&&o(),r()}},"Confirm"),n.createElement(b,{variant:"contained",onClick:r},"Cancel")))}function H(t){var r=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],d=c[1],s=e(a(""),2),u=s[0],p=s[1];return n.createElement("form",null,n.createElement(E,{open:r},n.createElement(h,null,"Cancel Return"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(x,null,"Are you sure you want to cancel this return?"),n.createElement(N,null,n.createElement(S,null,"By cancelling this return order you will update it's status from requested to cancelled"),n.createElement(S,null,"Please provide a reason for the cancellation"),n.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),n.createElement(O,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return d(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!u,helperText:u}))),n.createElement(g,null,n.createElement(b,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(j("ipos",o,m),l&&l(),i())}},"Yes"),n.createElement(b,{variant:"contained",onClick:i},"No"))))}function G(E){var g,y,h,D,j,N,S=E.data,O=E.sx,G=E.revalidateCallback,J=E.handleClose,L=E.role,Q=e(o(l,M),2),Y=Q[0],K=Q[1],V=e(a(S.items.data?S.items.data:[]),2),X=V[0],Z=V[1],$=e(a(!1),2),ee=$[0],te=$[1],re=e(a(!1),2),ne=re[0],ae=re[1],ie=e(a(["received","registered","released","reports"]),2),oe=ie[0],le=ie[1],ce=function(r,n,a){var i=t([],e(X),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,Z(i)},me=function(n,a){var i,o,l,c=t([],e(X),!1),m=c.findIndex((function(e){return e.id===a})),d=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],s=t(t([],e(d),!1),[n],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,Z(c)},de=function(r,n){var a,i,o=t([],e(X),!1),l=o.findIndex((function(e){return e.id===r})),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})),d=c.filter((function(e){return!("id"in e)}));d.splice(n,1);var s=t(t([],e(m),!1),e(d),!1);o[l].reports.data=s,Z(o)},se=W().handleAddMessage;return i((function(){"Ipo Updated"===(null==Y?void 0:Y.message)&&(se({message:"Ipo Updated",severity:"success"}),J&&J(),G&&G())}),[Y]),i((function(){(null==Y?void 0:Y.strapiErrors)&&se({message:Y.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==Y?void 0:Y.strapiErrors]),i((function(){var e;console.log("data",S),(null===(e=S.items)||void 0===e?void 0:e.data)&&Z(S.items.data?S.items.data:[])}),[S]),n.createElement(w,{sx:t([],e(Array.isArray(O)?O:[O]),!1)},n.createElement(C,{container:!0,spacing:2},n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),n.createElement(x,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),n.createElement(p,{content:"",related:[{id:S.id,__type:"api::logistics.ipo"}],revalidateCallback:G})),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(x,{variant:"h5",sx:{py:1}},"Details")),n.createElement(C,{item:!0,xs:6},n.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(P,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.ipo_number)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(F,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.customer_reference)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(U,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.order_date)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(B,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),n.createElement(x,{variant:"body1",fontWeight:"medium"},null===(y=null===(g=S.vendor_profile)||void 0===g?void 0:g.business_credentials)||void 0===y?void 0:y.company_name)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(T,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),n.createElement(R,{status:S.status}))))),("placed"===S.status||"released_on_stock"===S.status)&&"enduser"===L&&n.createElement(C,{item:!0,xs:6},n.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},n.createElement(b,{variant:"contained",color:"primary",onClick:function(){return te(!0)}},"Confirm order"),n.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),n.createElement(b,{variant:"contained",color:"error",onClick:function(){return ae(!0)}},"Cancel order"),n.createElement(z,{open:ee,handleClose:function(){return te(!1)},orderID:S.id,currentStatus:S.status,revalidateCallback:G}),n.createElement(H,{open:ne,handleClose:function(){return ae(!1)},orderID:S.id,revalidateCallback:G})))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h5"},"Documents"),n.createElement(_,{sx:{p:2}},n.createElement(I,{spacing:1},"enduser"===L&&n.createElement(n.Fragment,null,S.order_confirmation?n.createElement(n.Fragment,null,n.createElement(x,{variant:"h6"},"Order Confirmation"),n.createElement(x,null,null===(h=S.order_confirmation)||void 0===h?void 0:h.name),n.createElement(b,{variant:"contained",onClick:function(){m("api/ipos/".concat(S.id),"order_confirmation")}},"Download")):n.createElement(n.Fragment,null,n.createElement(x,{variant:"h5"},"Order Confirmation"),n.createElement(x,{variant:"body1"},"Here you can upload the the order confirmation for this order"),n.createElement(x,{variant:"body1"},"FileUpload"),n.createElement(k,null),n.createElement(c,{reference:"api::logistics.ipo",refID:S.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}))),S.delivery_note?n.createElement(n.Fragment,null,n.createElement(x,{variant:"h6"},"Delivery Note"),n.createElement(x,null,null===(D=S.delivery_note)||void 0===D?void 0:D.name),n.createElement(b,{variant:"contained",onClick:function(){m("api/ipos/".concat(S.id),"delivery_note")}},"Download")):n.createElement(n.Fragment,null,n.createElement(x,{variant:"h5"},"Delivery Note"),n.createElement(x,{variant:"body1"},"Here you can upload the the delivery note for this order"),n.createElement(k,null),n.createElement(c,{reference:"api::logistics.ipo",refID:S.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})))))),(null===(N=null===(j=null==S?void 0:S.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h5"},"Notes"),n.createElement(u,{notes:S.notes.data}),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:1},n.createElement(x,{variant:"h5"},"Items"),n.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},n.createElement(x,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return n.createElement(q,{key:r,control:n.createElement(A,{size:"small",checked:oe.includes(r),onChange:function(n){n.target.checked?le(t(t([],e(oe),!1),[r],!1)):le(oe.filter((function(e){return e!==r})))}}),label:n.createElement(x,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===S.status&&n.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(k,null),n.createElement("form",{action:K},n.createElement("input",{name:"id",type:"hidden",value:S.id}),X&&X.map((function(e,t){var r,a;return n.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===S.status||"cancelled"===S.status||"done"===S.status?n.createElement(s,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):n.createElement(d,{item:e,index:t,handleUpdateQuantity:ce,handleAddReport:me,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:de,revalidateCallback:G,showing:oe}))})),n.createElement(_,{sx:{p:2}},n.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(v,{text:"Update items",loadingText:"Loading..."}))),n.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(r=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===r?void 0:r.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(X))}))))))}export{G as default};
6
+ import{__read as e,__spreadArray as t,__assign as r}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useState as a,useEffect as o}from"react";import{useFormState as i}from"react-dom";import{updateIpoAction as l}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualIPOItemUpdater.js";import s from"./ItemDisplay.js";import u from"../note/NotesDisplay.js";import p from"../note/NoteTakingComponent.js";import{SubmitButton as v}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import h from"@mui/material/DialogTitle";import x from"@mui/material/Typography";import b from"@mui/material/Button";import C from"@mui/material/Grid";import w from"@mui/material/Box";import _ from"@mui/material/Paper";import I from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as D}from"../../../data/services/common/confirmation-service.js";import{cancellationService as j}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as q,Checkbox as A,List as N,ListItem as S,TextField as F}from"@mui/material";import O from"@mui/icons-material/Numbers";import P from"@mui/icons-material/CalendarToday";import U from"@mui/icons-material/Business";import B from"@mui/icons-material/Description";import T from"@mui/icons-material/Update";import{IpoStatusIndicator as R}from"./IpoStatusIndicator.js";import{useSnackbar as W}from"../../../context/common/SnackbarContext.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null};function z(e){var t=e.open,r=e.handleClose,a=e.orderID,o=e.currentStatus,i=e.revalidateCallback;return n.createElement(E,{open:t},n.createElement(h,null,"Confirm Order"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(x,null,"Are you sure you want to confirm this order?"),n.createElement(x,null,"Current status: ",o))),n.createElement(g,null,n.createElement(b,{variant:"contained",onClick:function(e){D("ipos",[a]),i&&i(),r()}},"Confirm"),n.createElement(b,{variant:"contained",onClick:r},"Cancel")))}function H(t){var r=t.open,o=t.handleClose,i=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],d=c[1],s=e(a(""),2),u=s[0],p=s[1];return n.createElement("form",null,n.createElement(E,{open:r},n.createElement(h,null,"Cancel Return"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(x,null,"Are you sure you want to cancel this return?"),n.createElement(N,null,n.createElement(S,null,"By cancelling this return order you will update it's status from requested to cancelled"),n.createElement(S,null,"Please provide a reason for the cancellation"),n.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),n.createElement(F,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return d(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!u,helperText:u}))),n.createElement(g,null,n.createElement(b,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(j("ipos",i,m),l&&l(),o())}},"Yes"),n.createElement(b,{variant:"contained",onClick:o},"No"))))}function G(E){var g,y,h,D,j,N,S=E.data,F=E.sx,G=E.revalidateCallback,J=E.handleClose,L=E.role,Q=e(i(l,M),2),Y=Q[0],K=Q[1],V=e(a(S.items.data?S.items.data:[]),2),X=V[0],Z=V[1],$=e(a(!1),2),ee=$[0],te=$[1],re=e(a(!1),2),ne=re[0],ae=re[1],oe=e(a(["received","registered","released","reports"]),2),ie=oe[0],le=oe[1],ce=function(r,n,a){var o=t([],e(X),!1),i=o.findIndex((function(e){return e.id===n}));o[i][a]=r,Z(o)},me=function(n,a){var o,i,l,c=t([],e(X),!1),m=c.findIndex((function(e){return e.id===a})),d=(null===(i=null===(o=c[m])||void 0===o?void 0:o.reports)||void 0===i?void 0:i.data)||[],s=t(t([],e(d),!1),[n],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,Z(c)},de=function(r,n){var a,o,i=t([],e(X),!1),l=i.findIndex((function(e){return e.id===r})),c=(null===(o=null===(a=i[l])||void 0===a?void 0:a.reports)||void 0===o?void 0:o.data)||[],m=c.filter((function(e){return"id"in e})),d=c.filter((function(e){return!("id"in e)}));d.splice(n,1);var s=t(t([],e(m),!1),e(d),!1);i[l].reports.data=s,Z(i)},se=W().handleAddMessage;return o((function(){"Ipo Updated"===(null==Y?void 0:Y.message)&&(se({message:"Ipo Updated",severity:"success"}),J&&J(),G&&G())}),[Y]),o((function(){(null==Y?void 0:Y.strapiErrors)&&se({message:Y.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==Y?void 0:Y.strapiErrors]),o((function(){var e;console.log("data",S),(null===(e=S.items)||void 0===e?void 0:e.data)&&Z(S.items.data?S.items.data:[])}),[S]),n.createElement(w,{sx:t([],e(Array.isArray(F)?F:[F]),!1)},n.createElement(C,{container:!0,spacing:2},n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),n.createElement(x,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),n.createElement(p,{content:"",related:[{id:S.id,__type:"api::logistics.ipo"}],revalidateCallback:G})),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(x,{variant:"h5",sx:{py:1}},"Details")),n.createElement(C,{item:!0,xs:6},n.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(O,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.ipo_number)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(B,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.customer_reference)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(P,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.order_date)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(U,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),n.createElement(x,{variant:"body1",fontWeight:"medium"},null===(y=null===(g=S.vendor_profile)||void 0===g?void 0:g.business_credentials)||void 0===y?void 0:y.company_name)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(T,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),n.createElement(R,{status:S.status}))))),"enduser"===L&&n.createElement(C,{item:!0,xs:6},n.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},("placed"===S.status||"released_on_stock"===S.status)&&n.createElement(n.Fragment,null,n.createElement(b,{variant:"contained",color:"primary",onClick:function(){return te(!0)}},"Confirm order"),n.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),n.createElement(z,{open:ee,handleClose:function(){return te(!1)},orderID:S.id,currentStatus:S.status,revalidateCallback:G})),("placed"===S.status||"ordered"===S.status)&&n.createElement(n.Fragment,null,n.createElement(b,{variant:"contained",color:"error",onClick:function(){return ae(!0)}},"Cancel order"),n.createElement(H,{open:ne,handleClose:function(){return ae(!1)},orderID:S.id,revalidateCallback:G}))))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h5"},"Documents"),n.createElement(_,{sx:{p:2}},n.createElement(I,{spacing:1},"enduser"===L&&n.createElement(n.Fragment,null,S.order_confirmation?n.createElement(n.Fragment,null,n.createElement(x,{variant:"h6"},"Order Confirmation"),n.createElement(x,null,null===(h=S.order_confirmation)||void 0===h?void 0:h.name),n.createElement(b,{variant:"contained",onClick:function(){m("api/ipos/".concat(S.id),"order_confirmation")}},"Download")):n.createElement(n.Fragment,null,n.createElement(x,{variant:"h5"},"Order Confirmation"),n.createElement(x,{variant:"body1"},"Here you can upload the the order confirmation for this order"),n.createElement(x,{variant:"body1"},"FileUpload"),n.createElement(k,null),n.createElement(c,{reference:"api::logistics.ipo",refID:S.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}))),S.delivery_note?n.createElement(n.Fragment,null,n.createElement(x,{variant:"h6"},"Delivery Note"),n.createElement(x,null,null===(D=S.delivery_note)||void 0===D?void 0:D.name),n.createElement(b,{variant:"contained",onClick:function(){m("api/ipos/".concat(S.id),"delivery_note")}},"Download")):n.createElement(n.Fragment,null,n.createElement(x,{variant:"h5"},"Delivery Note"),n.createElement(x,{variant:"body1"},"Here you can upload the the delivery note for this order"),n.createElement(k,null),n.createElement(c,{reference:"api::logistics.ipo",refID:S.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})))))),(null===(N=null===(j=null==S?void 0:S.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h5"},"Notes"),n.createElement(u,{notes:S.notes.data}),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:1},n.createElement(x,{variant:"h5"},"Items"),n.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},n.createElement(x,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return n.createElement(q,{key:r,control:n.createElement(A,{size:"small",checked:ie.includes(r),onChange:function(n){n.target.checked?le(t(t([],e(ie),!1),[r],!1)):le(ie.filter((function(e){return e!==r})))}}),label:n.createElement(x,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===S.status&&n.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(k,null),n.createElement("form",{action:K},n.createElement("input",{name:"id",type:"hidden",value:S.id}),X&&X.map((function(e,t){var r,a;return n.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===S.status||"cancelled"===S.status||"done"===S.status?n.createElement(s,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):n.createElement(d,{item:e,index:t,handleUpdateQuantity:ce,handleAddReport:me,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:de,revalidateCallback:G,showing:ie}))})),n.createElement(_,{sx:{p:2}},n.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(v,{text:"Update items",loadingText:"Loading..."}))),n.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(r=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===r?void 0:r.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(X))}))))))}export{G as default};