umwd-components 0.1.653 → 0.1.655

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.
Files changed (24) hide show
  1. package/.ai/{patterns.md → form-patterns.md} +39 -2
  2. package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
  3. package/dist/src/components/e-commerce/invoice/CreateInvoiceForm.js +1 -1
  4. package/dist/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
  5. package/dist/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
  6. package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  7. package/dist/src/components/e-commerce/products/AddProductForm.js +1 -1
  8. package/dist/src/components/e-commerce/products/EditProductForm.js +1 -1
  9. package/dist/src/components/e-commerce/products/EditStockForm.js +1 -1
  10. package/dist/tsconfig.build.tsbuildinfo +1 -1
  11. package/dist/types/components/e-commerce/invoice/CreateInvoiceForm.d.ts +2 -1
  12. package/dist/types/components/e-commerce/products/AddProductForm.d.ts +1 -1
  13. package/dist/types/components/e-commerce/products/EditProductForm.d.ts +2 -1
  14. package/dist/types/components/e-commerce/products/EditStockForm.d.ts +2 -1
  15. package/package.json +1 -1
  16. package/src/components/e-commerce/categories/CreateCategoryForm.tsx +13 -12
  17. package/src/components/e-commerce/categories/EditCategoryForm.tsx +13 -20
  18. package/src/components/e-commerce/invoice/CreateInvoiceForm.tsx +51 -49
  19. package/src/components/e-commerce/opo/CreateOpoForm.tsx +21 -8
  20. package/src/components/e-commerce/opo/ManageOpoForm.tsx +11 -6
  21. package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +12 -13
  22. package/src/components/e-commerce/products/AddProductForm.tsx +21 -18
  23. package/src/components/e-commerce/products/EditProductForm.tsx +23 -19
  24. package/src/components/e-commerce/products/EditStockForm.tsx +31 -31
