umwd-components 0.1.652 → 0.1.654
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/.ai/{patterns.md → form-patterns.md} +39 -2
- 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/invoice/CreateInvoiceForm.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/opo/CreateOpoForm.js +1 -1
- package/dist/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.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/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/e-commerce/invoice/CreateInvoiceForm.d.ts +2 -1
- package/dist/types/components/e-commerce/products/AddProductForm.d.ts +3 -1
- package/dist/types/components/e-commerce/products/EditProductForm.d.ts +2 -1
- package/dist/types/components/e-commerce/products/EditStockForm.d.ts +2 -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/invoice/CreateInvoiceForm.tsx +51 -49
- package/src/components/e-commerce/iro/CreateIROForm.tsx +1 -1
- 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/opo/CreateOpoForm.tsx +21 -8
- package/src/components/e-commerce/opo/ManageOpoForm.tsx +11 -6
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +12 -13
- package/src/components/e-commerce/products/AddProductForm.tsx +24 -25
- package/src/components/e-commerce/products/EditProductForm.tsx +24 -28
- package/src/components/e-commerce/products/EditStockForm.tsx +32 -39
|
@@ -81,10 +81,8 @@ styling:
|
|
|
81
81
|
```typescript
|
|
82
82
|
<Box
|
|
83
83
|
sx={[
|
|
84
|
-
{ p: 2 },
|
|
85
84
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
86
85
|
]}
|
|
87
|
-
component={Paper}
|
|
88
86
|
>
|
|
89
87
|
```
|
|
90
88
|
|
|
@@ -99,6 +97,45 @@ styling:
|
|
|
99
97
|
4. **Consistent Styling**: Uses consistent Box wrapper with padding and sx prop
|
|
100
98
|
spreading
|
|
101
99
|
|
|
100
|
+
### Form Layout Pattern
|
|
101
|
+
|
|
102
|
+
1. **Title Section**:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
<Grid item xs={12}>
|
|
106
|
+
<Stack spacing={2}>
|
|
107
|
+
<Typography variant="h3" component={"h1"}>
|
|
108
|
+
Form Title Here
|
|
109
|
+
</Typography>
|
|
110
|
+
</Stack>
|
|
111
|
+
</Grid>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
2. **Action Buttons**:
|
|
115
|
+
|
|
116
|
+
- Place at bottom of form
|
|
117
|
+
- Cancel button is optional (only shown if handleClose provided)
|
|
118
|
+
- Use consistent button layout with space-between
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
<Grid item xs={12}>
|
|
122
|
+
<Stack direction={"row"} justifyContent={"space-between"}>
|
|
123
|
+
{handleClose && (
|
|
124
|
+
<Button onClick={handleClose} variant="outlined">
|
|
125
|
+
Cancel
|
|
126
|
+
</Button>
|
|
127
|
+
)}
|
|
128
|
+
<SubmitButton text="Submit" loadingText="Loading..." variant="contained" />
|
|
129
|
+
</Stack>
|
|
130
|
+
</Grid>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
3. **Messages and Alerts**:
|
|
134
|
+
|
|
135
|
+
- Use Snackbar for all notifications instead of inline Alerts
|
|
136
|
+
- Remove StrapiErrors component as errors are shown in Snackbar
|
|
137
|
+
- Success messages automatically close the form and revalidate data
|
|
138
|
+
|
|
102
139
|
### Example Usage
|
|
103
140
|
|
|
104
141
|
```typescript
|
|
@@ -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 n,__assign as t,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import l,{useState as i,useEffect as o}from"react";import c from"@mui/material/
|
|
7
|
+
import{__read as e,__spreadArray as n,__assign as t,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import l,{useState as i,useEffect as o}from"react";import c from"@mui/material/Box";import s from"@mui/material/Stack";import m from"@mui/material/Button";import u from"@mui/material/TextField";import d from"@mui/material/Typography";import{SubmitButton as v}from"../../SubmitButton.js";import{useFormState as _}from"react-dom";import{createInvoiceAction as f}from"../../../data/actions/e-commerce/invoices/createInvoiceAction.js";import p from"@mui/material/Grid";import{AddressFields as b}from"../../common/Address.js";import E from"@mui/material/Divider";import{BusinessCredentialsFields as g}from"../customer/BusinessCredentials.js";import{CustomerSelector as y}from"../customer/CustomerSelector.js";import{getSingleCustomer as h}from"../../../data/loaders/e-commerce/getSingleCustomer.js";import C from"@mui/material/Checkbox";import{InvoiceItemFields as x}from"./InvoiceItemFields.js";import{InvoicePDFViewer as k}from"./InvoicePDF.js";import{getPublicInformation as j}from"../../../data/loaders/public-information/getPublicInformation.js";import I from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as w}from"../../../context/common/SnackbarContext.js";var A={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function N(N){var F=this,B=N.customerLabels,R=N.revalidateCallback,S=N.handleClose,T=N.sx,D=e(_(f,A),2),L=D[0],P=D[1],M=w().handleAddMessage,U=e(i(!1),2),z=U[0],G=U[1],V=e(i(!1),2),q=V[0],H=V[1],J=e(i(null),2),K=J[0],O=J[1],Q=e(i(null),2),W=Q[0],X=Q[1];o((function(){(null==L?void 0:L.message)&&(M({message:L.message,severity:L.severity||"error"}),"success"===L.severity&&(R&&R(),S&&S()))}),[null==L?void 0:L.message]),o((function(){(null==L?void 0:L.strapiErrors)&&M({message:L.strapiErrors.message||"Error creating invoice",severity:L.severity||"error"})}),[null==L?void 0:L.strapiErrors]);return o((function(){!function(){r(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,j()];case 1:return e=n.sent(),X((function(n){return t(t({},n),{seller_phone:null==e?void 0:e.phone,seller_email:null==e?void 0:e.email,seller_company_address:null==e?void 0:e.address,seller_business_credentials:null==e?void 0:e.business_credentials})})),[2]}}))}))}()}),[]),l.createElement(c,{sx:n([],e(Array.isArray(T)?T:[T]),!1)},l.createElement("form",{action:P},l.createElement(p,{container:!0,spacing:2},l.createElement(p,{item:!0,xs:12},l.createElement(s,{spacing:2},l.createElement(d,{variant:"h3",component:"h1"},"Create Invoice"),l.createElement(d,{variant:"body2"},"Create a new invoice by selecting a customer or filling in the details manually"))),l.createElement(p,{item:!0,xs:12},l.createElement(d,{variant:"h6"},"Choose a user"),l.createElement(y,{customerLabels:B,onChangeCallback:function(e){return r(F,void 0,void 0,(function(){var n;return a(this,(function(t){switch(t.label){case 0:return 0===e.length?(O(null),[2]):[4,h(e[0])];case 1:return n=t.sent(),O(n),[2]}}))}))}}),l.createElement(d,{variant:"h6"},"Set user details manually"),l.createElement(s,{spacing:2,direction:"row"},l.createElement(u,{name:"buyer_first_name",label:"First Name",value:(null==K?void 0:K.first_name)||(null==W?void 0:W.buyer_first_name)||"",onChange:function(e){X((function(n){return t(t({},n),{buyer_first_name:e.target.value})}))},disabled:null!==K}),l.createElement(u,{name:"buyer_last_name",label:"Last Name",value:(null==K?void 0:K.last_name)||(null==W?void 0:W.buyer_last_name)||"",onChange:function(e){X((function(n){return t(t({},n),{buyer_last_name:e.target.value})}))},disabled:null!==K})),l.createElement(d,{variant:"body2"}),l.createElement(d,{variant:"h6"},"Company Address"),l.createElement(E,null),l.createElement(b,{data:null==K?void 0:K.company_address,componentName:"buyer_company_address",componentReference:"common.address",onChangeCallback:function(e){X((function(n){return t(t({},n),{buyer_company_address:e})}))},disabled:null!==K}),l.createElement(d,{variant:"h6"},"Delivery Address"),l.createElement(E,null),null!==K?l.createElement(l.Fragment,null,null===K.delivery_address?l.createElement(d,{variant:"body2"},"No delivery address on file"):l.createElement(b,{data:null==K?void 0:K.delivery_address,componentName:"buyer_delivery_address",componentReference:"common.address",onChangeCallback:function(e){X((function(n){return t(t({},n),{buyer_delivery_address:e})}))},disabled:null!==K})):l.createElement(l.Fragment,null,l.createElement(s,{direction:"row",spacing:2,alignItems:"center"},l.createElement(C,{value:q,checked:q,onChange:function(){return H(!q)}}),l.createElement(d,null,"Use a different address for delivery")),q&&l.createElement(b,{componentName:"buyer_delivery_address",componentReference:"common.address",onChangeCallback:function(e){X((function(n){return t(t({},n),{buyer_delivery_address:e})}))}})),l.createElement(d,{variant:"h6"},"Billing Address"),l.createElement(E,null),null!==K?l.createElement(l.Fragment,null,null===K.billing_address?l.createElement(d,{variant:"body2"},"No billing address on file"):l.createElement(b,{data:null==K?void 0:K.billing_address,componentName:"buyer_billing_address",componentReference:"common.address",onChangeCallback:function(e){X((function(n){return t(t({},n),{buyer_billing_address:e})}))},disabled:null!==K})):l.createElement(l.Fragment,null,l.createElement(s,{direction:"row",spacing:2,alignItems:"center"},l.createElement(C,{value:z,checked:z,onChange:function(){return G(!z)}}),l.createElement(d,null,"Use a different address for billing")),z&&l.createElement(b,{componentName:"buyer_billing_address",componentReference:"common.address",onChangeCallback:function(e){X((function(n){return t(t({},n),{buyer_billing_address:e})}))}})),l.createElement(d,{variant:"h6"},"Bussiness Credentials"),l.createElement(E,null),l.createElement(g,{data:null==K?void 0:K.business_credentials,componentName:"buyer_business_credentials",componentReference:"business.credentials",onChangeCallback:function(e){X((function(n){return t(t({},n),{buyer_business_credentials:e})}))},disabled:null!==K})),l.createElement(p,{item:!0,xs:12},l.createElement(d,{variant:"h6"},"Invoice Items"),l.createElement(x,{onChangeCallback:function(e){X((function(n){return n?t(t({},n),{items:e.map((function(e){return t(t({},e),{product:"product"in e?e.product:void 0,item_description:"item_description"in e?e.item_description:void 0,price_excl_vat:"price_excl_vat"in e?e.price_excl_vat:0,vat_rate:"vat_rate"in e?e.vat_rate:0,vat:"vat"in e?e.vat:0,price_incl_vat:"price_incl_vat"in e?e.price_incl_vat:0})})),VAT_total:e.reduce((function(e,n){return e+n.price_excl_vat*(n.vat_rate/100)}),0),total_excl_vat:e.reduce((function(e,n){return e+n.price_excl_vat}),0),total_incl_vat:e.reduce((function(e,n){return e+n.price_excl_vat+n.price_excl_vat*(n.vat_rate/100)}),0)}):null}))}})),l.createElement(p,{item:!0,xs:12},l.createElement(d,{variant:"h6"},"Add a Comment"),l.createElement(I,{name:"comments",label:"Comments",onChangeCallback:function(e){return X((function(n){return n?t(t({},n),{comments:e}):null}))}})),l.createElement(p,{item:!0,xs:12},l.createElement(d,{variant:"h6"},"Preview the Invoice"),null!==W&&l.createElement(k,{invoice:W})),l.createElement(p,{item:!0,xs:12},l.createElement(s,{direction:"row",justifyContent:"space-between"},S&&l.createElement(m,{onClick:S,variant:"outlined"},"Cancel"),l.createElement(v,{text:"Create Invoice",loadingText:"Creating...",variant:"contained"}))))))}export{N as CreateInvoiceForm};
|
|
@@ -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 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([
|
|
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 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{createOpoAction as i}from"../../../data/actions/e-commerce/opo/createOpoAction.js";import{SubmitButton as m}from"../../SubmitButton.js";import{CustomerSelector as s}from"../customer/CustomerSelector.js";import{OPOItemFields as c}from"./OPOItemFields.js";import{useSnackbar as l}from"../../../context/common/SnackbarContext.js";import u from"@mui/material/Typography";import d from"@mui/material/Grid";import p from"@mui/material/Box";import f from"@mui/material/TextField";import E 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,k=e(a(!1),2),A=k[0],I=k[1],L=e(n(i,g),2),O=L[0],S=L[1],B=l().handleAddMessage;return o((function(){(null==O?void 0:O.message)&&(B({message:O.message,severity:O.severity||"error"}),"success"===O.severity&&(C&&C(),b&&b()))}),[null==O?void 0:O.message]),o((function(){(null==O?void 0:O.strapiErrors)&&B({message:O.strapiErrors.message||"Error creating order",severity:O.severity||"error"})}),[null==O?void 0:O.strapiErrors]),t.createElement(p,{sx:r([],e(Array.isArray(x)?x:[x]),!1)},t.createElement("form",{action:S},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 order"))),t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h6"},"Choose a customer"),t.createElement(s,{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(f,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}}))),t.createElement(d,{item:!0,xs:12},t.createElement(u,{variant:"h6"},"Choose products for this order"),t.createElement(c,{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 order? Creating a order this way will not create a shipping label nor will it invoke a payment. It does however create an invoice which you can find under invoices"),t.createElement(h,{direction:"row",spacing:1,alignItems:"center"},t.createElement(E,{value:A,checked:A,onChange:function(){return I(!A)}}),A&&t.createElement(u,{color:"primary"},"I am sure I want to confirm this order")),t.createElement("input",{name:"status",type:"hidden",value:A?"ordered":"placed"})),t.createElement(d,{item:!0,xs:12},t.createElement(h,{direction:"row",justifyContent:"space-between"},b&&t.createElement(v,{onClick:b,variant:"outlined"},"Cancel"),t.createElement(m,{text:"Confirm",loadingText:"Loading...",variant:"contained"}))))))}export{y as default};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import
|
|
6
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useState as r,useEffect as n}from"react";import{useFormState as i}from"react-dom";import{updateOpoAction as o}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as l}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import c from"./OpoItemUpdater.js";import s from"./OpoItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as u}from"../../SubmitButton.js";import v from"@mui/material/Alert";import E from"@mui/material/Dialog";import f from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import g from"@mui/material/DialogTitle";import h from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import _ from"@mui/material/Paper";import w from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as D}from"../../../data/services/common/confirmation-service.js";import{useSnackbar as j}from"../../../context/common/SnackbarContext.js";var O={zodErrors:null,strapiErrors:null,message:null};function q(e){var t=e.open,r=e.handleClose,n=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return a.createElement(E,{open:t},a.createElement(g,null,"Confirm Order"),a.createElement(y,null,a.createElement(w,{spacing:2},a.createElement(h,null,"Are you sure you want to confirm this order?"),a.createElement(h,null,"Current status: ",i))),a.createElement(f,null,a.createElement(b,{variant:"contained",onClick:function(e){D("opos",[n]),o&&o()}},"Confirm"),a.createElement(b,{variant:"contained",onClick:r},"Cancel")))}function N(E){var f,y,g,D,N,A=E.opo,I=E.sx,S=E.revalidateCallback,B=E.handleClose,F=E.role,P=e(i(o,O),2),M=P[0],T=P[1],U=j().handleAddMessage,z=e(r(A.opo_items.data?A.opo_items.data:[]),2),G=z[0],H=z[1],J=e(r(!1),2),L=J[0],Q=J[1],R=function(a,r,n){var i=t([],e(G),!1),o=i.findIndex((function(e){return e.id===r}));i[o][n]=a,H(i)};return n((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&H(A.opo_items.data)}),[A]),n((function(){(null==M?void 0:M.message)&&(U({message:M.message,severity:M.severity||"error"}),"success"===M.severity&&(S&&S(),B&&B()))}),[null==M?void 0:M.message]),n((function(){(null==M?void 0:M.strapiErrors)&&U({message:M.strapiErrors.message||"Error updating OPO",severity:M.severity||"error"})}),[null==M?void 0:M.strapiErrors]),a.createElement(C,{sx:t([],e(Array.isArray(I)?I:[I]),!1)},a.createElement(x,{container:!0,spacing:2},a.createElement(x,{item:!0,xs:12},a.createElement(w,{spacing:2},a.createElement(w,{direction:"row",spacing:2,justifyContent:"space-between"},a.createElement(w,{spacing:2},a.createElement(h,{variant:"h3",component:"h1"},"Manage Outbound Purchase Order"),a.createElement(h,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),a.createElement(p,{content:"",related:[{id:A.id,__type:"api::e-commerce.opo"}],revalidateCallback:S})),a.createElement(k,null))),a.createElement(x,{item:!0,xs:6},a.createElement(w,{spacing:1},a.createElement(h,{variant:"h5"},"Details"),a.createElement(w,{direction:"row",spacing:2},a.createElement(h,{variant:"body1",width:"250px"},"Purchase Order Number"),a.createElement(h,{variant:"body2"},A.opo_number)),a.createElement(w,{direction:"row",spacing:2},a.createElement(h,{variant:"body1",width:"250px"},"Custom reference"),a.createElement(h,{variant:"body2"},A.customer_reference)),a.createElement(w,{direction:"row",spacing:2},a.createElement(h,{variant:"body1",width:"250px"},"Order Date"),a.createElement(h,{variant:"body2"},A.order_date)),a.createElement(w,{direction:"row",spacing:2},a.createElement(h,{variant:"body1",width:"250px"},"Customer"),a.createElement(h,{variant:"body2"},null===(y=null===(f=A.customer)||void 0===f?void 0:f.business_credentials)||void 0===y?void 0:y.company_name)),a.createElement(w,{direction:"row",spacing:2},a.createElement(h,{variant:"body1",width:"250px"},"Order Status"),a.createElement(h,{variant:"body2",width:"250px"},A.status)),("placed"===A.status||"external_shipping_process"===A.status)&&"enduser"===F&&a.createElement(a.Fragment,null,a.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Q(!0)}},"Confirm order"),a.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),a.createElement(q,{open:L,handleClose:function(){return Q(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:S})))),a.createElement(x,{item:!0,xs:12},a.createElement(w,{spacing:2},a.createElement(h,{variant:"h5"},"Documents"),a.createElement(_,{sx:{p:2}},a.createElement(w,{spacing:1},A.delivery_note?a.createElement(a.Fragment,null,a.createElement(h,{variant:"h6"},"Delivery Note"),a.createElement(h,null,null===(g=A.delivery_note)||void 0===g?void 0:g.name),a.createElement(b,{variant:"contained",onClick:function(){m("api/opos/".concat(A.id),"delivery_note")}},"Download")):a.createElement(a.Fragment,null,a.createElement(h,{variant:"h5"},"Delivery Note"),a.createElement(h,{variant:"body1"},"Here you can upload the the delivery note for this order"),a.createElement(k,null),a.createElement(l,{reference:"api::e-commerce.opo",refID:A.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:S})))))),(null===(N=null===(D=null==A?void 0:A.notes)||void 0===D?void 0:D.data)||void 0===N?void 0:N.length)>0&&a.createElement(x,{item:!0,xs:12},a.createElement(w,{spacing:2},a.createElement(h,{variant:"h5"},"Notes"),a.createElement(d,{notes:A.notes.data}),a.createElement(k,null))),a.createElement(x,{item:!0,xs:12},a.createElement(w,{spacing:1},a.createElement(h,{variant:"h5"},"Items"),"placed"===A.status&&a.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),a.createElement(k,null),a.createElement("form",{action:T},a.createElement("input",{name:"id",type:"hidden",value:A.id}),G&&G.map((function(e,t){var r,n;return console.log("item",e),a.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===A.status?a.createElement(s,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):a.createElement(c,{item:e,index:t,handleUpdateQuantity:R,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,revalidateCallback:S}))})),a.createElement(_,{sx:{p:2}},a.createElement(w,{direction:"row",spacing:2,justifyContent:"space-between"},B&&a.createElement(b,{onClick:B,variant:"outlined"},"Cancel"),a.createElement(u,{text:"Update items",loadingText:"Loading..."}))),a.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity}}))}(G))}))))))}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 n}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as a,useEffect as o}from"react";import{useFormState as i}from"react-dom";import{updateOpoAction as l}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualOpoItemUpdater.js";import s from"./OpoItemDisplay.js";import u from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import{StrapiErrors as v}from"../../StrapiErrors.js";import{SubmitButton as E}from"../../SubmitButton.js";import f from"@mui/material/Alert";import h from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import x from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import C from"@mui/material/Button";import k from"@mui/material/Grid";import _ from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as N}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as O,Checkbox as q,List as A,ListItem as S,TextField as B}from"@mui/material";import T from"@mui/icons-material/Numbers";import P from"@mui/icons-material/CalendarToday";import U from"@mui/icons-material/Business";import F from"@mui/icons-material/Description";import R from"@mui/icons-material/Update";import{OpoStatusIndicator as W}from"./OpoStatusIndicator.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function Y(e){var t=e.open,n=e.handleClose,a=e.orderID,o=e.currentStatus,i=e.revalidateCallback;return r.createElement(h,{open:t},r.createElement(x,null,"Confirm Order"),r.createElement(y,null,r.createElement(I,{spacing:2},r.createElement(b,null,"Are you sure you want to confirm this order?"),r.createElement(b,null,"Current status: ",o))),r.createElement(g,null,r.createElement(C,{variant:"contained",onClick:function(e){j("opos",[a]),i&&i(),n()}},"Yes"),r.createElement(C,{variant:"contained",onClick:n},"No")))}function z(t){var n=t.open,o=t.handleClose,i=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],d=c[1],s=e(a(""),2),u=s[0],p=s[1];return r.createElement("form",null,r.createElement(h,{open:n},r.createElement(x,null,"Cancel Return"),r.createElement(y,null,r.createElement(I,{spacing:2},r.createElement(b,null,"Are you sure you want to cancel this order?"),r.createElement(A,null,r.createElement(S,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(S,null,"Please provide a reason for the cancellation"),r.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(B,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return d(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!u,helperText:u}))),r.createElement(g,null,r.createElement(C,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(N("opos",i,m),l&&l(),o())}},"Yes"),r.createElement(C,{variant:"contained",onClick:o},"No"))))}function G(h){var g,y,x,j,N,A=h.opo,S=h.sx,B=h.revalidateCallback;h.handleClose;var G=h.role,H=e(i(l,M),2),J=H[0],L=H[1],Q=e(a(A.opo_items.data?A.opo_items.data:[]),2),K=Q[0],V=Q[1],X=e(a(!1),2),Z=X[0],$=X[1],ee=e(a(!1),2),te=ee[0],ne=ee[1],re=e(a(["picked","packed","shipped","reports"]),2),ae=re[0],oe=re[1],ie=function(n,r,a){var o=t([],e(K),!1),i=o.findIndex((function(e){return e.id===r}));o[i][a]=n,V(o)},le=function(r,a){var o,i,l,c=t([],e(K),!1),m=c.findIndex((function(e){return e.id===a})),d=(null===(i=null===(o=c[m])||void 0===o?void 0:o.reports)||void 0===i?void 0:i.data)||[],s=t(t([],e(d),!1),[r],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,V(c)},ce=function(n,r){var a,o,i=t([],e(K),!1),l=i.findIndex((function(e){return e.id===n})),c=(null===(o=null===(a=i[l])||void 0===a?void 0:a.reports)||void 0===o?void 0:o.data)||[],m=c.filter((function(e){return"id"in e})),d=c.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(m),!1),e(d),!1);i[l].reports.data=s,V(i)};return o((function(){"Ipo Updated"===(null==J?void 0:J.message)&&B&&B()}),[J]),o((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&V(A.opo_items.data?A.opo_items.data:[])}),[A]),r.createElement(_,{sx:t([{p:2}],e(Array.isArray(S)?S:[S]),!1),component:w},r.createElement(k,{container:!0,spacing:2},r.createElement(k,{item:!0,xs:12},r.createElement(I,{spacing:2},r.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(I,{spacing:2},r.createElement(b,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),r.createElement(b,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),r.createElement(p,{content:"",related:[{id:A.id,__type:"api::e-commerce.opo"}],revalidateCallback:B})),r.createElement(D,null))),r.createElement(k,{item:!0,xs:12},r.createElement(b,{variant:"h5",sx:{py:1}},"Details")),r.createElement(k,{item:!0,xs:6},r.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(I,{spacing:2},r.createElement(I,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(b,{variant:"body1",fontWeight:"medium"},A.opo_number)),r.createElement(I,{direction:"row",spacing:2,alignItems:"center"},r.createElement(F,{color:"primary"}),r.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(b,{variant:"body1",fontWeight:"medium"},A.customer_reference)),r.createElement(I,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(b,{variant:"body1",fontWeight:"medium"},A.order_date)),r.createElement(I,{direction:"row",spacing:2,alignItems:"center"},r.createElement(U,{color:"primary"}),r.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(b,{variant:"body1",fontWeight:"medium"},null===(y=null===(g=A.customer)||void 0===g?void 0:g.business_credentials)||void 0===y?void 0:y.company_name)),r.createElement(I,{direction:"row",spacing:2,alignItems:"center"},r.createElement(R,{color:"primary"}),r.createElement(b,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(W,{status:A.status}))))),"enduser"===G&&r.createElement(k,{item:!0,xs:6},r.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(I,{spacing:2},("placed"===A.status||"external_shipping_process"===A.status)&&r.createElement(r.Fragment,null,r.createElement(C,{variant:"contained",color:"primary",onClick:function(){return $(!0)}},"Confirm order"),r.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(Y,{open:Z,handleClose:function(){return $(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:B})),("placed"===A.status||"ordered"===A.status)&&r.createElement(r.Fragment,null,r.createElement(C,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),r.createElement(z,{open:te,handleClose:function(){return ne(!1)},orderID:A.id,revalidateCallback:B}))))),r.createElement(k,{item:!0,xs:12},r.createElement(I,{spacing:2},r.createElement(b,{variant:"h5"},"Documents"),r.createElement(w,{sx:{p:2}},r.createElement(I,{spacing:1},A.delivery_note?r.createElement(r.Fragment,null,r.createElement(b,{variant:"h6"},"Delivery Note"),r.createElement(b,null,null===(x=A.delivery_note)||void 0===x?void 0:x.name),r.createElement(C,{variant:"contained",onClick:function(){m("api/ipos/".concat(A.id),"delivery_note")}},"Download")):r.createElement(r.Fragment,null,r.createElement(b,{variant:"h5"},"Delivery Note"),r.createElement(b,{variant:"body1"},"Here you can upload the the delivery note for this order"),r.createElement(D,null),r.createElement(c,{reference:"api::e-commerce.opo",refID:A.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:B})))))),(null===(N=null===(j=null==A?void 0:A.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&r.createElement(k,{item:!0,xs:12},r.createElement(I,{spacing:2},r.createElement(b,{variant:"h5"},"Notes"),r.createElement(u,{notes:A.notes.data}),r.createElement(D,null))),r.createElement(k,{item:!0,xs:12},r.createElement(I,{spacing:1},r.createElement(b,{variant:"h5"},"Items"),r.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},r.createElement(b,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(O,{key:n,control:r.createElement(q,{checked:ae.includes(n),onChange:function(r){r.target.checked?oe(t(t([],e(ae),!1),[n],!1)):oe(ae.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===A.status&&r.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(D,null),r.createElement("form",{action:L},r.createElement("input",{name:"id",type:"hidden",value:A.id}),K&&K.map((function(e,t){var n,a;return r.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===A.status||"external_shipping_process"===A.status||"done"===A.status||"cancelled"===A.status?r.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(d,{item:e,index:t,handleUpdateQuantity:ie,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:B,showing:ae}))})),r.createElement(w,{sx:{p:2}},r.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(E,{text:"Update items",loadingText:"Loading..."}),r.createElement(v,{error:null==J?void 0:J.strapiErrors}),(null==J?void 0:J.message)&&r.createElement(f,{severity:"error"},null==J?void 0:J.message))),r.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(K))}))))))}export{G as default};
|
|
6
|
+
import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as a,useEffect as i}from"react";import{useFormState as o}from"react-dom";import{updateOpoAction as l}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualOpoItemUpdater.js";import s from"./OpoItemDisplay.js";import u from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import v from"@mui/material/Alert";import E from"@mui/material/Dialog";import f from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import g from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import x from"@mui/material/Button";import b from"@mui/material/Grid";import C from"@mui/material/Box";import k from"@mui/material/Paper";import _ from"@mui/material/Stack";import w from"@mui/material/Divider";import{confirmationService as I}from"../../../data/services/common/confirmation-service.js";import{cancellationService as D}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as j,Checkbox as N,List as O,ListItem as q,TextField as A}from"@mui/material";import B from"@mui/icons-material/Numbers";import S from"@mui/icons-material/CalendarToday";import T from"@mui/icons-material/Business";import P from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{OpoStatusIndicator as F}from"./OpoStatusIndicator.js";import{SubmitButton as R}from"../../SubmitButton.js";var W={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M(e){var t=e.open,n=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return r.createElement(E,{open:t},r.createElement(g,null,"Confirm Order"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to confirm this order?"),r.createElement(y,null,"Current status: ",i))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){I("opos",[a]),o&&o(),n()}},"Yes"),r.createElement(x,{variant:"contained",onClick:n},"No")))}function Y(t){var n=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],d=c[1],s=e(a(""),2),u=s[0],p=s[1];return r.createElement("form",null,r.createElement(E,{open:n},r.createElement(g,null,"Cancel Return"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(O,null,r.createElement(q,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(q,null,"Please provide a reason for the cancellation"),r.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(A,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return d(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!u,helperText:u}))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(D("opos",o,m),l&&l(),i())}},"Yes"),r.createElement(x,{variant:"contained",onClick:i},"No"))))}function z(E){var f,h,g,I,D,O=E.opo,q=E.sx,A=E.revalidateCallback;E.handleClose;var z=E.role,G=l.bind(O.id),H=e(o(G,W),2),J=H[0],L=H[1],Q=e(a(O.opo_items.data?O.opo_items.data:[]),2),K=Q[0],V=Q[1],X=e(a(!1),2),Z=X[0],$=X[1],ee=e(a(!1),2),te=ee[0],ne=ee[1],re=e(a(["picked","packed","shipped","reports"]),2),ae=re[0],ie=re[1],oe=function(n,r,a){var i=t([],e(K),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,V(i)},le=function(r,a){var i,o,l,c=t([],e(K),!1),m=c.findIndex((function(e){return e.id===a})),d=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],s=t(t([],e(d),!1),[r],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,V(c)},ce=function(n,r){var a,i,o=t([],e(K),!1),l=o.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),d=c.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(m),!1),e(d),!1);o[l].reports.data=s,V(o)};return i((function(){"Ipo Updated"===(null==J?void 0:J.message)&&A&&A()}),[J]),i((function(){var e;(null===(e=O.opo_items)||void 0===e?void 0:e.data)&&V(O.opo_items.data?O.opo_items.data:[])}),[O]),r.createElement(C,{sx:t([{p:2}],e(Array.isArray(q)?q:[q]),!1),component:k},r.createElement(b,{container:!0,spacing:2},r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),r.createElement(y,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),r.createElement(p,{content:"",related:[{id:O.id,__type:"api::e-commerce.opo"}],revalidateCallback:A})),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(y,{variant:"h5",sx:{py:1}},"Details")),r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(h=null===(f=O.customer)||void 0===f?void 0:f.business_credentials)||void 0===h?void 0:h.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(U,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(F,{status:O.status}))))),"enduser"===z&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===O.status||"external_shipping_process"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return $(!0)}},"Confirm order"),r.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(M,{open:Z,handleClose:function(){return $(!1)},orderID:O.id,currentStatus:O.status,revalidateCallback:A})),("placed"===O.status||"ordered"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),r.createElement(Y,{open:te,handleClose:function(){return ne(!1)},orderID:O.id,revalidateCallback:A}))))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Documents"),r.createElement(k,{sx:{p:2}},r.createElement(_,{spacing:1},O.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(g=O.delivery_note)||void 0===g?void 0:g.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(O.id),"delivery_note")}},"Download")):r.createElement(r.Fragment,null,r.createElement(y,{variant:"h5"},"Delivery Note"),r.createElement(y,{variant:"body1"},"Here you can upload the the delivery note for this order"),r.createElement(w,null),r.createElement(c,{reference:"api::e-commerce.opo",refID:O.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:A})))))),(null===(D=null===(I=null==O?void 0:O.notes)||void 0===I?void 0:I.data)||void 0===D?void 0:D.length)>0&&r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Notes"),r.createElement(u,{notes:O.notes.data}),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:1},r.createElement(y,{variant:"h5"},"Items"),r.createElement(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:k,p:1},r.createElement(y,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(j,{key:n,control:r.createElement(N,{checked:ae.includes(n),onChange:function(r){r.target.checked?ie(t(t([],e(ae),!1),[n],!1)):ie(ae.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===O.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:L},r.createElement("input",{name:"id",type:"hidden",value:O.id}),r.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(K))}),K&&K.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===O.status||"external_shipping_process"===O.status||"done"===O.status||"cancelled"===O.status?r.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(d,{item:e,index:t,handleUpdateQuantity:oe,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:A,showing:ae}))})),r.createElement(k,{sx:{p:2}},r.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(R,{text:"Update items",loadingText:"Loading..."}))))))))}export{z as default};
|
|
@@ -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,useState as i}from"react";import{useFormState as a}from"react-dom";import l from"@mui/material/
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{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/TextField";import c from"@mui/material/Typography";import s from"@mui/material/Button";import d from"@mui/material/Grid";import{SubmitButton as u}from"../../SubmitButton.js";import{createProductAction as p}from"../../../data/actions/e-commerce/product/createProductAction.js";import{MediaLibraryDialog as E}from"../../common/media/MediaLibraryDialog.js";import{StrapiImage as g}from"../../StrapiImage.js";import{PriceFields as f}from"./PriceFields.js";import h from"../categories/CategorySelectorV2.js";import{DimensionsFields as v}from"../../common/Dimensions.js";import x from"../../logistics/vendor/VendorSelector.js";import y from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as b}from"../../../context/common/SnackbarContext.js";var C={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null},j=function(j){var w=j.vendorArr,k=j.categories,S=j.revalidateCallback,A=j.handleClose,N=j.sx,P=e(a(p,C),2),T=P[0],V=P[1],_=b().handleAddMessage;n((function(){(null==T?void 0:T.message)&&(_({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(S&&S(),A&&A()))}),[null==T?void 0:T.message]),n((function(){(null==T?void 0:T.strapiErrors)&&_({message:T.strapiErrors.message||"Error adding product",severity:T.severity||"error"})}),[null==T?void 0:T.strapiErrors]);var D=e(i(null),2),I=D[0],B=D[1],M=e(i(null),2),O=M[0],F=M[1],G=e(i([]),2),R=G[0],z=G[1];return r.createElement(l,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},r.createElement("form",{action:V},r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12},r.createElement(c,{variant:"h3",component:"h1"},"Add New Product")),r.createElement(d,{item:!0,xs:12},r.createElement(m,{spacing:2},r.createElement(o,{id:"title",name:"title",label:"Title"}),r.createElement(y,{name:"description",label:"Description"}),r.createElement(o,{id:"external_product_number",name:"external_product_number",label:"External Product Number"}))),r.createElement(d,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:(null==O?void 0:O.id)||""}),r.createElement(g,{id:(null==O?void 0:O.id)||"",url:(null==O?void 0:O.url)||"",alternativeText:"product image",width:(null==O?void 0:O.width)&&(null==O?void 0:O.height)?O.width/O.height*200:200,height:200}),r.createElement(s,{onClick:function(){return B("image")}},"open media library"),r.createElement(E,{open:"image"===I,handleClose:function(){return B(null)},handleCancel:function(){F(null),B(null)},handleSelect:function(e){F(e)},selected:O?[O]:[]})),r.createElement(d,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(R.map((function(e){return e.id})))}),r.createElement(m,{direction:"row",spacing:2},R.map((function(e){return r.createElement(g,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:e.width/e.height*100,height:100})}))),r.createElement(s,{onClick:function(){return B("gallery")}},"open media library"),r.createElement(E,{open:"gallery"===I,handleClose:function(){return B(null)},handleCancel:function(){z([]),B(null)},handleSelect:function(r){if(R.indexOf(r)>-1){var n=t([],e(R),!1);n.splice(R.indexOf(r),1),z(n)}else R.length>=5?z(t([],e(R),!1)):z(t(t([],e(R),!1),[r],!1))},selected:R})),r.createElement(d,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Price"),r.createElement(f,{componentName:"price",componentReference:"e-commerce-elements.price"})),r.createElement(d,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Categories"),r.createElement(h,{categories:k,currentValue:[]})),r.createElement(d,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Dimensions"),r.createElement(v,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions"})),r.createElement(d,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Vendors"),r.createElement(x,{vendorNames:w,currentValue:null})),r.createElement(d,{item:!0,xs:12},r.createElement(m,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{py:2}},A&&r.createElement(s,{onClick:A,variant:"outlined"},"Cancel"),r.createElement(u,{text:"create new product",loadingText:"loading"}))))))};export{j 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
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as n,useState as i}from"react";import a from"@mui/material/Box";import l from"@mui/material/Stack";import o from"@mui/material/TextField";import m from"@mui/material/Typography";import{SubmitButton as c}from"../../SubmitButton.js";import{useFormState as d}from"react-dom";import{updateProductAction as s}from"../../../data/actions/e-commerce/product/updateProductAction.js";import{MediaLibraryDialog as u}from"../../common/media/MediaLibraryDialog.js";import p from"@mui/material/Button";import E from"@mui/material/Grid";import{StrapiImage as g}from"../../StrapiImage.js";import{PriceFields as v}from"./PriceFields.js";import f from"../categories/CategorySelectorV2.js";import{DimensionsFields as h}from"../../common/Dimensions.js";import y from"../../logistics/vendor/VendorSelector.js";import x from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as b}from"../../../context/common/SnackbarContext.js";var C={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null};function j(j){var w,k,S=j.data,V=j.vendorArr,_=j.categoriesArray,A=j.revalidateCallback,P=j.handleClose,T=j.sx,I=S.id,N=S.title,D=S.description,B=S.external_product_number,M=S.image,F=S.gallery,G=S.price,R=S.dimensions,z=S.categories,J=S.vendors,L=(null==F?void 0:F.data)||[],O=(null==z?void 0:z.data)||[],q=b().handleAddMessage,H=e(d(s,C),2),K=H[0],Q=H[1];n((function(){(null==K?void 0:K.message)&&(q({message:K.message,severity:K.severity||"error"}),"success"===K.severity&&(A&&A(),P&&P()))}),[null==K?void 0:K.message]),n((function(){(null==K?void 0:K.strapiErrors)&&q({message:K.strapiErrors.message||"Error updating product",severity:K.severity||"error"})}),[null==K?void 0:K.strapiErrors]);var U=e(i(null),2),W=U[0],X=U[1],Y=e(i(M||null),2),Z=Y[0],$=Y[1],ee=e(i(t([],e(L),!1)),2),te=ee[0],re=ee[1];return r.createElement(a,{sx:t([],e(Array.isArray(T)?T:[T]),!1)},r.createElement("form",{action:Q},I&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:I}),r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(m,{variant:"h3",component:"h1"},"Edit Product")),r.createElement(E,{item:!0,xs:12},r.createElement(l,{spacing:2},r.createElement(o,{id:"title",name:"title",label:"Title",defaultValue:N}),r.createElement(x,{name:"description",label:"Description",defaultValue:D}),r.createElement(o,{id:"external_product_number",name:"external_product_number",label:"External Product Number",defaultValue:B}))),r.createElement(E,{item:!0,xs:6},r.createElement(m,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:null==Z?void 0:Z.id}),r.createElement(g,{id:(null==Z?void 0:Z.id)||"",url:(null==Z?void 0:Z.url)||"",alternativeText:"product image",width:(null==Z?void 0:Z.width)&&(null==Z?void 0:Z.height)?Z.width/Z.height*200:200,height:200}),r.createElement(p,{onClick:function(){return X("image")}},"open media library"),r.createElement(u,{open:"image"===W,handleClose:function(){return X(null)},handleCancel:function(){$(null),X(null)},handleSelect:function(e){$(e)},selected:Z?[Z]:[]})),r.createElement(E,{item:!0,xs:6},r.createElement(m,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(te.map((function(e){return e.id})))}),r.createElement(l,{direction:"row",spacing:2},te.map((function(e){return r.createElement(g,{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(p,{onClick:function(){return X("gallery")}},"open media library"),r.createElement(u,{open:"gallery"===W,handleClose:function(){return X(null)},handleCancel:function(){re([]),X(null)},handleSelect:function(r){var n=te.findIndex((function(e){return e.id===r.id}));if(n>-1){var i=t([],e(te),!1);i.splice(n,1),re(i)}else te.length>=5?re(t([],e(te),!1)):re(t(t([],e(te),!1),[r],!1))},selected:te})),r.createElement(E,{item:!0,xs:12},r.createElement(m,{variant:"h6"},"Price"),r.createElement(v,{componentName:"price",componentReference:"e-commerce-elements.price",data:G})),r.createElement(E,{item:!0,xs:12},r.createElement(m,{variant:"h6"},"Categories"),r.createElement(f,{categories:_,currentValue:t([],e(O.map((function(e){return e.id}))),!1)})),r.createElement(E,{item:!0,xs:12},r.createElement(m,{variant:"h6"},"Dimensions"),r.createElement(h,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions",data:R})),r.createElement(E,{item:!0,xs:12},r.createElement(m,{variant:"h6"},"Vendors"),r.createElement(y,{vendorNames:V,currentValue:null===(k=null===(w=J.data)||void 0===w?void 0:w[0])||void 0===k?void 0:k.id})),r.createElement(E,{item:!0,xs:12},r.createElement(l,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{py:1}},P&&r.createElement(p,{onClick:P,variant:"outlined"},"Cancel"),r.createElement(c,{text:"update product",loadingText:"loading"}))))))}export{j as EditProductForm};
|