umwd-components 0.1.655 → 0.1.656
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.
- package/dist/node_modules/base64-js/index.js +1 -1
- package/dist/node_modules/ieee754/index.js +1 -1
- package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/e-commerce/categories/CreateCategoryForm.tsx +17 -1
- package/src/components/e-commerce/categories/EditCategoryForm.tsx +17 -1
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +1 -1
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__exports as r}from"../../_virtual/
|
|
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/
|
|
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};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as a}from"react";import i from"@mui/material/Box";import o from"@mui/material/Stack";import m from"@mui/material/TextField";import n from"@mui/material/Typography";import{SubmitButton as l}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{updateCategoryAction as c}from"../../../data/actions/e-commerce/categories/updateCategoryAction.js";import d from"@mui/material/Grid";import u from"../products/ProductSelector.js";import p from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as a}from"react";import i from"@mui/material/Box";import o from"@mui/material/Stack";import m from"@mui/material/TextField";import n from"@mui/material/Typography";import{SubmitButton as l}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{updateCategoryAction as c}from"../../../data/actions/e-commerce/categories/updateCategoryAction.js";import d from"@mui/material/Grid";import u from"../products/ProductSelector.js";import p from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as E}from"../../../context/common/SnackbarContext.js";import{Button as g}from"@mui/material";var f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function v(v){var y=v.data,x=v.revalidateCallback,h=v.handleClose,b=v.productNamesArray,C=v.sx,j=y.id,k=y.title,A=y.description;y.slug,y.is_archive;var w=y.products,S=(null==w?void 0:w.data)||[],T=e(s(c,f),2),V=T[0],B=T[1],M=E().handleAddMessage;return a((function(){(null==V?void 0:V.message)&&(M({message:V.message,severity:V.severity||"error"}),"success"===V.severity&&(x&&x(),h&&h()))}),[null==V?void 0:V.message]),a((function(){(null==V?void 0:V.strapiErrors)&&M({message:V.strapiErrors.message||"Error updating category",severity:V.severity||"error"})}),[null==V?void 0:V.strapiErrors]),r.createElement(i,{sx:t([],e(Array.isArray(C)?C:[C]),!1)},r.createElement("form",{action:B},j&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:j}),r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(n,{variant:"h3",component:"h1"},"Edit Category"),r.createElement(n,{variant:"body2"},"Edit the category for your products. You can add products to this category later."))),r.createElement(d,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(m,{id:"title",name:"title",label:"Title",defaultValue:k}),r.createElement(p,{name:"description",label:"Description",defaultValue:A}))),r.createElement(d,{item:!0,xs:12},r.createElement(n,{variant:"h6"},"Products"),r.createElement(u,{productNames:b,currentValue:t([],e(S.map((function(e){return e.id}))),!1)}))),r.createElement(d,{item:!0,xs:12},r.createElement(o,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},h&&r.createElement(g,{onClick:h,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Update category",loadingText:"Loading...",variant:"contained"})))))}export{v as EditCategoryForm};
|
|
@@ -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 d from"./TextualOpoItemUpdater.js";import s 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 h from"@mui/material/DialogContent";import g 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 N,List as O,ListItem as q,TextField as A}from"@mui/material";import B from"@mui/icons-material/Numbers";import S from"@mui/icons-material/CalendarToday";import T from"@mui/icons-material/Business";import P from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{OpoStatusIndicator as F}from"./OpoStatusIndicator.js";import{SubmitButton as R}from"../../SubmitButton.js";var W={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M(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(g,null,"Confirm Order"),r.createElement(h,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 Y(t){var n=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 r.createElement("form",null,r.createElement(E,{open:n},r.createElement(g,null,"Cancel Return"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(O,null,r.createElement(q,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(q,null,"Please provide a reason for the cancellation"),r.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(A,{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}))),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 z(E){var f,h,g,I,D,O=E.opo,q=E.sx,A=E.revalidateCallback;E.handleClose;var z=E.role,G=l.bind(O.id),H=e(o(G,W),2),J=H[0],L=H[1],Q=e(a(O.opo_items.data?O.opo_items.data:[]),2),K=Q[0],V=Q[1],X=e(a(!1),2),Z=X[0],$=X[1],ee=e(a(!1),2),te=ee[0],ne=ee[1],re=e(a(["picked","packed","shipped","reports"]),2),ae=re[0],ie=re[1],oe=function(n,r,a){var i=t([],e(K),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,V(i)},le=function(r,a){var i,o,l,c=t([],e(K),!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),[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=s,V(c)},ce=function(n,r){var a,i,o=t([],e(K),!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})),d=c.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(m),!1),e(d),!1);o[l].reports.data=s,V(o)};return i((function(){"Ipo Updated"===(null==J?void 0:J.message)&&A&&A()}),[J]),i((function(){var e;(null===(e=O.opo_items)||void 0===e?void 0:e.data)&&V(O.opo_items.data?O.opo_items.data:[])}),[O]),r.createElement(C,{sx:t([{p:2}],e(Array.isArray(q)?q:[q]),!1),component:k},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:O.id,__type:"api::e-commerce.opo"}],revalidateCallback:A})),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(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(h=null===(f=O.customer)||void 0===f?void 0:f.business_credentials)||void 0===h?void 0:h.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(U,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(F,{status:O.status}))))),"enduser"===z&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===O.status||"external_shipping_process"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return $(!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(M,{open:Z,handleClose:function(){return $(!1)},orderID:O.id,currentStatus:O.status,revalidateCallback:A})),("placed"===O.status||"ordered"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),r.createElement(Y,{open:te,handleClose:function(){return ne(!1)},orderID:O.id,revalidateCallback:A}))))),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},O.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(g=O.delivery_note)||void 0===g?void 0:g.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(O.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:O.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:A})))))),(null===(D=null===(I=null==O?void 0:O.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:O.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:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(j,{key:n,control:r.createElement(N,{checked:ae.includes(n),onChange:function(r){r.target.checked?ie(t(t([],e(ae),!1),[n],!1)):ie(ae.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===O.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:L},r.createElement("input",{name:"id",type:"hidden",value:O.id}),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}})))||[]}}))}(K))}),K&&K.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===O.status||"external_shipping_process"===O.status||"done"===O.status||"cancelled"===O.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:oe,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:A,showing:ae}))})),r.createElement(k,{sx:{p:2}},r.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(R,{text:"Update items",loadingText:"Loading..."}))))))))}export{z 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 c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualOpoItemUpdater.js";import s 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 h from"@mui/material/DialogContent";import g 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 N,List as O,ListItem as q,TextField as A}from"@mui/material";import B from"@mui/icons-material/Numbers";import S from"@mui/icons-material/CalendarToday";import T from"@mui/icons-material/Business";import P from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{OpoStatusIndicator as F}from"./OpoStatusIndicator.js";import{SubmitButton as R}from"../../SubmitButton.js";var W={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M(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(g,null,"Confirm Order"),r.createElement(h,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 Y(t){var n=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 r.createElement("form",null,r.createElement(E,{open:n},r.createElement(g,null,"Cancel Return"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(O,null,r.createElement(q,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(q,null,"Please provide a reason for the cancellation"),r.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(A,{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}))),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 z(E){var f,h,g,I,D,O=E.opo,q=E.sx,A=E.revalidateCallback;E.handleClose;var z=E.role,G=l.bind(O.id),H=e(o(G,W),2),J=H[0],L=H[1],Q=e(a(O.opo_items.data?O.opo_items.data:[]),2),K=Q[0],V=Q[1],X=e(a(!1),2),Z=X[0],$=X[1],ee=e(a(!1),2),te=ee[0],ne=ee[1],re=e(a(["picked","packed","shipped","reports"]),2),ae=re[0],ie=re[1],oe=function(n,r,a){var i=t([],e(K),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,V(i)},le=function(r,a){var i,o,l,c=t([],e(K),!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),[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=s,V(c)},ce=function(n,r){var a,i,o=t([],e(K),!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})),d=c.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(m),!1),e(d),!1);o[l].reports.data=s,V(o)};return i((function(){"Ipo Updated"===(null==J?void 0:J.message)&&A&&A()}),[J]),i((function(){var e;(null===(e=O.opo_items)||void 0===e?void 0:e.data)&&V(O.opo_items.data?O.opo_items.data:[])}),[O]),r.createElement(C,{sx:t([],e(Array.isArray(q)?q:[q]),!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:O.id,__type:"api::e-commerce.opo"}],revalidateCallback:A})),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(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(h=null===(f=O.customer)||void 0===f?void 0:f.business_credentials)||void 0===h?void 0:h.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(U,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(F,{status:O.status}))))),"enduser"===z&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===O.status||"external_shipping_process"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return $(!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(M,{open:Z,handleClose:function(){return $(!1)},orderID:O.id,currentStatus:O.status,revalidateCallback:A})),("placed"===O.status||"ordered"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),r.createElement(Y,{open:te,handleClose:function(){return ne(!1)},orderID:O.id,revalidateCallback:A}))))),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},O.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(g=O.delivery_note)||void 0===g?void 0:g.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(O.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:O.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:A})))))),(null===(D=null===(I=null==O?void 0:O.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:O.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:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(j,{key:n,control:r.createElement(N,{checked:ae.includes(n),onChange:function(r){r.target.checked?ie(t(t([],e(ae),!1),[n],!1)):ie(ae.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===O.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:L},r.createElement("input",{name:"id",type:"hidden",value:O.id}),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}})))||[]}}))}(K))}),K&&K.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===O.status||"external_shipping_process"===O.status||"done"===O.status||"cancelled"===O.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:oe,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:A,showing:ae}))})),r.createElement(k,{sx:{p:2}},r.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(R,{text:"Update items",loadingText:"Loading..."}))))))))}export{z as default};
|