umwd-components 0.1.656 → 0.1.658

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.
@@ -79,11 +79,7 @@ When using this pattern, wrap your form in a Box component with consistent
79
79
  styling:
80
80
 
81
81
  ```typescript
82
- <Box
83
- sx={[
84
- ...(Array.isArray(sx) ? sx : [sx]),
85
- ]}
86
- >
82
+ <Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
87
83
  ```
88
84
 
89
85
  ### Key Features
@@ -172,9 +168,8 @@ export default function ExampleForm({
172
168
  });
173
169
  }
174
170
  }, [formState?.strapiErrors]);
175
-
176
171
  return (
177
- <Box sx={[{ p: 2 }, ...(Array.isArray(sx) ? sx : [sx])]} component={Paper}>
172
+ <Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
178
173
  <form action={formAction}>{/* Form content */}</form>
179
174
  </Box>
180
175
  );
@@ -0,0 +1,140 @@
1
+ ---
2
+ applyTo: "/**/*Form.tsx"
3
+ ---
4
+
5
+ # Form Implementation Instructions
6
+
7
+ ## Basic Form Setup
8
+
9
+ 1. Add required imports:
10
+
11
+ ```typescript
12
+ import { useSnackbar } from "../../../context/common/SnackbarContext";
13
+ import { useFormState } from "react-dom";
14
+ import { SxProps } from "@mui/material/styles";
15
+ ```
16
+
17
+ 2. Include standard props interface:
18
+
19
+ ```typescript
20
+ interface FormProps {
21
+ sx?: SxProps;
22
+ revalidateCallback?: () => void;
23
+ handleClose?: () => void;
24
+ }
25
+ ```
26
+
27
+ 3. Initialize form state:
28
+
29
+ ```typescript
30
+ const INITIAL_STATE = {
31
+ zodErrors: null,
32
+ strapiErrors: null,
33
+ data: null,
34
+ message: null,
35
+ severity: null,
36
+ };
37
+ ```
38
+
39
+ ## Required Form Structure
40
+
41
+ 1. **Base Structure**:
42
+
43
+ ```typescript
44
+ <Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
45
+ <form action={formAction}>
46
+ <Grid container spacing={2}>
47
+ {/* Form content */}
48
+ </Grid>
49
+ </form>
50
+ </Box>
51
+ ```
52
+
53
+ 2. **Title Section**:
54
+
55
+ ```typescript
56
+ <Grid item xs={12}>
57
+ <Stack spacing={2}>
58
+ <Typography variant="h3" component={"h1"}>
59
+ Form Title Here
60
+ </Typography>
61
+ <Typography variant="body2">Optional description text</Typography>
62
+ </Stack>
63
+ </Grid>
64
+ ```
65
+
66
+ 3. **Action Buttons**:
67
+
68
+ ```typescript
69
+ <Grid item xs={12}>
70
+ <Stack direction={"row"} justifyContent={"space-between"}>
71
+ {handleClose && (
72
+ <Button onClick={handleClose} variant="outlined">
73
+ Cancel
74
+ </Button>
75
+ )}
76
+ <SubmitButton text="Submit" loadingText="Loading..." variant="contained" />
77
+ </Stack>
78
+ </Grid>
79
+ ```
80
+
81
+ ## Message Handling Implementation
82
+
83
+ 1. Add snackbar message handling:
84
+
85
+ ```typescript
86
+ const { handleAddMessage } = useSnackbar();
87
+
88
+ useEffect(() => {
89
+ if (formState?.message) {
90
+ handleAddMessage({
91
+ message: formState.message,
92
+ severity: formState.severity || "error",
93
+ });
94
+
95
+ if (formState.severity === "success") {
96
+ revalidateCallback && revalidateCallback();
97
+ handleClose && handleClose();
98
+ }
99
+ }
100
+ }, [formState?.message]);
101
+ ```
102
+
103
+ 2. Add error handling:
104
+
105
+ ```typescript
106
+ useEffect(() => {
107
+ if (formState?.strapiErrors) {
108
+ handleAddMessage({
109
+ message: formState.strapiErrors.message || "Error performing action",
110
+ severity: formState.severity || "error",
111
+ });
112
+ }
113
+ }, [formState?.strapiErrors]);
114
+ ```
115
+
116
+ ## Best Practices
117
+
118
+ 1. **Form Layout**:
119
+
120
+ - Use Grid system with `spacing={2}`
121
+ - Group related fields in Stack components
122
+ - Use consistent spacing throughout the form
123
+
124
+ 2. **Error Handling**:
125
+
126
+ - Always provide fallback error messages
127
+ - Use Snackbar for notifications instead of inline alerts
128
+ - Handle both form validation and API errors
129
+
130
+ 3. **Success Handling**:
131
+
132
+ - Close form on success if handleClose is provided
133
+ - Trigger revalidation if revalidateCallback is provided
134
+ - Show success message through Snackbar
135
+
136
+ 4. **Accessibility**:
137
+
138
+ - Use semantic HTML elements
139
+ - Include proper ARIA labels
140
+ - Maintain heading hierarchy with h1 for form title
@@ -0,0 +1,156 @@
1
+ ---
2
+ mode: "agent"
3
+ tools: []
4
+ ---
5
+
6
+ # Form Pattern AI Assistant Guide
7
+
8
+ ## Form Creation and Modification
9
+
10
+ When assisting with form creation or modification, ensure the following patterns
11
+ are followed:
12
+
13
+ ### Structure Validation
14
+
15
+ 1. **Base Component Structure**
16
+
17
+ - Verify form is wrapped in a Box component with proper sx prop handling
18
+ - Check Grid container with spacing={2} is used
19
+ - Ensure form sections follow standard layout pattern
20
+
21
+ 2. **Required Sections**
22
+
23
+ - Title section with h3/h1 Typography
24
+ - Properly grouped form fields
25
+ - Action buttons section at bottom
26
+
27
+ ### Implementation Checks
28
+
29
+ 1. **State Management**
30
+
31
+ - Verify INITIAL_STATE includes all required fields
32
+ - Check useFormState implementation
33
+ - Validate form action setup
34
+
35
+ 2. **Message Handling**
36
+
37
+ - Confirm Snackbar context is properly imported and used
38
+ - Verify message handling useEffect is implemented
39
+ - Check error handling useEffect is present
40
+
41
+ 3. **Props Interface**
42
+
43
+ - Ensure required props (sx, revalidateCallback, handleClose) are included
44
+ - Verify props are properly typed
45
+ - Check optional props are marked as such
46
+
47
+ ### Common Fixes
48
+
49
+ When updating forms to match the pattern:
50
+
51
+ 1. **Structure Fixes**
52
+
53
+ ```typescript
54
+ // Convert from
55
+ <div>
56
+ <form>...</form>
57
+ </div>
58
+
59
+ // To
60
+ <Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
61
+ <form action={formAction}>
62
+ <Grid container spacing={2}>
63
+ ...
64
+ </Grid>
65
+ </form>
66
+ </Box>
67
+ ```
68
+
69
+ 2. **Message Handling Fixes**
70
+
71
+ ```typescript
72
+ // Remove inline alerts
73
+ <Alert severity="error">{error}</Alert>;
74
+
75
+ // Use Snackbar context instead
76
+ handleAddMessage({
77
+ message: error,
78
+ severity: "error",
79
+ });
80
+ ```
81
+
82
+ 3. **Button Layout Fixes**
83
+
84
+ ```typescript
85
+ // Convert from
86
+ <div>
87
+ <Button>Cancel</Button>
88
+ <Button>Submit</Button>
89
+ </div>
90
+
91
+ // To
92
+ <Stack direction={"row"} justifyContent={"space-between"}>
93
+ {handleClose && (
94
+ <Button onClick={handleClose} variant="outlined">
95
+ Cancel
96
+ </Button>
97
+ )}
98
+ <SubmitButton text="Submit" loadingText="Loading..." variant="contained" />
99
+ </Stack>
100
+ ```
101
+
102
+ ### Response Guidelines
103
+
104
+ When helping users with forms:
105
+
106
+ 1. **Analysis Phase**
107
+
108
+ - Review current form implementation
109
+ - Identify missing pattern elements
110
+ - List required changes
111
+
112
+ 2. **Implementation Phase**
113
+
114
+ - Make changes in logical groups (structure, handlers, props)
115
+ - Maintain existing form functionality
116
+ - Preserve custom business logic
117
+
118
+ 3. **Validation Phase**
119
+
120
+ - Verify pattern compliance
121
+ - Check for proper error handling
122
+ - Ensure success scenarios are handled
123
+
124
+ 4. **Documentation**
125
+
126
+ - Explain changes made
127
+ - Highlight any pattern deviations (if necessary)
128
+ - Provide reasoning for modifications
129
+
130
+ ## Form Best Practices Enforcement
131
+
132
+ When reviewing or modifying forms, enforce these best practices:
133
+
134
+ 1. **Consistent Error Handling**
135
+
136
+ - Use Snackbar for all notifications
137
+ - Provide fallback error messages
138
+ - Handle both validation and API errors
139
+
140
+ 2. **Proper Success Handling**
141
+
142
+ - Close form on success when appropriate
143
+ - Trigger data revalidation when needed
144
+ - Show success notifications
145
+
146
+ 3. **Accessibility**
147
+
148
+ - Maintain proper heading hierarchy
149
+ - Use semantic HTML elements
150
+ - Include necessary ARIA labels
151
+
152
+ 4. **Code Organization**
153
+
154
+ - Group related form fields
155
+ - Maintain consistent spacing
156
+ - Use appropriate MUI components
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as r}from"../../_virtual/index8.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
6
+ import{__exports as r}from"../../_virtual/index7.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
@@ -3,5 +3,5 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- import{__exports as a}from"../../_virtual/index7.js";
6
+ import{__exports as a}from"../../_virtual/index8.js";
7
7
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var t;function o(){return t||(t=1,a.read=function(a,t,o,r,h){var M,e,i=8*h-r-1,p=(1<<i)-1,f=p>>1,n=-7,w=o?h-1:0,s=o?-1:1,u=a[t+w];for(w+=s,M=u&(1<<-n)-1,u>>=-n,n+=i;n>0;M=256*M+a[t+w],w+=s,n-=8);for(e=M&(1<<-n)-1,M>>=-n,n+=r;n>0;e=256*e+a[t+w],w+=s,n-=8);if(0===M)M=1-f;else{if(M===p)return e?NaN:1/0*(u?-1:1);e+=Math.pow(2,r),M-=f}return(u?-1:1)*e*Math.pow(2,M-r)},a.write=function(a,t,o,r,h,M){var e,i,p,f=8*M-h-1,n=(1<<f)-1,w=n>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,N=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,e=n):(e=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-e))<1&&(e--,p*=2),(t+=e+w>=1?s/p:s*Math.pow(2,1-w))*p>=2&&(e++,p/=2),e+w>=n?(i=0,e=n):e+w>=1?(i=(t*p-1)*Math.pow(2,h),e+=w):(i=t*Math.pow(2,w-1)*Math.pow(2,h),e=0));h>=8;a[o+u]=255&i,u+=N,i/=256,h-=8);for(e=e<<h|i,f+=h;f>0;a[o+u]=255&e,u+=N,e/=256,f-=8);a[o+u-N]|=128*_}),a}export{o as __require};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import o from"@mui/material/Box";import s from"@mui/material/Stack";import m from"@mui/material/TextField";import i from"@mui/material/Typography";import{useFormState as l}from"react-dom";import{createCategoryAction as c}from"../../../data/actions/e-commerce/categories/createCategoryAction.js";import n from"@mui/material/Grid";import u from"../products/ProductSelector.js";import d from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as p}from"../../../context/common/SnackbarContext.js";var g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function y(y){var E=y.productNamesArray,f=y.revalidateCallback,v=y.sx,x=y.handleClose,b=e(l(c,g),2),j=b[0],k=b[1],A=p().handleAddMessage;return a((function(){(null==j?void 0:j.message)&&(A({message:j.message||"Error creating category",severity:j.severity||"error"}),"success"===j.severity&&(A({message:j.message||"Category created successfully",severity:j.severity||"success"}),f&&f(),x&&x()))}),[null==j?void 0:j.message]),a((function(){(null==j?void 0:j.strapiErrors)&&A({message:j.strapiErrors.message||"Error creating category",severity:j.severity||"error"})}),[null==j?void 0:j.strapiErrors]),t.createElement(o,{sx:r([],e(Array.isArray(v)?v:[v]),!1)},t.createElement("form",{action:k},t.createElement(n,{container:!0,spacing:2},t.createElement(n,{item:!0,xs:12},t.createElement(s,{spacing:2},t.createElement(m,{id:"title",name:"title",label:"Title"}),t.createElement(d,{name:"description",label:"Description"}))),t.createElement(n,{item:!0,xs:12},t.createElement(i,{variant:"h6"},"Products"),t.createElement(u,{productNames:E,currentValue:[]})))))}export{y as AddCategoryForm};
7
+ import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import o from"@mui/material/Box";import i from"@mui/material/Stack";import m from"@mui/material/TextField";import n from"@mui/material/Typography";import{Button as s}from"@mui/material";import{SubmitButton as c}from"../../SubmitButton.js";import{useFormState as l}from"react-dom";import{createCategoryAction as d}from"../../../data/actions/e-commerce/categories/createCategoryAction.js";import u from"@mui/material/Grid";import p from"../products/ProductSelector.js";import E from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as g}from"../../../context/common/SnackbarContext.js";var y={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function f(f){var v=f.productNamesArray,x=f.revalidateCallback,C=f.sx,b=f.handleClose,h=e(l(d,y),2),j=h[0],k=h[1],A=g().handleAddMessage;return a((function(){(null==j?void 0:j.message)&&(A({message:j.message||"Error creating category",severity:j.severity||"error"}),"success"===j.severity&&(x&&x(),b&&b()))}),[null==j?void 0:j.message]),a((function(){(null==j?void 0:j.strapiErrors)&&A({message:j.strapiErrors.message||"Error creating category",severity:j.severity||"error"})}),[null==j?void 0:j.strapiErrors]),t.createElement(o,{sx:r([],e(Array.isArray(C)?C:[C]),!1)},t.createElement("form",{action:k},t.createElement(u,{container:!0,spacing:2},t.createElement(u,{item:!0,xs:12},t.createElement(i,{spacing:2},t.createElement(n,{variant:"h3",component:"h1"},"Add Category"),t.createElement(n,{variant:"body2"},"Create a new category for your products. You can add products to this category later."))),t.createElement(u,{item:!0,xs:12},t.createElement(i,{spacing:2},t.createElement(m,{id:"title",name:"title",label:"Title"}),t.createElement(E,{name:"description",label:"Description"}))),t.createElement(u,{item:!0,xs:12},t.createElement(n,{variant:"h6"},"Products"),t.createElement(p,{productNames:v,currentValue:[]})),t.createElement(u,{item:!0,xs:12},t.createElement(i,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},b&&t.createElement(s,{onClick:b,variant:"outlined"},"Cancel"),t.createElement(c,{text:"Create category",loadingText:"Loading...",variant:"contained"}))))))}export{f as AddCategoryForm};
@@ -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 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 E}from"../../../context/common/SnackbarContext.js";import{Button as g}from"@mui/material";var f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function v(v){var y=v.data,x=v.revalidateCallback,h=v.handleClose,b=v.productNamesArray,C=v.sx,j=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,f),2),V=T[0],B=T[1],M=E().handleAddMessage;return a((function(){(null==V?void 0:V.message)&&(M({message:V.message,severity:V.severity||"error"}),"success"===V.severity&&(x&&x(),h&&h()))}),[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},j&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:j}),r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(n,{variant:"h3",component:"h1"},"Edit Category"),r.createElement(n,{variant:"body2"},"Edit the category for your products. You can add products to this category later."))),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:b,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",alignItems:"center",sx:{pt:2}},h&&r.createElement(g,{onClick:h,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Update category",loadingText:"Loading...",variant:"contained"})))))}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 E}from"../../../context/common/SnackbarContext.js";import{Button as g}from"@mui/material";var f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function v(v){var y=v.data,x=v.revalidateCallback,h=v.handleClose,b=v.productNamesArray,C=v.sx,j=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,f),2),V=T[0],B=T[1],M=E().handleAddMessage;return a((function(){(null==V?void 0:V.message)&&(M({message:V.message,severity:V.severity||"error"}),"success"===V.severity&&(x&&x(),h&&h()))}),[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},j&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:j}),r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(n,{variant:"h3",component:"h1"},"Edit Category"),r.createElement(n,{variant:"body2"},"Edit the category for your products. You can add products to this category later."))),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:b,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",alignItems:"center",sx:{pt:2}},h&&r.createElement(g,{onClick:h,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Update category",loadingText:"Loading...",variant:"contained"}))))))}export{v as EditCategoryForm};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t from"@mui/material/Divider";import a from"@mui/material/Paper";import n from"@mui/material/Box";import m from"@mui/material/Stack";import l from"@mui/material/Alert";import i from"@mui/material/TextField";import s from"@mui/material/Typography";import o from"@mui/material/Checkbox";import{AddressFields as c}from"../../common/Address.js";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as u}from"react-dom";import{updateCustomerProfileAction as p}from"../../../data/actions/profile-actions.js";import{StrapiErrors as f}from"../../StrapiErrors.js";import{BusinessCredentialsFields as E}from"./BusinessCredentials.js";import{useSession as v}from"../../../context/auth/SessionContext.js";import g,{useState as h,useEffect as b}from"react";var _={zodErrors:null,strapiErrors:null,data:null,message:null};function y(y){var x=y.data,j=y.sx,A=x.id;x.uuid,x.customer_number;var C=x.first_name,N=x.last_name,B=x.email,S=x.phone,k=x.company_address,R=x.delivery_address,V=x.billing_address,w=x.business_credentials,D=e(u(p,_),2),I=D[0],P=D[1],T=e(h(null!=R),2),F=T[0],U=T[1],z=e(h(null!=V),2),L=z[0],q=z[1],G=v().refreshSession;return b((function(){!I.strapiErrors&&I.message&&G()}),[I]),g.createElement(n,{sx:r([{p:2}],e(Array.isArray(j)?j:[j]),!1),component:a},g.createElement("form",{action:P},g.createElement(m,{spacing:2},g.createElement("input",{type:"hidden",name:"id",value:A}),g.createElement(s,{variant:"h6"},"Personal Details"),g.createElement(t,null),g.createElement(i,{id:"first_name",name:"first_name",label:"First Name",defaultValue:C}),g.createElement(i,{id:"last_name",name:"last_name",label:"Last Name",defaultValue:N}),g.createElement(i,{id:"email",name:"email",label:"Email",defaultValue:B,disabled:!0}),g.createElement(i,{id:"phone",name:"phone",label:"Phone",defaultValue:S}),g.createElement(s,{variant:"h6"},"Business Credentials"),g.createElement(t,null),g.createElement(E,{componentName:"business_credentials",componentReference:"business.credentials",data:w}),g.createElement(s,{variant:"h6"},"Company Address"),g.createElement(t,null),g.createElement(c,{componentName:"company_address",componentReference:"common.address",data:k}),g.createElement(s,{variant:"h6"},"Delivery Address"),g.createElement(t,null),g.createElement(m,{direction:"row",spacing:2,alignItems:"center"},g.createElement(o,{value:F,checked:F,onChange:function(){return U(!F)}}),g.createElement(s,null,"Use a different address for delivery")),F&&g.createElement(c,{componentName:"delivery_address",componentReference:"common.address",data:R}),g.createElement(s,{variant:"h6"},"Billing Address"),g.createElement(t,null),g.createElement(m,{direction:"row",spacing:2,alignItems:"center"},g.createElement(o,{value:L,checked:L,onChange:function(){return q(!L)}}),g.createElement(s,null,"Use a different address for billing")),L&&g.createElement(c,{componentName:"billing_address",componentReference:"common.address",data:V}),g.createElement(m,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},g.createElement(d,{text:"save changes",loadingText:"loading"}),g.createElement(f,{error:null==I?void 0:I.strapiErrors}),(null==I?void 0:I.message)&&g.createElement(l,{severity:"error"},null==I?void 0:I.message)))))}export{y as default};
7
+ import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import a from"@mui/material/Box";import r from"@mui/material/Stack";import n from"@mui/material/Grid";import m from"@mui/material/Divider";import l from"@mui/material/TextField";import i from"@mui/material/Typography";import s from"@mui/material/Checkbox";import o from"@mui/material/Button";import{AddressFields as c}from"../../common/Address.js";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as u}from"react-dom";import{updateCustomerProfileAction as p}from"../../../data/actions/profile-actions.js";import{BusinessCredentialsFields as E}from"./BusinessCredentials.js";import{useSession as f}from"../../../context/auth/SessionContext.js";import v,{useState as g,useEffect as x}from"react";import{useSnackbar as h}from"../../../context/common/SnackbarContext.js";var b={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function y(y){var _=y.data,C=y.sx,j=y.revalidateCallback,k=y.handleClose,A=_.id;_.uuid,_.customer_number;var S=_.first_name,B=_.last_name,N=_.email,w=_.phone,R=_.company_address,V=_.delivery_address,D=_.billing_address,I=_.business_credentials,P=e(u(p,b),2),T=P[0],U=P[1],F=e(g(null!=V),2),z=F[0],G=F[1],L=e(g(null!=D),2),M=L[0],q=L[1],H=f().refreshSession,J=h().handleAddMessage;return x((function(){(null==T?void 0:T.message)&&(J({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(H(),j&&j(),k&&k()))}),[null==T?void 0:T.message]),x((function(){(null==T?void 0:T.strapiErrors)&&J({message:T.strapiErrors.message||"Error updating profile",severity:T.severity||"error"})}),[null==T?void 0:T.strapiErrors]),v.createElement(a,{sx:t([],e(Array.isArray(C)?C:[C]),!1)},v.createElement("form",{action:U},v.createElement(n,{container:!0,spacing:2},v.createElement(n,{item:!0,xs:12},v.createElement(r,{spacing:2},v.createElement(i,{variant:"h3",component:"h1"},"Edit Profile"),v.createElement(i,{variant:"body2"},"Update your personal and business information"))),v.createElement(n,{item:!0,xs:12},v.createElement("input",{type:"hidden",name:"id",value:A}),v.createElement(i,{variant:"h6"},"Personal Details"),v.createElement(m,null),v.createElement(r,{spacing:2,sx:{mt:2}},v.createElement(l,{id:"first_name",name:"first_name",label:"First Name",defaultValue:S}),v.createElement(l,{id:"last_name",name:"last_name",label:"Last Name",defaultValue:B}),v.createElement(l,{id:"email",name:"email",label:"Email",defaultValue:N,disabled:!0}),v.createElement(l,{id:"phone",name:"phone",label:"Phone",defaultValue:w}))),v.createElement(n,{item:!0,xs:12},v.createElement(i,{variant:"h6"},"Business Credentials"),v.createElement(m,null),v.createElement(a,{sx:{mt:2}},v.createElement(E,{componentName:"business_credentials",componentReference:"business.credentials",data:I}))),v.createElement(n,{item:!0,xs:12},v.createElement(i,{variant:"h6"},"Company Address"),v.createElement(m,null),v.createElement(a,{sx:{mt:2}},v.createElement(c,{componentName:"company_address",componentReference:"common.address",data:R}))),v.createElement(n,{item:!0,xs:12},v.createElement(i,{variant:"h6"},"Delivery Address"),v.createElement(m,null),v.createElement(r,{spacing:2,sx:{mt:2}},v.createElement(r,{direction:"row",spacing:2,alignItems:"center"},v.createElement(s,{value:z,checked:z,onChange:function(){return G(!z)}}),v.createElement(i,null,"Use a different address for delivery")),z&&v.createElement(c,{componentName:"delivery_address",componentReference:"common.address",data:V}))),v.createElement(n,{item:!0,xs:12},v.createElement(i,{variant:"h6"},"Billing Address"),v.createElement(m,null),v.createElement(r,{spacing:2,sx:{mt:2}},v.createElement(r,{direction:"row",spacing:2,alignItems:"center"},v.createElement(s,{value:M,checked:M,onChange:function(){return q(!M)}}),v.createElement(i,null,"Use a different address for billing")),M&&v.createElement(c,{componentName:"billing_address",componentReference:"common.address",data:D}))),v.createElement(n,{item:!0,xs:12},v.createElement(r,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},k&&v.createElement(o,{onClick:k,variant:"outlined"},"Cancel"),v.createElement(d,{text:"Save changes",loadingText:"Saving...",variant:"contained"}))))))}export{y as default};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as 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};
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",alignItems:"center",sx:{pt:2}},S&&l.createElement(m,{onClick:S,variant:"outlined"},"Cancel"),l.createElement(v,{text:"Create Invoice",loadingText:"Creating...",variant:"contained"}))))))}export{N as CreateInvoiceForm};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as a,useEffect as o}from"react";import{useFormState as n}from"react-dom";import{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{createIroAction as i}from"../../../data/actions/e-commerce/iro/createIroAction.js";import{SubmitButton as s}from"../../SubmitButton.js";import{CustomerSelector as c}from"../customer/CustomerSelector.js";import{IROItemFields as l}from"./IROItemFields.js";import u from"@mui/material/Typography";import d from"@mui/material/Grid";import p from"@mui/material/Box";import E from"@mui/material/TextField";import f from"@mui/material/Checkbox";import h from"@mui/material/Stack";import v from"@mui/material/Button";var g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function y(y){var x=y.sx,C=y.revalidateCallback,b=y.handleClose,w=y.customerLabels,j=y.productLabels,I=e(a(!1),2),k=I[0],A=I[1],S=e(n(i,g),2),L=S[0],B=S[1],T=m().handleAddMessage;return o((function(){(null==L?void 0:L.message)&&(T({message:L.message,severity:L.severity||"error"}),"success"===L.severity&&(C&&C(),b&&b()))}),[null==L?void 0:L.message]),o((function(){(null==L?void 0:L.strapiErrors)&&T({message:L.strapiErrors.message||"Error creating return order",severity:L.severity||"error"})}),[null==L?void 0:L.strapiErrors]),t.createElement(p,{sx:r([],e(Array.isArray(x)?x:[x]),!1)},t.createElement("form",{action:B},t.createElement(d,{container:!0,spacing:2},t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h3",component:"h1"},"Create new return order"))),t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h6"},"Choose a customer"),t.createElement(u,{variant:"body2"},"Select the customer for which you want to create a return order"),t.createElement(c,{customerLabels:w}))),t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h6"},"Customer reference"),t.createElement(u,null,"If the customer utilizes a custom reference for inbound order management it should be left here"),t.createElement(E,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}}))),t.createElement(d,{item:!0,xs:12},t.createElement(u,{variant:"h6"},"Choose products that should be in this return order"),t.createElement(l,{productsArr:j})),t.createElement(d,{item:!0,xs:12},t.createElement(u,{variant:"h6"},"Confirm Order"),t.createElement(u,null,"Are you sure you want to confirm this return? Confirming this order means you are sure the customer wants to return the products and you are ready to process the return."),t.createElement(h,{direction:"row",spacing:1,alignItems:"center"},t.createElement(f,{value:k,checked:k,onChange:function(){return A(!k)}}),k&&t.createElement(u,{color:"primary"},"I am sure I want to confirm this return order")),t.createElement("input",{name:"status",type:"hidden",value:k?"returning":"requested"})),t.createElement(d,{item:!0,xs:12},t.createElement(h,{direction:"row",justifyContent:"space-between"},t.createElement(v,{onClick:b,variant:"outlined"},"Cancel"),t.createElement(s,{text:"Confirm",loadingText:"Loading...",variant:"contained"}))))))}export{y as default};
7
+ import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as a,useEffect as n}from"react";import{useFormState as o}from"react-dom";import{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{createIroAction as i}from"../../../data/actions/e-commerce/iro/createIroAction.js";import{SubmitButton as s}from"../../SubmitButton.js";import{CustomerSelector as c}from"../customer/CustomerSelector.js";import{IROItemFields as l}from"./IROItemFields.js";import u from"@mui/material/Typography";import d from"@mui/material/Grid";import p from"@mui/material/Box";import E from"@mui/material/TextField";import f from"@mui/material/Checkbox";import h from"@mui/material/Stack";import g from"@mui/material/Button";var v={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,I=y.productLabels,j=e(a(!1),2),k=j[0],A=j[1],S=e(o(i,v),2),L=S[0],B=S[1],T=m().handleAddMessage;return n((function(){(null==L?void 0:L.message)&&(T({message:L.message,severity:L.severity||"error"}),"success"===L.severity&&(C&&C(),b&&b()))}),[null==L?void 0:L.message]),n((function(){(null==L?void 0:L.strapiErrors)&&T({message:L.strapiErrors.message||"Error creating return order",severity:L.severity||"error"})}),[null==L?void 0:L.strapiErrors]),t.createElement(p,{sx:r([],e(Array.isArray(x)?x:[x]),!1)},t.createElement("form",{action:B},t.createElement(d,{container:!0,spacing:2},t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h3",component:"h1"},"Create new return order"))),t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h6"},"Choose a customer"),t.createElement(u,{variant:"body2"},"Select the customer for which you want to create a return order"),t.createElement(c,{customerLabels:w}))),t.createElement(d,{item:!0,xs:12},t.createElement(h,{spacing:2},t.createElement(u,{variant:"h6"},"Customer reference"),t.createElement(u,null,"If the customer utilizes a custom reference for inbound order management it should be left here"),t.createElement(E,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}}))),t.createElement(d,{item:!0,xs:12},t.createElement(u,{variant:"h6"},"Choose products that should be in this return order"),t.createElement(l,{productsArr:I})),t.createElement(d,{item:!0,xs:12},t.createElement(u,{variant:"h6"},"Confirm Order"),t.createElement(u,null,"Are you sure you want to confirm this return? Confirming this order means you are sure the customer wants to return the products and you are ready to process the return."),t.createElement(h,{direction:"row",spacing:1,alignItems:"center"},t.createElement(f,{value:k,checked:k,onChange:function(){return A(!k)}}),k&&t.createElement(u,{color:"primary"},"I am sure I want to confirm this return order")),t.createElement("input",{name:"status",type:"hidden",value:k?"returning":"requested"}))," ",t.createElement(d,{item:!0,xs:12},t.createElement(h,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},b&&t.createElement(g,{onClick:b,variant:"outlined"},"Cancel"),t.createElement(s,{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,__assign as n,__awaiter as r,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import s from"./TextualIROItemUpdater.js";import u from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as p}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import _ from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import q from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as A}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,DialogContentText as j,CircularProgress as T,TextField as W,List as S,ListItem as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import F from"@mui/icons-material/AssignmentReturn";import N from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import M from"@mui/icons-material/Description";import z from"@mui/icons-material/Update";import{IroStatusIndicator as U}from"./IroStatusIndicator.js";import{queryAllProducts as V}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Y from"../../../../node_modules/qs/lib/index.js";import{useSnackbar as Q}from"../../../context/common/SnackbarContext.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function J(c){var m,s,u=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,x=c.iro,C=e(l(!1),2),w=C[0],q=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==x?void 0:x.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&r(u,void 0,void 0,(function(){var e,t,n,r,i,l;return a(this,(function(a){switch(a.label){case 0:return q(!0),e=Y.stringify({filters:{product_number:{$in:x.iro_items.data.map((function(e){var t,n;return(null===(n=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===n?void 0:n.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,V(e)];case 1:return t=a.sent(),n=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",n),q(!1),r=0,i=0,l=x.iro_items.data.map((function(e,t){var a=e.product,l=n.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var s=o*e.returned_quantity,u=c*e.returned_quantity;r+=s,i+=u}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:x.customer_reference||"",total_excl_vat:parseFloat(r.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,x]),i.createElement(E,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(_,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(I,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(j,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(j,{variant:"h5"},"Overwrites"),w?i.createElement(T,null):i.createElement(I,{spacing:2},i.createElement(W,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(n(n({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(W,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(n(n({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(W,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(n(n({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(s=null===(m=null==x?void 0:x.iro_items)||void 0===m?void 0:m.data)||void 0===s?void 0:s.length)>0&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"h5"},"Items"),x.iro_items.data.map((function(r,a){var l,o,c,m,s,u,d,v,E,g,h,_,b,x;return i.createElement(I,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:r.id},i.createElement(y,{sx:{minWidth:100}},r.line_item_number),i.createElement(y,{sx:{minWidth:150}},null===(l=r.product)||void 0===l?void 0:l.product_number),i.createElement(y,{sx:{minWidth:200}},null===(o=r.product)||void 0===o?void 0:o.title),i.createElement(W,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(s=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==s?s:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{vat_rate:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(u=null==p?void 0:p.lines)||void 0===u?void 0:u[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_excl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(h=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==h?h:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{price_incl_vat:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}),i.createElement(W,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(_=null==p?void 0:p.lines)||void 0===_?void 0:_[a])||void 0===b?void 0:b.quantity)&&void 0!==x?x:"",onChange:function(r){var i=t([],e(p.lines||[]),!1);i[a]=n(n({},i[a]),{quantity:parseFloat(r.target.value)}),f(n(n({},p),{lines:i}))}}))}))))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){k("iros",[x.id],p),v()}},"Confirm"),i.createElement(b,{variant:"contained",onClick:v},"Cancel")))}function L(e){var t=e.open,n=e.handleClose,r=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(E,{open:t},i.createElement(_,null,"Confirm Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(S,null,"requested"===a&&i.createElement(O,null,"When confirming this return order a rma number will be generated"),i.createElement(O,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(O,null,"Confirming this order will automatically create an invoice")),i.createElement(y,null,"Current status: ",a))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),n()):"requested"===a&&(k("iros",[r]),l&&l(),n())}},"Yes"),i.createElement(b,{variant:"contained",onClick:n},"No")))}function $(t){var n=t.open,r=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],s=c[1],u=e(l(""),2),d=u[0],v=u[1];return i.createElement("form",null,i.createElement(E,{open:n},i.createElement(_,null,"Cancel Return"),i.createElement(h,null,i.createElement(I,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(S,null,i.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(O,null,"Please provide a reason for the cancellation"),i.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(W,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(A("iros",a,m),o&&o(),r())}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No"))))}function H(r){var a,E,g,h,_=r.data,k=r.sx,A=r.revalidateCallback,j=r.handleClose,T=r.role,W=e(c(m,G),2),S=W[0],O=W[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],H=V[1],K=e(l(!1),2),X=K[0],Z=K[1],ee=e(l(!1),2),te=ee[0],ne=ee[1],re=e(l(!1),2),ae=re[0],ie=re[1],le=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),oe=le[0],ce=le[1],me=e(l(["received","registered","released","reports"]),2),se=me[0],ue=me[1],de=function(n,r,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===r}));i[l][a]=n,H(i)},ve=function(r,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],u=t(t([],e(s),!1),[r],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=u,H(c)},pe=function(n,r){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var u=t(t([],e(m),!1),e(s),!1);l[o].reports.data=u,H(l)},fe=Q().handleAddMessage;return o((function(){"Iro Updated"===(null==S?void 0:S.message)&&(fe({message:"Iro Updated",severity:"success"}),j&&j(),A&&A())}),[S]),o((function(){(null==S?void 0:S.strapiErrors)&&fe({message:S.strapiErrors.message||"Error updating IRO",severity:"error"})}),[null==S?void 0:S.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&H(_.iro_items.data?_.iro_items.data:[])}),[_]),i.createElement(C,{sx:t([],e(Array.isArray(k)?k:[k]),!1)},i.createElement(x,{container:!0,spacing:2},i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(y,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:_.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(y,{variant:"h5",sx:{py:1}},"Details")),i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.rma_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(y,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=_.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(z,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(U,{status:_.status}))))),("requested"===_.status||"finalising_process"===_.status)&&"enduser"===T&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===_.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer recieves a return payment if eligible and than confirm this step. Status: finalising_process - done"),"finalising_process"===_.status&&i.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),i.createElement(L,{open:X,handleClose:function(){return Z(!1)},orderID:_.id,currentStatus:_.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:_}),i.createElement($,{open:te,handleClose:function(){return ne(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(I,{spacing:1})))),(null===(h=null===(g=null==_?void 0:_.notes)||void 0===g?void 0:g.data)||void 0===h?void 0:h.length)>0&&i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(q,null))),i.createElement(x,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(y,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(n){return i.createElement(D,{key:n,control:i.createElement(R,{size:"small",checked:se.includes(n),onChange:function(r){r.target.checked?ue(t(t([],e(se),!1),[n],!1)):ue(se.filter((function(e){return e!==n})))}}),label:i.createElement(y,{variant:"body2",color:"text.secondary"},n.charAt(0).toUpperCase()+n.slice(1)),sx:{mr:0}})}))),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(q,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(Y))}),Y&&Y.map((function(e,t){var n,r;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===_.status||"cancelled"===_.status||"done"===_.status?i.createElement(u,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):i.createElement(s,{item:e,index:t,handleUpdateQuantity:de,handleAddReport:ve,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image,handleRemoveReportAtIndex:pe,revalidateCallback:A,showing:se}))})),i.createElement(I,{direction:"row",justifyContent:"space-between"},i.createElement(b,{onClick:j,variant:"outlined"},"Cancel"),i.createElement(p,{text:"Confirm",loadingText:"Loading...",variant:"contained"})))))))}export{H as default};
6
+ import{__read as e,__spreadArray as t,__assign as r,__awaiter as n,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as l,useEffect as o}from"react";import{useFormState as c}from"react-dom";import{updateIroAction as m}from"../../../data/actions/e-commerce/iro/updateIroAction.js";import s from"./TextualIROItemUpdater.js";import u from"./IroItemDisplay.js";import d from"../../logistics/note/NotesDisplay.js";import v from"../../logistics/note/NoteTakingComponent.js";import{SubmitButton as p}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import _ from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import b from"@mui/material/Button";import x from"@mui/material/Grid";import C from"@mui/material/Box";import w from"@mui/material/Paper";import q from"@mui/material/Stack";import I from"@mui/material/Divider";import{confirmationService as k}from"../../../data/services/common/confirmation-service.js";import{cancellationService as A}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as D,Checkbox as R,DialogContentText as j,CircularProgress as S,TextField as T,List as W,ListItem as O}from"@mui/material";import P from"@mui/icons-material/Numbers";import F from"@mui/icons-material/AssignmentReturn";import N from"@mui/icons-material/CalendarToday";import B from"@mui/icons-material/Business";import M from"@mui/icons-material/Description";import z from"@mui/icons-material/Update";import{IroStatusIndicator as U}from"./IroStatusIndicator.js";import{queryAllProducts as V}from"../../../data/loaders/e-commerce/queryAllProducts.js";import Y from"../../../../node_modules/qs/lib/index.js";import{useSnackbar as Q}from"../../../context/common/SnackbarContext.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function J(c){var m,s,u=this,d=c.open,v=c.handleClose,p=c.overwrites,f=c.setOverwrites,x=c.iro,C=e(l(!1),2),w=C[0],I=C[1];return o((function(){var e,t;d&&(null===(t=null===(e=null==x?void 0:x.iro_items)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)>0&&n(u,void 0,void 0,(function(){var e,t,r,n,i,l;return a(this,(function(a){switch(a.label){case 0:return I(!0),e=Y.stringify({filters:{product_number:{$in:x.iro_items.data.map((function(e){var t,r;return(null===(r=null===(t=e.product)||void 0===t?void 0:t.product_number)||void 0===r?void 0:r.replace(/^r-/,""))||""}))}},populate:{price:!0}},{encodeValuesOnly:!0}),[4,V(e)];case 1:return t=a.sent(),r=t.data.map((function(e){return{id:e.id,product_number:e.product_number,price:e.price}})),console.log("correspondingProducts",r),I(!1),n=0,i=0,l=x.iro_items.data.map((function(e,t){var a=e.product,l=r.find((function(e){var t;return e.product_number===(null===(t=null==a?void 0:a.product_number)||void 0===t?void 0:t.replace(/^r-/,""))||""})),o=0,c=0,m=0;if(l&&l.price){o=l.price.price||0,c=l.price.price_incl_vat||0,m=l.price.vat_rate||0;var s=o*e.returned_quantity,u=c*e.returned_quantity;n+=s,i+=u}return{vat_rate:m,price_excl_vat:o,price_incl_vat:c,quantity:e.returned_quantity}})),f({customer_internal_reference:x.customer_reference||"",total_excl_vat:parseFloat(n.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:l}),[2]}}))}))}),[d,x]),i.createElement(E,{open:d,fullWidth:!0,maxWidth:"lg"},i.createElement(_,null,"Check or overwrite value for the return payment"),i.createElement(h,null,i.createElement(q,{spacing:2,alignItems:"left",sx:{px:0}},i.createElement(j,null,"This is very important because these values will be used for automated invoice generation"),i.createElement(j,{variant:"h5"},"Overwrites"),w?i.createElement(S,null):i.createElement(q,{spacing:2},i.createElement(T,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:p.customer_internal_reference,onChange:function(e){return f(r(r({},p),{customer_internal_reference:e.target.value}))}}),i.createElement(T,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_excl_vat,onChange:function(e){return f(r(r({},p),{total_excl_vat:parseFloat(e.target.value)}))}}),i.createElement(T,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:p.total_incl_vat,onChange:function(e){return f(r(r({},p),{total_incl_vat:parseFloat(e.target.value)}))}})),(null===(s=null===(m=null==x?void 0:x.iro_items)||void 0===m?void 0:m.data)||void 0===s?void 0:s.length)>0&&i.createElement(i.Fragment,null,i.createElement(j,{variant:"h5"},"Items"),x.iro_items.data.map((function(n,a){var l,o,c,m,s,u,d,v,E,g,h,_,b,x;return i.createElement(q,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},key:n.id},i.createElement(y,{sx:{minWidth:100}},n.line_item_number),i.createElement(y,{sx:{minWidth:150}},null===(l=n.product)||void 0===l?void 0:l.product_number),i.createElement(y,{sx:{minWidth:200}},null===(o=n.product)||void 0===o?void 0:o.title),i.createElement(T,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:null!==(s=null===(m=null===(c=null==p?void 0:p.lines)||void 0===c?void 0:c[a])||void 0===m?void 0:m.vat_rate)&&void 0!==s?s:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{vat_rate:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(T,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:null!==(v=null===(d=null===(u=null==p?void 0:p.lines)||void 0===u?void 0:u[a])||void 0===d?void 0:d.price_excl_vat)&&void 0!==v?v:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{price_excl_vat:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(T,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:null!==(h=null===(g=null===(E=null==p?void 0:p.lines)||void 0===E?void 0:E[a])||void 0===g?void 0:g.price_incl_vat)&&void 0!==h?h:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{price_incl_vat:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}),i.createElement(T,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:null!==(x=null===(b=null===(_=null==p?void 0:p.lines)||void 0===_?void 0:_[a])||void 0===b?void 0:b.quantity)&&void 0!==x?x:"",onChange:function(n){var i=t([],e(p.lines||[]),!1);i[a]=r(r({},i[a]),{quantity:parseFloat(n.target.value)}),f(r(r({},p),{lines:i}))}}))}))))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){k("iros",[x.id],p),v()}},"Confirm"),i.createElement(b,{variant:"contained",onClick:v},"Cancel")))}function $(e){var t=e.open,r=e.handleClose,n=e.orderID,a=e.currentStatus,l=e.revalidateCallback,o=e.openOverwritesDialog;return i.createElement(E,{open:t},i.createElement(_,null,"Confirm Return"),i.createElement(h,null,i.createElement(q,{spacing:2},i.createElement(y,null,"Are you sure you want to confirm this return?"),i.createElement(W,null,"requested"===a&&i.createElement(O,null,"When confirming this return order a rma number will be generated"),i.createElement(O,null,"requested"===a?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"),"finalising_process"===a&&i.createElement(O,null,"Confirming this order will automatically create an invoice")),i.createElement(y,null,"Current status: ",a))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){"finalising_process"===a?(o&&o(),r()):"requested"===a&&(k("iros",[n]),l&&l(),r())}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No")))}function H(t){var r=t.open,n=t.handleClose,a=t.orderID,o=t.revalidateCallback,c=e(l(""),2),m=c[0],s=c[1],u=e(l(""),2),d=u[0],v=u[1];return i.createElement("form",null,i.createElement(E,{open:r},i.createElement(_,null,"Cancel Return"),i.createElement(h,null,i.createElement(q,{spacing:2},i.createElement(y,null,"Are you sure you want to cancel this return?"),i.createElement(W,null,i.createElement(O,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(O,null,"Please provide a reason for the cancellation"),i.createElement(O,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(T,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return s(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d}))),i.createElement(g,null,i.createElement(b,{variant:"contained",onClick:function(e){m.length<5?v("Please provide a reason for the cancellation"):(A("iros",a,m),o&&o(),n())}},"Yes"),i.createElement(b,{variant:"contained",onClick:n},"No"))))}function K(n){var a,E,g,h,_=n.data,k=n.sx,A=n.revalidateCallback,j=n.handleClose,S=n.role,T=e(c(m,G),2),W=T[0],O=T[1],V=e(l(_.iro_items.data?_.iro_items.data:[]),2),Y=V[0],K=V[1],L=e(l(!1),2),X=L[0],Z=L[1],ee=e(l(!1),2),te=ee[0],re=ee[1],ne=e(l(!1),2),ae=ne[0],ie=ne[1],le=e(l({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),2),oe=le[0],ce=le[1],me=e(l(["received","registered","released","reports"]),2),se=me[0],ue=me[1],de=function(r,n,a){var i=t([],e(Y),!1),l=i.findIndex((function(e){return e.id===n}));i[l][a]=r,K(i)},ve=function(n,a){var i,l,o,c=t([],e(Y),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(l=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===l?void 0:l.data)||[],u=t(t([],e(s),!1),[n],!1);null==(null===(o=c[m])||void 0===o?void 0:o.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=u,K(c)},pe=function(r,n){var a,i,l=t([],e(Y),!1),o=l.findIndex((function(e){return e.id===r})),c=(null===(i=null===(a=l[o])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var u=t(t([],e(m),!1),e(s),!1);l[o].reports.data=u,K(l)},fe=Q().handleAddMessage;return o((function(){(null==W?void 0:W.message)&&(fe({message:W.message,severity:W.severity||"error"}),"success"===W.severity&&(A&&A(),j&&j()))}),[null==W?void 0:W.message]),o((function(){(null==W?void 0:W.strapiErrors)&&fe({message:W.strapiErrors.message||"Error updating IRO",severity:W.severity||"error"})}),[null==W?void 0:W.strapiErrors]),o((function(){var e;console.log("data",_),(null===(e=_.iro_items)||void 0===e?void 0:e.data)&&K(_.iro_items.data?_.iro_items.data:[])}),[_]),i.createElement(C,{sx:t([],e(Array.isArray(k)?k:[k]),!1)},i.createElement(x,{container:!0,spacing:2},i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:2},i.createElement(q,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(q,{spacing:2},i.createElement(y,{variant:"h3",component:"h1"},"Management Inbound Return"),i.createElement(y,{variant:"body1"},"Manage arrival, registration and release of returns")),i.createElement(v,{content:"",related:[{id:_.id,__type:"api::e-commerce.iro"}],revalidateCallback:A})),i.createElement(I,null))),i.createElement(x,{item:!0,xs:12},i.createElement(y,{variant:"h5",sx:{py:1}},"Details")),i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(q,{spacing:2},i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_number)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"RMA Number"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.rma_number)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer Reference"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.customer_reference)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(N,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Date"),i.createElement(y,{variant:"body1",fontWeight:"medium"},_.return_date)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(y,{variant:"body1",fontWeight:"medium"},null===(E=null===(a=_.customer)||void 0===a?void 0:a.business_credentials)||void 0===E?void 0:E.company_name)),i.createElement(q,{direction:"row",spacing:2,alignItems:"center"},i.createElement(z,{color:"primary"}),i.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Return Status"),i.createElement(U,{status:_.status}))))),("requested"===_.status||"finalising_process"===_.status)&&"enduser"===S&&i.createElement(x,{item:!0,xs:6},i.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(q,{spacing:2},i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return Z(!0)}},"Confirm order"),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"),"finalising_process"===_.status&&i.createElement(f,{severity:"warning"},"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"),"finalising_process"===_.status&&i.createElement(b,{variant:"contained",sx:{color:"yellow"}},"// TODO RE-PAYMENT PROCESS"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return re(!0)}},"Cancel order"),i.createElement($,{open:X,handleClose:function(){return Z(!1)},orderID:_.id,currentStatus:_.status,revalidateCallback:A,openOverwritesDialog:function(){return ie(!0)}}),i.createElement(J,{open:ae,handleClose:function(){return ie(!1)},overwrites:oe,setOverwrites:ce,iro:_}),i.createElement(H,{open:te,handleClose:function(){return re(!1)},orderID:_.id,revalidateCallback:A})))),i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:2},i.createElement(y,{variant:"h5"},"Documents"),i.createElement(w,{sx:{p:2}},i.createElement(q,{spacing:1})))),(null===(h=null===(g=null==_?void 0:_.notes)||void 0===g?void 0:g.data)||void 0===h?void 0:h.length)>0&&i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:2},i.createElement(y,{variant:"h5"},"Notes"),i.createElement(d,{notes:_.notes.data}),i.createElement(I,null))),i.createElement(x,{item:!0,xs:12},i.createElement(q,{spacing:1},i.createElement(y,{variant:"h5"},"Items"),i.createElement(q,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(y,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(D,{key:r,control:i.createElement(R,{size:"small",checked:se.includes(r),onChange:function(n){n.target.checked?ue(t(t([],e(se),!1),[r],!1)):ue(se.filter((function(e){return e!==r})))}}),label:i.createElement(y,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"requested"===_.status&&i.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(I,null),i.createElement("form",{action:O},i.createElement("input",{name:"id",type:"hidden",value:_.id}),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:(null===(r=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===r?void 0:r.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(Y))}),Y&&Y.map((function(e,t){var r,n;return i.createElement(w,{sx:{p:2,mb:2},key:t},"requested"===_.status||"cancelled"===_.status||"done"===_.status?i.createElement(u,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(s,{item:e,index:t,handleUpdateQuantity:de,handleAddReport:ve,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:pe,revalidateCallback:A,showing:se}))})),i.createElement(q,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},j&&i.createElement(b,{onClick:j,variant:"outlined"},"Cancel"),i.createElement(p,{text:"Save changes",loadingText:"Saving...",variant:"contained"})))))))}export{K as default};