umwd-components 0.1.646 → 0.1.648

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as r}from"../../_virtual/index7.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
6
+ import{__exports as r}from"../../_virtual/index8.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
@@ -3,5 +3,5 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as a}from"../../_virtual/index8.js";
6
+ import{__exports as a}from"../../_virtual/index7.js";
7
7
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var t;function o(){return t||(t=1,a.read=function(a,t,o,r,h){var M,e,i=8*h-r-1,p=(1<<i)-1,f=p>>1,n=-7,w=o?h-1:0,s=o?-1:1,u=a[t+w];for(w+=s,M=u&(1<<-n)-1,u>>=-n,n+=i;n>0;M=256*M+a[t+w],w+=s,n-=8);for(e=M&(1<<-n)-1,M>>=-n,n+=r;n>0;e=256*e+a[t+w],w+=s,n-=8);if(0===M)M=1-f;else{if(M===p)return e?NaN:1/0*(u?-1:1);e+=Math.pow(2,r),M-=f}return(u?-1:1)*e*Math.pow(2,M-r)},a.write=function(a,t,o,r,h,M){var e,i,p,f=8*M-h-1,n=(1<<f)-1,w=n>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,N=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,e=n):(e=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-e))<1&&(e--,p*=2),(t+=e+w>=1?s/p:s*Math.pow(2,1-w))*p>=2&&(e++,p/=2),e+w>=n?(i=0,e=n):e+w>=1?(i=(t*p-1)*Math.pow(2,h),e+=w):(i=t*Math.pow(2,w-1)*Math.pow(2,h),e=0));h>=8;a[o+u]=255&i,u+=N,i/=256,h-=8);for(e=e<<h|i,f+=h;f>0;a[o+u]=255&e,u+=N,e/=256,f-=8);a[o+u-N]|=128*_}),a}export{o as __require};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__read as e,__spreadArray as t,__assign as n,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import s from"./TextualIROItemUpdater.js";import u from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as p}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import _ from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import q from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as A}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,DialogContentText as j,CircularProgress as T,TextField as W,List as S,ListItem as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import F from"@mui/icons-material/AssignmentReturn";import N from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import M from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{IroStatusIndicator as z}from"./IroStatusIndicator.js";import{queryAllProducts as V}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Y from"../../../../node_modules/qs/lib/index.js";import{useSnackbar as Q}from"../../../context/common/SnackbarContext.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null};function J(c){var m,s,u=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,x=c.iro,C=e(l(!1),2),w=C[0],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==x?void 0:x.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&r(u,void 0,void 0,(function(){var e,t,n,r,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Y.stringify({filters:{product_number:{$in:x.iro_items.data.map((function(e){var t,n;return(null===(n=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===n?void 0:n.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,V(e)];case 1:return t=a.sent(),n=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",n),q(!1),r=0,i=0,l=x.iro_items.data.map((function(e,t){var a=e.product,l=n.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var s=o*e.returned_quantity,u=c*e.returned_quantity;r+=s,i+=u}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:x.customer_reference||"",total_excl_vat:parseFloat(r.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,x]),i.createElement(E,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(_,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(j,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(j,{variant:"h5"},"Overwrites"),w?i.createElement(T,null):i.createElement(I,{spacing:2},i.createElement(W,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(n(n({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(W,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(n(n({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(W,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(n(n({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(s=null===(m=null==x?void 0:x.iro_items)||void 0===m?void 0:m.data)||void 0===s?void 0:s.length)>0&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"h5"},"Items"),x.iro_items.data.map((function(r,a){var l,o,c,m,s,u,d,v,E,g,h,_,b,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:r.id},i.createElement(y,{sx:{minWidth:100}},r.line_item_number),i.createElement(y,{sx:{minWidth:150}},null===(l=r.product)||void 0===l?void 0:l.product_number),i.createElement(y,{sx:{minWidth:200}},null===(o=r.product)||void 0===o?void 0:o.title),i.createElement(W,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(s=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==s?s:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{vat_rate:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(u=null==p?void 0:p.lines)||void 0===u?void 0:u[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_excl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(h=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==h?h:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_incl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(_=null==p?void 0:p.lines)||void 0===_?void 0:_[a])||void 0===b?void 0:b.quantity)&&void 0!==x?x:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{quantity:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}))}))))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){k("iros",[x.id],p),v()}},"Confirm"),i.createElement(b,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,n=e.handleClose,r=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(E,{open:t},i.createElement(_,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(S,null,"requested"===a&&i.createElement(O,null,"When confirming this return order a rma number will be generated"),i.createElement(O,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(O,null,"Confirming this order will automatically create an invoice")),i.createElement(y,null,"Current status: ",a))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),n()):"requested"===a&&(k("iros",[r]),l&&l(),n())}},"Yes"),i.createElement(b,{variant:"contained",onClick:n},"No")))}function $(t){var n=t.open,r=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],s=c[1],u=e(l(""),2),d=u[0],v=u[1];return i.createElement("form",null,i.createElement(E,{open:n},i.createElement(_,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(S,null,i.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(O,null,"Please provide a reason for the cancellation"),i.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(W,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(A("iros",a,m),o&&o(),r())}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No"))))}function H(r){var a,E,g,h,_=r.data,k=r.sx,A=r.revalidateCallback,j=r.handleClose,T=r.role,W=e(c(m,G),2),S=W[0],O=W[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],H=V[1],K=e(l(!1),2),X=K[0],Z=K[1],ee=e(l(!1),2),te=ee[0],ne=ee[1],re=e(l(!1),2),ae=re[0],ie=re[1],le=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),oe=le[0],ce=le[1],me=e(l(["received","registered","released","reports"]),2),se=me[0],ue=me[1],de=function(n,r,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===r}));i[l][a]=n,H(i)},ve=function(r,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],u=t(t([],e(s),!1),[r],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=u,H(c)},pe=function(n,r){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var u=t(t([],e(m),!1),e(s),!1);l[o].reports.data=u,H(l)},fe=Q().handleAddMessage;return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&(fe({message:"Iro Updated",severity:"success"}),j&&j(),A&&A())}),[S]),o((function(){(null==S?void 0:S.strapiErrors)&&fe({message:S.strapiErrors.message||"Error updating IRO",severity:"error"})}),[null==S?void 0:S.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&H(_.iro_items.data?_.iro_items.data:[])}),[_]),i.createElement(C,{sx:t([],e(Array.isArray(k)?k:[k]),!1)},i.createElement(x,{container:!0,spacing:2},i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(y,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:_.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(y,{variant:"h5",sx:{py:1}},"Details")),i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(y,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=_.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(z,{status:_.status}))))),("requested"===_.status||"finalising_process"===_.status)&&"enduser"===T&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===_.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===_.status&&i.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),i.createElement(L,{open:X,handleClose:function(){return Z(!1)},orderID:_.id,currentStatus:_.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:_}),i.createElement($,{open:te,handleClose:function(){return ne(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(g=null==_?void 0:_.notes)||void 0===g?void 0:g.data)||void 0===h?void 0:h.length)>0&&i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},i.createElement(y,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(n){return i.createElement(D,{key:n,control:i.createElement(R,{checked:se.includes(n),onChange:function(r){r.target.checked?ue(t(t([],e(se),!1),[n],!1)):ue(se.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(q,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),Y&&Y.map((function(e,t){var n,r;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===_.status||"cancelled"===_.status||"done"===_.status?i.createElement(u,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):i.createElement(s,{item:e,index:t,handleUpdateQuantity:de,handleAddReport:ve,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image,handleRemoveReportAtIndex:pe,revalidateCallback:A,showing:se}))})),i.createElement(w,{sx:{p:2}},i.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(p,{text:"Update items",loadingText:"Loading..."}))),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_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}})))||[]}}))}(Y))}))))))}export{H as default};
6
+ import{__read as e,__spreadArray as t,__assign as r,__awaiter as n,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import s from"./TextualIROItemUpdater.js";import u from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as p}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import _ from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import q from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as A}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,DialogContentText as j,CircularProgress as T,TextField as W,List as S,ListItem as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import F from"@mui/icons-material/AssignmentReturn";import N from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import M from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{IroStatusIndicator as z}from"./IroStatusIndicator.js";import{queryAllProducts as V}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Y from"../../../../node_modules/qs/lib/index.js";import{useSnackbar as Q}from"../../../context/common/SnackbarContext.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null};function J(c){var m,s,u=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,x=c.iro,C=e(l(!1),2),w=C[0],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==x?void 0:x.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&n(u,void 0,void 0,(function(){var e,t,r,n,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Y.stringify({filters:{product_number:{$in:x.iro_items.data.map((function(e){var t,r;return(null===(r=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===r?void 0:r.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,V(e)];case 1:return t=a.sent(),r=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",r),q(!1),n=0,i=0,l=x.iro_items.data.map((function(e,t){var a=e.product,l=r.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var s=o*e.returned_quantity,u=c*e.returned_quantity;n+=s,i+=u}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:x.customer_reference||"",total_excl_vat:parseFloat(n.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,x]),i.createElement(E,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(_,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(j,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(j,{variant:"h5"},"Overwrites"),w?i.createElement(T,null):i.createElement(I,{spacing:2},i.createElement(W,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(r(r({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(W,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(r(r({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(W,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(r(r({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(s=null===(m=null==x?void 0:x.iro_items)||void 0===m?void 0:m.data)||void 0===s?void 0:s.length)>0&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"h5"},"Items"),x.iro_items.data.map((function(n,a){var l,o,c,m,s,u,d,v,E,g,h,_,b,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:n.id},i.createElement(y,{sx:{minWidth:100}},n.line_item_number),i.createElement(y,{sx:{minWidth:150}},null===(l=n.product)||void 0===l?void 0:l.product_number),i.createElement(y,{sx:{minWidth:200}},null===(o=n.product)||void 0===o?void 0:o.title),i.createElement(W,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(s=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==s?s:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{vat_rate:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(u=null==p?void 0:p.lines)||void 0===u?void 0:u[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{price_excl_vat:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(h=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==h?h:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{price_incl_vat:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(_=null==p?void 0:p.lines)||void 0===_?void 0:_[a])||void 0===b?void 0:b.quantity)&&void 0!==x?x:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{quantity:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}))}))))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){k("iros",[x.id],p),v()}},"Confirm"),i.createElement(b,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,r=e.handleClose,n=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(E,{open:t},i.createElement(_,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(S,null,"requested"===a&&i.createElement(O,null,"When confirming this return order a rma number will be generated"),i.createElement(O,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(O,null,"Confirming this order will automatically create an invoice")),i.createElement(y,null,"Current status: ",a))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),r()):"requested"===a&&(k("iros",[n]),l&&l(),r())}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No")))}function $(t){var r=t.open,n=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],s=c[1],u=e(l(""),2),d=u[0],v=u[1];return i.createElement("form",null,i.createElement(E,{open:r},i.createElement(_,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(S,null,i.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(O,null,"Please provide a reason for the cancellation"),i.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(W,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(A("iros",a,m),o&&o(),n())}},"Yes"),i.createElement(b,{variant:"contained",onClick:n},"No"))))}function H(n){var a,E,g,h,_=n.data,k=n.sx,A=n.revalidateCallback,j=n.handleClose,T=n.role,W=e(c(m,G),2),S=W[0],O=W[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],H=V[1],K=e(l(!1),2),X=K[0],Z=K[1],ee=e(l(!1),2),te=ee[0],re=ee[1],ne=e(l(!1),2),ae=ne[0],ie=ne[1],le=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),oe=le[0],ce=le[1],me=e(l(["received","registered","released","reports"]),2),se=me[0],ue=me[1],de=function(r,n,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===n}));i[l][a]=r,H(i)},ve=function(n,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],u=t(t([],e(s),!1),[n],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=u,H(c)},pe=function(r,n){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===r})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var u=t(t([],e(m),!1),e(s),!1);l[o].reports.data=u,H(l)},fe=Q().handleAddMessage;return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&(fe({message:"Iro Updated",severity:"success"}),j&&j(),A&&A())}),[S]),o((function(){(null==S?void 0:S.strapiErrors)&&fe({message:S.strapiErrors.message||"Error updating IRO",severity:"error"})}),[null==S?void 0:S.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&H(_.iro_items.data?_.iro_items.data:[])}),[_]),i.createElement(C,{sx:t([],e(Array.isArray(k)?k:[k]),!1)},i.createElement(x,{container:!0,spacing:2},i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(y,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:_.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(y,{variant:"h5",sx:{py:1}},"Details")),i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(y,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=_.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(z,{status:_.status}))))),("requested"===_.status||"finalising_process"===_.status)&&"enduser"===T&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===_.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===_.status&&i.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return re(!0)}},"Cancel order"),i.createElement(L,{open:X,handleClose:function(){return Z(!1)},orderID:_.id,currentStatus:_.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:_}),i.createElement($,{open:te,handleClose:function(){return re(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(g=null==_?void 0:_.notes)||void 0===g?void 0:g.data)||void 0===h?void 0:h.length)>0&&i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(y,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(D,{key:r,control:i.createElement(R,{size:"small",checked:se.includes(r),onChange:function(n){n.target.checked?ue(t(t([],e(se),!1),[r],!1)):ue(se.filter((function(e){return e!==r})))}}),label:i.createElement(y,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(q,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),Y&&Y.map((function(e,t){var r,n;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===_.status||"cancelled"===_.status||"done"===_.status?i.createElement(u,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(s,{item:e,index:t,handleUpdateQuantity:de,handleAddReport:ve,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:pe,revalidateCallback:A,showing:se}))})),i.createElement(w,{sx:{p:2}},i.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(p,{text:"Update items",loadingText:"Loading..."}))),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,returned_quantity:e.returned_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}})))||[]}}))}(Y))}))))))}export{H 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 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{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{StrapiErrors as v}from"../../StrapiErrors.js";import{SubmitButton as E}from"../../SubmitButton.js";import f from"@mui/material/Alert";import h from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import x from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import C from"@mui/material/Button";import k from"@mui/material/Grid";import _ from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as N}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as O,Checkbox as q,List as A,ListItem as S,TextField as B}from"@mui/material";import T from"@mui/icons-material/Numbers";import P from"@mui/icons-material/CalendarToday";import U from"@mui/icons-material/Business";import R from"@mui/icons-material/Description";import W from"@mui/icons-material/Update";import{OpoStatusIndicator as F}from"./OpoStatusIndicator.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null};function Y(e){var t=e.open,r=e.handleClose,a=e.orderID,o=e.currentStatus,i=e.revalidateCallback;return n.createElement(h,{open:t},n.createElement(x,null,"Confirm Order"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(b,null,"Are you sure you want to confirm this order?"),n.createElement(b,null,"Current status: ",o))),n.createElement(g,null,n.createElement(C,{variant:"contained",onClick:function(e){j("opos",[a]),i&&i(),r()}},"Yes"),n.createElement(C,{variant:"contained",onClick:r},"No")))}function z(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(h,{open:r},n.createElement(x,null,"Cancel Return"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(b,null,"Are you sure you want to cancel this order?"),n.createElement(A,null,n.createElement(S,null,"By cancelling this order you will update it's status from ordered 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(B,{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(C,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(N("opos",i,m),l&&l(),o())}},"Yes"),n.createElement(C,{variant:"contained",onClick:o},"No"))))}function G(h){var g,y,x,j,N,A=h.opo,S=h.sx,B=h.revalidateCallback;h.handleClose;var G=h.role,H=e(i(l,M),2),J=H[0],L=H[1],Q=e(a(A.opo_items.data?A.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],re=ee[1],ne=e(a(["picked","packed","shipped","reports"]),2),ae=ne[0],oe=ne[1],ie=function(r,n,a){var o=t([],e(K),!1),i=o.findIndex((function(e){return e.id===n}));o[i][a]=r,V(o)},le=function(n,a){var o,i,l,c=t([],e(K),!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,V(c)},ce=function(r,n){var a,o,i=t([],e(K),!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,V(i)};return o((function(){"Ipo Updated"===(null==J?void 0:J.message)&&B&&B()}),[J]),o((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&V(A.opo_items.data?A.opo_items.data:[])}),[A]),n.createElement(_,{sx:t([],e(Array.isArray(S)?S:[S]),!1)},n.createElement(k,{container:!0,spacing:2},n.createElement(k,{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(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),n.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),n.createElement(p,{content:"",related:[{id:A.id,__type:"api::e-commerce.opo"}],revalidateCallback:B})),n.createElement(D,null))),n.createElement(k,{item:!0,xs:12},n.createElement(b,{variant:"h5",sx:{py:1}},"Details")),n.createElement(k,{item:!0,xs:6},n.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(T,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),n.createElement(b,{variant:"body1",fontWeight:"medium"},A.opo_number)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(R,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),n.createElement(b,{variant:"body1",fontWeight:"medium"},A.customer_reference)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(P,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),n.createElement(b,{variant:"body1",fontWeight:"medium"},A.order_date)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(U,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),n.createElement(b,{variant:"body1",fontWeight:"medium"},null===(y=null===(g=A.customer)||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(W,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),n.createElement(F,{status:A.status}))))),("placed"===A.status||"external_shipping_process"===A.status)&&"enduser"===G&&n.createElement(k,{item:!0,xs:6},n.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},n.createElement(C,{variant:"contained",color:"primary",onClick:function(){return $(!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(C,{variant:"contained",color:"error",onClick:function(){return re(!0)}},"Cancel order"),n.createElement(Y,{open:Z,handleClose:function(){return $(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:B}),n.createElement(z,{open:te,handleClose:function(){return re(!1)},orderID:A.id,revalidateCallback:B})))),n.createElement(k,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(b,{variant:"h5"},"Documents"),n.createElement(w,{sx:{p:2}},n.createElement(I,{spacing:1},A.delivery_note?n.createElement(n.Fragment,null,n.createElement(b,{variant:"h6"},"Delivery Note"),n.createElement(b,null,null===(x=A.delivery_note)||void 0===x?void 0:x.name),n.createElement(C,{variant:"contained",onClick:function(){m("api/ipos/".concat(A.id),"delivery_note")}},"Download")):n.createElement(n.Fragment,null,n.createElement(b,{variant:"h5"},"Delivery Note"),n.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),n.createElement(D,null),n.createElement(c,{reference:"api::e-commerce.opo",refID:A.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:B})))))),(null===(N=null===(j=null==A?void 0:A.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&n.createElement(k,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(b,{variant:"h5"},"Notes"),n.createElement(u,{notes:A.notes.data}),n.createElement(D,null))),n.createElement(k,{item:!0,xs:12},n.createElement(I,{spacing:1},n.createElement(b,{variant:"h5"},"Items"),n.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},n.createElement(b,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(r){return n.createElement(O,{key:r,control:n.createElement(q,{checked:ae.includes(r),onChange:function(n){n.target.checked?oe(t(t([],e(ae),!1),[r],!1)):oe(ae.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"placed"===A.status&&n.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(D,null),n.createElement("form",{action:L},n.createElement("input",{name:"id",type:"hidden",value:A.id}),K&&K.map((function(e,t){var r,a;return n.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===A.status||"external_shipping_process"===A.status||"done"===A.status||"cancelled"===A.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:ie,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:B,showing:ae}))})),n.createElement(w,{sx:{p:2}},n.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(E,{text:"Update items",loadingText:"Loading..."}),n.createElement(v,{error:null==J?void 0:J.strapiErrors}),(null==J?void 0:J.message)&&n.createElement(f,{severity:"error"},null==J?void 0:J.message))),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,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_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}})))||[]}}))}(K))}))))))}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{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{StrapiErrors as v}from"../../StrapiErrors.js";import{SubmitButton as E}from"../../SubmitButton.js";import f from"@mui/material/Alert";import h from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import x from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import C from"@mui/material/Button";import k from"@mui/material/Grid";import _ from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as N}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as O,Checkbox as q,List as A,ListItem as S,TextField as B}from"@mui/material";import T from"@mui/icons-material/Numbers";import P from"@mui/icons-material/CalendarToday";import U from"@mui/icons-material/Business";import F from"@mui/icons-material/Description";import R from"@mui/icons-material/Update";import{OpoStatusIndicator as W}from"./OpoStatusIndicator.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null};function Y(e){var t=e.open,r=e.handleClose,a=e.orderID,o=e.currentStatus,i=e.revalidateCallback;return n.createElement(h,{open:t},n.createElement(x,null,"Confirm Order"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(b,null,"Are you sure you want to confirm this order?"),n.createElement(b,null,"Current status: ",o))),n.createElement(g,null,n.createElement(C,{variant:"contained",onClick:function(e){j("opos",[a]),i&&i(),r()}},"Yes"),n.createElement(C,{variant:"contained",onClick:r},"No")))}function z(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(h,{open:r},n.createElement(x,null,"Cancel Return"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(b,null,"Are you sure you want to cancel this order?"),n.createElement(A,null,n.createElement(S,null,"By cancelling this order you will update it's status from ordered 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(B,{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(C,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(N("opos",i,m),l&&l(),o())}},"Yes"),n.createElement(C,{variant:"contained",onClick:o},"No"))))}function G(h){var g,y,x,j,N,A=h.opo,S=h.sx,B=h.revalidateCallback;h.handleClose;var G=h.role,H=e(i(l,M),2),J=H[0],L=H[1],Q=e(a(A.opo_items.data?A.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],re=ee[1],ne=e(a(["picked","packed","shipped","reports"]),2),ae=ne[0],oe=ne[1],ie=function(r,n,a){var o=t([],e(K),!1),i=o.findIndex((function(e){return e.id===n}));o[i][a]=r,V(o)},le=function(n,a){var o,i,l,c=t([],e(K),!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,V(c)},ce=function(r,n){var a,o,i=t([],e(K),!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,V(i)};return o((function(){"Ipo Updated"===(null==J?void 0:J.message)&&B&&B()}),[J]),o((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&V(A.opo_items.data?A.opo_items.data:[])}),[A]),n.createElement(_,{sx:t([],e(Array.isArray(S)?S:[S]),!1)},n.createElement(k,{container:!0,spacing:2},n.createElement(k,{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(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),n.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),n.createElement(p,{content:"",related:[{id:A.id,__type:"api::e-commerce.opo"}],revalidateCallback:B})),n.createElement(D,null))),n.createElement(k,{item:!0,xs:12},n.createElement(b,{variant:"h5",sx:{py:1}},"Details")),n.createElement(k,{item:!0,xs:6},n.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(T,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),n.createElement(b,{variant:"body1",fontWeight:"medium"},A.opo_number)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(F,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),n.createElement(b,{variant:"body1",fontWeight:"medium"},A.customer_reference)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(P,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),n.createElement(b,{variant:"body1",fontWeight:"medium"},A.order_date)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(U,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),n.createElement(b,{variant:"body1",fontWeight:"medium"},null===(y=null===(g=A.customer)||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(R,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),n.createElement(W,{status:A.status}))))),"enduser"===G&&n.createElement(k,{item:!0,xs:6},n.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},("placed"===A.status||"external_shipping_process"===A.status)&&n.createElement(n.Fragment,null,n.createElement(C,{variant:"contained",color:"primary",onClick:function(){return $(!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(Y,{open:Z,handleClose:function(){return $(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:B})),("placed"===A.status||"ordered"===A.status)&&n.createElement(n.Fragment,null,n.createElement(C,{variant:"contained",color:"error",onClick:function(){return re(!0)}},"Cancel order"),n.createElement(z,{open:te,handleClose:function(){return re(!1)},orderID:A.id,revalidateCallback:B}))))),n.createElement(k,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(b,{variant:"h5"},"Documents"),n.createElement(w,{sx:{p:2}},n.createElement(I,{spacing:1},A.delivery_note?n.createElement(n.Fragment,null,n.createElement(b,{variant:"h6"},"Delivery Note"),n.createElement(b,null,null===(x=A.delivery_note)||void 0===x?void 0:x.name),n.createElement(C,{variant:"contained",onClick:function(){m("api/ipos/".concat(A.id),"delivery_note")}},"Download")):n.createElement(n.Fragment,null,n.createElement(b,{variant:"h5"},"Delivery Note"),n.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),n.createElement(D,null),n.createElement(c,{reference:"api::e-commerce.opo",refID:A.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:B})))))),(null===(N=null===(j=null==A?void 0:A.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&n.createElement(k,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(b,{variant:"h5"},"Notes"),n.createElement(u,{notes:A.notes.data}),n.createElement(D,null))),n.createElement(k,{item:!0,xs:12},n.createElement(I,{spacing:1},n.createElement(b,{variant:"h5"},"Items"),n.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},n.createElement(b,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(r){return n.createElement(O,{key:r,control:n.createElement(q,{checked:ae.includes(r),onChange:function(n){n.target.checked?oe(t(t([],e(ae),!1),[r],!1)):oe(ae.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"placed"===A.status&&n.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(D,null),n.createElement("form",{action:L},n.createElement("input",{name:"id",type:"hidden",value:A.id}),K&&K.map((function(e,t){var r,a;return n.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===A.status||"external_shipping_process"===A.status||"done"===A.status||"cancelled"===A.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:ie,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:B,showing:ae}))})),n.createElement(w,{sx:{p:2}},n.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(E,{text:"Update items",loadingText:"Loading..."}),n.createElement(v,{error:null==J?void 0:J.strapiErrors}),(null==J?void 0:J.message)&&n.createElement(f,{severity:"error"},null==J?void 0:J.message))),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,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_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}})))||[]}}))}(K))}))))))}export{G 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 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 f}from"../../SubmitButton.js";import v 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 b from"@mui/material/Typography";import x 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 O,TextField as S}from"@mui/material";import F 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 H(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(b,null,"Are you sure you want to confirm this order?"),n.createElement(b,null,"Current status: ",i))),n.createElement(g,null,n.createElement(x,{variant:"contained",onClick:function(e){D("ipos",[a]),o&&o()}},"Confirm"),n.createElement(x,{variant:"contained",onClick:r},"Cancel")))}function z(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(b,null,"Are you sure you want to cancel this return?"),n.createElement(N,null,n.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),n.createElement(O,null,"Please provide a reason for the cancellation"),n.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),n.createElement(S,{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(x,{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(x,{variant:"contained",onClick:i},"No"))))}function G(E){var g,y,h,D,j,N,O=E.data,S=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(O.items.data?O.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",O),(null===(e=O.items)||void 0===e?void 0:e.data)&&Z(O.items.data?O.items.data:[])}),[O]),n.createElement(w,{sx:t([],e(Array.isArray(S)?S:[S]),!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(b,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),n.createElement(b,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),n.createElement(p,{content:"",related:[{id:O.id,__type:"api::logistics.ipo"}],revalidateCallback:G})),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(b,{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(F,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),n.createElement(b,{variant:"body1",fontWeight:"medium"},O.ipo_number)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(B,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),n.createElement(b,{variant:"body1",fontWeight:"medium"},O.customer_reference)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(P,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),n.createElement(b,{variant:"body1",fontWeight:"medium"},O.order_date)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(U,{color:"primary"}),n.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),n.createElement(b,{variant:"body1",fontWeight:"medium"},null===(y=null===(g=O.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(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),n.createElement(R,{status:O.status}))),("placed"===O.status||"released_on_stock"===O.status)&&"enduser"===L&&n.createElement(n.Fragment,null,n.createElement(x,{variant:"contained",color:"primary",onClick:function(){return te(!0)}},"Confirm order"),n.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),n.createElement(H,{open:ee,handleClose:function(){return te(!1)},orderID:O.id,currentStatus:O.status,revalidateCallback:G}),n.createElement(z,{open:ne,handleClose:function(){return ae(!1)},orderID:O.id,revalidateCallback:G})))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(b,{variant:"h5"},"Documents"),n.createElement(_,{sx:{p:2}},n.createElement(I,{spacing:1},"enduser"===L&&n.createElement(n.Fragment,null,O.order_confirmation?n.createElement(n.Fragment,null,n.createElement(b,{variant:"h6"},"Order Confirmation"),n.createElement(b,null,null===(h=O.order_confirmation)||void 0===h?void 0:h.name),n.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(O.id),"order_confirmation")}},"Download")):n.createElement(n.Fragment,null,n.createElement(b,{variant:"h5"},"Order Confirmation"),n.createElement(b,{variant:"body1"},"Here you can upload the the order confirmation for this order"),n.createElement(b,{variant:"body1"},"FileUpload"),n.createElement(k,null),n.createElement(c,{reference:"api::logistics.ipo",refID:O.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}))),O.delivery_note?n.createElement(n.Fragment,null,n.createElement(b,{variant:"h6"},"Delivery Note"),n.createElement(b,null,null===(D=O.delivery_note)||void 0===D?void 0:D.name),n.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(O.id),"delivery_note")}},"Download")):n.createElement(n.Fragment,null,n.createElement(b,{variant:"h5"},"Delivery Note"),n.createElement(b,{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: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:G})))))),(null===(N=null===(j=null==O?void 0:O.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(b,{variant:"h5"},"Notes"),n.createElement(u,{notes:O.notes.data}),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:1},n.createElement(b,{variant:"h5"},"Items"),n.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1},n.createElement(b,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(r){return n.createElement(q,{key:r,control:n.createElement(A,{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:r.charAt(0).toUpperCase()+r.slice(1)})}))),"placed"===O.status&&n.createElement(v,{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:O.id}),X&&X.map((function(e,t){var r,a;return n.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===O.status||"cancelled"===O.status||"done"===O.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(f,{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 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};