umwd-components 0.1.615 → 0.1.617

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{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useState as r,useEffect as n}from"react";import{useFormState as i}from"react-dom";import{updateOpoAction as o}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as l}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import c from"./OpoItemUpdater.js";import d from"./OpoItemDisplay.js";import s from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as u}from"../../StrapiErrors.js";import{SubmitButton as E}from"../../SubmitButton.js";import v from"@mui/material/Alert";import f from"@mui/material/Dialog";import y from"@mui/material/DialogActions";import g from"@mui/material/DialogContent";import h from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import _ from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import k from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/logistics/ipo/confirmation-service.js";var O={zodErrors:null,strapiErrors:null,data:null,message:null};function q(e){var t=e.open,r=e.handleClose,n=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return a.createElement(f,{open:t},a.createElement(h,null,"Confirm Order"),a.createElement(g,null,a.createElement(k,{spacing:2},a.createElement(b,null,"Are you sure you want to confirm this order?"),a.createElement(b,null,"Current status: ",i))),a.createElement(y,null,a.createElement(_,{variant:"contained",onClick:function(e){j("opos",[n]),o&&o()}},"Confirm"),a.createElement(_,{variant:"contained",onClick:r},"Cancel")))}function N(f){var y,g,h,j,N,I=f.opo,S=f.sx,A=f.revalidateCallback;f.handleClose;var B=f.role,F=e(i(o,O),2),P=F[0],T=F[1],U=e(r(I.opo_items.data?I.opo_items.data:[]),2),M=U[0],z=U[1],G=e(r(!1),2),H=G[0],J=G[1],L=function(a,r,n){var i=t([],e(M),!1),o=i.findIndex((function(e){return e.id===r}));i[o][n]=a,z(i)};return n((function(){var e;(null===(e=I.opo_items)||void 0===e?void 0:e.data)&&z(I.opo_items.data)}),[I]),a.createElement(C,{sx:t([],e(Array.isArray(S)?S:[S]),!1)},a.createElement(x,{container:!0,spacing:2},a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:2},a.createElement(k,{direction:"row",spacing:2,justifyContent:"space-between"},a.createElement(k,{spacing:2},a.createElement(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),a.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),a.createElement(p,{content:"",related:[{id:I.id,__type:"api::e-commerce.opo"}],revalidateCallback:A})),a.createElement(D,null))),a.createElement(x,{item:!0,xs:6},a.createElement(k,{spacing:1},a.createElement(b,{variant:"h5"},"Details"),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Purchase Order Number"),a.createElement(b,{variant:"body2"},I.opo_number)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Custom reference"),a.createElement(b,{variant:"body2"},I.customer_inhouse_reference)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Order Date"),a.createElement(b,{variant:"body2"},I.order_date)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Customer"),a.createElement(b,{variant:"body2"},null===(g=null===(y=I.customer)||void 0===y?void 0:y.business_credentials)||void 0===g?void 0:g.company_name)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Order Status"),a.createElement(b,{variant:"body2",width:"250px"},I.status)),("placed"===I.status||"external_shipping_process"===I.status)&&"enduser"===B&&a.createElement(a.Fragment,null,a.createElement(_,{variant:"contained",color:"primary",onClick:function(){return J(!0)}},"Confirm order"),a.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),a.createElement(q,{open:H,handleClose:function(){return J(!1)},orderID:I.id,currentStatus:I.status,revalidateCallback:A})))),a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:2},a.createElement(b,{variant:"h5"},"Documents"),a.createElement(w,null,a.createElement(k,{spacing:1},I.delivery_note?a.createElement(a.Fragment,null,a.createElement(b,{variant:"h6"},"Delivery Note"),a.createElement(b,null,null===(h=I.delivery_note)||void 0===h?void 0:h.name),a.createElement(_,{variant:"contained",onClick:function(){m("api/opos/".concat(I.id),"delivery_note")}},"Download")):a.createElement(a.Fragment,null,a.createElement(b,{variant:"h5"},"Delivery Note"),a.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),a.createElement(D,null),a.createElement(l,{reference:"api::e-commerce.opo",refID:I.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:A})))))),(null===(N=null===(j=null==I?void 0:I.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:2},a.createElement(b,{variant:"h5"},"Notes"),a.createElement(s,{notes:I.notes.data}),a.createElement(D,null))),a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:1},a.createElement(b,{variant:"h5"},"Items"),"placed"===I.status&&a.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),a.createElement(D,null),a.createElement("form",{action:T},a.createElement("input",{name:"id",type:"hidden",value:I.id}),M&&M.map((function(e,t){var r,n;return console.log("item",e),a.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===I.status?a.createElement(d,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):a.createElement(c,{item:e,index:t,handleUpdateQuantity:L,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,revalidateCallback:A}))})),a.createElement(w,{sx:{p:2}},a.createElement(k,{direction:"row",spacing:2,justifyContent:"end"},a.createElement(E,{text:"Update items",loadingText:"Loading..."}),a.createElement(u,{error:null==P?void 0:P.strapiErrors}),(null==P?void 0:P.message)&&a.createElement(v,{severity:"error"},null==P?void 0:P.message))),a.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity}}))}(M))}))))))}export{N as default};
6
+ import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useState as r,useEffect as n}from"react";import{useFormState as i}from"react-dom";import{updateOpoAction as o}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as l}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import c from"./OpoItemUpdater.js";import d from"./OpoItemDisplay.js";import s from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as u}from"../../StrapiErrors.js";import{SubmitButton as E}from"../../SubmitButton.js";import v from"@mui/material/Alert";import f from"@mui/material/Dialog";import y from"@mui/material/DialogActions";import g from"@mui/material/DialogContent";import h from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import _ from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import k from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/logistics/ipo/confirmation-service.js";var O={zodErrors:null,strapiErrors:null,data:null,message:null};function q(e){var t=e.open,r=e.handleClose,n=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return a.createElement(f,{open:t},a.createElement(h,null,"Confirm Order"),a.createElement(g,null,a.createElement(k,{spacing:2},a.createElement(b,null,"Are you sure you want to confirm this order?"),a.createElement(b,null,"Current status: ",i))),a.createElement(y,null,a.createElement(_,{variant:"contained",onClick:function(e){j("opos",[n]),o&&o()}},"Confirm"),a.createElement(_,{variant:"contained",onClick:r},"Cancel")))}function N(f){var y,g,h,j,N,I=f.opo,S=f.sx,A=f.revalidateCallback;f.handleClose;var B=f.role,F=e(i(o,O),2),P=F[0],T=F[1],U=e(r(I.opo_items.data?I.opo_items.data:[]),2),M=U[0],z=U[1],G=e(r(!1),2),H=G[0],J=G[1],L=function(a,r,n){var i=t([],e(M),!1),o=i.findIndex((function(e){return e.id===r}));i[o][n]=a,z(i)};return n((function(){var e;(null===(e=I.opo_items)||void 0===e?void 0:e.data)&&z(I.opo_items.data)}),[I]),a.createElement(C,{sx:t([],e(Array.isArray(S)?S:[S]),!1)},a.createElement(x,{container:!0,spacing:2},a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:2},a.createElement(k,{direction:"row",spacing:2,justifyContent:"space-between"},a.createElement(k,{spacing:2},a.createElement(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),a.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),a.createElement(p,{content:"",related:[{id:I.id,__type:"api::e-commerce.opo"}],revalidateCallback:A})),a.createElement(D,null))),a.createElement(x,{item:!0,xs:6},a.createElement(k,{spacing:1},a.createElement(b,{variant:"h5"},"Details"),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Purchase Order Number"),a.createElement(b,{variant:"body2"},I.opo_number)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Custom reference"),a.createElement(b,{variant:"body2"},I.customer_inhouse_reference)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Order Date"),a.createElement(b,{variant:"body2"},I.order_date)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Customer"),a.createElement(b,{variant:"body2"},null===(g=null===(y=I.customer)||void 0===y?void 0:y.business_credentials)||void 0===g?void 0:g.company_name)),a.createElement(k,{direction:"row",spacing:2},a.createElement(b,{variant:"body1",width:"250px"},"Order Status"),a.createElement(b,{variant:"body2",width:"250px"},I.status)),("placed"===I.status||"external_shipping_process"===I.status)&&"enduser"===B&&a.createElement(a.Fragment,null,a.createElement(_,{variant:"contained",color:"primary",onClick:function(){return J(!0)}},"Confirm order"),a.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),a.createElement(q,{open:H,handleClose:function(){return J(!1)},orderID:I.id,currentStatus:I.status,revalidateCallback:A})))),a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:2},a.createElement(b,{variant:"h5"},"Documents"),a.createElement(w,{sx:{p:2}},a.createElement(k,{spacing:1},I.delivery_note?a.createElement(a.Fragment,null,a.createElement(b,{variant:"h6"},"Delivery Note"),a.createElement(b,null,null===(h=I.delivery_note)||void 0===h?void 0:h.name),a.createElement(_,{variant:"contained",onClick:function(){m("api/opos/".concat(I.id),"delivery_note")}},"Download")):a.createElement(a.Fragment,null,a.createElement(b,{variant:"h5"},"Delivery Note"),a.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),a.createElement(D,null),a.createElement(l,{reference:"api::e-commerce.opo",refID:I.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:A})))))),(null===(N=null===(j=null==I?void 0:I.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:2},a.createElement(b,{variant:"h5"},"Notes"),a.createElement(s,{notes:I.notes.data}),a.createElement(D,null))),a.createElement(x,{item:!0,xs:12},a.createElement(k,{spacing:1},a.createElement(b,{variant:"h5"},"Items"),"placed"===I.status&&a.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),a.createElement(D,null),a.createElement("form",{action:T},a.createElement("input",{name:"id",type:"hidden",value:I.id}),M&&M.map((function(e,t){var r,n;return console.log("item",e),a.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===I.status?a.createElement(d,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):a.createElement(c,{item:e,index:t,handleUpdateQuantity:L,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,revalidateCallback:A}))})),a.createElement(w,{sx:{p:2}},a.createElement(k,{direction:"row",spacing:2,justifyContent:"end"},a.createElement(E,{text:"Update items",loadingText:"Loading..."}),a.createElement(u,{error:null==P?void 0:P.strapiErrors}),(null==P?void 0:P.message)&&a.createElement(v,{severity:"error"},null==P?void 0:P.message))),a.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity}}))}(M))}))))))}export{N as default};
@@ -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 m}from"../../common/media/UploadBase64MediaForm.js";import c from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualOpoItemUpdater.js";import s from"./OpoItemDisplay.js";import p from"../../logistics/note/NotesDisplay.js";import u from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as v}from"../../StrapiErrors.js";import{SubmitButton as E}from"../../SubmitButton.js";import f from"@mui/material/Alert";import y from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import b from"@mui/material/DialogTitle";import x from"@mui/material/Typography";import _ from"@mui/material/Button";import C from"@mui/material/Grid";import k from"@mui/material/Box";import w from"@mui/material/Paper";import D from"@mui/material/Stack";import j from"@mui/material/Divider";import{confirmationService as I}from"../../../data/services/logistics/ipo/confirmation-service.js";import{FormControlLabel as q,Checkbox as O}from"@mui/material";var A={zodErrors:null,strapiErrors:null,data:null,message:null};function N(e){var t=e.open,n=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return r.createElement(y,{open:t},r.createElement(b,null,"Confirm Order"),r.createElement(h,null,r.createElement(D,{spacing:2},r.createElement(x,null,"Are you sure you want to confirm this order?"),r.createElement(x,null,"Current status: ",i))),r.createElement(g,null,r.createElement(_,{variant:"contained",onClick:function(e){I("opos",[a]),o&&o()}},"Confirm"),r.createElement(_,{variant:"contained",onClick:n},"Cancel")))}function S(y){var g,h,b,I,S,B=y.opo,U=y.sx,F=y.revalidateCallback;y.handleClose;var T=y.role,P=e(o(l,A),2),R=P[0],M=P[1],z=e(a(B.opo_items.data?B.opo_items.data:[]),2),G=z[0],H=z[1],J=e(a(!1),2),L=J[0],Q=J[1],K=e(a(["picked","packed","shipped","reports"]),2),V=K[0],W=K[1],X=function(n,r,a){var i=t([],e(G),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,H(i)},Y=function(r,a){var i,o,l,m=t([],e(G),!1),c=m.findIndex((function(e){return e.id===a})),d=(null===(o=null===(i=m[c])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],s=t(t([],e(d),!1),[r],!1);null==(null===(l=m[c])||void 0===l?void 0:l.reports)&&(m[c]=n(n({},m[c]),{reports:{data:[]}})),m[c].reports.data=s,H(m)},Z=function(n,r){var a,i,o=t([],e(G),!1),l=o.findIndex((function(e){return e.id===n})),m=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],c=m.filter((function(e){return"id"in e})),d=m.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(c),!1),e(d),!1);o[l].reports.data=s,H(o)};return i((function(){"Ipo Updated"===(null==R?void 0:R.message)&&F&&F()}),[R]),i((function(){var e;(null===(e=B.opo_items)||void 0===e?void 0:e.data)&&H(B.opo_items.data?B.opo_items.data:[])}),[B]),r.createElement(k,{sx:t([],e(Array.isArray(U)?U:[U]),!1)},r.createElement(C,{container:!0,spacing:2},r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:2},r.createElement(D,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(D,{spacing:2},r.createElement(x,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),r.createElement(x,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),r.createElement(u,{content:"",related:[{id:B.id,__type:"api::e-commerce.opo"}],revalidateCallback:F})),r.createElement(j,null))),r.createElement(C,{item:!0,xs:6},r.createElement(D,{spacing:1},r.createElement(x,{variant:"h5"},"Details"),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Purchase Order Number"),r.createElement(x,{variant:"body2"},B.opo_number)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Custom reference"),r.createElement(x,{variant:"body2"},B.customer_inhouse_reference)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Order Date"),r.createElement(x,{variant:"body2"},B.order_date)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Customer"),r.createElement(x,{variant:"body2"},null===(h=null===(g=B.customer)||void 0===g?void 0:g.business_credentials)||void 0===h?void 0:h.company_name)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Order Status"),r.createElement(x,{variant:"body2",width:"250px"},B.status)),("placed"===B.status||"external_shipping_process"===B.status)&&"enduser"===T&&r.createElement(r.Fragment,null,r.createElement(_,{variant:"contained",color:"primary",onClick:function(){return Q(!0)}},"Confirm order"),r.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(N,{open:L,handleClose:function(){return Q(!1)},orderID:B.id,currentStatus:B.status,revalidateCallback:F})))),r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:2},r.createElement(x,{variant:"h5"},"Documents"),r.createElement(w,null,r.createElement(D,{spacing:1},B.delivery_note?r.createElement(r.Fragment,null,r.createElement(x,{variant:"h6"},"Delivery Note"),r.createElement(x,null,null===(b=B.delivery_note)||void 0===b?void 0:b.name),r.createElement(_,{variant:"contained",onClick:function(){c("api/ipos/".concat(B.id),"delivery_note")}},"Download")):r.createElement(r.Fragment,null,r.createElement(x,{variant:"h5"},"Delivery Note"),r.createElement(x,{variant:"body1"},"Here you can upload the the delivery note for this order"),r.createElement(j,null),r.createElement(m,{reference:"api::e-commerce.opo",refID:B.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:F})))))),(null===(S=null===(I=null==B?void 0:B.notes)||void 0===I?void 0:I.data)||void 0===S?void 0:S.length)>0&&r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:2},r.createElement(x,{variant:"h5"},"Notes"),r.createElement(p,{notes:B.notes.data}),r.createElement(j,null))),r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:1},r.createElement(x,{variant:"h5"},"Items"),r.createElement(D,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},r.createElement(x,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(q,{key:n,control:r.createElement(O,{checked:V.includes(n),onChange:function(r){r.target.checked?W(t(t([],e(V),!1),[n],!1)):W(V.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===B.status&&r.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(j,null),r.createElement("form",{action:M},r.createElement("input",{name:"id",type:"hidden",value:B.id}),G&&G.map((function(e,t){var n,a;return r.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===B.status?r.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(d,{item:e,index:t,handleUpdateQuantity:X,handleAddReport:Y,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:Z,revalidateCallback:F,showing:V}))})),r.createElement(w,{sx:{p:2}},r.createElement(D,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(E,{text:"Update items",loadingText:"Loading..."}),r.createElement(v,{error:null==R?void 0:R.strapiErrors}),(null==R?void 0:R.message)&&r.createElement(f,{severity:"error"},null==R?void 0:R.message))),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}})))||[]}}))}(G))}))))))}export{S as default};
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 m}from"../../common/media/UploadBase64MediaForm.js";import c from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualOpoItemUpdater.js";import s from"./OpoItemDisplay.js";import p from"../../logistics/note/NotesDisplay.js";import u from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as v}from"../../StrapiErrors.js";import{SubmitButton as E}from"../../SubmitButton.js";import f from"@mui/material/Alert";import y from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import b from"@mui/material/DialogTitle";import x from"@mui/material/Typography";import _ from"@mui/material/Button";import C from"@mui/material/Grid";import k from"@mui/material/Box";import w from"@mui/material/Paper";import D from"@mui/material/Stack";import j from"@mui/material/Divider";import{confirmationService as I}from"../../../data/services/logistics/ipo/confirmation-service.js";import{FormControlLabel as q,Checkbox as O}from"@mui/material";var A={zodErrors:null,strapiErrors:null,data:null,message:null};function N(e){var t=e.open,n=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return r.createElement(y,{open:t},r.createElement(b,null,"Confirm Order"),r.createElement(h,null,r.createElement(D,{spacing:2},r.createElement(x,null,"Are you sure you want to confirm this order?"),r.createElement(x,null,"Current status: ",i))),r.createElement(g,null,r.createElement(_,{variant:"contained",onClick:function(e){I("opos",[a]),o&&o()}},"Confirm"),r.createElement(_,{variant:"contained",onClick:n},"Cancel")))}function S(y){var g,h,b,I,S,B=y.opo,U=y.sx,F=y.revalidateCallback;y.handleClose;var T=y.role,P=e(o(l,A),2),R=P[0],M=P[1],z=e(a(B.opo_items.data?B.opo_items.data:[]),2),G=z[0],H=z[1],J=e(a(!1),2),L=J[0],Q=J[1],K=e(a(["picked","packed","shipped","reports"]),2),V=K[0],W=K[1],X=function(n,r,a){var i=t([],e(G),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,H(i)},Y=function(r,a){var i,o,l,m=t([],e(G),!1),c=m.findIndex((function(e){return e.id===a})),d=(null===(o=null===(i=m[c])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],s=t(t([],e(d),!1),[r],!1);null==(null===(l=m[c])||void 0===l?void 0:l.reports)&&(m[c]=n(n({},m[c]),{reports:{data:[]}})),m[c].reports.data=s,H(m)},Z=function(n,r){var a,i,o=t([],e(G),!1),l=o.findIndex((function(e){return e.id===n})),m=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],c=m.filter((function(e){return"id"in e})),d=m.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(c),!1),e(d),!1);o[l].reports.data=s,H(o)};return i((function(){"Ipo Updated"===(null==R?void 0:R.message)&&F&&F()}),[R]),i((function(){var e;(null===(e=B.opo_items)||void 0===e?void 0:e.data)&&H(B.opo_items.data?B.opo_items.data:[])}),[B]),r.createElement(k,{sx:t([],e(Array.isArray(U)?U:[U]),!1)},r.createElement(C,{container:!0,spacing:2},r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:2},r.createElement(D,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(D,{spacing:2},r.createElement(x,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),r.createElement(x,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),r.createElement(u,{content:"",related:[{id:B.id,__type:"api::e-commerce.opo"}],revalidateCallback:F})),r.createElement(j,null))),r.createElement(C,{item:!0,xs:6},r.createElement(D,{spacing:1},r.createElement(x,{variant:"h5"},"Details"),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Purchase Order Number"),r.createElement(x,{variant:"body2"},B.opo_number)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Custom reference"),r.createElement(x,{variant:"body2"},B.customer_inhouse_reference)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Order Date"),r.createElement(x,{variant:"body2"},B.order_date)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Customer"),r.createElement(x,{variant:"body2"},null===(h=null===(g=B.customer)||void 0===g?void 0:g.business_credentials)||void 0===h?void 0:h.company_name)),r.createElement(D,{direction:"row",spacing:2},r.createElement(x,{variant:"body1",width:"250px"},"Order Status"),r.createElement(x,{variant:"body2",width:"250px"},B.status)),("placed"===B.status||"external_shipping_process"===B.status)&&"enduser"===T&&r.createElement(r.Fragment,null,r.createElement(_,{variant:"contained",color:"primary",onClick:function(){return Q(!0)}},"Confirm order"),r.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(N,{open:L,handleClose:function(){return Q(!1)},orderID:B.id,currentStatus:B.status,revalidateCallback:F})))),r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:2},r.createElement(x,{variant:"h5"},"Documents"),r.createElement(w,{sx:{p:2}},r.createElement(D,{spacing:1},B.delivery_note?r.createElement(r.Fragment,null,r.createElement(x,{variant:"h6"},"Delivery Note"),r.createElement(x,null,null===(b=B.delivery_note)||void 0===b?void 0:b.name),r.createElement(_,{variant:"contained",onClick:function(){c("api/ipos/".concat(B.id),"delivery_note")}},"Download")):r.createElement(r.Fragment,null,r.createElement(x,{variant:"h5"},"Delivery Note"),r.createElement(x,{variant:"body1"},"Here you can upload the the delivery note for this order"),r.createElement(j,null),r.createElement(m,{reference:"api::e-commerce.opo",refID:B.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:F})))))),(null===(S=null===(I=null==B?void 0:B.notes)||void 0===I?void 0:I.data)||void 0===S?void 0:S.length)>0&&r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:2},r.createElement(x,{variant:"h5"},"Notes"),r.createElement(p,{notes:B.notes.data}),r.createElement(j,null))),r.createElement(C,{item:!0,xs:12},r.createElement(D,{spacing:1},r.createElement(x,{variant:"h5"},"Items"),r.createElement(D,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},r.createElement(x,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(q,{key:n,control:r.createElement(O,{checked:V.includes(n),onChange:function(r){r.target.checked?W(t(t([],e(V),!1),[n],!1)):W(V.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===B.status&&r.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(j,null),r.createElement("form",{action:M},r.createElement("input",{name:"id",type:"hidden",value:B.id}),G&&G.map((function(e,t){var n,a;return r.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===B.status?r.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(d,{item:e,index:t,handleUpdateQuantity:X,handleAddReport:Y,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:Z,revalidateCallback:F,showing:V}))})),r.createElement(w,{sx:{p:2}},r.createElement(D,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(E,{text:"Update items",loadingText:"Loading..."}),r.createElement(v,{error:null==R?void 0:R.strapiErrors}),(null==R?void 0:R.message)&&r.createElement(f,{severity:"error"},null==R?void 0:R.message))),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}})))||[]}}))}(G))}))))))}export{S as default};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useState as r}from"react";import m from"@mui/material/Paper";import o from"@mui/material/Box";import i from"@mui/material/Stack";import c from"@mui/material/Alert";import l from"@mui/material/TextField";import s from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as u}from"react-dom";import{StrapiErrors as p}from"../../StrapiErrors.js";import{updateVendorAction as f}from"../../../data/actions/logistics/vendor/updateVendorAction.js";import E from"@mui/material/Grid";import{BusinessCredentialsFields as v}from"../../e-commerce/customer/BusinessCredentials.js";import{AddressFields as g}from"../../common/Address.js";import x from"../../e-commerce/products/ProductSelector.js";import b,{ContactsFields as h}from"../../common/Contacts.js";import y from"@mui/material/IconButton";import _ from"@mui/icons-material/Add";import{ContactType as j}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as N}from"../../ExplanatoryFoldOut.js";var C={zodErrors:null,strapiErrors:null,data:null,message:null};function k(k){var A=k.data,V=k.productNamesArr;k.revalidateCallback;var R=k.sx,w=A.id,B=A.website_url,P=A.phone_number,S=A.email,I=A.business_credentials,T=A.address,F=A.products,O=A.contacts;console.log("data",A);var z=e(u(f,C),2),G=z[0],M=z[1],U=(null==F?void 0:F.data)||[],W=e(r([]),2),q=W[0],D=W[1],H=function(n,a){q.includes(a)?D(q.filter((function(e){return e!==a}))):D(t(t([],e(q),!1),[a],!1))},J=e(r(O.reduce((function(e,t,n){return e.push({componentName:"contacts[".concat(n,"]"),componentReference:"logistics-elements.contact",data:t}),e}),[])),2),K=J[0],L=J[1],Q=e(r([]),2),X=Q[0],Y=Q[1];return a.createElement(o,{sx:t([{p:2}],e(Array.isArray(R)?R:[R]),!1),component:m},a.createElement("form",{action:M},w&&a.createElement("input",{id:"id",type:"hidden",name:"id",value:w}),a.createElement(E,{container:!0,spacing:2},a.createElement(E,{item:!0,xs:12},a.createElement(s,{variant:"h5"},"Edit Vendor")),a.createElement(E,{item:!0,xs:12},a.createElement(N,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(v,{data:I,componentName:"business_credentials",componentReference:"common.business-credentials"})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(i,{spacing:2},a.createElement(l,{id:"website_url",name:"website_url",label:"Website Url",defaultValue:B}),a.createElement(l,{id:"phone_number",name:"phone_number",label:"Phone Number",defaultValue:P}),a.createElement(l,{id:"email",name:"email",label:"Email",defaultValue:S}))),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(s,{variant:"h6"},"Address"),a.createElement(g,{data:T,componentName:"address",componentReference:"common.address"})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Products"),a.createElement(x,{productNames:V,currentValue:U.map((function(e){return e.id}))})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Contacts")),null==K?void 0:K.map((function(e,t){var r,m;return(null===(r=e.data)||void 0===r?void 0:r.id)?q.includes(null===(m=e.data)||void 0===m?void 0:m.id)?a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement(h,{data:e.data,componentName:"contacts[".concat(t,"]"),componentReference:"logistics-elements.contact",deleteCallback:function(){L(K.filter((function(e,n){return n!==t})))}})):a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].id"),value:e.data.id}),a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].__component"),value:"logistics-elements.contact"}),a.createElement(b,{data:n(n({},e.data),{onClick:H})})):null})),X.map((function(e,t){var r;return a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:null===(r=e.data)||void 0===r?void 0:r.uuid},a.createElement(h,{data:e.data,componentName:e.componentName,componentReference:"logistics-elements.contact",deleteCallback:function(){Y(X.filter((function(e,n){return n!==t})).map((function(e,t){return n(n({},e),{componentName:"contacts[".concat(t+K.length,"]")})})))}}))})),a.createElement(E,{item:!0,xs:12,md:6,lg:4,justifyContent:"center",alignItems:"center"},a.createElement(y,{onClick:function(){Y(t(t([],e(X),!1),[{componentName:"contacts[".concat(K.length+X.length,"]"),componentReference:"logistics-elements.contact",data:{uuid:Math.random(),first_name:"",last_name:"",email:"",phone_number:"",type:j.Other}}],!1))}},a.createElement(_,null))),a.createElement(E,{item:!0,xs:12},a.createElement(i,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},a.createElement(d,{text:"update vendor",loadingText:"loading"}),(null==G?void 0:G.strapiErrors)&&a.createElement(p,{error:null==G?void 0:G.strapiErrors}),(null==G?void 0:G.message)&&a.createElement(c,{severity:"error"},null==G?void 0:G.message))))))}export{k as EditVendorForm};
7
+ import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useState as r}from"react";import o from"@mui/material/Paper";import m from"@mui/material/Box";import i from"@mui/material/Stack";import c from"@mui/material/Alert";import l from"@mui/material/TextField";import s from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as u}from"react-dom";import{StrapiErrors as p}from"../../StrapiErrors.js";import{updateVendorAction as f}from"../../../data/actions/logistics/vendor/updateVendorAction.js";import E from"@mui/material/Grid";import{BusinessCredentialsFields as v}from"../../e-commerce/customer/BusinessCredentials.js";import{AddressFields as g}from"../../common/Address.js";import b from"../../e-commerce/products/ProductSelector.js";import x,{ContactsFields as h}from"../../common/Contacts.js";import y from"@mui/material/IconButton";import _ from"@mui/icons-material/Add";import{ContactType as j}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as C}from"../../ExplanatoryFoldOut.js";import N from"../note/NoteTakingComponent.js";var k={zodErrors:null,strapiErrors:null,data:null,message:null};function A(A){var V=A.data,w=A.productNamesArr,R=A.revalidateCallback,B=A.sx,P=V.id,S=V.website_url,T=V.phone_number,I=V.email,F=V.business_credentials,O=V.address,z=V.products,G=V.contacts;console.log("data",V);var M=e(u(f,k),2),U=M[0],W=M[1],q=(null==z?void 0:z.data)||[],D=e(r([]),2),H=D[0],J=D[1],K=function(n,a){H.includes(a)?J(H.filter((function(e){return e!==a}))):J(t(t([],e(H),!1),[a],!1))},L=e(r(G.reduce((function(e,t,n){return e.push({componentName:"contacts[".concat(n,"]"),componentReference:"logistics-elements.contact",data:t}),e}),[])),2),Q=L[0],X=L[1],Y=e(r([]),2),Z=Y[0],$=Y[1];return a.createElement(m,{sx:t([{p:2}],e(Array.isArray(B)?B:[B]),!1),component:o},a.createElement("form",{action:W},P&&a.createElement("input",{id:"id",type:"hidden",name:"id",value:P}),a.createElement(E,{container:!0,spacing:2},a.createElement(E,{item:!0,xs:12},a.createElement(i,{direction:"row",justifyContent:"space-between"},a.createElement(s,{variant:"h5"},"Edit Vendor"),a.createElement(N,{content:"",related:[{id:V.id,__type:"api::logistics.vendor-profile"}],revalidateCallback:R}))),a.createElement(E,{item:!0,xs:12},a.createElement(C,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(v,{data:F,componentName:"business_credentials",componentReference:"common.business-credentials"})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(i,{spacing:2},a.createElement(l,{id:"website_url",name:"website_url",label:"Website Url",defaultValue:S}),a.createElement(l,{id:"phone_number",name:"phone_number",label:"Phone Number",defaultValue:T}),a.createElement(l,{id:"email",name:"email",label:"Email",defaultValue:I}))),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(s,{variant:"h6"},"Address"),a.createElement(g,{data:O,componentName:"address",componentReference:"common.address"})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Products"),a.createElement(b,{productNames:w,currentValue:q.map((function(e){return e.id}))})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Contacts")),null==Q?void 0:Q.map((function(e,t){var r,o;return(null===(r=e.data)||void 0===r?void 0:r.id)?H.includes(null===(o=e.data)||void 0===o?void 0:o.id)?a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement(h,{data:e.data,componentName:"contacts[".concat(t,"]"),componentReference:"logistics-elements.contact",deleteCallback:function(){X(Q.filter((function(e,n){return n!==t})))}})):a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].id"),value:e.data.id}),a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].__component"),value:"logistics-elements.contact"}),a.createElement(x,{data:n(n({},e.data),{onClick:K})})):null})),Z.map((function(e,t){var r;return a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:null===(r=e.data)||void 0===r?void 0:r.uuid},a.createElement(h,{data:e.data,componentName:e.componentName,componentReference:"logistics-elements.contact",deleteCallback:function(){$(Z.filter((function(e,n){return n!==t})).map((function(e,t){return n(n({},e),{componentName:"contacts[".concat(t+Q.length,"]")})})))}}))})),a.createElement(E,{item:!0,xs:12,md:6,lg:4,justifyContent:"center",alignItems:"center"},a.createElement(y,{onClick:function(){$(t(t([],e(Z),!1),[{componentName:"contacts[".concat(Q.length+Z.length,"]"),componentReference:"logistics-elements.contact",data:{uuid:Math.random(),first_name:"",last_name:"",email:"",phone_number:"",type:j.Other}}],!1))}},a.createElement(_,null))),a.createElement(E,{item:!0,xs:12},a.createElement(i,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},a.createElement(d,{text:"update vendor",loadingText:"loading"}),(null==U?void 0:U.strapiErrors)&&a.createElement(p,{error:null==U?void 0:U.strapiErrors}),(null==U?void 0:U.message)&&a.createElement(c,{severity:"error"},null==U?void 0:U.message))))))}export{A as EditVendorForm};