umwd-components 0.1.638 → 0.1.639

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 e from"react";import t from"@mui/material/Stack";import r from"@mui/material/Typography";import a from"../../common/ImagePreviewTooltip.js";function n(n){var i,m=n.item,o=n.index,l=n.image,c=m.line_item_number,u=m.product,d=m.returned_quantity,p=m.reason,b=m.other_reason;return e.createElement(t,{spacing:1,key:o},m&&e.createElement(t,{direction:"row",justifyContent:"space-between",alignItems:"center"},e.createElement(t,{spacing:1},e.createElement(r,{variant:"body1"},"Line Item Number: ",c),e.createElement(r,{variant:"body1"},"Part Number: ",null==u?void 0:u.product_number),e.createElement(r,{variant:"body1"},"Quantity Ordered: ",d)),e.createElement(t,{spacing:1},e.createElement(r,{variant:"body1"},"Reason: ",p),void 0!==b&&e.createElement(r,{variant:"body1"},b)),l&&e.createElement(e.Fragment,null,e.createElement(a,{image:l,label:null===(i=m.product)||void 0===i?void 0:i.title}))))}export{n as default};
6
+ import e from"react";import t from"@mui/material/Stack";import r from"@mui/material/Typography";import n from"../../common/ImagePreviewTooltip.js";import a from"../../logistics/report/ReportsDisplay.js";function i(i){var c,o,m=i.item,l=i.index,s=i.image,d=m.line_item_number,p=m.product,u=m.returned_quantity,E=m.received_quantity,g=m.registered_quantity,v=m.released_quantity,y=m.reports,b=m.reason,f=m.other_reason;return e.createElement(t,{spacing:1,key:l},m&&e.createElement(t,{direction:"row",justifyContent:"space-between",alignItems:"center"},e.createElement(t,{spacing:1,sx:{width:"100%"}},e.createElement(r,{variant:"body1"},"Line Item Number: ",d),e.createElement(r,{variant:"body1"},"Part Number: ",null==p?void 0:p.product_number)),e.createElement(t,{spacing:1},e.createElement(r,{variant:"body1"},"Reason: ",b),void 0!==f&&e.createElement(r,{variant:"body1"},f)),s&&e.createElement(e.Fragment,null,e.createElement(n,{image:s,label:null===(c=m.product)||void 0===c?void 0:c.title}))),e.createElement(t,{direction:"row",spacing:1,justifyContent:"space-between",alignItems:"center"},e.createElement(t,{direction:"row",spacing:1,alignItems:"center"},e.createElement(r,{variant:"caption"},"Ordered"),e.createElement(r,{variant:"h6"},u)),e.createElement(t,{direction:"row",spacing:1,alignItems:"center"},e.createElement(r,{variant:"caption"},"Received"),e.createElement(r,{variant:"h6"},E)),e.createElement(t,{direction:"row",spacing:1,alignItems:"center"},e.createElement(r,{variant:"caption"},"Registered"),e.createElement(r,{variant:"h6"},g)),e.createElement(t,{direction:"row",spacing:1,alignItems:"center"},e.createElement(r,{variant:"caption"},"Released"),e.createElement(r,{variant:"h6"},v))),(null===(o=null==y?void 0:y.data)||void 0===o?void 0:o.length)>0&&e.createElement(t,{spacing:1},e.createElement(r,{variant:"body1"},"Reports:"),e.createElement(a,{reports:y.data.filter((function(e){return"id"in e&&!("pre_report"in e)}))})))}export{i as default};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as t,__assign as r}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useState as a,useEffect as o,Suspense as i}from"react";import{useFormState as l}from"react-dom";import{requestRmaAction as m}from"../../../data/actions/e-commerce/iro/requestRmaAction.js";import{StrapiErrors as u}from"../../StrapiErrors.js";import{SubmitButton as c}from"../../SubmitButton.js";import s from"@mui/material/Typography";import d from"@mui/material/Grid";import p from"@mui/material/Box";import f from"@mui/material/TextField";import v from"@mui/material/Checkbox";import E from"@mui/material/Button";import g from"@mui/material/Alert";import y from"@mui/material/Stack";import{Divider as h,List as b,ListItem as _}from"@mui/material";import C from"@mui/material/Dialog";import x from"@mui/material/DialogActions";import k from"@mui/material/DialogContent";import q from"@mui/material/DialogContentText";import I from"@mui/material/DialogTitle";import w from"../../common/NumberInput.js";var S={zodErrors:null,strapiErrors:null,data:null,message:null},T=function(l){var m=l.items,u=l.itemsToReturn,c=l.setItemsToReturn,d=l.selectedItems,p=l.setSelectedItems,E=e(a(!1),2),g=E[0],b=E[1],_=function(e,t,n){c(u.map((function(a,o){var i;return o===e?r(r({},a),((i={})[t]=n,i)):a})))};o((function(){m&&c(m.map((function(e){return{line_item_number:e.line_item_number,product:e.product,ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""}})))}),[m]);var C=e(a([]),2),x=C[0],k=C[1];return o((function(){u&&k(u.map((function(e,t){return{line_item_number:"".concat(t+1,".0.0"),product:"object"==typeof e.product&&"id"in e.product?e.product.id:0,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""}})))}),[u]),n.createElement(i,{fallback:n.createElement("div",null,"Loading...")},n.createElement(y,{spacing:2},n.createElement(s,{variant:"h6"},"Items"),n.createElement(s,{variant:"body1"},"from the items in the original order please select the items you'd like to return"),n.createElement("input",{type:"hidden",name:"iro_items",value:JSON.stringify(x)}),n.createElement(y,{spacing:1},m.map((function(r,a){var o,i;return n.createElement(n.Fragment,null,n.createElement(y,{spacing:1,direction:"row",alignItems:"center"},n.createElement(v,{checked:d.includes(a),onChange:function(r){r.target.checked?p(t(t([],e(d),!1),[a],!1)):p(d.filter((function(e){return e!==a})))}}),n.createElement(s,{variant:"body1"},"Line Item Number: ",r.line_item_number),n.createElement(s,{variant:"body1"},"Part Number: ",null===(o=r.product)||void 0===o?void 0:o.product_number),n.createElement(s,{variant:"body1"},"Quantity Ordered: ",r.ordered_quantity)),d.includes(a)&&n.createElement(n.Fragment,null,n.createElement(y,{direction:"row",spacing:1,alignItems:"center"},n.createElement(w,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:function(e){_(a,"returned_quantity",e)},sx:{width:"12rem"}}),n.createElement(h,{orientation:"vertical",flexItem:!0}),n.createElement(s,{variant:"body1",sx:{width:"12rem"}},"Reason for return:"),n.createElement(f,{value:null===(i=u[a])||void 0===i?void 0:i.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:function(e){var t=e.target.value;b("other"===t),_(a,"reason",t)}},n.createElement("option",{value:"damaged"},"Damaged on arrival"),n.createElement("option",{value:"not_as_described"},"Not as described"),n.createElement("option",{value:"wrong_item"},"Wrong item"),n.createElement("option",{value:"other"},"Other"))),g&&n.createElement(f,{value:u[a].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:function(e){var t=e.target.value;_(a,"other_reason",t)}})),n.createElement(h,null))})))))},D=function(t){var r=t.open,o=t.onClose,i=t.items,l=t.formState,m=t.submitCallback,d=e(a(!0),2),p=d[0],f=d[1];return n.createElement(C,{open:r,onClose:o},n.createElement(I,null,"Confirm RMA"),n.createElement(k,null,n.createElement(q,null,"Summary of items to be returned:"),n.createElement(b,null,i.map((function(e,t){var r,a;return n.createElement(_,{key:t},"object"==typeof e.product?"".concat(null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.product_number," ").concat(null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.title):"Product with ID ".concat(e.product)," ","- Quantity: ",e.returned_quantity)}))),n.createElement(q,null,"Are you sure you want to request a return merchandise authorization for these items?"),n.createElement(v,{onChange:function(e){return f(!e.target.checked)}}),n.createElement(s,{variant:"body1"},"I understand that all returned items must be unused and unopened")),n.createElement(x,null,m?n.createElement(c,{text:"Yes",loadingText:"Loading...",disabled:p,onClick:m}):n.createElement(c,{text:"Yes",loadingText:"Loading...",disabled:p}),n.createElement(E,{onClick:o},"No"),null!==(null==l?void 0:l.strapiErrors)&&n.createElement(u,{error:null==l?void 0:l.strapiErrors}),(null==l?void 0:l.message)&&n.createElement(g,{severity:"error"},null==l?void 0:l.message)))};function N(r){var i,c,f,v=r.opo,h=r.sx,b=r.revalidateCallback;r.handleClose;var _=e(l(m,S),2),C=_[0],x=_[1],k=e(a(!1),2),q=k[0],I=k[1],w=e(a([]),2),N=w[0],R=w[1],A=e(a([]),2),j=A[0],F=A[1];return o((function(){(null==C?void 0:C.data)&&b&&b()}),[C.data]),n.createElement(p,{sx:t([],e(Array.isArray(h)?h:[h]),!1)},n.createElement("form",{action:x},n.createElement(d,{container:!0,spacing:2},n.createElement(d,{item:!0,xs:12},n.createElement(s,{variant:"h6"},"RMA Form")),n.createElement("input",{type:"hidden",name:"opos",value:JSON.stringify([v.id])}),n.createElement(d,{item:!0,xs:12},n.createElement(y,{spacing:2},n.createElement(s,{variant:"body1"},"Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned."),n.createElement(g,{severity:"warning"},"We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items."))),n.createElement(d,{item:!0,xs:12},(null===(i=v.opo_items)||void 0===i?void 0:i.data)?n.createElement(y,{spacing:1},(null===(c=v.opo_items)||void 0===c?void 0:c.data)&&n.createElement(T,{items:null===(f=v.opo_items)||void 0===f?void 0:f.data,itemsToReturn:N,setItemsToReturn:R,selectedItems:j,setSelectedItems:F})):n.createElement(s,{variant:"body1"},"No items")),n.createElement(D,{formState:C,open:q,items:N.filter((function(e){return e.returned_quantity>0})),onClose:function(){return I(!q)},submitCallback:function(){console.log("submit callback");var e=document.querySelector("form");x(e?new FormData(e):new FormData),I(!q)}}),n.createElement(d,{item:!0,xs:12},n.createElement(E,{onClick:function(){console.log(C),I(!q)},disabled:0===j.length||0===j.reduce((function(e,t){return e+N[t].returned_quantity}),0)},"Request RMA"),null!==(null==C?void 0:C.strapiErrors)&&n.createElement(u,{error:null==C?void 0:C.strapiErrors}),(null==C?void 0:C.message)&&n.createElement(g,{severity:"error"},null==C?void 0:C.message)))))}export{N as default};
7
+ 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,Suspense as i}from"react";import{useFormState as l}from"react-dom";import{requestRmaAction as m}from"../../../data/actions/e-commerce/iro/requestRmaAction.js";import{StrapiErrors as u}from"../../StrapiErrors.js";import{SubmitButton as c}from"../../SubmitButton.js";import s from"@mui/material/Typography";import d from"@mui/material/Grid";import p from"@mui/material/Box";import f from"@mui/material/TextField";import v from"@mui/material/Checkbox";import E from"@mui/material/Button";import g from"@mui/material/Alert";import h from"@mui/material/Stack";import{Divider as y,List as b,ListItem as _}from"@mui/material";import x from"@mui/material/Dialog";import C from"@mui/material/DialogActions";import k from"@mui/material/DialogContent";import q from"@mui/material/DialogContentText";import I from"@mui/material/DialogTitle";import w from"../../common/NumberInput.js";var S={zodErrors:null,strapiErrors:null,data:null,message:null},T=function(l){var m=l.items,u=l.itemsToReturn,c=l.setItemsToReturn,d=l.selectedItems,p=l.setSelectedItems,E=e(a(!1),2),g=E[0],b=E[1],_=function(e,t,n){c(u.map((function(a,o){var i;return o===e?r(r({},a),((i={})[t]=n,i)):a})))};o((function(){m&&c(m.map((function(e){return{line_item_number:e.line_item_number,product:e.product,ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""}})))}),[m]);var x=e(a([]),2),C=x[0],k=x[1];return o((function(){u&&k(u.map((function(e,t){return{line_item_number:"".concat(t+1,".0.0"),product:"object"==typeof e.product&&"id"in e.product?e.product.id:0,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""}})))}),[u]),n.createElement(i,{fallback:n.createElement("div",null,"Loading...")},n.createElement(h,{spacing:2},n.createElement(s,{variant:"h6"},"Items"),n.createElement(s,{variant:"body1"},"from the items in the original order please select the items you'd like to return"),n.createElement("input",{type:"hidden",name:"iro_items",value:JSON.stringify(C)}),n.createElement(h,{spacing:1},m.map((function(r,a){var o,i;return n.createElement(n.Fragment,null,n.createElement(h,{spacing:1,direction:"row",alignItems:"center"},n.createElement(v,{checked:d.includes(a),onChange:function(r){r.target.checked?p(t(t([],e(d),!1),[a],!1)):p(d.filter((function(e){return e!==a})))}}),n.createElement(s,{variant:"body1"},"Line Item Number: ",r.line_item_number),n.createElement(s,{variant:"body1"},"Part Number: ",null===(o=r.product)||void 0===o?void 0:o.product_number),n.createElement(s,{variant:"body1"},"Quantity Ordered: ",r.ordered_quantity)),d.includes(a)&&n.createElement(n.Fragment,null,n.createElement(h,{direction:"row",spacing:1,alignItems:"center"},n.createElement(w,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:function(e){_(a,"returned_quantity",e)},sx:{width:"12rem"}}),n.createElement(y,{orientation:"vertical",flexItem:!0}),n.createElement(s,{variant:"body1",sx:{width:"12rem"}},"Reason for return:"),n.createElement(f,{value:null===(i=u[a])||void 0===i?void 0:i.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:function(e){var t=e.target.value;b("other"===t),_(a,"reason",t)}},n.createElement("option",{value:"damaged"},"Damaged on arrival"),n.createElement("option",{value:"not_as_described"},"Not as described"),n.createElement("option",{value:"wrong_item"},"Wrong item"),n.createElement("option",{value:"other"},"Other"))),g&&n.createElement(f,{value:u[a].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:function(e){var t=e.target.value;_(a,"other_reason",t)}})),n.createElement(y,null))})))))},D=function(t){var r=t.open,o=t.onClose,i=t.items,l=t.formState,m=t.submitCallback,d=e(a(!0),2),p=d[0],f=d[1];return n.createElement(x,{open:r,onClose:o},n.createElement(I,null,"Confirm RMA"),n.createElement(k,null,n.createElement(q,null,"Summary of items to be returned:"),n.createElement(b,null,i.map((function(e,t){var r,a;return n.createElement(_,{key:t},"object"==typeof e.product?"".concat(null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.product_number," ").concat(null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.title):"Product with ID ".concat(e.product)," ","- Quantity: ",e.returned_quantity)}))),n.createElement(q,null,"Are you sure you want to request a return merchandise authorization for these items?"),n.createElement(v,{onChange:function(e){return f(!e.target.checked)}}),n.createElement(s,{variant:"body1"},"I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration.")),n.createElement(C,null,m?n.createElement(c,{text:"Yes",loadingText:"Loading...",disabled:p,onClick:m}):n.createElement(c,{text:"Yes",loadingText:"Loading...",disabled:p}),n.createElement(E,{onClick:o},"No"),null!==(null==l?void 0:l.strapiErrors)&&n.createElement(u,{error:null==l?void 0:l.strapiErrors}),(null==l?void 0:l.message)&&n.createElement(g,{severity:"error"},null==l?void 0:l.message)))};function N(r){var i,c,f,v=r.opo,y=r.sx,b=r.revalidateCallback;r.handleClose;var _=e(l(m,S),2),x=_[0],C=_[1],k=e(a(!1),2),q=k[0],I=k[1],w=e(a([]),2),N=w[0],R=w[1],A=e(a([]),2),j=A[0],F=A[1];return o((function(){(null==x?void 0:x.data)&&b&&b()}),[x.data]),n.createElement(p,{sx:t([],e(Array.isArray(y)?y:[y]),!1)},n.createElement("form",{action:C},n.createElement(d,{container:!0,spacing:2},n.createElement(d,{item:!0,xs:12},n.createElement(s,{variant:"h6"},"RMA Form")),n.createElement("input",{type:"hidden",name:"opos",value:JSON.stringify([v.id])}),n.createElement(d,{item:!0,xs:12},n.createElement(h,{spacing:2},n.createElement(s,{variant:"body1"},"Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned."),n.createElement(g,{severity:"warning"},"We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items."))),n.createElement(d,{item:!0,xs:12},(null===(i=v.opo_items)||void 0===i?void 0:i.data)?n.createElement(h,{spacing:1},(null===(c=v.opo_items)||void 0===c?void 0:c.data)&&n.createElement(T,{items:null===(f=v.opo_items)||void 0===f?void 0:f.data,itemsToReturn:N,setItemsToReturn:R,selectedItems:j,setSelectedItems:F})):n.createElement(s,{variant:"body1"},"No items")),n.createElement(D,{formState:x,open:q,items:N.filter((function(e){return e.returned_quantity>0})),onClose:function(){return I(!q)},submitCallback:function(){console.log("submit callback");var e=document.querySelector("form");C(e?new FormData(e):new FormData),I(!q)}}),n.createElement(d,{item:!0,xs:12},n.createElement(E,{onClick:function(){console.log(x),I(!q)},disabled:0===j.length||0===j.reduce((function(e,t){return e+N[t].returned_quantity}),0)},"Request RMA"),null!==(null==x?void 0:x.strapiErrors)&&n.createElement(u,{error:null==x?void 0:x.strapiErrors}),(null==x?void 0:x.message)&&n.createElement(g,{severity:"error"},null==x?void 0:x.message)))))}export{N as default};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__read as e,__spreadArray as t,__assign as 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{updateIroAction as l}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import m from"./TextualIROItemUpdater.js";import c from"./IroItemDisplay.js";import s from"../../logistics/note/NotesDisplay.js";import d from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as u}from"../../StrapiErrors.js";import{SubmitButton as p}from"../../SubmitButton.js";import v from"@mui/material/Alert";import E from"@mui/material/Dialog";import f from"@mui/material/DialogActions";import g from"@mui/material/DialogContent";import y from"@mui/material/DialogTitle";import h from"@mui/material/Typography";import b from"@mui/material/Button";import C from"@mui/material/Grid";import w from"@mui/material/Box";import x from"@mui/material/Paper";import _ from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as q}from"../../../data/services/common/confirmation-service.js";import{FormControlLabel as I,Checkbox as D,List as j,ListItem as A}from"@mui/material";var R={zodErrors:null,strapiErrors:null,data:null,message:null};function S(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(y,null,"Confirm Return"),n.createElement(g,null,n.createElement(_,{spacing:2},n.createElement(h,null,"Are you sure you want to confirm this return?"),n.createElement(j,null,"requested"===i&&n.createElement(A,null,"When confirming this return order a rma number will be generated"),n.createElement(A,null,"requested"===i?"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")),n.createElement(h,null,"Current status: ",i))),n.createElement(f,null,n.createElement(b,{variant:"contained",onClick:function(e){q("iros",[a]),o&&o(),r()}},"Yes"),n.createElement(b,{variant:"contained",onClick:r},"No")))}function N(e){var t=e.open,r=e.handleClose;return e.orderID,e.revalidateCallback,n.createElement(E,{open:t},n.createElement(y,null,"Cancel Return"),n.createElement(g,null,n.createElement(_,{spacing:2},n.createElement(h,null,"Are you sure you want to cancel this return?"),n.createElement(j,null))),n.createElement(f,null,n.createElement(b,{variant:"contained",onClick:function(e){r()}},"Yes"),n.createElement(b,{variant:"contained",onClick:r},"No")))}function B(E){var f,g,y,q,j=E.data,A=E.sx,B=E.revalidateCallback;E.handleClose;var M=E.role,T=e(o(l,R),2),U=T[0],P=T[1],O=e(a(j.iro_items.data?j.iro_items.data:[]),2),Y=O[0],z=O[1],F=e(a(!1),2),G=F[0],J=F[1],L=e(a(!1),2),Q=L[0],W=L[1],H=e(a(["received","registered","released","reports"]),2),K=H[0],V=H[1],X=function(r,n,a){var i=t([],e(Y),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,z(i)},Z=function(n,a){var i,o,l,m=t([],e(Y),!1),c=m.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=m[c])||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=m[c])||void 0===l?void 0:l.reports)&&(m[c]=r(r({},m[c]),{reports:{data:[]}})),m[c].reports.data=d,z(m)},$=function(r,n){var a,i,o=t([],e(Y),!1),l=o.findIndex((function(e){return e.id===r})),m=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],c=m.filter((function(e){return"id"in e})),s=m.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(c),!1),e(s),!1);o[l].reports.data=d,z(o)};return i((function(){"Iro Updated"===(null==U?void 0:U.message)&&B&&B()}),[U]),i((function(){var e;console.log(j),(null===(e=j.iro_items)||void 0===e?void 0:e.data)&&z(j.iro_items.data?j.iro_items.data:[])}),[j]),n.createElement(w,{sx:t([],e(Array.isArray(A)?A:[A]),!1)},n.createElement(C,{container:!0,spacing:2},n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(_,{direction:"row",spacing:2,justifyContent:"space-between"},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h3",component:"h1"},"Management Inbound Return"),n.createElement(h,{variant:"body1"},"Manage arrival, registration and release of returns")),n.createElement(d,{content:"",related:[{id:j.id,__type:"api::e-commerce.iro"}],revalidateCallback:B})),n.createElement(k,null))),n.createElement(C,{item:!0,xs:6},n.createElement(_,{spacing:1},n.createElement(h,{variant:"h5"},"Details"),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Return Number"),n.createElement(h,{variant:"body2"},j.return_number)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"RMA Number"),n.createElement(h,{variant:"body2"},j.rma_number)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Customer internal reference number"),n.createElement(h,{variant:"body2"},j.customer_reference)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Return Date"),n.createElement(h,{variant:"body2"},j.return_date)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Customer"),n.createElement(h,{variant:"body2"},null===(g=null===(f=j.customer)||void 0===f?void 0:f.business_credentials)||void 0===g?void 0:g.company_name)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Return Status"),n.createElement(h,{variant:"body2",width:"250px"},j.status)),("requested"===j.status||"finalising_process"===j.status)&&"enduser"===M&&n.createElement(n.Fragment,null,n.createElement(b,{variant:"contained",color:"primary",onClick:function(){return J(!0)}},"Confirm order"),"requested"===j.status?n.createElement(v,{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"):n.createElement(v,{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"),n.createElement(b,{variant:"contained",color:"error",onClick:function(){return W(!0)}},"Cancel order"),n.createElement(S,{open:G,handleClose:function(){return J(!1)},orderID:j.id,currentStatus:j.status,revalidateCallback:B}),n.createElement(N,{open:Q,handleClose:function(){return W(!1)},orderID:j.id,revalidateCallback:B})))),n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h5"},"Documents"),n.createElement(x,{sx:{p:2}},n.createElement(_,{spacing:1})))),(null===(q=null===(y=null==j?void 0:j.notes)||void 0===y?void 0:y.data)||void 0===q?void 0:q.length)>0&&n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h5"},"Notes"),n.createElement(s,{notes:j.notes.data}),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:1},n.createElement(h,{variant:"h5"},"Items"),n.createElement(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:x,p:1},n.createElement(h,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(r){return n.createElement(I,{key:r,control:n.createElement(D,{checked:K.includes(r),onChange:function(n){n.target.checked?V(t(t([],e(K),!1),[r],!1)):V(K.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"requested"===j.status&&n.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(k,null),n.createElement("form",{action:P},n.createElement("input",{name:"id",type:"hidden",value:j.id}),Y&&Y.map((function(e,t){var r,a;return n.createElement(x,{sx:{p:2,mb:2},key:t},"requested"===j.status?n.createElement(c,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):n.createElement(m,{item:e,index:t,handleUpdateQuantity:X,handleAddReport:Z,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:$,revalidateCallback:B,showing:K}))})),n.createElement(x,{sx:{p:2}},n.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(p,{text:"Update items",loadingText:"Loading..."}),n.createElement(u,{error:null==U?void 0:U.strapiErrors}),(null==U?void 0:U.message)&&n.createElement(v,{severity:"error"},null==U?void 0:U.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,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{B 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{updateIroAction as l}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import c from"./TextualIROItemUpdater.js";import m from"./IroItemDisplay.js";import s from"../../logistics/note/NotesDisplay.js";import u from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as d}from"../../StrapiErrors.js";import{SubmitButton as p}from"../../SubmitButton.js";import v from"@mui/material/Alert";import E from"@mui/material/Dialog";import f from"@mui/material/DialogActions";import g from"@mui/material/DialogContent";import y from"@mui/material/DialogTitle";import h from"@mui/material/Typography";import b from"@mui/material/Button";import C from"@mui/material/Grid";import w from"@mui/material/Box";import x from"@mui/material/Paper";import _ from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as q}from"../../../data/services/common/confirmation-service.js";import{cancellationService as I}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,List as j,ListItem as A,TextField as S}from"@mui/material";var N={zodErrors:null,strapiErrors:null,data:null,message:null};function T(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(y,null,"Confirm Return"),n.createElement(g,null,n.createElement(_,{spacing:2},n.createElement(h,null,"Are you sure you want to confirm this return?"),n.createElement(j,null,"requested"===i&&n.createElement(A,null,"When confirming this return order a rma number will be generated"),n.createElement(A,null,"requested"===i?"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")),n.createElement(h,null,"Current status: ",i))),n.createElement(f,null,n.createElement(b,{variant:"contained",onClick:function(e){q("iros",[a]),o&&o(),r()}},"Yes"),n.createElement(b,{variant:"contained",onClick:r},"No")))}function P(t){var r=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],s=c[1],u=e(a(""),2),d=u[0],p=u[1];return n.createElement("form",null,n.createElement(E,{open:r},n.createElement(y,null,"Cancel Return"),n.createElement(g,null,n.createElement(_,{spacing:2},n.createElement(h,null,"Are you sure you want to cancel this return?"),n.createElement(j,null,n.createElement(A,null,"By cancelling this return order you will update it's status from requested to cancelled"),n.createElement(A,null,"Please provide a reason for the cancellation"),n.createElement(A,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 s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),n.createElement(f,null,n.createElement(b,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(I("iros",o,m),l&&l(),i())}},"Yes"),n.createElement(b,{variant:"contained",onClick:i},"No"))))}function B(E){var f,g,y,q,I=E.data,j=E.sx,A=E.revalidateCallback;E.handleClose;var S=E.role,B=e(o(l,N),2),M=B[0],O=B[1],U=e(a(I.iro_items.data?I.iro_items.data:[]),2),Y=U[0],W=U[1],z=e(a(!1),2),F=z[0],G=z[1],J=e(a(!1),2),L=J[0],Q=J[1],H=e(a(["received","registered","released","reports"]),2),K=H[0],V=H[1],X=function(r,n,a){var i=t([],e(Y),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,W(i)},Z=function(n,a){var i,o,l,c=t([],e(Y),!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)||[],u=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=u,W(c)},$=function(r,n){var a,i,o=t([],e(Y),!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 u=t(t([],e(m),!1),e(s),!1);o[l].reports.data=u,W(o)};return i((function(){"Iro Updated"===(null==M?void 0:M.message)&&A&&A()}),[M]),i((function(){var e;console.log(I),(null===(e=I.iro_items)||void 0===e?void 0:e.data)&&W(I.iro_items.data?I.iro_items.data:[])}),[I]),n.createElement(w,{sx:t([],e(Array.isArray(j)?j:[j]),!1)},n.createElement(C,{container:!0,spacing:2},n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(_,{direction:"row",spacing:2,justifyContent:"space-between"},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h3",component:"h1"},"Management Inbound Return"),n.createElement(h,{variant:"body1"},"Manage arrival, registration and release of returns")),n.createElement(u,{content:"",related:[{id:I.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),n.createElement(k,null))),n.createElement(C,{item:!0,xs:6},n.createElement(_,{spacing:1},n.createElement(h,{variant:"h5"},"Details"),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Return Number"),n.createElement(h,{variant:"body2"},I.return_number)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"RMA Number"),n.createElement(h,{variant:"body2"},I.rma_number)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Customer internal reference number"),n.createElement(h,{variant:"body2"},I.customer_reference)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Return Date"),n.createElement(h,{variant:"body2"},I.return_date)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Customer"),n.createElement(h,{variant:"body2"},null===(g=null===(f=I.customer)||void 0===f?void 0:f.business_credentials)||void 0===g?void 0:g.company_name)),n.createElement(_,{direction:"row",spacing:2},n.createElement(h,{variant:"body1",width:"250px"},"Return Status"),n.createElement(h,{variant:"body2",width:"250px"},I.status)),("requested"===I.status||"finalising_process"===I.status)&&"enduser"===S&&n.createElement(n.Fragment,null,n.createElement(b,{variant:"contained",color:"primary",onClick:function(){return G(!0)}},"Confirm order"),"requested"===I.status&&n.createElement(v,{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"===I.status&&n.createElement(v,{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"===I.status&&n.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),n.createElement(b,{variant:"contained",color:"error",onClick:function(){return Q(!0)}},"Cancel order"),n.createElement(T,{open:F,handleClose:function(){return G(!1)},orderID:I.id,currentStatus:I.status,revalidateCallback:A}),n.createElement(P,{open:L,handleClose:function(){return Q(!1)},orderID:I.id,revalidateCallback:A})))),n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h5"},"Documents"),n.createElement(x,{sx:{p:2}},n.createElement(_,{spacing:1})))),(null===(q=null===(y=null==I?void 0:I.notes)||void 0===y?void 0:y.data)||void 0===q?void 0:q.length)>0&&n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:2},n.createElement(h,{variant:"h5"},"Notes"),n.createElement(s,{notes:I.notes.data}),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(_,{spacing:1},n.createElement(h,{variant:"h5"},"Items"),n.createElement(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:x,p:1},n.createElement(h,{variant:"body1"},"Show:"),["received","registered","released","reports"].map((function(r){return n.createElement(D,{key:r,control:n.createElement(R,{checked:K.includes(r),onChange:function(n){n.target.checked?V(t(t([],e(K),!1),[r],!1)):V(K.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"requested"===I.status&&n.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(k,null),n.createElement("form",{action:O},n.createElement("input",{name:"id",type:"hidden",value:I.id}),Y&&Y.map((function(e,t){var r,a;return n.createElement(x,{sx:{p:2,mb:2},key:t},"requested"===I.status||"cancelled"===I.status||"done"===I.status?n.createElement(m,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):n.createElement(c,{item:e,index:t,handleUpdateQuantity:X,handleAddReport:Z,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:$,revalidateCallback:A,showing:K}))})),n.createElement(x,{sx:{p:2}},n.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(p,{text:"Update items",loadingText:"Loading..."}),n.createElement(d,{error:null==M?void 0:M.strapiErrors}),(null==M?void 0:M.message)&&n.createElement(v,{severity:"error"},null==M?void 0:M.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,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{B as default};
@@ -0,0 +1,7 @@
1
+ "use server";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+ import{__awaiter as o,__generator as e}from"../../../../node_modules/tslib/tslib.es6.js";import{getAuthToken as t}from"../get-token.js";import{getStrapiURL as n}from"../../../lib/utils.js";function r(r,s,a){return o(this,void 0,void 0,(function(){var o,i,c,l,u,d;return e(this,(function(e){switch(e.label){case 0:return[4,t()];case 1:if(o=e.sent(),i=n(),c=new URL("api/".concat(r,"/cancel"),i),!o)throw new Error("No auth token found");l=JSON.stringify({data:{id:s,reason:a}}),console.log("payload",l),console.log("url",c),e.label=2;case 2:return e.trys.push([2,5,,6]),[4,fetch(c,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(o)},body:l})];case 3:return u=e.sent(),console.log(u),[4,u.json()];case 4:return[2,e.sent()];case 5:throw d=e.sent(),console.log("error",d),d;case 6:return[2]}}))}))}export{r as cancellationService};