umwd-components 0.1.695 → 0.1.696
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/iro/TextualManageIROForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +87 -25
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +45 -40
- package/src/components/logistics/ipo/TextualManageIPOForm.tsx +3 -3
|
@@ -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};
|
|
@@ -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,__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 q from"@mui/material/Stack";import I 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 S,TextField as T,List as W,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 z from"@mui/icons-material/Update";import{IroStatusIndicator as U}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,severity: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],I=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 I(!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),I(!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(q,{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(S,null):i.createElement(q,{spacing:2},i.createElement(T,{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(T,{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(T,{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(q,{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(T,{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(T,{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(T,{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(T,{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 $(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(q,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(W,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 H(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(q,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(W,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(T,{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 K(n){var a,E,g,h,_=n.data,k=n.sx,A=n.revalidateCallback,j=n.handleClose,S=n.role,T=e(c(m,G),2),W=T[0],O=T[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],K=V[1],L=e(l(!1),2),X=L[0],Z=L[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,K(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,K(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,K(l)},fe=Q().handleAddMessage;return o((function(){(null==W?void 0:W.message)&&(fe({message:W.message,severity:W.severity||"error"}),"success"===W.severity&&(A&&A(),j&&j()))}),[null==W?void 0:W.message]),o((function(){(null==W?void 0:W.strapiErrors)&&fe({message:W.strapiErrors.message||"Error updating IRO",severity:W.severity||"error"})}),[null==W?void 0:W.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&K(_.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(q,{spacing:2},i.createElement(q,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(q,{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(I,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(q,{spacing:2},i.createElement(q,{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(q,{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(q,{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(q,{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(q,{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(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(z,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(U,{status:_.status}))))),("requested"===_.status||"finalising_process"===_.status)&&"enduser"===S&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(q,{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 receives a return payment if eligible and then 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($,{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(H,{open:te,handleClose:function(){return re(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(q,{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(q,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(I,null))),i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(q,{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(I,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),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))}),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(q,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},j&&i.createElement(b,{onClick:j,variant:"outlined"},"Cancel"),i.createElement(p,{text:"Save changes",loadingText:"Saving...",variant:"contained"})))))))}export{K 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 s}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import u from"./TextualIROItemUpdater.js";import m 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 y from"@mui/material/DialogTitle";import _ 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 q from"@mui/material/Stack";import I 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 R,Checkbox as D,DialogContentText as j,CircularProgress as S,TextField as T,List as W,ListItem as F}from"@mui/material";import P from"@mui/icons-material/Numbers";import O from"@mui/icons-material/AssignmentReturn";import M from"@mui/icons-material/CalendarToday";import N from"@mui/icons-material/Business";import B from"@mui/icons-material/Description";import z from"@mui/icons-material/Update";import{IroStatusIndicator as U}from"./IroStatusIndicator.js";import{queryAllProducts as V}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Q from"../../../../node_modules/qs/lib/index.js";import{useSnackbar as Y}from"../../../context/common/SnackbarContext.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function J(c){var s,u,m=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,x=c.iro,C=e(l(!1),2),w=C[0],I=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(m,void 0,void 0,(function(){var e,t,r,n,i,l;return a(this,(function(a){switch(a.label){case 0:return I(!0),e=Q.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),I(!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,s=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,s=l.price.vat_rate||0;var u=o*e.returned_quantity,m=c*e.returned_quantity;n+=u,i+=m}return{vat_rate:s,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(y,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(q,{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(S,null):i.createElement(q,{spacing:2},i.createElement(T,{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(T,{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(T,{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===(u=null===(s=null==x?void 0:x.iro_items)||void 0===s?void 0:s.data)||void 0===u?void 0:u.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,s,u,m,d,v,E,g,h,y,b,x;return i.createElement(q,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:n.id},i.createElement(_,{sx:{minWidth:100}},n.line_item_number),i.createElement(_,{sx:{minWidth:150}},null===(l=n.product)||void 0===l?void 0:l.product_number),i.createElement(_,{sx:{minWidth:200}},null===(o=n.product)||void 0===o?void 0:o.title),i.createElement(T,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(u=null===(s=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===s?void 0:s.vat_rate)&&void 0!==u?u:"",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(T,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(m=null==p?void 0:p.lines)||void 0===m?void 0:m[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(T,{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(T,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(y=null==p?void 0:p.lines)||void 0===y?void 0:y[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 $(e){var t=this,r=e.open,l=e.handleClose,o=e.orderID,c=e.currentStatus,s=e.revalidateCallback,u=e.openOverwritesDialog,m=Y().handleAddMessage;return i.createElement(E,{open:r},i.createElement(y,null,"Confirm Return"),i.createElement(h,null,i.createElement(q,{spacing:2},i.createElement(_,null,"Are you sure you want to confirm this return?"),i.createElement(W,null,"requested"===c&&i.createElement(F,null,"When confirming this return order a rma number will be generated"),i.createElement(F,null,"requested"===c?"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"===c&&i.createElement(F,null,"Confirming this order will automatically create an invoice")),i.createElement(_,null,"Current status: ",c))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(){return n(t,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if("requested"!==c&&"finalising_process"!==c)return m({message:"Cannot confirm return order in current status",severity:"error"}),[2];if("finalising_process"===c)return u?(u(),l(),[2]):(m({message:"Please provide overwrites for the invoice",severity:"error"}),[2]);e.label=1;case 1:return e.trys.push([1,3,,4]),[4,k("iros",[o])];case 2:return e.sent(),m({message:"Return order confirmed successfully",severity:"success"}),s&&s(),l(),[3,4];case 3:return e.sent(),m({message:"Failed to confirm return order",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Yes"),i.createElement(b,{variant:"contained",onClick:l},"No")))}function H(t){var r=this,o=t.open,c=t.handleClose,s=t.orderID,u=t.revalidateCallback,m=e(l(""),2),d=m[0],v=m[1],p=e(l(""),2),f=p[0],x=p[1],C=Y().handleAddMessage;return i.createElement("form",null,i.createElement(E,{open:o},i.createElement(y,null,"Cancel Return"),i.createElement(h,null,i.createElement(q,{spacing:2},i.createElement(_,null,"Are you sure you want to cancel this return?"),i.createElement(W,null,i.createElement(F,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(F,null,"Please provide a reason for the cancellation"),i.createElement(F,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(T,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:d,onChange:function(e){return v(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!f,helperText:f}))),i.createElement(g,null,i.createElement(b,{variant:"outlined",onClick:c},"Close"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return n(r,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(d.length<5)return x("Please provide a reason for the cancellation (min 5 characters)"),[2];x(""),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,A("iros",s,d)];case 2:return e.sent(),C({message:"Return order cancelled successfully",severity:"success"}),u&&u(),c(),[3,4];case 3:return e.sent(),C({message:"Failed to cancel return order",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation"))))}function K(n){var a,E,g,h,y=n.data,k=n.sx,A=n.revalidateCallback,j=n.handleClose,S=n.role,T=e(c(s,G),2),W=T[0],F=T[1],V=e(l(y.iro_items.data?y.iro_items.data:[]),2),Q=V[0],K=V[1],L=e(l(!1),2),X=L[0],Z=L[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],se=e(l(["received","registered","released","reports"]),2),ue=se[0],me=se[1],de=function(r,n,a){var i=t([],e(Q),!1),l=i.findIndex((function(e){return e.id===n}));i[l][a]=r,K(i)},ve=function(n,a){var i,l,o,c=t([],e(Q),!1),s=c.findIndex((function(e){return e.id===a})),u=(null===(l=null===(i=c[s])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],m=t(t([],e(u),!1),[n],!1);null==(null===(o=c[s])||void 0===o?void 0:o.reports)&&(c[s]=r(r({},c[s]),{reports:{data:[]}})),c[s].reports.data=m,K(c)},pe=function(r,n){var a,i,l=t([],e(Q),!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)||[],s=c.filter((function(e){return"id"in e})),u=c.filter((function(e){return!("id"in e)}));u.splice(n,1);var m=t(t([],e(s),!1),e(u),!1);l[o].reports.data=m,K(l)},fe=Y().handleAddMessage;return o((function(){(null==W?void 0:W.message)&&(fe({message:W.message,severity:W.severity||"error"}),"success"===W.severity&&(A&&A(),j&&j()))}),[null==W?void 0:W.message]),o((function(){(null==W?void 0:W.strapiErrors)&&fe({message:W.strapiErrors.message||"Error updating IRO",severity:W.severity||"error"})}),[null==W?void 0:W.strapiErrors]),o((function(){var e;console.log("data",y),(null===(e=y.iro_items)||void 0===e?void 0:e.data)&&K(y.iro_items.data?y.iro_items.data:[])}),[y]),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(q,{spacing:2},i.createElement(q,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(q,{spacing:2},i.createElement(_,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(_,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:y.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(I,null))),i.createElement(x,{item:!0,xs:12},i.createElement(_,{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(q,{spacing:2},i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(_,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(_,{variant:"body1",fontWeight:"medium"},y.return_number)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(O,{color:"primary"}),i.createElement(_,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(_,{variant:"body1",fontWeight:"medium"},y.rma_number)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(_,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(_,{variant:"body1",fontWeight:"medium"},y.customer_reference)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(_,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(_,{variant:"body1",fontWeight:"medium"},y.return_date)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(_,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(_,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=y.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(z,{color:"primary"}),i.createElement(_,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(U,{status:y.status}))))),("requested"===y.status||"finalising_process"===y.status)&&"enduser"===S&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(q,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===y.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"===y.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"),"finalising_process"===y.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($,{open:X,handleClose:function(){return Z(!1)},orderID:y.id,currentStatus:y.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:y}),i.createElement(H,{open:te,handleClose:function(){return re(!1)},orderID:y.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:2},i.createElement(_,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(q,{spacing:1})))),(null===(h=null===(g=null==y?void 0:y.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(q,{spacing:2},i.createElement(_,{variant:"h5"},"Notes"),i.createElement(d,{notes:y.notes.data}),i.createElement(I,null))),i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:1},i.createElement(_,{variant:"h5"},"Items"),i.createElement(q,{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(_,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(R,{key:r,control:i.createElement(D,{size:"small",checked:ue.includes(r),onChange:function(n){n.target.checked?me(t(t([],e(ue),!1),[r],!1)):me(ue.filter((function(e){return e!==r})))}}),label:i.createElement(_,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"requested"===y.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(I,null),i.createElement("form",{action:F},i.createElement("input",{name:"id",type:"hidden",value:y.id}),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}})))||[]}}))}(Q))}),Q&&Q.map((function(e,t){var r,n;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===y.status||"cancelled"===y.status||"done"===y.status?i.createElement(m,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(u,{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:ue}))})),i.createElement(q,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},j&&i.createElement(b,{onClick:j,variant:"outlined"},"Cancel"),i.createElement(p,{text:"Save changes",loadingText:"Saving...",variant:"contained"})))))))}export{K 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,__awaiter as r,__generator as n,__assign as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{updateOpoAction as m}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as s}from"../../common/media/UploadBase64MediaForm.js";import d from"../../../data/loaders/common/media/downloadBase64File.js";import u from"./TextualOpoItemUpdater.js";import p from"./OpoItemDisplay.js";import v from"../../logistics/note/NotesDisplay.js";import f from"../../logistics/note/NoteTakingComponent.js";import E from"@mui/material/Alert";import g from"@mui/material/Dialog";import h from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import x from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import C from"@mui/material/Button";import k from"@mui/material/Grid";import w from"@mui/material/Box";import _ from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as O}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as A,Checkbox as N,List as q,ListItem as S,TextField as B}from"@mui/material";import P from"@mui/icons-material/Numbers";import T from"@mui/icons-material/CalendarToday";import F from"@mui/icons-material/Business";import U from"@mui/icons-material/Description";import M from"@mui/icons-material/Update";import{OpoStatusIndicator as R}from"./OpoStatusIndicator.js";import{useSnackbar as W}from"../../../context/common/SnackbarContext.js";import{SubmitButton as Y}from"../../SubmitButton.js";var z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},G=["picked","packed","shipped","reports"];function H(e){var t=e.open,r=e.handleClose,n=e.orderID,a=e.currentStatus,o=e.revalidateCallback;return i.createElement(g,{open:t},i.createElement(x,null,"Confirm Order"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to confirm this order?"),i.createElement(b,null,"Current status: ",a))),i.createElement(h,null,i.createElement(C,{variant:"contained",onClick:function(e){j("opos",[n]),o&&o(),r()}},"Yes"),i.createElement(C,{variant:"contained",onClick:r},"No")))}function J(t){var a=this,l=t.open,c=t.handleClose,m=t.orderID,s=t.revalidateCallback,d=e(o(""),2),u=d[0],p=d[1],v=e(o(""),2),f=v[0],E=v[1],k=W().handleAddMessage;return i.createElement("form",null,i.createElement(g,{open:l},i.createElement(x,null,"Cancel Return"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to cancel this order?"),i.createElement(q,null,i.createElement(S,null,"By cancelling this order you will update it's status from ordered to cancelled"),i.createElement(S,null,"Please provide a reason for the cancellation"),i.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(B,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:u,onChange:function(e){return p(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!f,helperText:f}))),i.createElement(h,null,i.createElement(C,{variant:"contained",onClick:function(e){return r(a,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:if(u.length<5)return E("Please provide a reason for the cancellation"),[2];E(""),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,O("opos",m,u)];case 2:return e.sent(),k({message:"Order cancelled successfully",severity:"success"}),s&&s(),c(),[3,4];case 3:return e.sent(),k({message:"Error cancelling order",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Yes"),i.createElement(C,{variant:"contained",onClick:c},"No"))))}function Q(r){var n,g,h,y,x,j=r.opo,O=r.sx,q=r.revalidateCallback,S=r.handleClose,B=r.role,Q=m.bind(null,j.id),K=e(c(Q,z),2),L=K[0],V=K[1],X=W().handleAddMessage,Z=e(o(j.opo_items.data?j.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(o(!1),2),re=te[0],ne=te[1],ae=e(o(!1),2),ie=ae[0],oe=ae[1],le=e(o(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];l((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==q||q(),null==S||S()))}),[null==L?void 0:L.message]),l((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),l((function(){var e;(null===(e=j.opo_items)||void 0===e?void 0:e.data)&&ee(j.opo_items.data?j.opo_items.data:[])}),[j]);var se=function(r,n,a){var i=t([],e($),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,ee(i)},de=function(r,n){var i,o,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===n})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[r],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=a(a({},c[m]),{reports:{data:[]}})),c[m].reports.data=d,ee(c)},ue=function(r,n){var a,i,o=t([],e($),!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})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,ee(o)};return i.createElement(w,{sx:t([],e(Array.isArray(O)?O:[O]),!1)},i.createElement(k,{container:!0,spacing:2},i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),i.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),i.createElement(f,{content:"",related:[{id:j.id,__type:"api::e-commerce.opo"}],revalidateCallback:q})),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(b,{variant:"h5",sx:{py:1}},"Details")),i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.opo_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(T,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.order_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(b,{variant:"body1",fontWeight:"medium"},null===(g=null===(n=j.customer)||void 0===n?void 0:n.business_credentials)||void 0===g?void 0:g.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(R,{status:j.status}))))),"enduser"===B&&i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},("placed"===j.status||"external_shipping_process"===j.status)&&i.createElement(i.Fragment,null,i.createElement(C,{variant:"contained",color:"primary",onClick:function(){return ne(!0)}},"Confirm order"),i.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(H,{open:re,handleClose:function(){return ne(!1)},orderID:j.id,currentStatus:j.status,revalidateCallback:q})),("placed"===j.status||"ordered"===j.status)&&i.createElement(i.Fragment,null,i.createElement(C,{variant:"contained",color:"error",onClick:function(){return oe(!0)}},"Cancel order"),i.createElement(J,{open:ie,handleClose:function(){return oe(!1)},orderID:j.id,revalidateCallback:q}))))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Documents"),i.createElement(_,{sx:{p:2}},i.createElement(I,{spacing:1},j.delivery_note?i.createElement(i.Fragment,null,i.createElement(b,{variant:"h6"},"Delivery Note"),i.createElement(b,null,null===(h=j.delivery_note)||void 0===h?void 0:h.name),i.createElement(C,{variant:"contained",onClick:function(){d("api/ipos/".concat(j.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(b,{variant:"h5"},"Delivery Note"),i.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(D,null),i.createElement(s,{reference:"api::e-commerce.opo",refID:j.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:q})))))),(null===(x=null===(y=null==j?void 0:j.notes)||void 0===y?void 0:y.data)||void 0===x?void 0:x.length)>0&&i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Notes"),i.createElement(v,{notes:j.notes.data}),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(b,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1},i.createElement(b,{variant:"body1"},"Show:"),G.map((function(r){return i.createElement(A,{key:r,control:i.createElement(N,{checked:ce.includes(r),onChange:function(n){n.target.checked?me(t(t([],e(ce),!1),[r],!1)):me(ce.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"placed"===j.status&&i.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(D,null),i.createElement("form",{action:V},i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,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}})))||[]}}))}($))}),$&&$.map((function(e,t){var r,n;return i.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===j.status||"external_shipping_process"===j.status||"done"===j.status||"cancelled"===j.status?i.createElement(p,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(u,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:ue,revalidateCallback:q,showing:ce}))}))," ",i.createElement(I,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},S&&i.createElement(C,{onClick:S,variant:"outlined"},"Cancel"),i.createElement(Y,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{Q as default};
|
|
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 o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{updateOpoAction as m}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as s}from"../../common/media/UploadBase64MediaForm.js";import d from"../../../data/loaders/common/media/downloadBase64File.js";import u from"./TextualOpoItemUpdater.js";import p from"./OpoItemDisplay.js";import v from"../../logistics/note/NotesDisplay.js";import f from"../../logistics/note/NoteTakingComponent.js";import E from"@mui/material/Alert";import g from"@mui/material/Dialog";import h from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import x from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import C from"@mui/material/Button";import k from"@mui/material/Grid";import w from"@mui/material/Box";import _ from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as O}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as A,Checkbox as q,List as N,ListItem as S,TextField as B}from"@mui/material";import P from"@mui/icons-material/Numbers";import T from"@mui/icons-material/CalendarToday";import F from"@mui/icons-material/Business";import U from"@mui/icons-material/Description";import M from"@mui/icons-material/Update";import{OpoStatusIndicator as R}from"./OpoStatusIndicator.js";import{useSnackbar as W}from"../../../context/common/SnackbarContext.js";import{SubmitButton as z}from"../../SubmitButton.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},H=["picked","packed","shipped","reports"];function J(e){var t=e.open,r=e.handleClose,n=e.orderID,a=e.currentStatus,o=e.revalidateCallback;return i.createElement(g,{open:t},i.createElement(x,null,"Confirm Order"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to confirm this order?"),i.createElement(b,null,"Current status: ",a))),i.createElement(h,null,i.createElement(C,{variant:"contained",onClick:function(e){j("opos",[n]),o&&o(),r()}},"Yes"),i.createElement(C,{variant:"contained",onClick:r},"No")))}function Q(t){var r=this,l=t.open,c=t.handleClose,m=t.orderID,s=t.revalidateCallback,d=e(o(""),2),u=d[0],p=d[1],v=e(o(""),2),f=v[0],E=v[1],k=W().handleAddMessage;return i.createElement("form",null,i.createElement(g,{open:l},i.createElement(x,null,"Cancel Return"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(b,null,"Are you sure you want to cancel this order?"),i.createElement(N,null,i.createElement(S,null,"By cancelling this order you will update it's status from ordered to cancelled"),i.createElement(S,null,"Please provide a reason for the cancellation"),i.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(B,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:u,onChange:function(e){return p(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!f,helperText:f}))),i.createElement(h,null,i.createElement(C,{variant:"outlined",onClick:c},"Close"),i.createElement(C,{variant:"contained",color:"error",onClick:function(){return n(r,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(u.length<5)return E("Please provide a reason for the cancellation (min 5 characters)"),[2];E(""),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,O("opos",m,u)];case 2:return e.sent(),k({message:"Order cancelled successfully",severity:"success"}),s&&s(),c(),[3,4];case 3:return e.sent(),k({message:"Failed to cancel order",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation"))))}function Y(n){var a,g,h,y,x,j=n.opo,O=n.sx,N=n.revalidateCallback,S=n.handleClose,B=n.role,Y=m.bind(null,j.id),K=e(c(Y,G),2),L=K[0],V=K[1],X=W().handleAddMessage,Z=e(o(j.opo_items.data?j.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(o(!1),2),re=te[0],ne=te[1],ae=e(o(!1),2),ie=ae[0],oe=ae[1],le=e(o(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];l((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==N||N(),null==S||S()))}),[null==L?void 0:L.message]),l((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),l((function(){var e;(null===(e=j.opo_items)||void 0===e?void 0:e.data)&&ee(j.opo_items.data?j.opo_items.data:[])}),[j]);var se=function(r,n,a){var i=t([],e($),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,ee(i)},de=function(n,a){var i,o,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[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=d,ee(c)},ue=function(r,n){var a,i,o=t([],e($),!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})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,ee(o)};return i.createElement(w,{sx:t([],e(Array.isArray(O)?O:[O]),!1)},i.createElement(k,{container:!0,spacing:2},i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),i.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),i.createElement(f,{content:"",related:[{id:j.id,__type:"api::e-commerce.opo"}],revalidateCallback:N})),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(b,{variant:"h5",sx:{py:1}},"Details")),i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.opo_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(T,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(b,{variant:"body1",fontWeight:"medium"},j.order_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(b,{variant:"body1",fontWeight:"medium"},null===(g=null===(a=j.customer)||void 0===a?void 0:a.business_credentials)||void 0===g?void 0:g.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(R,{status:j.status}))))),"enduser"===B&&i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},("placed"===j.status||"external_shipping_process"===j.status)&&i.createElement(i.Fragment,null,i.createElement(C,{variant:"contained",color:"primary",onClick:function(){return ne(!0)}},"Confirm order"),i.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(J,{open:re,handleClose:function(){return ne(!1)},orderID:j.id,currentStatus:j.status,revalidateCallback:N})),("placed"===j.status||"ordered"===j.status)&&i.createElement(i.Fragment,null,i.createElement(C,{variant:"contained",color:"error",onClick:function(){return oe(!0)}},"Cancel order"),i.createElement(Q,{open:ie,handleClose:function(){return oe(!1)},orderID:j.id,revalidateCallback:N}))))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Documents"),i.createElement(_,{sx:{p:2}},i.createElement(I,{spacing:1},j.delivery_note?i.createElement(i.Fragment,null,i.createElement(b,{variant:"h6"},"Delivery Note"),i.createElement(b,null,null===(h=j.delivery_note)||void 0===h?void 0:h.name),i.createElement(C,{variant:"contained",onClick:function(){d("api/ipos/".concat(j.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(b,{variant:"h5"},"Delivery Note"),i.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(D,null),i.createElement(s,{reference:"api::e-commerce.opo",refID:j.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:N})))))),(null===(x=null===(y=null==j?void 0:j.notes)||void 0===y?void 0:y.data)||void 0===x?void 0:x.length)>0&&i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(b,{variant:"h5"},"Notes"),i.createElement(v,{notes:j.notes.data}),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(b,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1},i.createElement(b,{variant:"body1"},"Show:"),H.map((function(r){return i.createElement(A,{key:r,control:i.createElement(q,{checked:ce.includes(r),onChange:function(n){n.target.checked?me(t(t([],e(ce),!1),[r],!1)):me(ce.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"placed"===j.status&&i.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(D,null),i.createElement("form",{action:V},i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,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}})))||[]}}))}($))}),$&&$.map((function(e,t){var r,n;return i.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===j.status||"external_shipping_process"===j.status||"done"===j.status||"cancelled"===j.status?i.createElement(p,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(u,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:ue,revalidateCallback:N,showing:ce}))}))," ",i.createElement(I,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},S&&i.createElement(C,{onClick:S,variant:"outlined"},"Cancel"),i.createElement(z,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{Y 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,__awaiter as n,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{updateIpoAction as s}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{confirmationService as d}from"../../../data/services/common/confirmation-service.js";import{cancellationService as u}from"../../../data/services/common/cancellation-service.js";import p from"../../../data/loaders/common/media/downloadBase64File.js";import{UploadBase64MediaForm as v}from"../../common/media/UploadBase64MediaForm.js";import f from"../note/NoteTakingComponent.js";import E from"../note/NotesDisplay.js";import g from"./ItemDisplay.js";import y from"./TextualIPOItemUpdater.js";import{IpoStatusIndicator as h}from"./IpoStatusIndicator.js";import b from"@mui/material/Box";import x from"@mui/material/Stack";import C from"@mui/material/Paper";import w from"@mui/material/Dialog";import I from"@mui/material/DialogActions";import _ from"@mui/material/DialogContent";import k from"@mui/material/DialogTitle";import D from"@mui/material/Typography";import O from"@mui/material/Button";import j from"@mui/material/Grid";import F from"@mui/material/Divider";import P from"@mui/material/TextField";import A from"@mui/material/List";import q from"@mui/material/ListItem";import S from"@mui/material/Alert";import N from"@mui/material/Checkbox";import T from"@mui/material/FormControlLabel";import U from"@mui/icons-material/Numbers";import B from"@mui/icons-material/Description";import R from"@mui/icons-material/CalendarToday";import M from"@mui/icons-material/Business";import W from"@mui/icons-material/Update";import{SubmitButton as L}from"../../SubmitButton.js";var z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function H(e){var t=this,r=e.open,o=e.handleClose,l=e.orderID,c=e.currentStatus,s=e.revalidateCallback,u=m().handleAddMessage;return i.createElement(w,{open:r},i.createElement(k,null,"Confirm Order"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to confirm this order?"),i.createElement(D,null,"Current status: ",c),i.createElement(S,{severity:"info"},"Once confirmed, the order will be available for processing."))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:o},"Cancel"),i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return n(t,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,d("ipos",[l])];case 1:return e.sent(),u({message:"IPO confirmed successfully",severity:"success"}),s&&s(),o(),[3,3];case 2:return e.sent(),u({message:"Failed to confirm IPO",severity:"error"}),[3,3];case 3:return[2]}}))}))}},"Confirm Order")))}function G(t){var r=this,l=t.open,c=t.handleClose,s=t.orderID,d=t.revalidateCallback,p=e(o(""),2),v=p[0],f=p[1],E=e(o(""),2),g=E[0],y=E[1],h=m().handleAddMessage;return i.createElement(w,{open:l},i.createElement(k,null,"Cancel Return"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to cancel this return?"),i.createElement(A,null,i.createElement(q,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(q,null,"Please provide a reason for the cancellation"),i.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(P,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:v,onChange:function(e){return f(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!g,helperText:g}))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:c},"Cancel"),i.createElement(O,{variant:"contained",color:"error",onClick:function(){return n(r,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(v.length<5)return y("Please provide a reason for the cancellation (min 5 characters)"),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,u("ipos",s,v)];case 2:return e.sent(),h({message:"IPO cancelled successfully",severity:"success"}),d&&d(),c(),[3,4];case 3:return e.sent(),h({message:"Failed to cancel IPO",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation")))}function J(n){var a,d,u,w,I,_,k=n.data,P=n.sx,A=n.revalidateCallback,q=n.handleClose,J=n.role,Q=e(c((function(e,t){return s(k.id,e,t)}),z),2),K=Q[0],V=Q[1],X=m().handleAddMessage,Y=e(o(k.items.data?k.items.data:[]),2),Z=Y[0],$=Y[1],ee=e(o(!1),2),te=ee[0],re=ee[1],ne=e(o(!1),2),ae=ne[0],ie=ne[1],oe=e(o(["received","registered","released","reports"]),2),le=oe[0],ce=oe[1];l((function(){(null==K?void 0:K.message)&&(X({message:K.message,severity:K.severity||"error"}),"success"===K.severity&&(A&&A(),q&&q()))}),[null==K?void 0:K.message]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]);var me=function(r,n,a){var i=t([],e(Z),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,$(i)},se=function(n,a){var i,o,l,c=t([],e(Z),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[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=d,$(c)},de=function(r,n){var a,i,o=t([],e(Z),!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})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,$(o)};return l((function(){"Ipo Updated"===(null==K?void 0:K.message)&&(X({message:"Ipo Updated",severity:"success"}),q&&q(),A&&A())}),[K]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]),l((function(){var e;console.log("data",k),(null===(e=k.items)||void 0===e?void 0:e.data)&&$(k.items.data?k.items.data:[])}),[k]),i.createElement(b,{sx:t([],e(Array.isArray(P)?P:[P]),!1)},i.createElement(j,{container:!0,spacing:2},i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),i.createElement(D,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),i.createElement(f,{content:"",related:[{id:k.id,__type:"api::logistics.ipo"}],revalidateCallback:A})),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(D,{variant:"h5",sx:{py:1}},"Details")),i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.ipo_number)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.customer_reference)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(R,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.order_date)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),i.createElement(D,{variant:"body1",fontWeight:"medium"},null===(d=null===(a=k.vendor_profile)||void 0===a?void 0:a.business_credentials)||void 0===d?void 0:d.company_name)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(W,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(h,{status:k.status}))))),"enduser"===J&&i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},("placed"===k.status||"released_on_stock"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return re(!0)}},"Confirm order"),i.createElement(S,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(H,{open:te,handleClose:function(){return re(!1)},orderID:k.id,currentStatus:k.status,revalidateCallback:A})),("placed"===k.status||"ordered"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"error",onClick:function(){return ie(!0)}},"Cancel order"),i.createElement(G,{open:ae,handleClose:function(){return ie(!1)},orderID:k.id,revalidateCallback:A}))))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Documents"),i.createElement(C,{sx:{p:2}},i.createElement(x,{spacing:1},"enduser"===J&&i.createElement(i.Fragment,null,k.order_confirmation?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Order Confirmation"),i.createElement(D,null,null===(u=k.order_confirmation)||void 0===u?void 0:u.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"order_confirmation")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Order Confirmation"),i.createElement(D,{variant:"body1"},"Here you can upload the the order confirmation for this order"),i.createElement(D,{variant:"body1"},"FileUpload"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.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:A}))),k.delivery_note?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Delivery Note"),i.createElement(D,null,null===(w=k.delivery_note)||void 0===w?void 0:w.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Delivery Note"),i.createElement(D,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.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===(_=null===(I=null==k?void 0:k.notes)||void 0===I?void 0:I.data)||void 0===_?void 0:_.length)>0&&i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Notes"),i.createElement(E,{notes:k.notes.data}),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:1},i.createElement(D,{variant:"h5"},"Items"),i.createElement(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:C,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(D,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(T,{key:r,control:i.createElement(N,{size:"small",checked:le.includes(r),onChange:function(n){n.target.checked?ce(t(t([],e(le),!1),[r],!1)):ce(le.filter((function(e){return e!==r})))}}),label:i.createElement(D,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===k.status&&i.createElement(S,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(F,null),i.createElement("form",{action:V},i.createElement("input",{name:"id",type:"hidden",value:k.id}),Z&&Z.map((function(e,t){var r,n;return i.createElement(C,{sx:{p:2,mb:2},key:t},"placed"===k.status||"cancelled"===k.status||"done"===k.status?i.createElement(g,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(y,{item:e,index:t,handleUpdateQuantity:me,handleAddReport:se,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:de,revalidateCallback:A,showing:le}))})),i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},q&&i.createElement(O,{onClick:q,variant:"outlined"},"Cancel"),i.createElement(L,{variant:"contained",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,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}})))||[]}}))}(Z))}))))))}export{J 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 o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{updateIpoAction as s}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{confirmationService as d}from"../../../data/services/common/confirmation-service.js";import{cancellationService as u}from"../../../data/services/common/cancellation-service.js";import p from"../../../data/loaders/common/media/downloadBase64File.js";import{UploadBase64MediaForm as v}from"../../common/media/UploadBase64MediaForm.js";import f from"../note/NoteTakingComponent.js";import E from"../note/NotesDisplay.js";import g from"./ItemDisplay.js";import y from"./TextualIPOItemUpdater.js";import{IpoStatusIndicator as h}from"./IpoStatusIndicator.js";import b from"@mui/material/Box";import x from"@mui/material/Stack";import C from"@mui/material/Paper";import w from"@mui/material/Dialog";import I from"@mui/material/DialogActions";import _ from"@mui/material/DialogContent";import k from"@mui/material/DialogTitle";import D from"@mui/material/Typography";import j from"@mui/material/Button";import O from"@mui/material/Grid";import F from"@mui/material/Divider";import A from"@mui/material/TextField";import P from"@mui/material/List";import q from"@mui/material/ListItem";import S from"@mui/material/Alert";import N from"@mui/material/Checkbox";import T from"@mui/material/FormControlLabel";import U from"@mui/icons-material/Numbers";import B from"@mui/icons-material/Description";import R from"@mui/icons-material/CalendarToday";import M from"@mui/icons-material/Business";import W from"@mui/icons-material/Update";import{SubmitButton as L}from"../../SubmitButton.js";var z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function H(e){var t=this,r=e.open,o=e.handleClose,l=e.orderID,c=e.currentStatus,s=e.revalidateCallback,u=m().handleAddMessage;return i.createElement(w,{open:r},i.createElement(k,null,"Confirm Order"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to confirm this order?"),i.createElement(D,null,"Current status: ",c),i.createElement(S,{severity:"info"},"Once confirmed, the order will be available for processing."))),i.createElement(I,null,i.createElement(j,{variant:"outlined",onClick:o},"Cancel"),i.createElement(j,{variant:"contained",color:"primary",onClick:function(){return n(t,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,d("ipos",[l])];case 1:return e.sent(),u({message:"IPO confirmed successfully",severity:"success"}),s&&s(),o(),[3,3];case 2:return e.sent(),u({message:"Failed to confirm IPO",severity:"error"}),[3,3];case 3:return[2]}}))}))}},"Confirm Order")))}function G(t){var r=this,l=t.open,c=t.handleClose,s=t.orderID,d=t.revalidateCallback,p=e(o(""),2),v=p[0],f=p[1],E=e(o(""),2),g=E[0],y=E[1],h=m().handleAddMessage;return i.createElement(w,{open:l},i.createElement(k,null,"Cancel Return"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to cancel this return?"),i.createElement(P,null,i.createElement(q,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(q,null,"Please provide a reason for the cancellation"),i.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(A,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:v,onChange:function(e){return f(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!g,helperText:g}))),i.createElement(I,null,i.createElement(j,{variant:"outlined",onClick:c},"Close"),i.createElement(j,{variant:"contained",color:"error",onClick:function(){return n(r,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(v.length<5)return y("Please provide a reason for the cancellation (min 5 characters)"),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,u("ipos",s,v)];case 2:return e.sent(),h({message:"Order cancelled successfully",severity:"success"}),d&&d(),c(),[3,4];case 3:return e.sent(),h({message:"Failed to cancel order",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation")))}function J(n){var a,d,u,w,I,_,k=n.data,A=n.sx,P=n.revalidateCallback,q=n.handleClose,J=n.role,Q=e(c((function(e,t){return s(k.id,e,t)}),z),2),K=Q[0],V=Q[1],X=m().handleAddMessage,Y=e(o(k.items.data?k.items.data:[]),2),Z=Y[0],$=Y[1],ee=e(o(!1),2),te=ee[0],re=ee[1],ne=e(o(!1),2),ae=ne[0],ie=ne[1],oe=e(o(["received","registered","released","reports"]),2),le=oe[0],ce=oe[1];l((function(){(null==K?void 0:K.message)&&(X({message:K.message,severity:K.severity||"error"}),"success"===K.severity&&(P&&P(),q&&q()))}),[null==K?void 0:K.message]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]);var me=function(r,n,a){var i=t([],e(Z),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,$(i)},se=function(n,a){var i,o,l,c=t([],e(Z),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[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=d,$(c)},de=function(r,n){var a,i,o=t([],e(Z),!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})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,$(o)};return l((function(){"Ipo Updated"===(null==K?void 0:K.message)&&(X({message:"Ipo Updated",severity:"success"}),q&&q(),P&&P())}),[K]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]),l((function(){var e;console.log("data",k),(null===(e=k.items)||void 0===e?void 0:e.data)&&$(k.items.data?k.items.data:[])}),[k]),i.createElement(b,{sx:t([],e(Array.isArray(A)?A:[A]),!1)},i.createElement(O,{container:!0,spacing:2},i.createElement(O,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),i.createElement(D,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),i.createElement(f,{content:"",related:[{id:k.id,__type:"api::logistics.ipo"}],revalidateCallback:P})),i.createElement(F,null))),i.createElement(O,{item:!0,xs:12},i.createElement(D,{variant:"h5",sx:{py:1}},"Details")),i.createElement(O,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.ipo_number)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.customer_reference)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(R,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.order_date)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),i.createElement(D,{variant:"body1",fontWeight:"medium"},null===(d=null===(a=k.vendor_profile)||void 0===a?void 0:a.business_credentials)||void 0===d?void 0:d.company_name)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(W,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(h,{status:k.status}))))),"enduser"===J&&i.createElement(O,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},("placed"===k.status||"released_on_stock"===k.status)&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"contained",color:"primary",onClick:function(){return re(!0)}},"Confirm order"),i.createElement(S,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(H,{open:te,handleClose:function(){return re(!1)},orderID:k.id,currentStatus:k.status,revalidateCallback:P})),("placed"===k.status||"ordered"===k.status)&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"contained",color:"error",onClick:function(){return ie(!0)}},"Cancel order"),i.createElement(G,{open:ae,handleClose:function(){return ie(!1)},orderID:k.id,revalidateCallback:P}))))),i.createElement(O,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Documents"),i.createElement(C,{sx:{p:2}},i.createElement(x,{spacing:1},"enduser"===J&&i.createElement(i.Fragment,null,k.order_confirmation?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Order Confirmation"),i.createElement(D,null,null===(u=k.order_confirmation)||void 0===u?void 0:u.name),i.createElement(j,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"order_confirmation")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Order Confirmation"),i.createElement(D,{variant:"body1"},"Here you can upload the the order confirmation for this order"),i.createElement(D,{variant:"body1"},"FileUpload"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.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:P}))),k.delivery_note?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Delivery Note"),i.createElement(D,null,null===(w=k.delivery_note)||void 0===w?void 0:w.name),i.createElement(j,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Delivery Note"),i.createElement(D,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.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:P})))))),(null===(_=null===(I=null==k?void 0:k.notes)||void 0===I?void 0:I.data)||void 0===_?void 0:_.length)>0&&i.createElement(O,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Notes"),i.createElement(E,{notes:k.notes.data}),i.createElement(F,null))),i.createElement(O,{item:!0,xs:12},i.createElement(x,{spacing:1},i.createElement(D,{variant:"h5"},"Items"),i.createElement(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:C,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(D,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(T,{key:r,control:i.createElement(N,{size:"small",checked:le.includes(r),onChange:function(n){n.target.checked?ce(t(t([],e(le),!1),[r],!1)):ce(le.filter((function(e){return e!==r})))}}),label:i.createElement(D,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===k.status&&i.createElement(S,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(F,null),i.createElement("form",{action:V},i.createElement("input",{name:"id",type:"hidden",value:k.id}),Z&&Z.map((function(e,t){var r,n;return i.createElement(C,{sx:{p:2,mb:2},key:t},"placed"===k.status||"cancelled"===k.status||"done"===k.status?i.createElement(g,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(y,{item:e,index:t,handleUpdateQuantity:me,handleAddReport:se,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:de,revalidateCallback:P,showing:le}))})),i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},q&&i.createElement(j,{onClick:q,variant:"outlined"},"Cancel"),i.createElement(L,{variant:"contained",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,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}})))||[]}}))}(Z))}))))))}export{J as default};
|