umwd-components 0.1.651 → 0.1.653
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node_modules/base64-js/index.js +1 -1
- package/dist/node_modules/ieee754/index.js +1 -1
- package/dist/src/components/e-commerce/categories/AddCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/iro/CreateIROForm.js +1 -1
- package/dist/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/src/components/e-commerce/products/AddProductForm.js +1 -1
- package/dist/src/components/e-commerce/products/EditProductForm.js +1 -1
- package/dist/src/components/e-commerce/products/EditStockForm.js +1 -1
- package/dist/src/data/actions/e-commerce/iro/createIroAction.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/e-commerce/products/AddProductForm.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/e-commerce/categories/AddCategoryForm.tsx +3 -6
- package/src/components/e-commerce/categories/CreateCategoryForm.tsx +2 -2
- package/src/components/e-commerce/categories/EditCategoryForm.tsx +3 -10
- package/src/components/e-commerce/iro/CreateIROForm.tsx +18 -13
- package/src/components/e-commerce/iro/RmaForm.tsx +1 -1
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +16 -11
- package/src/components/e-commerce/products/AddProductForm.tsx +4 -8
- package/src/components/e-commerce/products/EditProductForm.tsx +1 -9
- package/src/components/e-commerce/products/EditStockForm.tsx +1 -8
- package/src/data/actions/e-commerce/iro/createIroAction.ts +3 -0
|
@@ -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/index7.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
|
|
@@ -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/index8.js";
|
|
7
7
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var t;function o(){return t||(t=1,a.read=function(a,t,o,r,h){var M,e,i=8*h-r-1,p=(1<<i)-1,f=p>>1,n=-7,w=o?h-1:0,s=o?-1:1,u=a[t+w];for(w+=s,M=u&(1<<-n)-1,u>>=-n,n+=i;n>0;M=256*M+a[t+w],w+=s,n-=8);for(e=M&(1<<-n)-1,M>>=-n,n+=r;n>0;e=256*e+a[t+w],w+=s,n-=8);if(0===M)M=1-f;else{if(M===p)return e?NaN:1/0*(u?-1:1);e+=Math.pow(2,r),M-=f}return(u?-1:1)*e*Math.pow(2,M-r)},a.write=function(a,t,o,r,h,M){var e,i,p,f=8*M-h-1,n=(1<<f)-1,w=n>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,N=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,e=n):(e=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-e))<1&&(e--,p*=2),(t+=e+w>=1?s/p:s*Math.pow(2,1-w))*p>=2&&(e++,p/=2),e+w>=n?(i=0,e=n):e+w>=1?(i=(t*p-1)*Math.pow(2,h),e+=w):(i=t*Math.pow(2,w-1)*Math.pow(2,h),e=0));h>=8;a[o+u]=255&i,u+=N,i/=256,h-=8);for(e=e<<h|i,f+=h;f>0;a[o+u]=255&e,u+=N,e/=256,f-=8);a[o+u-N]|=128*_}),a}export{o as __require};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import o from"@mui/material/
|
|
7
|
+
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import o from"@mui/material/Box";import s from"@mui/material/Stack";import m from"@mui/material/TextField";import i from"@mui/material/Typography";import{useFormState as l}from"react-dom";import{createCategoryAction as c}from"../../../data/actions/e-commerce/categories/createCategoryAction.js";import n from"@mui/material/Grid";import u from"../products/ProductSelector.js";import d from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as p}from"../../../context/common/SnackbarContext.js";var g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function y(y){var E=y.productNamesArray,f=y.revalidateCallback,v=y.sx,x=y.handleClose,b=e(l(c,g),2),j=b[0],k=b[1],A=p().handleAddMessage;return a((function(){(null==j?void 0:j.message)&&(A({message:j.message||"Error creating category",severity:j.severity||"error"}),"success"===j.severity&&(A({message:j.message||"Category created successfully",severity:j.severity||"success"}),f&&f(),x&&x()))}),[null==j?void 0:j.message]),a((function(){(null==j?void 0:j.strapiErrors)&&A({message:j.strapiErrors.message||"Error creating category",severity:j.severity||"error"})}),[null==j?void 0:j.strapiErrors]),t.createElement(o,{sx:r([],e(Array.isArray(v)?v:[v]),!1)},t.createElement("form",{action:k},t.createElement(n,{container:!0,spacing:2},t.createElement(n,{item:!0,xs:12},t.createElement(s,{spacing:2},t.createElement(m,{id:"title",name:"title",label:"Title"}),t.createElement(d,{name:"description",label:"Description"}))),t.createElement(n,{item:!0,xs:12},t.createElement(i,{variant:"h6"},"Products"),t.createElement(u,{productNames:E,currentValue:[]})))))}export{y as AddCategoryForm};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import i from"@mui/material/
|
|
7
|
+
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import i from"@mui/material/Box";import o from"@mui/material/Stack";import m from"@mui/material/TextField";import s from"@mui/material/Typography";import{useFormState as l}from"react-dom";import{updateCategoryAction as n}from"../../../data/actions/e-commerce/categories/updateCategoryAction.js";import c from"@mui/material/Grid";import d from"../products/ProductSelector.js";import u from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as p}from"../../../context/common/SnackbarContext.js";var f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function v(v){var E=v.data,g=v.revalidateCallback,y=v.handleClose,x=v.productNamesArray,b=v.sx,h=E.id,j=E.title,k=E.description;E.slug,E.is_archive;var A=E.products,C=(null==A?void 0:A.data)||[],S=e(l(n,f),2),T=S[0],V=S[1],w=p().handleAddMessage;return a((function(){(null==T?void 0:T.message)&&(w({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(g&&g(),y&&y()))}),[null==T?void 0:T.message]),a((function(){(null==T?void 0:T.strapiErrors)&&w({message:T.strapiErrors.message||"Error updating category",severity:T.severity||"error"})}),[null==T?void 0:T.strapiErrors]),t.createElement(i,{sx:r([],e(Array.isArray(b)?b:[b]),!1)},t.createElement("form",{action:V},h&&t.createElement("input",{id:"id",type:"hidden",name:"id",value:h}),t.createElement(c,{container:!0,spacing:2},t.createElement(c,{item:!0,xs:12},t.createElement(o,{spacing:2},t.createElement(m,{id:"title",name:"title",label:"Title",defaultValue:j}),t.createElement(u,{name:"description",label:"Description",defaultValue:k}))),t.createElement(c,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Products"),t.createElement(d,{productNames:x,currentValue:r([],e(C.map((function(e){return e.id}))),!1)})))))}export{v as EditCategoryForm};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as
|
|
7
|
+
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as a,useEffect as o}from"react";import{useFormState as n}from"react-dom";import{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{createIroAction as i}from"../../../data/actions/e-commerce/iro/createIroAction.js";import{SubmitButton as s}from"../../SubmitButton.js";import{CustomerSelector as c}from"../customer/CustomerSelector.js";import{IROItemFields as l}from"./IROItemFields.js";import u from"@mui/material/Typography";import d from"@mui/material/Grid";import p from"@mui/material/Box";import E from"@mui/material/TextField";import f from"@mui/material/Checkbox";import h from"@mui/material/Stack";import v from"@mui/material/Button";var g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function y(y){var x=y.sx,C=y.revalidateCallback,b=y.handleClose,w=y.customerLabels,j=y.productLabels,I=e(a(!1),2),k=I[0],A=I[1],S=e(n(i,g),2),L=S[0],B=S[1],T=m().handleAddMessage;return o((function(){(null==L?void 0:L.message)&&(T({message:L.message,severity:L.severity||"error"}),"success"===L.severity&&(C&&C(),b&&b()))}),[null==L?void 0:L.message]),o((function(){(null==L?void 0:L.strapiErrors)&&T({message:L.strapiErrors.message||"Error creating return order",severity:L.severity||"error"})}),[null==L?void 0:L.strapiErrors]),t.createElement(p,{sx:r([],e(Array.isArray(x)?x:[x]),!1)},t.createElement("form",{action:B},t.createElement(d,{container:!0,spacing:2},t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h3",component:"h1"},"Create new return order"))),t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h6"},"Choose a customer"),t.createElement(u,{variant:"body2"},"Select the customer for which you want to create a return order"),t.createElement(c,{customerLabels:w}))),t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h6"},"Customer reference"),t.createElement(u,null,"If the customer utilizes a custom reference for inbound order management it should be left here"),t.createElement(E,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}}))),t.createElement(d,{item:!0,xs:12},t.createElement(u,{variant:"h6"},"Choose products that should be in this return order"),t.createElement(l,{productsArr:j})),t.createElement(d,{item:!0,xs:12},t.createElement(u,{variant:"h6"},"Confirm Order"),t.createElement(u,null,"Are you sure you want to confirm this return? Confirming this order means you are sure the customer wants to return the products and you are ready to process the return."),t.createElement(h,{direction:"row",spacing:1,alignItems:"center"},t.createElement(f,{value:k,checked:k,onChange:function(){return A(!k)}}),k&&t.createElement(u,{color:"primary"},"I am sure I want to confirm this return order")),t.createElement("input",{name:"status",type:"hidden",value:k?"returning":"requested"})),t.createElement(d,{item:!0,xs:12},t.createElement(h,{direction:"row",justifyContent:"space-between"},t.createElement(v,{onClick:b,variant:"outlined"},"Cancel"),t.createElement(s,{text:"Confirm",loadingText:"Loading...",variant:"contained"}))))))}export{y 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{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{requestRmaAction as u}from"../../../data/actions/e-commerce/iro/requestRmaAction.js";import{StrapiErrors as c}from"../../StrapiErrors.js";import{SubmitButton as s}from"../../SubmitButton.js";import d from"@mui/material/Typography";import p from"@mui/material/Grid";import f from"@mui/material/Box";import v from"@mui/material/TextField";import E from"@mui/material/Checkbox";import g from"@mui/material/Button";import y from"@mui/material/Alert";import h from"@mui/material/Stack";import{Divider as b,List as _,ListItem as x}from"@mui/material";import C from"@mui/material/Dialog";import k from"@mui/material/DialogActions";import q from"@mui/material/DialogContent";import I from"@mui/material/DialogContentText";import w from"@mui/material/DialogTitle";import S from"../../common/NumberInput.js";var A={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},R=function(l){var m=l.items,u=l.itemsToReturn,c=l.setItemsToReturn,s=l.selectedItems,p=l.setSelectedItems,f=e(a(!1),2),g=f[0],y=f[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(d,{variant:"h6"},"Items"),n.createElement(d,{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(E,{checked:s.includes(a),onChange:function(r){r.target.checked?p(t(t([],e(s),!1),[a],!1)):p(s.filter((function(e){return e!==a})))}}),n.createElement(d,{variant:"body1"},"Line Item Number: ",r.line_item_number),n.createElement(d,{variant:"body1"},"Part Number: ",null===(o=r.product)||void 0===o?void 0:o.product_number),n.createElement(d,{variant:"body1"},"Quantity Ordered: ",r.ordered_quantity)),s.includes(a)&&n.createElement(n.Fragment,null,n.createElement(h,{direction:"row",spacing:1,alignItems:"center"},n.createElement(S,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:function(e){_(a,"returned_quantity",e)},sx:{width:"12rem"}}),n.createElement(b,{orientation:"vertical",flexItem:!0}),n.createElement(d,{variant:"body1",sx:{width:"12rem"}},"Reason for return:"),n.createElement(v,{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;y("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(v,{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(b,null))})))))},T=function(t){var r=t.open,o=t.onClose,i=t.items,l=t.formState,m=t.submitCallback,u=e(a(!0),2),p=u[0],f=u[1];return n.createElement(C,{open:r,onClose:o},n.createElement(w,null,"Confirm RMA"),n.createElement(q,null,n.createElement(I,null,"Summary of items to be returned:"),n.createElement(_,null,i.map((function(e,t){var r,a;return n.createElement(x,{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(I,null,"Are you sure you want to request a return merchandise authorization for these items?"),n.createElement(E,{onChange:function(e){return f(!e.target.checked)}}),n.createElement(d,{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(k,null,m?n.createElement(s,{text:"Yes",loadingText:"Loading...",disabled:p,onClick:m}):n.createElement(s,{text:"Yes",loadingText:"Loading...",disabled:p}),n.createElement(g,{onClick:o},"No"),null!==(null==l?void 0:l.strapiErrors)&&n.createElement(c,{error:null==l?void 0:l.strapiErrors}),(null==l?void 0:l.message)&&n.createElement(y,{severity:"error"},null==l?void 0:l.message)))};function D(r){var i,s,v,E=r.opo,b=r.sx,_=r.revalidateCallback,x=r.handleClose,C=e(l(u,A),2),k=C[0],q=C[1],I=m().handleAddMessage,w=e(a(!1),2),S=w[0],D=w[1],N=e(a([]),2),j=N[0],F=N[1],M=e(a([]),2),B=M[0],L=M[1];return o((function(){(null==k?void 0:k.message)&&(I({message:k.message,severity:k.severity||"error"}),"success"===k.severity&&(_&&_(),x&&x()))}),[null==k?void 0:k.message]),o((function(){(null==k?void 0:k.strapiErrors)&&I({message:k.strapiErrors.message||"Error requesting RMA",severity:k.severity||"error"})}),[null==k?void 0:k.strapiErrors]),n.createElement(f,{sx:t([
|
|
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{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{requestRmaAction as u}from"../../../data/actions/e-commerce/iro/requestRmaAction.js";import{StrapiErrors as c}from"../../StrapiErrors.js";import{SubmitButton as s}from"../../SubmitButton.js";import d from"@mui/material/Typography";import p from"@mui/material/Grid";import f from"@mui/material/Box";import v from"@mui/material/TextField";import E from"@mui/material/Checkbox";import g from"@mui/material/Button";import y from"@mui/material/Alert";import h from"@mui/material/Stack";import{Divider as b,List as _,ListItem as x}from"@mui/material";import C from"@mui/material/Dialog";import k from"@mui/material/DialogActions";import q from"@mui/material/DialogContent";import I from"@mui/material/DialogContentText";import w from"@mui/material/DialogTitle";import S from"../../common/NumberInput.js";var A={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},R=function(l){var m=l.items,u=l.itemsToReturn,c=l.setItemsToReturn,s=l.selectedItems,p=l.setSelectedItems,f=e(a(!1),2),g=f[0],y=f[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(d,{variant:"h6"},"Items"),n.createElement(d,{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(E,{checked:s.includes(a),onChange:function(r){r.target.checked?p(t(t([],e(s),!1),[a],!1)):p(s.filter((function(e){return e!==a})))}}),n.createElement(d,{variant:"body1"},"Line Item Number: ",r.line_item_number),n.createElement(d,{variant:"body1"},"Part Number: ",null===(o=r.product)||void 0===o?void 0:o.product_number),n.createElement(d,{variant:"body1"},"Quantity Ordered: ",r.ordered_quantity)),s.includes(a)&&n.createElement(n.Fragment,null,n.createElement(h,{direction:"row",spacing:1,alignItems:"center"},n.createElement(S,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:function(e){_(a,"returned_quantity",e)},sx:{width:"12rem"}}),n.createElement(b,{orientation:"vertical",flexItem:!0}),n.createElement(d,{variant:"body1",sx:{width:"12rem"}},"Reason for return:"),n.createElement(v,{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;y("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(v,{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(b,null))})))))},T=function(t){var r=t.open,o=t.onClose,i=t.items,l=t.formState,m=t.submitCallback,u=e(a(!0),2),p=u[0],f=u[1];return n.createElement(C,{open:r,onClose:o},n.createElement(w,null,"Confirm RMA"),n.createElement(q,null,n.createElement(I,null,"Summary of items to be returned:"),n.createElement(_,null,i.map((function(e,t){var r,a;return n.createElement(x,{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(I,null,"Are you sure you want to request a return merchandise authorization for these items?"),n.createElement(E,{onChange:function(e){return f(!e.target.checked)}}),n.createElement(d,{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(k,null,m?n.createElement(s,{text:"Yes",loadingText:"Loading...",disabled:p,onClick:m}):n.createElement(s,{text:"Yes",loadingText:"Loading...",disabled:p}),n.createElement(g,{onClick:o},"No"),null!==(null==l?void 0:l.strapiErrors)&&n.createElement(c,{error:null==l?void 0:l.strapiErrors}),(null==l?void 0:l.message)&&n.createElement(y,{severity:"error"},null==l?void 0:l.message)))};function D(r){var i,s,v,E=r.opo,b=r.sx,_=r.revalidateCallback,x=r.handleClose,C=e(l(u,A),2),k=C[0],q=C[1],I=m().handleAddMessage,w=e(a(!1),2),S=w[0],D=w[1],N=e(a([]),2),j=N[0],F=N[1],M=e(a([]),2),B=M[0],L=M[1];return o((function(){(null==k?void 0:k.message)&&(I({message:k.message,severity:k.severity||"error"}),"success"===k.severity&&(_&&_(),x&&x()))}),[null==k?void 0:k.message]),o((function(){(null==k?void 0:k.strapiErrors)&&I({message:k.strapiErrors.message||"Error requesting RMA",severity:k.severity||"error"})}),[null==k?void 0:k.strapiErrors]),n.createElement(f,{sx:t([],e(Array.isArray(b)?b:[b]),!1)},n.createElement("form",{action:q},n.createElement(p,{container:!0,spacing:2},n.createElement(p,{item:!0,xs:12},n.createElement(d,{variant:"h6"},"RMA Form")),n.createElement("input",{type:"hidden",name:"opos",value:JSON.stringify([E.id])}),n.createElement(p,{item:!0,xs:12},n.createElement(h,{spacing:2},n.createElement(d,{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(y,{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(p,{item:!0,xs:12},(null===(i=E.opo_items)||void 0===i?void 0:i.data)?n.createElement(h,{spacing:1},(null===(s=E.opo_items)||void 0===s?void 0:s.data)&&n.createElement(R,{items:null===(v=E.opo_items)||void 0===v?void 0:v.data,itemsToReturn:j,setItemsToReturn:F,selectedItems:B,setSelectedItems:L})):n.createElement(d,{variant:"body1"},"No items")),n.createElement(T,{formState:k,open:S,items:j.filter((function(e){return e.returned_quantity>0})),onClose:function(){return D(!S)},submitCallback:function(){console.log("submit callback");var e=document.querySelector("form");q(e?new FormData(e):new FormData),D(!S)}}),n.createElement(p,{item:!0,xs:12},n.createElement(g,{onClick:function(){console.log(k),D(!S)},disabled:0===B.length||0===B.reduce((function(e,t){return e+j[t].returned_quantity}),0)},"Request RMA"),null!==(null==k?void 0:k.strapiErrors)&&n.createElement(c,{error:null==k?void 0:k.strapiErrors}),(null==k?void 0:k.message)&&n.createElement(y,{severity:"error"},null==k?void 0:k.message)))))}export{D 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 l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import s from"./TextualIROItemUpdater.js";import u from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as p}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import _ from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import q from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as A}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,DialogContentText as j,CircularProgress as T,TextField as W,List as S,ListItem as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import F from"@mui/icons-material/AssignmentReturn";import N from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import M from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{IroStatusIndicator as z}from"./IroStatusIndicator.js";import{queryAllProducts as V}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Y from"../../../../node_modules/qs/lib/index.js";import{useSnackbar as Q}from"../../../context/common/SnackbarContext.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null,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],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==x?void 0:x.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&n(u,void 0,void 0,(function(){var e,t,r,n,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Y.stringify({filters:{product_number:{$in:x.iro_items.data.map((function(e){var t,r;return(null===(r=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===r?void 0:r.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,V(e)];case 1:return t=a.sent(),r=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",r),q(!1),n=0,i=0,l=x.iro_items.data.map((function(e,t){var a=e.product,l=r.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var s=o*e.returned_quantity,u=c*e.returned_quantity;n+=s,i+=u}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:x.customer_reference||"",total_excl_vat:parseFloat(n.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,x]),i.createElement(E,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(_,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(j,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(j,{variant:"h5"},"Overwrites"),w?i.createElement(T,null):i.createElement(I,{spacing:2},i.createElement(W,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(r(r({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(W,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(r(r({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(W,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(r(r({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(s=null===(m=null==x?void 0:x.iro_items)||void 0===m?void 0:m.data)||void 0===s?void 0:s.length)>0&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"h5"},"Items"),x.iro_items.data.map((function(n,a){var l,o,c,m,s,u,d,v,E,g,h,_,b,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:n.id},i.createElement(y,{sx:{minWidth:100}},n.line_item_number),i.createElement(y,{sx:{minWidth:150}},null===(l=n.product)||void 0===l?void 0:l.product_number),i.createElement(y,{sx:{minWidth:200}},null===(o=n.product)||void 0===o?void 0:o.title),i.createElement(W,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(s=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==s?s:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{vat_rate:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(u=null==p?void 0:p.lines)||void 0===u?void 0:u[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{price_excl_vat:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(h=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==h?h:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{price_incl_vat:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(_=null==p?void 0:p.lines)||void 0===_?void 0:_[a])||void 0===b?void 0:b.quantity)&&void 0!==x?x:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{quantity:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}))}))))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){k("iros",[x.id],p),v()}},"Confirm"),i.createElement(b,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,r=e.handleClose,n=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(E,{open:t},i.createElement(_,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(S,null,"requested"===a&&i.createElement(O,null,"When confirming this return order a rma number will be generated"),i.createElement(O,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(O,null,"Confirming this order will automatically create an invoice")),i.createElement(y,null,"Current status: ",a))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),r()):"requested"===a&&(k("iros",[n]),l&&l(),r())}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No")))}function $(t){var r=t.open,n=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],s=c[1],u=e(l(""),2),d=u[0],v=u[1];return i.createElement("form",null,i.createElement(E,{open:r},i.createElement(_,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(S,null,i.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(O,null,"Please provide a reason for the cancellation"),i.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(W,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(A("iros",a,m),o&&o(),n())}},"Yes"),i.createElement(b,{variant:"contained",onClick:n},"No"))))}function H(n){var a,E,g,h,_=n.data,k=n.sx,A=n.revalidateCallback,j=n.handleClose,T=n.role,W=e(c(m,G),2),S=W[0],O=W[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],H=V[1],K=e(l(!1),2),X=K[0],Z=K[1],ee=e(l(!1),2),te=ee[0],re=ee[1],ne=e(l(!1),2),ae=ne[0],ie=ne[1],le=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),oe=le[0],ce=le[1],me=e(l(["received","registered","released","reports"]),2),se=me[0],ue=me[1],de=function(r,n,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===n}));i[l][a]=r,H(i)},ve=function(n,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],u=t(t([],e(s),!1),[n],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=u,H(c)},pe=function(r,n){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===r})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var u=t(t([],e(m),!1),e(s),!1);l[o].reports.data=u,H(l)},fe=Q().handleAddMessage;return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&(fe({message:"Iro Updated",severity:"success"}),j&&j(),A&&A())}),[S]),o((function(){(null==S?void 0:S.strapiErrors)&&fe({message:S.strapiErrors.message||"Error updating IRO",severity:"error"})}),[null==S?void 0:S.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&H(_.iro_items.data?_.iro_items.data:[])}),[_]),i.createElement(C,{sx:t([{p:2}],e(Array.isArray(k)?k:[k]),!1),component:w},i.createElement(x,{container:!0,spacing:2},i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(y,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:_.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(y,{variant:"h5",sx:{py:1}},"Details")),i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(y,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=_.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(z,{status:_.status}))))),("requested"===_.status||"finalising_process"===_.status)&&"enduser"===T&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===_.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===_.status&&i.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return re(!0)}},"Cancel order"),i.createElement(L,{open:X,handleClose:function(){return Z(!1)},orderID:_.id,currentStatus:_.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:_}),i.createElement($,{open:te,handleClose:function(){return re(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(g=null==_?void 0:_.notes)||void 0===g?void 0:g.data)||void 0===h?void 0:h.length)>0&&i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(y,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(D,{key:r,control:i.createElement(R,{size:"small",checked:se.includes(r),onChange:function(n){n.target.checked?ue(t(t([],e(se),!1),[r],!1)):ue(se.filter((function(e){return e!==r})))}}),label:i.createElement(y,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(q,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),Y&&Y.map((function(e,t){var r,n;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===_.status||"cancelled"===_.status||"done"===_.status?i.createElement(u,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(s,{item:e,index:t,handleUpdateQuantity:de,handleAddReport:ve,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:pe,revalidateCallback:A,showing:se}))})),i.createElement(w,{sx:{p:2}},i.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(p,{text:"Update items",loadingText:"Loading..."}))),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(r=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===r?void 0:r.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(Y))}))))))}export{H as default};
|
|
6
|
+
import{__read as e,__spreadArray as t,__assign as n,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import s from"./TextualIROItemUpdater.js";import u from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as p}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import _ from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import q from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as A}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,DialogContentText as j,CircularProgress as T,TextField as W,List as S,ListItem as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import F from"@mui/icons-material/AssignmentReturn";import N from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import M from"@mui/icons-material/Description";import 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],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==x?void 0:x.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&r(u,void 0,void 0,(function(){var e,t,n,r,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Y.stringify({filters:{product_number:{$in:x.iro_items.data.map((function(e){var t,n;return(null===(n=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===n?void 0:n.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,V(e)];case 1:return t=a.sent(),n=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",n),q(!1),r=0,i=0,l=x.iro_items.data.map((function(e,t){var a=e.product,l=n.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var s=o*e.returned_quantity,u=c*e.returned_quantity;r+=s,i+=u}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:x.customer_reference||"",total_excl_vat:parseFloat(r.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,x]),i.createElement(E,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(_,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(j,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(j,{variant:"h5"},"Overwrites"),w?i.createElement(T,null):i.createElement(I,{spacing:2},i.createElement(W,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(n(n({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(W,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(n(n({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(W,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(n(n({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(s=null===(m=null==x?void 0:x.iro_items)||void 0===m?void 0:m.data)||void 0===s?void 0:s.length)>0&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"h5"},"Items"),x.iro_items.data.map((function(r,a){var l,o,c,m,s,u,d,v,E,g,h,_,b,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:r.id},i.createElement(y,{sx:{minWidth:100}},r.line_item_number),i.createElement(y,{sx:{minWidth:150}},null===(l=r.product)||void 0===l?void 0:l.product_number),i.createElement(y,{sx:{minWidth:200}},null===(o=r.product)||void 0===o?void 0:o.title),i.createElement(W,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(s=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==s?s:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{vat_rate:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(u=null==p?void 0:p.lines)||void 0===u?void 0:u[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_excl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(h=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==h?h:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_incl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(_=null==p?void 0:p.lines)||void 0===_?void 0:_[a])||void 0===b?void 0:b.quantity)&&void 0!==x?x:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{quantity:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}))}))))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){k("iros",[x.id],p),v()}},"Confirm"),i.createElement(b,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,n=e.handleClose,r=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(E,{open:t},i.createElement(_,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(S,null,"requested"===a&&i.createElement(O,null,"When confirming this return order a rma number will be generated"),i.createElement(O,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(O,null,"Confirming this order will automatically create an invoice")),i.createElement(y,null,"Current status: ",a))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),n()):"requested"===a&&(k("iros",[r]),l&&l(),n())}},"Yes"),i.createElement(b,{variant:"contained",onClick:n},"No")))}function $(t){var n=t.open,r=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],s=c[1],u=e(l(""),2),d=u[0],v=u[1];return i.createElement("form",null,i.createElement(E,{open:n},i.createElement(_,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(S,null,i.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(O,null,"Please provide a reason for the cancellation"),i.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(W,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(A("iros",a,m),o&&o(),r())}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No"))))}function H(r){var a,E,g,h,_=r.data,k=r.sx,A=r.revalidateCallback,j=r.handleClose,T=r.role,W=e(c(m,G),2),S=W[0],O=W[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],H=V[1],K=e(l(!1),2),X=K[0],Z=K[1],ee=e(l(!1),2),te=ee[0],ne=ee[1],re=e(l(!1),2),ae=re[0],ie=re[1],le=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),oe=le[0],ce=le[1],me=e(l(["received","registered","released","reports"]),2),se=me[0],ue=me[1],de=function(n,r,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===r}));i[l][a]=n,H(i)},ve=function(r,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],u=t(t([],e(s),!1),[r],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=u,H(c)},pe=function(n,r){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var u=t(t([],e(m),!1),e(s),!1);l[o].reports.data=u,H(l)},fe=Q().handleAddMessage;return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&(fe({message:"Iro Updated",severity:"success"}),j&&j(),A&&A())}),[S]),o((function(){(null==S?void 0:S.strapiErrors)&&fe({message:S.strapiErrors.message||"Error updating IRO",severity:"error"})}),[null==S?void 0:S.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&H(_.iro_items.data?_.iro_items.data:[])}),[_]),i.createElement(C,{sx:t([],e(Array.isArray(k)?k:[k]),!1)},i.createElement(x,{container:!0,spacing:2},i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(y,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:_.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(y,{variant:"h5",sx:{py:1}},"Details")),i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(y,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=_.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(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"===T&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===_.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===_.status&&i.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),i.createElement(L,{open:X,handleClose:function(){return Z(!1)},orderID:_.id,currentStatus:_.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:_}),i.createElement($,{open:te,handleClose:function(){return ne(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(g=null==_?void 0:_.notes)||void 0===g?void 0:g.data)||void 0===h?void 0:h.length)>0&&i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1,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(n){return i.createElement(D,{key:n,control:i.createElement(R,{size:"small",checked:se.includes(n),onChange:function(r){r.target.checked?ue(t(t([],e(se),!1),[n],!1)):ue(se.filter((function(e){return e!==n})))}}),label:i.createElement(y,{variant:"body2",color:"text.secondary"},n.charAt(0).toUpperCase()+n.slice(1)),sx:{mr:0}})}))),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(q,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(Y))}),Y&&Y.map((function(e,t){var n,r;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===_.status||"cancelled"===_.status||"done"===_.status?i.createElement(u,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):i.createElement(s,{item:e,index:t,handleUpdateQuantity:de,handleAddReport:ve,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image,handleRemoveReportAtIndex:pe,revalidateCallback:A,showing:se}))})),i.createElement(I,{direction:"row",justifyContent:"space-between"},i.createElement(b,{onClick:j,variant:"outlined"},"Cancel"),i.createElement(p,{text:"Confirm",loadingText:"Loading...",variant:"contained"})))))))}export{H as default};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as
|
|
7
|
+
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as n,useState as i}from"react";import{useFormState as a}from"react-dom";import l from"@mui/material/Box";import m from"@mui/material/Stack";import o from"@mui/material/Alert";import c from"@mui/material/TextField";import s from"@mui/material/Typography";import d from"@mui/material/Button";import u from"@mui/material/Grid";import{SubmitButton as p}from"../../SubmitButton.js";import{StrapiErrors as E}from"../../StrapiErrors.js";import{createProductAction as g}from"../../../data/actions/e-commerce/product/createProductAction.js";import{MediaLibraryDialog as f}from"../../common/media/MediaLibraryDialog.js";import{StrapiImage as v}from"../../StrapiImage.js";import{PriceFields as h}from"./PriceFields.js";import y from"../categories/CategorySelectorV2.js";import{DimensionsFields as x}from"../../common/Dimensions.js";import b from"../../logistics/vendor/VendorSelector.js";import j from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as C}from"../../../context/common/SnackbarContext.js";var w={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null},S=function(S){var k=S.vendorArr,A=S.categories,T=S.revalidateCallback,N=S.handleClose,P=S.sx,V=C();V.state,V.dispatch;var _=e(a(g,w),2),D=_[0],I=_[1],B=C().handleAddMessage;n((function(){(null==D?void 0:D.message)&&(B({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(T&&T(),N&&N()))}),[null==D?void 0:D.message]),n((function(){(null==D?void 0:D.strapiErrors)&&B({message:D.strapiErrors.message||"Error adding product",severity:D.severity||"error"})}),[null==D?void 0:D.strapiErrors]);var M=e(i(null),2),O=M[0],F=M[1],G=e(i(null),2),R=G[0],z=G[1],J=e(i([]),2),L=J[0],q=J[1];return t.createElement(l,{sx:r([],e(Array.isArray(P)?P:[P]),!1)},t.createElement("form",{action:I},t.createElement(u,{container:!0,spacing:2},t.createElement(u,{item:!0,xs:12},t.createElement(m,{spacing:2},t.createElement(c,{id:"title",name:"title",label:"Title"}),t.createElement(j,{name:"description",label:"Description"}),t.createElement(c,{id:"external_product_number",name:"external_product_number",label:"External Product Number"}))),t.createElement(u,{item:!0,xs:6},t.createElement(s,{variant:"h6"},"Product Image"),t.createElement("input",{id:"image",type:"hidden",name:"image",value:(null==R?void 0:R.id)||""}),t.createElement(v,{id:(null==R?void 0:R.id)||"",url:(null==R?void 0:R.url)||"",alternativeText:"product image",width:(null==R?void 0:R.width)&&(null==R?void 0:R.height)?R.width/R.height*200:200,height:200}),t.createElement(d,{onClick:function(){return F("image")}},"open media library"),t.createElement(f,{open:"image"===O,handleClose:function(){return F(null)},handleCancel:function(){z(null),F(null)},handleSelect:function(e){z(e)},selected:R?[R]:[]})),t.createElement(u,{item:!0,xs:6},t.createElement(s,{variant:"h6"},"Image Gallery"),t.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(L.map((function(e){return e.id})))}),t.createElement(m,{direction:"row",spacing:2},L.map((function(e){return t.createElement(v,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:e.width/e.height*100,height:100})}))),t.createElement(d,{onClick:function(){return F("gallery")}},"open media library"),t.createElement(f,{open:"gallery"===O,handleClose:function(){return F(null)},handleCancel:function(){q([]),F(null)},handleSelect:function(t){if(L.indexOf(t)>-1){var n=r([],e(L),!1);n.splice(L.indexOf(t),1),q(n)}else L.length>=5?q(r([],e(L),!1)):q(r(r([],e(L),!1),[t],!1))},selected:L})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Price"),t.createElement(h,{componentName:"price",componentReference:"e-commerce-elements.price"})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Categories"),t.createElement(y,{categories:A,currentValue:[]})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Dimensions"),t.createElement(x,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions"})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Vendors"),t.createElement(b,{vendorNames:k,currentValue:null}))),t.createElement(u,{item:!0,xs:12},t.createElement(m,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:2}},t.createElement(p,{text:"create new product",loadingText:"loading"}),t.createElement(E,{error:null==D?void 0:D.strapiErrors}),(null==D?void 0:D.message)&&t.createElement(o,{severity:"error"},null==D?void 0:D.message)))))};export{S as AddProductForm};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as i,useState as n}from"react";import a from"@mui/material/
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as i,useState as n}from"react";import a from"@mui/material/Box";import l from"@mui/material/Stack";import o from"@mui/material/Alert";import m from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{StrapiErrors as u}from"../../StrapiErrors.js";import{updateProductAction as p}from"../../../data/actions/e-commerce/product/updateProductAction.js";import{MediaLibraryDialog as g}from"../../common/media/MediaLibraryDialog.js";import v from"@mui/material/Button";import E from"@mui/material/Grid";import{StrapiImage as f}from"../../StrapiImage.js";import{PriceFields as h}from"./PriceFields.js";import y from"../categories/CategorySelectorV2.js";import{DimensionsFields as x}from"../../common/Dimensions.js";import b from"../../logistics/vendor/VendorSelector.js";import j from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as w}from"../../../context/common/SnackbarContext.js";var C={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null};function S(S){var k,V,A=S.data,_=S.vendorArr,T=S.categoriesArray,I=S.revalidateCallback,N=S.sx,P=A.id,D=A.title,B=A.description,M=A.external_product_number,F=A.image,G=A.gallery,R=A.price,z=A.dimensions,J=A.categories,L=A.vendors,O=(null==G?void 0:G.data)||[],q=(null==J?void 0:J.data)||[],H=w().handleAddMessage,K=e(s(p,C),2),Q=K[0],U=K[1];i((function(){(null==Q?void 0:Q.message)&&(H({message:Q.message,severity:Q.severity||"error"}),"success"===Q.severity&&I&&I())}),[null==Q?void 0:Q.message]),i((function(){(null==Q?void 0:Q.strapiErrors)&&H({message:Q.strapiErrors.message||"Error updating product",severity:Q.severity||"error"})}),[null==Q?void 0:Q.strapiErrors]);var W=e(n(null),2),X=W[0],Y=W[1],Z=e(n(F||null),2),$=Z[0],ee=Z[1],te=e(n(t([],e(O),!1)),2),re=te[0],ie=te[1];return r.createElement(a,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},r.createElement("form",{action:U},P&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:P}),r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(l,{spacing:2},r.createElement(m,{id:"title",name:"title",label:"Title",defaultValue:D}),r.createElement(j,{name:"description",label:"Description",defaultValue:B}),r.createElement(m,{id:"external_product_number",name:"external_product_number",label:"External Product Number",defaultValue:M}))),r.createElement(E,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:null==$?void 0:$.id}),r.createElement(f,{id:(null==$?void 0:$.id)||"",url:(null==$?void 0:$.url)||"",alternativeText:"product image",width:(null==$?void 0:$.width)&&(null==$?void 0:$.height)?$.width/$.height*200:200,height:200}),r.createElement(v,{onClick:function(){return Y("image")}},"open media library"),r.createElement(g,{open:"image"===X,handleClose:function(){return Y(null)},handleCancel:function(){ee(null),Y(null)},handleSelect:function(e){ee(e)},selected:$?[$]:[]})),r.createElement(E,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(re.map((function(e){return e.id})))}),r.createElement(l,{direction:"row",spacing:2},re.map((function(e){return r.createElement(f,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:(null==e?void 0:e.width)&&(null==e?void 0:e.height)?e.width/e.height*100:100,height:100})}))),r.createElement(v,{onClick:function(){return Y("gallery")}},"open media library"),r.createElement(g,{open:"gallery"===X,handleClose:function(){return Y(null)},handleCancel:function(){ie([]),Y(null)},handleSelect:function(r){var i=re.findIndex((function(e){return e.id===r.id}));if(i>-1){var n=t([],e(re),!1);n.splice(i,1),ie(n)}else re.length>=5?ie(t([],e(re),!1)):ie(t(t([],e(re),!1),[r],!1))},selected:re})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Price"),r.createElement(h,{componentName:"price",componentReference:"e-commerce-elements.price",data:R})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Categories"),r.createElement(y,{categories:T,currentValue:t([],e(q.map((function(e){return e.id}))),!1)})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Dimensions"),r.createElement(x,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions",data:z})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Vendors"),r.createElement(b,{vendorNames:_,currentValue:null===(V=null===(k=L.data)||void 0===k?void 0:k[0])||void 0===V?void 0:V.id}))),r.createElement(E,{item:!0,xs:12},r.createElement(l,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},r.createElement(d,{text:"update product",loadingText:"loading"}),(null==Q?void 0:Q.strapiErrors)&&r.createElement(u,{error:null==Q?void 0:Q.strapiErrors}),(null==Q?void 0:Q.message)&&r.createElement(o,{severity:"error"},null==Q?void 0:Q.message)))))}export{S as EditProductForm};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as n}from"react";import l from"@mui/material/Paper";import a from"@mui/material/Box";import m from"@mui/material/Stack";import
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as n}from"react";import l from"@mui/material/Paper";import a from"@mui/material/Box";import m from"@mui/material/Stack";import i from"@mui/material/Alert";import c from"@mui/material/Typography";import{SubmitButton as u}from"../../SubmitButton.js";import{useFormState as o}from"react-dom";import{StrapiErrors as d}from"../../StrapiErrors.js";import{updateProductAction as s}from"../../../data/actions/e-commerce/product/updateProductAction.js";import E from"@mui/material/Grid";import p from"../../logistics/report/ReportsDisplay.js";import y from"../../logistics/report/ReportMakingComponent.js";import{TableContainer as f,Table as g,TableHead as _,TableRow as v,TableCell as q,TableBody as k,TableFooter as x,Tooltip as b}from"@mui/material";import{AmountIndicator as h}from"../../common/AmountIndicator.js";import{useSnackbar as S}from"../../../context/common/SnackbarContext.js";var T={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null};function j(j){var Q=j.data,V=j.revalidateCallback,A=j.sx,O=Q.id,C=Q.title;Q.product_number,Q.stock;var I=Q.ipos,N=Q.opos,R=Q.reports,z=e(o(s,T),2),D=z[0],P=z[1],w=S().handleAddMessage;return n((function(){(null==D?void 0:D.message)&&(w({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&V&&V())}),[null==D?void 0:D.message]),n((function(){(null==D?void 0:D.strapiErrors)&&w({message:D.strapiErrors.message||"Error updating stock",severity:D.severity||"error"})}),[null==D?void 0:D.strapiErrors]),r.createElement(a,{sx:t([],e(Array.isArray(A)?A:[A]),!1)},r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},C)),r.createElement(E,{item:!0,xs:12},r.createElement(f,{component:l},r.createElement(c,{variant:"h6"},"Incoming orders"),r.createElement(g,{size:"small"},r.createElement(_,null,r.createElement(v,null,r.createElement(q,null,"Number"),r.createElement(q,null,"Order Date"),r.createElement(q,null,"Line Item Number"),r.createElement(q,null,"Ordered Quantity"),r.createElement(q,null,"Received Quantity"),r.createElement(q,null,"Registered Quantity"),r.createElement(q,null,"Released Quantity"))),r.createElement(k,null,I.map((function(e){return r.createElement(r.Fragment,null,e.items.map((function(t){return r.createElement(v,{key:e.id},r.createElement(q,null,e.ipo_number),r.createElement(q,null,e.order_date),r.createElement(q,null,t.line_item_number),r.createElement(q,null,r.createElement(h,{value:t.ordered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.received_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.registered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.released_quantity,maxValue:t.ordered_quantity,color:"primary"})))})))}))),r.createElement(x,null,r.createElement(v,null,r.createElement(q,{colSpan:6,align:"right"},"Total added to stock:"),r.createElement(q,null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0))))),r.createElement(c,{variant:"h6"},"Outgoing orders"),r.createElement(g,{size:"small"},r.createElement(_,null,r.createElement(v,null,r.createElement(q,null,"Number"),r.createElement(q,null,"Order Date"),r.createElement(q,null,"Line Item Number"),r.createElement(q,null,"Ordered Quantity"),r.createElement(q,null,"Picked Quantity"),r.createElement(q,null,"Packed Quantity"),r.createElement(q,null,"Shipped Quantity"))),r.createElement(k,null,N.map((function(e){return r.createElement(r.Fragment,null,e.opo_items.map((function(t){return r.createElement(v,{key:e.id},r.createElement(q,null,e.opo_number),r.createElement(q,null,e.order_date),r.createElement(q,null,t.line_item_number),r.createElement(q,null,r.createElement(h,{value:t.ordered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.picked_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.packed_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.shipped_quantity,maxValue:t.ordered_quantity,color:"primary"})))})))}))),r.createElement(x,null,r.createElement(v,null,r.createElement(q,{colSpan:3,align:"right"},"Total reduced from stock:"),r.createElement(q,null,N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0))))),r.createElement(g,{size:"small"},r.createElement(v,null,r.createElement(q,{align:"right"},"Total added to stock:"),r.createElement(q,null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0))),r.createElement(v,null,r.createElement(q,{align:"right"},"Total reduced from stock:"),r.createElement(q,null,N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0))),r.createElement(v,null,r.createElement(q,{align:"right"},"Corrections:"),r.createElement(q,null,r.createElement(b,{title:"Total stock corrections"},r.createElement(c,null,R?R.reduce((function(e,t){return e+t.quantity}),0):0))),r.createElement(q,null,r.createElement(b,{title:"Total stock corrections after updating"},r.createElement("b",null,R?R.reduce((function(e,t){return e+t.quantity}),0):0)))),r.createElement(v,null,r.createElement(q,{align:"right"},"Stock:"),r.createElement(q,null,r.createElement(b,{title:"Total stock"},r.createElement(c,null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0)-N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0)+(R?R.reduce((function(e,t){return e+t.quantity}),0):0)))),r.createElement(q,null,r.createElement(b,{title:"Total stock after updating"},r.createElement("b",null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0)-N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0)+(R?R.reduce((function(e,t){return e+t.quantity}),0):0))))))))),r.createElement("form",{action:P},O&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:O}),r.createElement("input",{id:"stock_reports",type:"hidden",name:"stock_reports",value:JSON.stringify(R)}),r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12,sx:{mt:2}},r.createElement(m,{spacing:2},r.createElement(c,{variant:"h5"},"Stock corrections"),r.createElement(c,{variant:"body2"},"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"),r.createElement(p,{reports:R}),r.createElement(y,{content:"content",quantity:0,type:"stock",related:[{id:O,__type:"api::e-commerce.product"}],revalidateCallback:V}))),r.createElement(E,{item:!0,xs:12},r.createElement(m,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},r.createElement(u,{text:"update stock",loadingText:"loading"}),(null==D?void 0:D.strapiErrors)&&r.createElement(d,{error:null==D?void 0:D.strapiErrors}),(null==D?void 0:D.message)&&r.createElement(i,{severity:"error"},null==D?void 0:D.message))))))}export{j as EditStockForm};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as r,__generator as e,__assign as
|
|
7
|
+
import{__awaiter as r,__generator as e,__assign as s}from"../../../../../node_modules/tslib/tslib.es6.js";import{mutateData as t}from"../../../services/mutate-data.js";import{flattenAttributes as o}from"../../../../lib/utils.js";import{parseFormData as a}from"../../../../lib/parseFormData.js";function i(i,n){return r(this,void 0,void 0,(function(){var r,l,m;return e(this,(function(e){switch(e.label){case 0:return Object.fromEntries(n),(r=a(n)).data.iro_items&&(r.data.iro_items=JSON.parse(r.data.iro_items)),console.log(r),0===r.data.iro_items.length?[2,s(s({},i),{strapiErrors:null,message:"Please add at least one item to the Iro."})]:[4,t("POST","/api/iros/createAdmin",r)];case 1:return(l=e.sent())?l.error?[2,s(s({},i),{strapiErrors:l.error,severity:"error",message:"Failed to Create Iro."})]:(m=o(l),[2,s(s({},i),{message:"Iro Created Successfully",severity:"success",data:m,strapiErrors:null})]):[2,s(s({},i),{strapiErrors:null,severity:"error",message:"Ops! Something went wrong. Please try again."})]}}))}))}export{i as createIroAction};
|