@@ -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 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};
7
+ import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as a}from"react";import i from"@mui/material/Box";import o from"@mui/material/Stack";import m from"@mui/material/TextField";import n from"@mui/material/Typography";import{SubmitButton as l}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{updateCategoryAction as c}from"../../../data/actions/e-commerce/categories/updateCategoryAction.js";import d from"@mui/material/Grid";import u from"../products/ProductSelector.js";import p from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as f}from"../../../context/common/SnackbarContext.js";import{Button as E}from"@mui/material";var v={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function g(g){var y=g.data,x=g.revalidateCallback,b=g.handleClose,j=g.productNamesArray,C=g.sx,h=y.id,k=y.title,A=y.description;y.slug,y.is_archive;var w=y.products,S=(null==w?void 0:w.data)||[],T=e(s(c,v),2),V=T[0],B=T[1],M=f().handleAddMessage;return a((function(){(null==V?void 0:V.message)&&(M({message:V.message,severity:V.severity||"error"}),"success"===V.severity&&(x&&x(),b&&b()))}),[null==V?void 0:V.message]),a((function(){(null==V?void 0:V.strapiErrors)&&M({message:V.strapiErrors.message||"Error updating category",severity:V.severity||"error"})}),[null==V?void 0:V.strapiErrors]),r.createElement(i,{sx:t([],e(Array.isArray(C)?C:[C]),!1)},r.createElement("form",{action:B},h&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:h}),r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(m,{id:"title",name:"title",label:"Title",defaultValue:k}),r.createElement(p,{name:"description",label:"Description",defaultValue:A}))),r.createElement(d,{item:!0,xs:12},r.createElement(n,{variant:"h6"},"Products"),r.createElement(u,{productNames:j,currentValue:t([],e(S.map((function(e){return e.id}))),!1)}))),r.createElement(d,{item:!0,xs:12},r.createElement(o,{direction:"row",justifyContent:"space-between"},b&&r.createElement(E,{onClick:b,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Update category",loadingText:"Loading...",variant:"contained"})))))}export{g 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/Paper";import m from"@mui/material/Box";import s from"@mui/material/Stack";import u from"@mui/material/Alert";import d from"@mui/material/TextField";import v from"@mui/material/Typography";import{SubmitButton as _}from"../../SubmitButton.js";import{useFormState as f}from"react-dom";import{StrapiErrors as p}from"../../StrapiErrors.js";import{createInvoiceAction as b}from"../../../data/actions/e-commerce/invoices/createInvoiceAction.js";import E from"@mui/material/Grid";import{AddressFields as g}from"../../common/Address.js";import y from"@mui/material/Divider";import{BusinessCredentialsFields as h}from"../customer/BusinessCredentials.js";import{CustomerSelector as C}from"../customer/CustomerSelector.js";import{getSingleCustomer as x}from"../../../data/loaders/e-commerce/getSingleCustomer.js";import k from"@mui/material/Checkbox";import{InvoiceItemFields as I}from"./InvoiceItemFields.js";import{InvoicePDFViewer as j}from"./InvoicePDF.js";import{getPublicInformation as A}from"../../../data/loaders/public-information/getPublicInformation.js";import N from"../../common/markdown/MarkdownEditor.js";var w={zodErrors:null,strapiErrors:null,data:null,message:null};function F(F){var R=this,S=F.customerLabels,B=F.revalidateCallback,P=F.sx,T=e(f(b,w),2),D=T[0],L=T[1],U=e(i(!1),2),z=U[0],G=U[1],M=e(i(!1),2),V=M[0],q=M[1],H=e(i(null),2),J=H[0],K=H[1],O=e(i(null),2),Q=O[0],W=O[1];return o((function(){(null==D?void 0:D.data)&&B&&B()}),[D.data]),o((function(){!function(){r(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,A()];case 1:return e=n.sent(),W((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(m,{sx:n([{p:2}],e(Array.isArray(P)?P:[P]),!1),component:c},l.createElement("form",{action:L},l.createElement(E,{container:!0,spacing:2},l.createElement(E,{item:!0,xs:12},l.createElement(v,{variant:"h6"},"Create Invoice"),l.createElement(v,{variant:"body2"},"Information on creating a invoice")),l.createElement(E,{item:!0,xs:12},l.createElement(v,{variant:"h6"},"Choose a user"),l.createElement(C,{customerLabels:S,onChangeCallback:function(e){return r(R,void 0,void 0,(function(){var n;return a(this,(function(t){switch(t.label){case 0:return 0===e.length?(K(null),[2]):[4,x(e[0])];case 1:return n=t.sent(),K(n),[2]}}))}))}}),l.createElement(v,{variant:"h6"},"Set user details manually"),l.createElement(s,{spacing:2,direction:"row"},l.createElement(d,{name:"buyer_first_name",label:"First Name",value:(null==J?void 0:J.first_name)||(null==Q?void 0:Q.buyer_first_name)||"",onChange:function(e){W((function(n){return t(t({},n),{buyer_first_name:e.target.value})}))},disabled:null!==J}),l.createElement(d,{name:"buyer_last_name",label:"Last Name",value:(null==J?void 0:J.last_name)||(null==Q?void 0:Q.buyer_last_name)||"",onChange:function(e){W((function(n){return t(t({},n),{buyer_last_name:e.target.value})}))},disabled:null!==J})),l.createElement(v,{variant:"body2"}),l.createElement(v,{variant:"h6"},"Company Address"),l.createElement(y,null),l.createElement(g,{data:null==J?void 0:J.company_address,componentName:"buyer_company_address",componentReference:"common.address",onChangeCallback:function(e){W((function(n){return t(t({},n),{buyer_company_address:e})}))},disabled:null!==J}),l.createElement(v,{variant:"h6"},"Delivery Address"),l.createElement(y,null),null!==J?l.createElement(l.Fragment,null,null===J.delivery_address?l.createElement(v,{variant:"body2"},"No delivery address on file"):l.createElement(g,{data:null==J?void 0:J.delivery_address,componentName:"buyer_delivery_address",componentReference:"common.address",onChangeCallback:function(e){W((function(n){return t(t({},n),{buyer_delivery_address:e})}))},disabled:null!==J})):l.createElement(l.Fragment,null,l.createElement(s,{direction:"row",spacing:2,alignItems:"center"},l.createElement(k,{value:V,checked:V,onChange:function(){return q(!V)}}),l.createElement(v,null,"Use a different address for delivery")),V&&l.createElement(g,{componentName:"buyer_delivery_address",componentReference:"common.address",onChangeCallback:function(e){W((function(n){return t(t({},n),{buyer_delivery_address:e})}))}})),l.createElement(v,{variant:"h6"},"Billing Address"),l.createElement(y,null),null!==J?l.createElement(l.Fragment,null,null===J.billing_address?l.createElement(v,{variant:"body2"},"No billing address on file"):l.createElement(g,{data:null==J?void 0:J.billing_address,componentName:"buyer_billing_address",componentReference:"common.address",onChangeCallback:function(e){W((function(n){return t(t({},n),{buyer_billing_address:e})}))},disabled:null!==J})):l.createElement(l.Fragment,null,l.createElement(s,{direction:"row",spacing:2,alignItems:"center"},l.createElement(k,{value:z,checked:z,onChange:function(){return G(!z)}}),l.createElement(v,null,"Use a different address for billing")),z&&l.createElement(g,{componentName:"buyer_billing_address",componentReference:"common.address",onChangeCallback:function(e){W((function(n){return t(t({},n),{buyer_billing_address:e})}))}})),l.createElement(v,{variant:"h6"},"Bussiness Credentials"),l.createElement(y,null),l.createElement(h,{data:null==J?void 0:J.business_credentials,componentName:"buyer_business_credentials",componentReference:"business.credentials",onChangeCallback:function(e){W((function(n){return t(t({},n),{buyer_business_credentials:e})}))},disabled:null!==J})),l.createElement(E,{item:!0,xs:12},l.createElement(v,{variant:"h6"},"Invoice Items"),l.createElement(I,{onChangeCallback:function(e){W((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(E,{item:!0,xs:12},l.createElement(v,{variant:"h6"},"Add a Comment"),l.createElement(N,{name:"comments",label:"Comments",onChangeCallback:function(e){return W((function(n){return n?t(t({},n),{comments:e}):null}))}})),l.createElement(E,{item:!0,xs:12},l.createElement(v,{variant:"h6"},"Preview the Invoice"),null!==Q&&l.createElement(j,{invoice:Q})),l.createElement(E,{item:!0,xs:12},l.createElement(s,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},l.createElement(_,{text:"create invoice",loadingText:"loading"}),(null==D?void 0:D.strapiErrors)&&l.createElement(p,{error:null==D?void 0:D.strapiErrors}),(null==D?void 0:D.message)&&l.createElement(u,{severity:"error"},null==D?void 0:D.message))))))}export{F as CreateInvoiceForm};
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 o,useEffect as a}from"react";import{useFormState as m}from"react-dom";import{createOpoAction as i}from"../../../data/actions/e-commerce/opo/createOpoAction.js";import{StrapiErrors as n}from"../../StrapiErrors.js";import{SubmitButton as s}from"../../SubmitButton.js";import{CustomerSelector as l}from"../customer/CustomerSelector.js";import{OPOItemFields as c}from"./OPOItemFields.js";import{useSnackbar as u}from"../../../context/common/SnackbarContext.js";import d from"@mui/material/Typography";import p from"@mui/material/Grid";import f from"@mui/material/Box";import E from"@mui/material/TextField";import v from"@mui/material/Checkbox";import h from"@mui/material/Alert";import g from"@mui/material/Stack";var y={zodErrors:null,strapiErrors:null,data:null,message:null};function x(x){var b=x.sx,C=x.revalidateCallback,w=x.handleClose,j=x.customerLabels,A=x.productLabels,k=e(o(!1),2),I=k[0],S=k[1],L=e(m(i,y),2),O=L[0],T=L[1],_=u().handleAddMessage;return a((function(){(null==O?void 0:O.message)&&(_({message:O.message,severity:O.severity||"error"}),"success"===O.severity&&(C&&C(),w&&w()))}),[null==O?void 0:O.message]),a((function(){(null==O?void 0:O.strapiErrors)&&_({message:O.strapiErrors.message||"Error creating order",severity:O.severity||"error"})}),[null==O?void 0:O.strapiErrors]),t.createElement(f,{sx:r([],e(Array.isArray(b)?b:[b]),!1)},t.createElement("form",{action:T},t.createElement(p,{container:!0,spacing:2},t.createElement(p,{item:!0,xs:12},t.createElement(g,{spacing:2},t.createElement(d,{variant:"h6"},"Choose a customer"),t.createElement(l,{customerLabels:j}))),t.createElement(p,{item:!0,xs:12},t.createElement(g,{spacing:2},t.createElement(d,{variant:"h6"},"Customer reference"),t.createElement(d,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(p,{item:!0,xs:12},t.createElement(d,{variant:"h6"},"Choose products for this order"),t.createElement(c,{productsArr:A})),t.createElement(p,{item:!0,xs:12},t.createElement(d,{variant:"h6"},"Confirm Order"),t.createElement(d,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(g,{direction:"row",spacing:1,alignItems:"center"},t.createElement(v,{value:I,checked:I,onChange:function(){return S(!I)}}),I&&t.createElement(d,{color:"primary"},"I am sure I want to confirm this order")),t.createElement("input",{name:"status",type:"hidden",value:I?"ordered":"placed"})),t.createElement(p,{item:!0,xs:12},t.createElement(s,{text:"Confirm",loadingText:"Loading..."}),null!==(null==O?void 0:O.strapiErrors)&&t.createElement(n,{error:null==O?void 0:O.strapiErrors}),(null==O?void 0:O.message)&&t.createElement(h,{severity:"error"},null==O?void 0:O.message)))))}export{x as default};
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 r,{useState as a,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 m}from"../../common/media/UploadBase64MediaForm.js";import l 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{StrapiErrors as u}from"../../StrapiErrors.js";import{SubmitButton as v}from"../../SubmitButton.js";import E from"@mui/material/Alert";import f from"@mui/material/Dialog";import y from"@mui/material/DialogActions";import g from"@mui/material/DialogContent";import h from"@mui/material/DialogTitle";import b from"@mui/material/Typography";import x from"@mui/material/Button";import _ from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import k from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{useSnackbar as O}from"../../../context/common/SnackbarContext.js";var q={zodErrors:null,strapiErrors:null,message:null};function N(e){var t=e.open,a=e.handleClose,n=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return r.createElement(f,{open:t},r.createElement(h,null,"Confirm Order"),r.createElement(g,null,r.createElement(k,{spacing:2},r.createElement(b,null,"Are you sure you want to confirm this order?"),r.createElement(b,null,"Current status: ",i))),r.createElement(y,null,r.createElement(x,{variant:"contained",onClick:function(e){j("opos",[n]),o&&o()}},"Confirm"),r.createElement(x,{variant:"contained",onClick:a},"Cancel")))}function S(f){var y,g,h,j,S,A=f.opo,I=f.sx,B=f.revalidateCallback,F=f.handleClose,P=f.role,M=e(i(o,q),2),T=M[0],U=M[1],z=O().handleAddMessage,G=e(a(A.opo_items.data?A.opo_items.data:[]),2),H=G[0],J=G[1],L=e(a(!1),2),Q=L[0],R=L[1],K=function(r,a,n){var i=t([],e(H),!1),o=i.findIndex((function(e){return e.id===a}));i[o][n]=r,J(i)};return n((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&J(A.opo_items.data)}),[A]),n((function(){(null==T?void 0:T.message)&&(z({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(B&&B(),F&&F()))}),[null==T?void 0:T.message]),n((function(){(null==T?void 0:T.strapiErrors)&&z({message:T.strapiErrors.message||"Error updating OPO",severity:T.severity||"error"})}),[null==T?void 0:T.strapiErrors]),r.createElement(C,{sx:t([],e(Array.isArray(I)?I:[I]),!1)},r.createElement(_,{container:!0,spacing:2},r.createElement(_,{item:!0,xs:12},r.createElement(k,{spacing:2},r.createElement(k,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(k,{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(_,{item:!0,xs:6},r.createElement(k,{spacing:1},r.createElement(b,{variant:"h5"},"Details"),r.createElement(k,{direction:"row",spacing:2},r.createElement(b,{variant:"body1",width:"250px"},"Purchase Order Number"),r.createElement(b,{variant:"body2"},A.opo_number)),r.createElement(k,{direction:"row",spacing:2},r.createElement(b,{variant:"body1",width:"250px"},"Custom reference"),r.createElement(b,{variant:"body2"},A.customer_reference)),r.createElement(k,{direction:"row",spacing:2},r.createElement(b,{variant:"body1",width:"250px"},"Order Date"),r.createElement(b,{variant:"body2"},A.order_date)),r.createElement(k,{direction:"row",spacing:2},r.createElement(b,{variant:"body1",width:"250px"},"Customer"),r.createElement(b,{variant:"body2"},null===(g=null===(y=A.customer)||void 0===y?void 0:y.business_credentials)||void 0===g?void 0:g.company_name)),r.createElement(k,{direction:"row",spacing:2},r.createElement(b,{variant:"body1",width:"250px"},"Order Status"),r.createElement(b,{variant:"body2",width:"250px"},A.status)),("placed"===A.status||"external_shipping_process"===A.status)&&"enduser"===P&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return R(!0)}},"Confirm order"),r.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(N,{open:Q,handleClose:function(){return R(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:B})))),r.createElement(_,{item:!0,xs:12},r.createElement(k,{spacing:2},r.createElement(b,{variant:"h5"},"Documents"),r.createElement(w,{sx:{p:2}},r.createElement(k,{spacing:1},A.delivery_note?r.createElement(r.Fragment,null,r.createElement(b,{variant:"h6"},"Delivery Note"),r.createElement(b,null,null===(h=A.delivery_note)||void 0===h?void 0:h.name),r.createElement(x,{variant:"contained",onClick:function(){l("api/opos/".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(m,{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:B})))))),(null===(S=null===(j=null==A?void 0:A.notes)||void 0===j?void 0:j.data)||void 0===S?void 0:S.length)>0&&r.createElement(_,{item:!0,xs:12},r.createElement(k,{spacing:2},r.createElement(b,{variant:"h5"},"Notes"),r.createElement(d,{notes:A.notes.data}),r.createElement(D,null))),r.createElement(_,{item:!0,xs:12},r.createElement(k,{spacing:1},r.createElement(b,{variant:"h5"},"Items"),"placed"===A.status&&r.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(D,null),r.createElement("form",{action:U},r.createElement("input",{name:"id",type:"hidden",value:A.id}),H&&H.map((function(e,t){var a,n;return console.log("item",e),r.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===A.status?r.createElement(s,{item:e,index:t,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image}):r.createElement(c,{item:e,index:t,handleUpdateQuantity:K,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,revalidateCallback:B}))})),r.createElement(w,{sx:{p:2}},r.createElement(k,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(v,{text:"Update items",loadingText:"Loading..."}),r.createElement(u,{error:null==T?void 0:T.strapiErrors}),(null==T?void 0:T.message)&&r.createElement(E,{severity:"error"},null==T?void 0:T.message))),r.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}}))}(H))}))))))}export{S as default};
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 r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as n,useState as i}from"react";import{useFormState as a}from"react-dom";import l from"@mui/material/Box";import m from"@mui/material/Stack";import o from"@mui/material/Alert";import c from"@mui/material/TextField";import s from"@mui/material/Typography";import d from"@mui/material/Button";import u from"@mui/material/Grid";import{SubmitButton as p}from"../../SubmitButton.js";import{StrapiErrors as E}from"../../StrapiErrors.js";import{createProductAction as g}from"../../../data/actions/e-commerce/product/createProductAction.js";import{MediaLibraryDialog as f}from"../../common/media/MediaLibraryDialog.js";import{StrapiImage as v}from"../../StrapiImage.js";import{PriceFields as h}from"./PriceFields.js";import y from"../categories/CategorySelectorV2.js";import{DimensionsFields as x}from"../../common/Dimensions.js";import b from"../../logistics/vendor/VendorSelector.js";import j from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as C}from"../../../context/common/SnackbarContext.js";var w={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null},S=function(S){var k=S.vendorArr,A=S.categories,T=S.revalidateCallback,N=S.handleClose,P=S.sx,V=C();V.state,V.dispatch;var _=e(a(g,w),2),D=_[0],I=_[1],B=C().handleAddMessage;n((function(){(null==D?void 0:D.message)&&(B({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(T&&T(),N&&N()))}),[null==D?void 0:D.message]),n((function(){(null==D?void 0:D.strapiErrors)&&B({message:D.strapiErrors.message||"Error adding product",severity:D.severity||"error"})}),[null==D?void 0:D.strapiErrors]);var M=e(i(null),2),O=M[0],F=M[1],G=e(i(null),2),R=G[0],z=G[1],J=e(i([]),2),L=J[0],q=J[1];return t.createElement(l,{sx:r([],e(Array.isArray(P)?P:[P]),!1)},t.createElement("form",{action:I},t.createElement(u,{container:!0,spacing:2},t.createElement(u,{item:!0,xs:12},t.createElement(m,{spacing:2},t.createElement(c,{id:"title",name:"title",label:"Title"}),t.createElement(j,{name:"description",label:"Description"}),t.createElement(c,{id:"external_product_number",name:"external_product_number",label:"External Product Number"}))),t.createElement(u,{item:!0,xs:6},t.createElement(s,{variant:"h6"},"Product Image"),t.createElement("input",{id:"image",type:"hidden",name:"image",value:(null==R?void 0:R.id)||""}),t.createElement(v,{id:(null==R?void 0:R.id)||"",url:(null==R?void 0:R.url)||"",alternativeText:"product image",width:(null==R?void 0:R.width)&&(null==R?void 0:R.height)?R.width/R.height*200:200,height:200}),t.createElement(d,{onClick:function(){return F("image")}},"open media library"),t.createElement(f,{open:"image"===O,handleClose:function(){return F(null)},handleCancel:function(){z(null),F(null)},handleSelect:function(e){z(e)},selected:R?[R]:[]})),t.createElement(u,{item:!0,xs:6},t.createElement(s,{variant:"h6"},"Image Gallery"),t.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(L.map((function(e){return e.id})))}),t.createElement(m,{direction:"row",spacing:2},L.map((function(e){return t.createElement(v,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:e.width/e.height*100,height:100})}))),t.createElement(d,{onClick:function(){return F("gallery")}},"open media library"),t.createElement(f,{open:"gallery"===O,handleClose:function(){return F(null)},handleCancel:function(){q([]),F(null)},handleSelect:function(t){if(L.indexOf(t)>-1){var n=r([],e(L),!1);n.splice(L.indexOf(t),1),q(n)}else L.length>=5?q(r([],e(L),!1)):q(r(r([],e(L),!1),[t],!1))},selected:L})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Price"),t.createElement(h,{componentName:"price",componentReference:"e-commerce-elements.price"})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Categories"),t.createElement(y,{categories:A,currentValue:[]})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Dimensions"),t.createElement(x,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions"})),t.createElement(u,{item:!0,xs:12},t.createElement(s,{variant:"h6"},"Vendors"),t.createElement(b,{vendorNames:k,currentValue:null}))),t.createElement(u,{item:!0,xs:12},t.createElement(m,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:2}},t.createElement(p,{text:"create new product",loadingText:"loading"}),t.createElement(E,{error:null==D?void 0:D.strapiErrors}),(null==D?void 0:D.message)&&t.createElement(o,{severity:"error"},null==D?void 0:D.message)))))};export{S as AddProductForm};
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 i,useState as n}from"react";import a from"@mui/material/Box";import l from"@mui/material/Stack";import o from"@mui/material/Alert";import m from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{StrapiErrors as u}from"../../StrapiErrors.js";import{updateProductAction as p}from"../../../data/actions/e-commerce/product/updateProductAction.js";import{MediaLibraryDialog as g}from"../../common/media/MediaLibraryDialog.js";import v from"@mui/material/Button";import E from"@mui/material/Grid";import{StrapiImage as f}from"../../StrapiImage.js";import{PriceFields as h}from"./PriceFields.js";import y from"../categories/CategorySelectorV2.js";import{DimensionsFields as x}from"../../common/Dimensions.js";import b from"../../logistics/vendor/VendorSelector.js";import j from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as w}from"../../../context/common/SnackbarContext.js";var C={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null};function S(S){var k,V,A=S.data,_=S.vendorArr,T=S.categoriesArray,I=S.revalidateCallback,N=S.sx,P=A.id,D=A.title,B=A.description,M=A.external_product_number,F=A.image,G=A.gallery,R=A.price,z=A.dimensions,J=A.categories,L=A.vendors,O=(null==G?void 0:G.data)||[],q=(null==J?void 0:J.data)||[],H=w().handleAddMessage,K=e(s(p,C),2),Q=K[0],U=K[1];i((function(){(null==Q?void 0:Q.message)&&(H({message:Q.message,severity:Q.severity||"error"}),"success"===Q.severity&&I&&I())}),[null==Q?void 0:Q.message]),i((function(){(null==Q?void 0:Q.strapiErrors)&&H({message:Q.strapiErrors.message||"Error updating product",severity:Q.severity||"error"})}),[null==Q?void 0:Q.strapiErrors]);var W=e(n(null),2),X=W[0],Y=W[1],Z=e(n(F||null),2),$=Z[0],ee=Z[1],te=e(n(t([],e(O),!1)),2),re=te[0],ie=te[1];return r.createElement(a,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},r.createElement("form",{action:U},P&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:P}),r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(l,{spacing:2},r.createElement(m,{id:"title",name:"title",label:"Title",defaultValue:D}),r.createElement(j,{name:"description",label:"Description",defaultValue:B}),r.createElement(m,{id:"external_product_number",name:"external_product_number",label:"External Product Number",defaultValue:M}))),r.createElement(E,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:null==$?void 0:$.id}),r.createElement(f,{id:(null==$?void 0:$.id)||"",url:(null==$?void 0:$.url)||"",alternativeText:"product image",width:(null==$?void 0:$.width)&&(null==$?void 0:$.height)?$.width/$.height*200:200,height:200}),r.createElement(v,{onClick:function(){return Y("image")}},"open media library"),r.createElement(g,{open:"image"===X,handleClose:function(){return Y(null)},handleCancel:function(){ee(null),Y(null)},handleSelect:function(e){ee(e)},selected:$?[$]:[]})),r.createElement(E,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(re.map((function(e){return e.id})))}),r.createElement(l,{direction:"row",spacing:2},re.map((function(e){return r.createElement(f,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:(null==e?void 0:e.width)&&(null==e?void 0:e.height)?e.width/e.height*100:100,height:100})}))),r.createElement(v,{onClick:function(){return Y("gallery")}},"open media library"),r.createElement(g,{open:"gallery"===X,handleClose:function(){return Y(null)},handleCancel:function(){ie([]),Y(null)},handleSelect:function(r){var i=re.findIndex((function(e){return e.id===r.id}));if(i>-1){var n=t([],e(re),!1);n.splice(i,1),ie(n)}else re.length>=5?ie(t([],e(re),!1)):ie(t(t([],e(re),!1),[r],!1))},selected:re})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Price"),r.createElement(h,{componentName:"price",componentReference:"e-commerce-elements.price",data:R})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Categories"),r.createElement(y,{categories:T,currentValue:t([],e(q.map((function(e){return e.id}))),!1)})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Dimensions"),r.createElement(x,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions",data:z})),r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Vendors"),r.createElement(b,{vendorNames:_,currentValue:null===(V=null===(k=L.data)||void 0===k?void 0:k[0])||void 0===V?void 0:V.id}))),r.createElement(E,{item:!0,xs:12},r.createElement(l,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},r.createElement(d,{text:"update product",loadingText:"loading"}),(null==Q?void 0:Q.strapiErrors)&&r.createElement(u,{error:null==Q?void 0:Q.strapiErrors}),(null==Q?void 0:Q.message)&&r.createElement(o,{severity:"error"},null==Q?void 0:Q.message)))))}export{S as EditProductForm};
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};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as n}from"react";import l from"@mui/material/Paper";import a from"@mui/material/Box";import m from"@mui/material/Stack";import i from"@mui/material/Alert";import c from"@mui/material/Typography";import{SubmitButton as u}from"../../SubmitButton.js";import{useFormState as o}from"react-dom";import{StrapiErrors as d}from"../../StrapiErrors.js";import{updateProductAction as s}from"../../../data/actions/e-commerce/product/updateProductAction.js";import E from"@mui/material/Grid";import p from"../../logistics/report/ReportsDisplay.js";import y from"../../logistics/report/ReportMakingComponent.js";import{TableContainer as f,Table as g,TableHead as _,TableRow as v,TableCell as q,TableBody as k,TableFooter as x,Tooltip as b}from"@mui/material";import{AmountIndicator as h}from"../../common/AmountIndicator.js";import{useSnackbar as S}from"../../../context/common/SnackbarContext.js";var T={zodErrors:null,strapiErrors:null,severity:null,data:null,message:null};function j(j){var Q=j.data,V=j.revalidateCallback,A=j.sx,O=Q.id,C=Q.title;Q.product_number,Q.stock;var I=Q.ipos,N=Q.opos,R=Q.reports,z=e(o(s,T),2),D=z[0],P=z[1],w=S().handleAddMessage;return n((function(){(null==D?void 0:D.message)&&(w({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&V&&V())}),[null==D?void 0:D.message]),n((function(){(null==D?void 0:D.strapiErrors)&&w({message:D.strapiErrors.message||"Error updating stock",severity:D.severity||"error"})}),[null==D?void 0:D.strapiErrors]),r.createElement(a,{sx:t([],e(Array.isArray(A)?A:[A]),!1)},r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h6"},C)),r.createElement(E,{item:!0,xs:12},r.createElement(f,{component:l},r.createElement(c,{variant:"h6"},"Incoming orders"),r.createElement(g,{size:"small"},r.createElement(_,null,r.createElement(v,null,r.createElement(q,null,"Number"),r.createElement(q,null,"Order Date"),r.createElement(q,null,"Line Item Number"),r.createElement(q,null,"Ordered Quantity"),r.createElement(q,null,"Received Quantity"),r.createElement(q,null,"Registered Quantity"),r.createElement(q,null,"Released Quantity"))),r.createElement(k,null,I.map((function(e){return r.createElement(r.Fragment,null,e.items.map((function(t){return r.createElement(v,{key:e.id},r.createElement(q,null,e.ipo_number),r.createElement(q,null,e.order_date),r.createElement(q,null,t.line_item_number),r.createElement(q,null,r.createElement(h,{value:t.ordered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.received_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.registered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.released_quantity,maxValue:t.ordered_quantity,color:"primary"})))})))}))),r.createElement(x,null,r.createElement(v,null,r.createElement(q,{colSpan:6,align:"right"},"Total added to stock:"),r.createElement(q,null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0))))),r.createElement(c,{variant:"h6"},"Outgoing orders"),r.createElement(g,{size:"small"},r.createElement(_,null,r.createElement(v,null,r.createElement(q,null,"Number"),r.createElement(q,null,"Order Date"),r.createElement(q,null,"Line Item Number"),r.createElement(q,null,"Ordered Quantity"),r.createElement(q,null,"Picked Quantity"),r.createElement(q,null,"Packed Quantity"),r.createElement(q,null,"Shipped Quantity"))),r.createElement(k,null,N.map((function(e){return r.createElement(r.Fragment,null,e.opo_items.map((function(t){return r.createElement(v,{key:e.id},r.createElement(q,null,e.opo_number),r.createElement(q,null,e.order_date),r.createElement(q,null,t.line_item_number),r.createElement(q,null,r.createElement(h,{value:t.ordered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.picked_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.packed_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(q,null,r.createElement(h,{value:t.shipped_quantity,maxValue:t.ordered_quantity,color:"primary"})))})))}))),r.createElement(x,null,r.createElement(v,null,r.createElement(q,{colSpan:3,align:"right"},"Total reduced from stock:"),r.createElement(q,null,N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0))))),r.createElement(g,{size:"small"},r.createElement(v,null,r.createElement(q,{align:"right"},"Total added to stock:"),r.createElement(q,null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0))),r.createElement(v,null,r.createElement(q,{align:"right"},"Total reduced from stock:"),r.createElement(q,null,N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0))),r.createElement(v,null,r.createElement(q,{align:"right"},"Corrections:"),r.createElement(q,null,r.createElement(b,{title:"Total stock corrections"},r.createElement(c,null,R?R.reduce((function(e,t){return e+t.quantity}),0):0))),r.createElement(q,null,r.createElement(b,{title:"Total stock corrections after updating"},r.createElement("b",null,R?R.reduce((function(e,t){return e+t.quantity}),0):0)))),r.createElement(v,null,r.createElement(q,{align:"right"},"Stock:"),r.createElement(q,null,r.createElement(b,{title:"Total stock"},r.createElement(c,null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0)-N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0)+(R?R.reduce((function(e,t){return e+t.quantity}),0):0)))),r.createElement(q,null,r.createElement(b,{title:"Total stock after updating"},r.createElement("b",null,I.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0)-N.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0)+(R?R.reduce((function(e,t){return e+t.quantity}),0):0))))))))),r.createElement("form",{action:P},O&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:O}),r.createElement("input",{id:"stock_reports",type:"hidden",name:"stock_reports",value:JSON.stringify(R)}),r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12,sx:{mt:2}},r.createElement(m,{spacing:2},r.createElement(c,{variant:"h5"},"Stock corrections"),r.createElement(c,{variant:"body2"},"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"),r.createElement(p,{reports:R}),r.createElement(y,{content:"content",quantity:0,type:"stock",related:[{id:O,__type:"api::e-commerce.product"}],revalidateCallback:V}))),r.createElement(E,{item:!0,xs:12},r.createElement(m,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},r.createElement(u,{text:"update stock",loadingText:"loading"}),(null==D?void 0:D.strapiErrors)&&r.createElement(d,{error:null==D?void 0:D.strapiErrors}),(null==D?void 0:D.message)&&r.createElement(i,{severity:"error"},null==D?void 0:D.message))))))}export{j as EditStockForm};
7
+ import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as n}from"react";import l from"@mui/material/Paper";import a from"@mui/material/Box";import m from"@mui/material/Stack";import i from"@mui/material/Typography";import{SubmitButton as o}from"../../SubmitButton.js";import{useFormState as u}from"react-dom";import{updateProductAction as c}from"../../../data/actions/e-commerce/product/updateProductAction.js";import d from"@mui/material/Grid";import s from"../../logistics/report/ReportsDisplay.js";import E from"../../logistics/report/ReportMakingComponent.js";import{useSnackbar as p}from"../../../context/common/SnackbarContext.js";import y from"@mui/material/Table";import f from"@mui/material/TableBody";import g from"@mui/material/TableCell";import _ from"@mui/material/TableContainer";import v from"@mui/material/TableFooter";import k from"@mui/material/TableHead";import q from"@mui/material/TableRow";import b from"@mui/material/Tooltip";import x from"@mui/material/Button";import{AmountIndicator as h}from"../../common/AmountIndicator.js";var T={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function C(C){var S=C.data,j=C.revalidateCallback,Q=C.handleClose,V=C.sx,O=S.id,R=S.title;S.product_number,S.stock;var A=S.ipos,I=S.opos,N=S.reports,w=p().handleAddMessage,z=e(u(c,T),2),B=z[0],D=z[1];return n((function(){(null==B?void 0:B.message)&&(w({message:B.message,severity:B.severity||"error"}),"success"===B.severity&&(j&&j(),Q&&Q()))}),[null==B?void 0:B.message,w,j,Q]),n((function(){(null==B?void 0:B.strapiErrors)&&w({message:B.strapiErrors.message||"Error updating stock",severity:"error"})}),[null==B?void 0:B.strapiErrors,w]),r.createElement(a,{sx:t([],e(Array.isArray(V)?V:[V]),!1)},r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12},r.createElement(i,{variant:"h6"},R)),r.createElement(d,{item:!0,xs:12},r.createElement(_,{component:l},r.createElement(i,{variant:"h6"},"Incoming orders"),r.createElement(y,{size:"small"},r.createElement(k,null,r.createElement(q,null,r.createElement(g,null,"Number"),r.createElement(g,null,"Order Date"),r.createElement(g,null,"Line Item Number"),r.createElement(g,null,"Ordered Quantity"),r.createElement(g,null,"Received Quantity"),r.createElement(g,null,"Registered Quantity"),r.createElement(g,null,"Released Quantity"))),r.createElement(f,null,A.map((function(e){return r.createElement(r.Fragment,null,e.items.map((function(t){return r.createElement(q,{key:e.id},r.createElement(g,null,e.ipo_number),r.createElement(g,null,e.order_date),r.createElement(g,null,t.line_item_number),r.createElement(g,null,r.createElement(h,{value:t.ordered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(g,null,r.createElement(h,{value:t.received_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(g,null,r.createElement(h,{value:t.registered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(g,null,r.createElement(h,{value:t.released_quantity,maxValue:t.ordered_quantity,color:"primary"})))})))}))),r.createElement(v,null,r.createElement(q,null,r.createElement(g,{colSpan:6,align:"right"},"Total added to stock:"),r.createElement(g,null,A.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0))))),r.createElement(i,{variant:"h6"},"Outgoing orders"),r.createElement(y,{size:"small"},r.createElement(k,null,r.createElement(q,null,r.createElement(g,null,"Number"),r.createElement(g,null,"Order Date"),r.createElement(g,null,"Line Item Number"),r.createElement(g,null,"Ordered Quantity"),r.createElement(g,null,"Picked Quantity"),r.createElement(g,null,"Packed Quantity"),r.createElement(g,null,"Shipped Quantity"))),r.createElement(f,null,I.map((function(e){return r.createElement(r.Fragment,null,e.opo_items.map((function(t){return r.createElement(q,{key:e.id},r.createElement(g,null,e.opo_number),r.createElement(g,null,e.order_date),r.createElement(g,null,t.line_item_number),r.createElement(g,null,r.createElement(h,{value:t.ordered_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(g,null,r.createElement(h,{value:t.picked_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(g,null,r.createElement(h,{value:t.packed_quantity,maxValue:t.ordered_quantity,color:"primary"})),r.createElement(g,null,r.createElement(h,{value:t.shipped_quantity,maxValue:t.ordered_quantity,color:"primary"})))})))}))),r.createElement(v,null,r.createElement(q,null,r.createElement(g,{colSpan:3,align:"right"},"Total reduced from stock:"),r.createElement(g,null,I.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0))))),r.createElement(y,{size:"small"},r.createElement(q,null,r.createElement(g,{align:"right"},"Total added to stock:"),r.createElement(g,null,A.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0))),r.createElement(q,null,r.createElement(g,{align:"right"},"Total reduced from stock:"),r.createElement(g,null,I.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0))),r.createElement(q,null,r.createElement(g,{align:"right"},"Corrections:"),r.createElement(g,null,r.createElement(b,{title:"Total stock corrections"},r.createElement(i,null,N?N.reduce((function(e,t){return e+t.quantity}),0):0))),r.createElement(g,null,r.createElement(b,{title:"Total stock corrections after updating"},r.createElement("b",null,N?N.reduce((function(e,t){return e+t.quantity}),0):0)))),r.createElement(q,null,r.createElement(g,{align:"right"},"Stock:"),r.createElement(g,null,r.createElement(b,{title:"Total stock"},r.createElement(i,null,A.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0)-I.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0)+(N?N.reduce((function(e,t){return e+t.quantity}),0):0)))),r.createElement(g,null,r.createElement(b,{title:"Total stock after updating"},r.createElement("b",null,A.reduce((function(e,t){return e+t.items.reduce((function(e,t){return e+t.released_quantity}),0)}),0)-I.reduce((function(e,t){return e+t.opo_items.reduce((function(e,t){return e+t.ordered_quantity}),0)}),0)+(N?N.reduce((function(e,t){return e+t.quantity}),0):0))))))))),r.createElement("form",{action:D},O&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:O}),r.createElement("input",{id:"stock_reports",type:"hidden",name:"stock_reports",value:JSON.stringify(N)}),r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12,sx:{mt:2}},r.createElement(m,{spacing:2},r.createElement(i,{variant:"h5"},"Stock corrections"),r.createElement(i,{variant:"body2"},"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"),r.createElement(s,{reports:N}),r.createElement(E,{content:"content",quantity:0,type:"stock",related:[{id:O,__type:"api::e-commerce.product"}],revalidateCallback:j}))),r.createElement(d,{item:!0,xs:12},r.createElement(m,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{py:1}},Q&&r.createElement(x,{onClick:Q,variant:"outlined"},"Close"),r.createElement(o,{text:"Update Stock",loadingText:"Updating...",variant:"contained"}))))))}export{C as EditStockForm};