umwd-components 0.1.660 → 0.1.662
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai/action-patterns.md +170 -0
- package/.ai/form-patterns.md +21 -0
- package/.ai/instructions/form-patterns.instructions.md +10 -0
- package/.ai/prompts/form-patterns.prompt.md +15 -0
- package/.ai/prompts/update-form-and-actions.prompt.md +5 -0
- package/dist/node_modules/base64-js/index.js +1 -1
- package/dist/node_modules/ieee754/index.js +1 -1
- package/dist/src/components/e-commerce/enduser/EnduserProfileDisplay.js +7 -0
- package/dist/src/components/e-commerce/enduser/EnduserProfileEditForm.js +7 -0
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/src/components/logistics/dispatcher/DispatcherProfileEditForm.js +1 -1
- package/dist/src/components/logistics/ipo/AddIPOForm.js +1 -1
- package/dist/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/src/components/logistics/vendor/AddVendorForm.js +1 -1
- package/dist/src/components/logistics/vendor/EditVendorForm.js +1 -1
- package/dist/src/data/actions/e-commerce/enduser/profile-actions.js +7 -0
- package/dist/src/data/actions/logistics/dispatcher/profile-actions.js +1 -1
- package/dist/src/data/actions/logistics/ipo/createIPOAction.js +1 -1
- package/dist/src/data/actions/logistics/ipo/updateIpoAction.js +1 -1
- package/dist/src/data/actions/logistics/vendor/createVendorAction.js +1 -1
- package/dist/src/data/actions/logistics/vendor/updateVendorAction.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/e-commerce/enduser/EnduserProfileDisplay.d.ts +13 -0
- package/dist/types/components/e-commerce/enduser/EnduserProfileEditForm.d.ts +9 -0
- package/dist/types/components/logistics/ipo/AddIPOForm.d.ts +3 -1
- package/dist/types/components/logistics/ipo/TextualManageIPOForm.d.ts +1 -1
- package/dist/types/components/logistics/vendor/AddVendorForm.d.ts +7 -2
- package/dist/types/components/logistics/vendor/EditVendorForm.d.ts +5 -2
- package/dist/types/data/actions/e-commerce/enduser/profile-actions.d.ts +1 -0
- package/dist/types/data/actions/logistics/dispatcher/profile-actions.d.ts +1 -1
- package/dist/types/data/actions/logistics/ipo/updateIpoAction.d.ts +1 -1
- package/dist/types/data/actions/logistics/vendor/updateVendorAction.d.ts +9 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types/e-commerce/enduser/types.d.ts +14 -0
- package/package.json +1 -1
- package/src/components/e-commerce/enduser/EnduserProfileDisplay.tsx +100 -0
- package/src/components/e-commerce/enduser/EnduserProfileEditForm.tsx +145 -0
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +0 -1
- package/src/components/logistics/dispatcher/DispatcherProfileEditForm.tsx +2 -5
- package/src/components/logistics/ipo/AddIPOForm.tsx +58 -25
- package/src/components/logistics/ipo/ManageIPOForm.tsx +95 -133
- package/src/components/logistics/ipo/TextualManageIPOForm.tsx +165 -118
- package/src/components/logistics/vendor/AddVendorForm.tsx +46 -36
- package/src/components/logistics/vendor/EditVendorForm.tsx +48 -35
- package/src/data/actions/e-commerce/enduser/profile-actions.ts +47 -0
- package/src/data/actions/logistics/dispatcher/profile-actions.ts +6 -8
- package/src/data/actions/logistics/ipo/createIPOAction.ts +8 -9
- package/src/data/actions/logistics/ipo/updateIpoAction.ts +12 -7
- package/src/data/actions/logistics/vendor/createVendorAction.tsx +43 -27
- package/src/data/actions/logistics/vendor/updateVendorAction.tsx +59 -27
- package/src/index.ts +3 -0
- package/src/types/e-commerce/enduser/types.ts +15 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Action Patterns
|
|
2
|
+
|
|
3
|
+
## Server Action Parameter Pattern
|
|
4
|
+
|
|
5
|
+
### Setup
|
|
6
|
+
|
|
7
|
+
1. Action Definition:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
export async function updateEntityAction(
|
|
11
|
+
id: EntityId, // Entity identifier first
|
|
12
|
+
prevState: any, // Form state second
|
|
13
|
+
formData: FormData // Form data last
|
|
14
|
+
) {
|
|
15
|
+
// action implementation
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Form Implementation:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
const boundAction = updateEntityAction.bind(null, entityId);
|
|
23
|
+
const [formState, formAction] = useFormState(boundAction, INITIAL_STATE);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Implementation Pattern
|
|
27
|
+
|
|
28
|
+
1. Action Structure:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
export async function updateEntityAction(
|
|
32
|
+
id: number,
|
|
33
|
+
prevState: any,
|
|
34
|
+
formData: FormData
|
|
35
|
+
) {
|
|
36
|
+
// 1. Parse form data if needed
|
|
37
|
+
const parsedData = parseFormData(formData);
|
|
38
|
+
|
|
39
|
+
// 2. Call API or service
|
|
40
|
+
const responseData = await mutateData(
|
|
41
|
+
"PUT",
|
|
42
|
+
`/api/entities/${id}`,
|
|
43
|
+
parsedData
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// 3. Handle error cases
|
|
47
|
+
if (!responseData) {
|
|
48
|
+
return {
|
|
49
|
+
...prevState,
|
|
50
|
+
severity: "error",
|
|
51
|
+
strapiErrors: null,
|
|
52
|
+
message: "Operation failed. Please try again.",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 4. Return success result
|
|
57
|
+
return {
|
|
58
|
+
...prevState,
|
|
59
|
+
severity: "success",
|
|
60
|
+
message: "Operation completed successfully",
|
|
61
|
+
data: responseData,
|
|
62
|
+
strapiErrors: null,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Key Features
|
|
68
|
+
|
|
69
|
+
1. **Parameter Order by Action Type**:
|
|
70
|
+
|
|
71
|
+
For Update Actions:
|
|
72
|
+
|
|
73
|
+
- Entity identifiers come first (id, uuid, etc.)
|
|
74
|
+
- prevState is always second
|
|
75
|
+
- formData is always last
|
|
76
|
+
|
|
77
|
+
For Create Actions:
|
|
78
|
+
|
|
79
|
+
- prevState is always first
|
|
80
|
+
- formData is always second
|
|
81
|
+
- No entity identifiers needed
|
|
82
|
+
|
|
83
|
+
2. **Action Binding**:
|
|
84
|
+
|
|
85
|
+
- Only used for update operations on specific entities
|
|
86
|
+
- Use Function.bind() to pre-fill entity parameters
|
|
87
|
+
- Bind with null as first argument
|
|
88
|
+
- Not needed for creation actions
|
|
89
|
+
|
|
90
|
+
3. **Response Structure**:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
{
|
|
94
|
+
...prevState, // Always preserve previous state
|
|
95
|
+
severity: string, // "success" | "error"
|
|
96
|
+
message: string, // User-friendly message
|
|
97
|
+
data?: any, // Optional updated entity data
|
|
98
|
+
strapiErrors?: any // Optional Strapi error details
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Best Practices
|
|
103
|
+
|
|
104
|
+
1. **Error Handling**:
|
|
105
|
+
|
|
106
|
+
- Always return prevState spread first
|
|
107
|
+
- Include user-friendly error messages
|
|
108
|
+
- Provide appropriate severity levels
|
|
109
|
+
- Handle API errors consistently
|
|
110
|
+
|
|
111
|
+
2. **Success Handling**:
|
|
112
|
+
|
|
113
|
+
- Return updated data when available
|
|
114
|
+
- Clear error states on success
|
|
115
|
+
- Set appropriate success message
|
|
116
|
+
- Use "success" severity
|
|
117
|
+
|
|
118
|
+
3. **Code Organization**:
|
|
119
|
+
|
|
120
|
+
- Group related actions in feature folders
|
|
121
|
+
- Use consistent file naming (e.g., updateEntityAction.ts)
|
|
122
|
+
- Export actions as named exports
|
|
123
|
+
- Include proper TypeScript types
|
|
124
|
+
|
|
125
|
+
## Server Action Types
|
|
126
|
+
|
|
127
|
+
### 1. Entity Update Actions
|
|
128
|
+
|
|
129
|
+
These actions modify an existing entity and therefore require the entity ID as
|
|
130
|
+
the first parameter.
|
|
131
|
+
|
|
132
|
+
1. Action Definition:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
export async function updateEntityAction(
|
|
136
|
+
id: EntityId, // Entity identifier first
|
|
137
|
+
prevState: any, // Form state second
|
|
138
|
+
formData: FormData // Form data last
|
|
139
|
+
) {
|
|
140
|
+
// action implementation
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
2. Form Implementation:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const boundAction = updateEntityAction.bind(null, entityId);
|
|
148
|
+
const [formState, formAction] = useFormState(boundAction, INITIAL_STATE);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 2. Entity Creation Actions
|
|
152
|
+
|
|
153
|
+
These actions create new entities and don't require pre-bound parameters.
|
|
154
|
+
|
|
155
|
+
1. Action Definition:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
export async function createEntityAction(
|
|
159
|
+
prevState: any, // Form state first
|
|
160
|
+
formData: FormData // Form data second
|
|
161
|
+
) {
|
|
162
|
+
// action implementation
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
2. Form Implementation:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
const [formState, formAction] = useFormState(createEntityAction, INITIAL_STATE);
|
|
170
|
+
```
|
package/.ai/form-patterns.md
CHANGED
|
@@ -132,6 +132,27 @@ styling:
|
|
|
132
132
|
- Remove StrapiErrors component as errors are shown in Snackbar
|
|
133
133
|
- Success messages automatically close the form and revalidate data
|
|
134
134
|
|
|
135
|
+
### Form Action Setup
|
|
136
|
+
|
|
137
|
+
1. Action Binding Pattern:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// For actions that require an ID or other parameters
|
|
141
|
+
const boundAction = actionFunction.bind(null, entityId);
|
|
142
|
+
const [formState, formAction] = useFormState(boundAction, INITIAL_STATE);
|
|
143
|
+
|
|
144
|
+
// Example with type:
|
|
145
|
+
const updateEntityWithIdAction = updateEntityAction.bind(null, entity.id);
|
|
146
|
+
const [formState, formAction] = useFormState(updateEntityWithIdAction, INITIAL_STATE);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This pattern ensures:
|
|
150
|
+
|
|
151
|
+
- Clean separation of entity ID from form data
|
|
152
|
+
- Consistent action parameter order
|
|
153
|
+
- Type safety for bound parameters
|
|
154
|
+
- Clear distinction between entity parameters and form data
|
|
155
|
+
|
|
135
156
|
### Example Usage
|
|
136
157
|
|
|
137
158
|
```typescript
|
|
@@ -36,6 +36,16 @@ const INITIAL_STATE = {
|
|
|
36
36
|
};
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
4. Setup form action binding:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// For forms that operate on an entity
|
|
43
|
+
const boundAction = actionFunction.bind(null, entity.id);
|
|
44
|
+
const [formState, formAction] = useFormState(boundAction, INITIAL_STATE);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Note: Always bind entity IDs and other fixed parameters to the action, rather than including them in the form data.
|
|
48
|
+
|
|
39
49
|
## Required Form Structure
|
|
40
50
|
|
|
41
51
|
1. **Base Structure**:
|
|
@@ -31,6 +31,7 @@ are followed:
|
|
|
31
31
|
- Verify INITIAL_STATE includes all required fields
|
|
32
32
|
- Check useFormState implementation
|
|
33
33
|
- Validate form action setup
|
|
34
|
+
- Ensure entity IDs are bound to action using bind pattern
|
|
34
35
|
|
|
35
36
|
2. **Message Handling**
|
|
36
37
|
|
|
@@ -99,6 +100,20 @@ handleAddMessage({
|
|
|
99
100
|
</Stack>
|
|
100
101
|
```
|
|
101
102
|
|
|
103
|
+
4. **Action Binding Fixes**
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Convert from
|
|
107
|
+
const [formState, formAction] = useFormState(
|
|
108
|
+
(prevState, formData) => updateAction(id, prevState, formData),
|
|
109
|
+
INITIAL_STATE
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// To
|
|
113
|
+
const boundAction = updateAction.bind(null, id);
|
|
114
|
+
const [formState, formAction] = useFormState(boundAction, INITIAL_STATE);
|
|
115
|
+
```
|
|
116
|
+
|
|
102
117
|
### Response Guidelines
|
|
103
118
|
|
|
104
119
|
When helping users with forms:
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__exports as r}from"../../_virtual/
|
|
6
|
+
import{__exports as r}from"../../_virtual/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};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__exports as a}from"../../_virtual/
|
|
6
|
+
import{__exports as a}from"../../_virtual/index7.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};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
import e from"react";import t from"@mui/material/Paper";import r from"@mui/material/Stack";import a from"@mui/material/Typography";import i from"@mui/material/Button";import m from"@mui/material/Divider";import n from"@mui/material/Grid";import o from"@mui/material/Alert";import l from"../../common/Address.js";import s from"../customer/BusinessCredentials.js";import{StyledLink as c}from"../../StyledLink.js";import{usePathname as d}from"next/navigation";function u(u){var p=u.data,f=p.private_address,E=p.company_address,v=p.business_credentials,y=p.editProfileUrl,g=void 0===y?"/dashboard/enduser/user/profile/edit":y,h=p.completeEnough,x=void 0!==h&&h,b=d().includes("/user/");return e.createElement(t,{sx:{p:2}},e.createElement(r,{spacing:2},b&&e.createElement(e.Fragment,null,Boolean(x)?e.createElement(r,{direction:"row",justifyContent:"flex-end"},e.createElement(c,{href:g,target:"_self"},e.createElement(i,{variant:"contained"},"edit profile"))):e.createElement(o,{severity:"warning",action:e.createElement(c,{href:g,target:"_self"},e.createElement(i,{variant:"contained"},"complete profile"))},"After completion of your profile you can enjoy all the benefits of your services.")),v?e.createElement(s,{data:v}):e.createElement(a,null,"Business credentials not available"),e.createElement(m,null)," ",e.createElement(n,{container:!0,spacing:2,sx:{width:"100%"}},e.createElement(n,{item:!0,xs:12,md:6},e.createElement(a,{variant:"h6",gutterBottom:!0},"Company Address"),E?e.createElement(l,{data:E}):e.createElement(a,null,"Company address not available")),e.createElement(n,{item:!0,xs:12,md:6},e.createElement(a,{variant:"h6",gutterBottom:!0},"Private Address"),f?e.createElement(l,{data:f}):e.createElement(a,null,"Private address not available")))))}export{u as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r from"@mui/material/Divider";import a from"@mui/material/Paper";import m from"@mui/material/Box";import n from"@mui/material/Stack";import s from"@mui/material/Grid";import o from"@mui/material/Button";import i from"@mui/material/Typography";import{AddressFields as l}from"../../common/Address.js";import{BusinessCredentialsFields as c}from"../customer/BusinessCredentials.js";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as p}from"react-dom";import{updateEnduserProfileAction as u}from"../../../data/actions/e-commerce/enduser/profile-actions.js";import{useSession as E}from"../../../context/auth/SessionContext.js";import{useSnackbar as f}from"../../../context/common/SnackbarContext.js";import v,{useEffect as x}from"react";var g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function b(b){var y=b.data,h=b.sx,C=b.revalidateCallback,B=b.handleClose,j=y.id,S=y.private_address,_=y.company_address,A=y.business_credentials,k=u.bind(null,parseInt(j)),N=e(p(k,g),2),P=N[0],R=N[1],w=f().handleAddMessage,I=E().refreshSession;return x((function(){(null==P?void 0:P.message)&&(w({message:P.message,severity:P.severity||"error"}),"success"===P.severity&&(I(),C&&C(),B&&B()))}),[null==P?void 0:P.message]),x((function(){(null==P?void 0:P.strapiErrors)&&w({message:P.strapiErrors.message||"Error performing action",severity:"error"})}),[null==P?void 0:P.strapiErrors]),v.createElement(m,{sx:t([],e(Array.isArray(h)?h:[h]),!1)},v.createElement("form",{action:R},v.createElement(s,{container:!0,spacing:2},v.createElement(s,{item:!0,xs:12},v.createElement(n,{spacing:2},v.createElement(i,{variant:"h3",component:"h1",gutterBottom:!0},"Edit Profile"))),v.createElement(s,{item:!0,xs:12},v.createElement(a,{sx:{p:2}},v.createElement(i,{variant:"h6",gutterBottom:!0},"Business Credentials"),v.createElement(r,{sx:{mb:2}}),v.createElement(c,{componentName:"business_credentials",componentReference:"business.credentials",data:A})))," ",v.createElement(s,{item:!0,xs:12},v.createElement(a,{sx:{p:2}},v.createElement(i,{variant:"h6",gutterBottom:!0},"Company Address"),v.createElement(r,{sx:{mb:2}}),v.createElement(l,{componentName:"company_address",componentReference:"common.address",data:_}))),v.createElement(s,{item:!0,xs:12},v.createElement(a,{sx:{p:2}},v.createElement(i,{variant:"h6",gutterBottom:!0},"Private Address"),v.createElement(r,{sx:{mb:2}}),v.createElement(l,{componentName:"private_address",componentReference:"common.address",data:S}))),v.createElement(s,{item:!0,xs:12},v.createElement(n,{direction:"row",justifyContent:"space-between",spacing:2,alignItems:"center",sx:{mt:2}},B&&v.createElement(o,{onClick:B,variant:"outlined"},"Cancel"),v.createElement(d,{text:"Save Changes",loadingText:"Saving...",variant:"contained"}))))))}export{b 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 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 s from"./TextualOpoItemUpdater.js";import d 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 g from"@mui/material/DialogContent";import h 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 O,List as A,ListItem as N,TextField as q}from"@mui/material";import S from"@mui/icons-material/Numbers";import B from"@mui/icons-material/CalendarToday";import P from"@mui/icons-material/Business";import T from"@mui/icons-material/Description";import F from"@mui/icons-material/Update";import{OpoStatusIndicator as U}from"./OpoStatusIndicator.js";import{useSnackbar as R}from"../../../context/common/SnackbarContext.js";import{SubmitButton as W}from"../../SubmitButton.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},Y=["picked","packed","shipped","reports"];function z(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(h,null,"Confirm Order"),r.createElement(g,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 G(t){var n=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],s=c[1],d=e(a(""),2),u=d[0],p=d[1];return r.createElement("form",null,r.createElement(E,{open:n},r.createElement(h,null,"Cancel Return"),r.createElement(g,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(A,null,r.createElement(N,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(N,null,"Please provide a reason for the cancellation"),r.createElement(N,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(q,{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:!!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 H(E){var f,g,h,I,D,A=E.opo,N=E.sx,q=E.revalidateCallback,H=E.handleClose,J=E.role,Q=l.bind(null,A.id),K=e(o(Q,M),2),L=K[0],V=K[1],X=R().handleAddMessage,Z=e(a(A.opo_items.data?A.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(a(!1),2),ne=te[0],re=te[1],ae=e(a(!1),2),ie=ae[0],oe=ae[1],le=e(a(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];i((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==q||q(),null==H||H()))}),[null==L?void 0:L.message]),i((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),i((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&ee(A.opo_items.data?A.opo_items.data:[])}),[A]);var se=function(n,r,a){var i=t([],e($),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,ee(i)},de=function(r,a){var i,o,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!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=d,ee(c)},ue=function(n,r){var a,i,o=t([],e($),!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})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,ee(o)};return r.createElement(C,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},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:A.id,__type:"api::e-commerce.opo"}],revalidateCallback:q})),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(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(g=null===(f=A.customer)||void 0===f?void 0:f.business_credentials)||void 0===g?void 0:g.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(F,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(U,{status:A.status}))))),"enduser"===J&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===A.status||"external_shipping_process"===A.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return re(!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(z,{open:ne,handleClose:function(){return re(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:q})),("placed"===A.status||"ordered"===A.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return oe(!0)}},"Cancel order"),r.createElement(G,{open:ie,handleClose:function(){return oe(!1)},orderID:A.id,revalidateCallback:q}))))),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},A.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(h=A.delivery_note)||void 0===h?void 0:h.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(A.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: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:q})))))),(null===(D=null===(I=null==A?void 0:A.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:A.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:"),Y.map((function(n){return r.createElement(j,{key:n,control:r.createElement(O,{checked:ce.includes(n),onChange:function(r){r.target.checked?me(t(t([],e(ce),!1),[n],!1)):me(ce.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===A.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:V},r.createElement("input",{name:"id",type:"hidden",value:A.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}})))||[]}}))}($))}),$&&$.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===A.status||"external_shipping_process"===A.status||"done"===A.status||"cancelled"===A.status?r.createElement(d,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(s,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ue,revalidateCallback:q,showing:ce}))}))," ",r.createElement(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},H&&r.createElement(x,{onClick:H,variant:"outlined"},"Cancel"),r.createElement(W,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{H 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 s from"./TextualOpoItemUpdater.js";import d 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 g from"@mui/material/DialogContent";import h 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 O,List as A,ListItem as N,TextField as q}from"@mui/material";import S from"@mui/icons-material/Numbers";import B from"@mui/icons-material/CalendarToday";import P from"@mui/icons-material/Business";import T from"@mui/icons-material/Description";import F from"@mui/icons-material/Update";import{OpoStatusIndicator as U}from"./OpoStatusIndicator.js";import{useSnackbar as R}from"../../../context/common/SnackbarContext.js";import{SubmitButton as W}from"../../SubmitButton.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},Y=["picked","packed","shipped","reports"];function z(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(h,null,"Confirm Order"),r.createElement(g,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 G(t){var n=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],s=c[1],d=e(a(""),2),u=d[0],p=d[1];return r.createElement("form",null,r.createElement(E,{open:n},r.createElement(h,null,"Cancel Return"),r.createElement(g,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(A,null,r.createElement(N,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(N,null,"Please provide a reason for the cancellation"),r.createElement(N,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(q,{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:!!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 H(E){var f,g,h,I,D,A=E.opo,N=E.sx,q=E.revalidateCallback,H=E.handleClose,J=E.role,Q=l.bind(null,A.id),K=e(o(Q,M),2),L=K[0],V=K[1],X=R().handleAddMessage,Z=e(a(A.opo_items.data?A.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(a(!1),2),ne=te[0],re=te[1],ae=e(a(!1),2),ie=ae[0],oe=ae[1],le=e(a(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];i((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==q||q(),null==H||H()))}),[null==L?void 0:L.message]),i((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),i((function(){var e;(null===(e=A.opo_items)||void 0===e?void 0:e.data)&&ee(A.opo_items.data?A.opo_items.data:[])}),[A]);var se=function(n,r,a){var i=t([],e($),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,ee(i)},de=function(r,a){var i,o,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!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=d,ee(c)},ue=function(n,r){var a,i,o=t([],e($),!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})),s=c.filter((function(e){return!("id"in e)}));s.splice(r,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,ee(o)};return r.createElement(C,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},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:A.id,__type:"api::e-commerce.opo"}],revalidateCallback:q})),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(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},A.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(g=null===(f=A.customer)||void 0===f?void 0:f.business_credentials)||void 0===g?void 0:g.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(F,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(U,{status:A.status}))))),"enduser"===J&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===A.status||"external_shipping_process"===A.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return re(!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(z,{open:ne,handleClose:function(){return re(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:q})),("placed"===A.status||"ordered"===A.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return oe(!0)}},"Cancel order"),r.createElement(G,{open:ie,handleClose:function(){return oe(!1)},orderID:A.id,revalidateCallback:q}))))),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},A.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(h=A.delivery_note)||void 0===h?void 0:h.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(A.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: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:q})))))),(null===(D=null===(I=null==A?void 0:A.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:A.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:"),Y.map((function(n){return r.createElement(j,{key:n,control:r.createElement(O,{checked:ce.includes(n),onChange:function(r){r.target.checked?me(t(t([],e(ce),!1),[n],!1)):me(ce.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===A.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:V},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}})))||[]}}))}($))}),$&&$.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===A.status||"external_shipping_process"===A.status||"done"===A.status||"cancelled"===A.status?r.createElement(d,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(s,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ue,revalidateCallback:q,showing:ce}))}))," ",r.createElement(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},H&&r.createElement(x,{onClick:H,variant:"outlined"},"Cancel"),r.createElement(W,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{H as default};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r from"@mui/material/Divider";import a from"@mui/material/Paper";import
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r from"@mui/material/Divider";import a from"@mui/material/Paper";import s from"@mui/material/Box";import m from"@mui/material/Stack";import n from"@mui/material/Grid";import o from"@mui/material/Typography";import i from"@mui/material/Button";import{AddressFields as l}from"../../common/Address.js";import{SubmitButton as c}from"../../SubmitButton.js";import{useFormState as d}from"react-dom";import{updateDispatcherProfileAction as u}from"../../../data/actions/logistics/dispatcher/profile-actions.js";import{BusinessCredentialsFields as p}from"../../e-commerce/customer/BusinessCredentials.js";import{useSession as f}from"../../../context/auth/SessionContext.js";import{useSnackbar as E}from"../../../context/common/SnackbarContext.js";import g,{useEffect as v}from"react";var x={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function b(b){var h=b.data,y=b.sx,C=b.revalidateCallback,j=b.handleClose,B=h.id;h.uuid,h.dispatcher_number;var S=h.address,A=h.business_credentials,k=u.bind(null,parseInt(B)),_=e(d(k,x),2),w=_[0],I=_[1],N=E().handleAddMessage,P=f().refreshSession;return v((function(){(null==w?void 0:w.message)&&(N({message:w.message,severity:w.severity||"error"}),"success"===w.severity&&(P(),C&&C(),j&&j()))}),[null==w?void 0:w.message]),v((function(){(null==w?void 0:w.strapiErrors)&&N({message:w.strapiErrors.message||"Error performing action",severity:"error"})}),[null==w?void 0:w.strapiErrors]),g.createElement(s,{sx:t([],e(Array.isArray(y)?y:[y]),!1)},g.createElement("form",{action:I},g.createElement(n,{container:!0,spacing:2},g.createElement(n,{item:!0,xs:12},g.createElement(m,{spacing:2},g.createElement(o,{variant:"h3",component:"h1",gutterBottom:!0},"Edit Profile"))),g.createElement(n,{item:!0,xs:12},g.createElement(a,{sx:{p:2}},g.createElement(o,{variant:"h6",gutterBottom:!0},"Business Credentials"),g.createElement(r,{sx:{mb:2}}),g.createElement(p,{componentName:"business_credentials",componentReference:"business.credentials",data:A}))),g.createElement(n,{item:!0,xs:12},g.createElement(a,{sx:{p:2}},g.createElement(o,{variant:"h6",gutterBottom:!0},"Company Address"),g.createElement(r,{sx:{mb:2}}),g.createElement(l,{componentName:"address",componentReference:"common.address",data:S}))),g.createElement(n,{item:!0,xs:12},g.createElement(m,{direction:"row",justifyContent:"space-between",spacing:2,alignItems:"center",sx:{mt:2}},j&&g.createElement(i,{onClick:j,variant:"outlined"},"Cancel"),g.createElement(c,{text:"Save Changes",loadingText:"Saving...",variant:"contained"}))))))}export{b 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,__awaiter as t,__generator as
|
|
7
|
+
import{__read as e,__spreadArray as r,__awaiter as t,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import o,{useState as n,useEffect as i}from"react";import m from"@mui/material/Box";import l from"@mui/material/Stack";import s from"@mui/material/TextField";import c from"@mui/material/Typography";import d from"@mui/material/Divider";import u from"@mui/material/Button";import{SubmitButton as p}from"../../SubmitButton.js";import{useFormState as f}from"react-dom";import{createIPOAction as v}from"../../../data/actions/logistics/ipo/createIPOAction.js";import E from"@mui/material/Grid";import g from"../vendor/VendorSelector.js";import{getSingleVendor as x}from"../../../data/loaders/logistics/getSingleVendor.js";import{IPOItemFields as y}from"./IPOItemFields.js";import{AdapterDayjs as h}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as b}from"@mui/x-date-pickers/LocalizationProvider";import{DatePicker as C}from"@mui/x-date-pickers/DatePicker";import{useSnackbar as j}from"../../../context/common/SnackbarContext.js";var A={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k(k){var I=this,P=k.vendorNamesArr,D=k.sx,O=k.revalidateCallback,S=k.handleClose,w=e(f(v,A),2),T=w[0],V=w[1],_=e(n([]),2),B=_[0],N=_[1],z=e(n(null),2),F=z[0],G=z[1],L=j().handleAddMessage;i((function(){(null==T?void 0:T.message)&&(L({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(O&&O(),S&&S()))}),[null==T?void 0:T.message]),i((function(){(null==T?void 0:T.strapiErrors)&&L({message:T.strapiErrors.message||"Error performing action",severity:"error"})}),[null==T?void 0:T.strapiErrors]);return o.createElement(m,{sx:r([],e(Array.isArray(D)?D:[D]),!1)},o.createElement("form",{action:V},o.createElement(E,{container:!0,spacing:2},o.createElement(E,{item:!0,xs:12},o.createElement(l,{spacing:2},o.createElement(c,{variant:"h3",component:"h1"},"Add IPO"),o.createElement(c,{variant:"body1"},"Create a new incoming purchase order"))),o.createElement(E,{item:!0,xs:12,md:6,sx:{mt:1}},P?o.createElement(g,{vendorNames:P,currentValue:null,onSelectVendor:function(e){return t(I,void 0,void 0,(function(){var r,t;return a(this,(function(a){switch(a.label){case 0:return G(e),e?[4,x(e)]:(N([]),[2]);case 1:return r=a.sent(),N(null===(t=null==r?void 0:r.products)||void 0===t?void 0:t.data),[2]}}))}))}}):o.createElement(c,null,"No vendors on file, you need to create a vendor first before you are able to create incoming purchase orders")),o.createElement(E,{item:!0,xs:12},o.createElement(l,{spacing:2},o.createElement(c,{variant:"h5"},"Order Details"),o.createElement(c,{variant:"body1"},"The orderdate should be the official date of the order, don't worry, you can also set days in the past or future"),o.createElement(b,{dateAdapter:h},o.createElement(C,{name:"order_date",label:"Order Date"})),o.createElement(c,{variant:"body1"},"Please enter a custom reference for this order"),o.createElement(s,{id:"customer_reference",name:"customer_reference",type:"text",label:"Custom Reference"}),o.createElement(d,null))),o.createElement(E,{item:!0,xs:12},o.createElement(y,{productsArr:B,vendorID:F})),o.createElement(E,{item:!0,xs:12},o.createElement(l,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:2}},S&&o.createElement(u,{onClick:S,variant:"outlined"},"Cancel"),o.createElement(p,{text:"Create IPO",loadingText:"Creating...",variant:"contained"}))))))}export{k as AddIPOForm};
|
|
@@ -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 a,{useState as r}from"react";import{useFormState as
|
|
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{useSnackbar as o}from"../../../context/common/SnackbarContext.js";import{updateIpoAction as l}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{UploadBase64MediaForm as m}from"../../common/media/UploadBase64MediaForm.js";import c from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./IPOItemUpdater.js";import s from"./ItemDisplay.js";import p from"../note/NotesDisplay.js";import u from"../note/NoteTakingComponent.js";import{SubmitButton as v}from"../../SubmitButton.js";import{confirmationService as E}from"../../../data/services/common/confirmation-service.js";import f from"@mui/material/Alert";import g from"@mui/material/Dialog";import y from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import b from"@mui/material/DialogTitle";import x from"@mui/material/Typography";import C from"@mui/material/Button";import _ from"@mui/material/Grid";import w from"@mui/material/Box";import k from"@mui/material/Paper";import D from"@mui/material/Stack";import j from"@mui/material/Divider";var I={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function O(e){var t=e.open,r=e.handleClose,n=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return a.createElement(g,{open:t},a.createElement(b,null,"Confirm Order"),a.createElement(h,null,a.createElement(D,{spacing:2},a.createElement(x,null,"Are you sure you want to confirm this order?"),a.createElement(x,null,"Current status: ",i))),a.createElement(y,null,a.createElement(C,{variant:"contained",onClick:function(e){E("ipos",[n]),o&&o(),r()}},"Confirm"),a.createElement(C,{variant:"outlined",onClick:r},"Cancel")))}function N(E){var g,y,h,b,N,S,U,A=E.data,q=E.sx,B=E.revalidateCallback,P=E.handleClose,F=E.role,T=e(i((function(e,t){return l(A.id,e,t)}),I),2),M=T[0],R=T[1],z=o().handleAddMessage,G=e(r(A.items.data?A.items.data:[]),2),J=G[0],Q=G[1],H=e(r(!1),2),K=H[0],L=H[1];n((function(){(null==M?void 0:M.message)&&(z({message:M.message,severity:M.severity||"error"}),"success"===M.severity&&(B&&B(),P&&P()))}),[null==M?void 0:M.message]),n((function(){(null==M?void 0:M.strapiErrors)&&z({message:M.strapiErrors.message||"Error performing action",severity:"error"})}),[null==M?void 0:M.strapiErrors]);var V=function(a,r,n){var i=t([],e(J),!1),o=i.findIndex((function(e){return e.id===r}));i[o][n]=a,Q(i)};return a.createElement(w,{sx:t([],e(Array.isArray(q)?q:[q]),!1)},a.createElement(_,{container:!0,spacing:2},a.createElement(_,{item:!0,xs:12},a.createElement(D,{spacing:2},a.createElement(D,{direction:"row",spacing:2,justifyContent:"space-between"},a.createElement(D,{spacing:2},a.createElement(x,{variant:"h3",component:"h1"},"Manage Inbound Purchase Order"),a.createElement(x,{variant:"body1"},"Update the incoming purchase order details")),a.createElement(u,{content:"",related:[{id:A.id,__type:"api::logistics.ipo"}],revalidateCallback:B})),a.createElement(j,null))),a.createElement(_,{item:!0,xs:6},a.createElement(D,{spacing:1},a.createElement(x,{variant:"h5"},"Details"),a.createElement(D,{direction:"row",spacing:2},a.createElement(x,{variant:"body1",width:"250px"},"Purchase Order Number"),a.createElement(x,{variant:"body2"},A.ipo_number)),a.createElement(D,{direction:"row",spacing:2},a.createElement(x,{variant:"body1",width:"250px"},"Custom reference"),a.createElement(x,{variant:"body2"},A.customer_reference)),a.createElement(D,{direction:"row",spacing:2},a.createElement(x,{variant:"body1",width:"250px"},"Order Date"),a.createElement(x,{variant:"body2"},A.order_date)),a.createElement(D,{direction:"row",spacing:2},a.createElement(x,{variant:"body1",width:"250px"},"Supplier"),a.createElement(x,{variant:"body2"},null===(y=null===(g=A.vendor_profile)||void 0===g?void 0:g.business_credentials)||void 0===y?void 0:y.company_name)),a.createElement(D,{direction:"row",spacing:2},a.createElement(x,{variant:"body1",width:"250px"},"Order Status"),a.createElement(x,{variant:"body2",width:"250px"},A.status)),("placed"===A.status||"released_on_stock"===A.status)&&"enduser"===F&&a.createElement(a.Fragment,null,a.createElement(C,{variant:"contained",color:"primary",onClick:function(){return L(!0)}},"Confirm order"),a.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher."),a.createElement(O,{open:K,handleClose:function(){return L(!1)},orderID:A.id,currentStatus:A.status,revalidateCallback:B})))),a.createElement(_,{item:!0,xs:12},a.createElement(D,{spacing:2},a.createElement(x,{variant:"h5"},"Documents"),a.createElement(k,{sx:{p:2}},a.createElement(D,{spacing:1},"enduser"===F&&a.createElement(a.Fragment,null,A.order_confirmation?a.createElement(D,{spacing:1},a.createElement(x,{variant:"h6"},"Order Confirmation"),a.createElement(x,null,null===(h=A.order_confirmation)||void 0===h?void 0:h.name),a.createElement(C,{variant:"contained",onClick:function(){c("api/ipos/".concat(A.id),"order_confirmation")}},"Download")):a.createElement(D,{spacing:1},a.createElement(x,{variant:"h6"},"Order Confirmation"),a.createElement(x,{variant:"body1"},"Upload the order confirmation for this order"),a.createElement(m,{reference:"api::logistics.ipo",refID:A.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:B}))),A.delivery_note?a.createElement(D,{spacing:1},a.createElement(x,{variant:"h6"},"Delivery Note"),a.createElement(x,null,null===(b=A.delivery_note)||void 0===b?void 0:b.name),a.createElement(C,{variant:"contained",onClick:function(){c("api/ipos/".concat(A.id),"delivery_note")}},"Download")):a.createElement(D,{spacing:1},a.createElement(x,{variant:"h6"},"Delivery Note"),a.createElement(x,{variant:"body1"},"Upload the delivery note for this order"),a.createElement(m,{reference:"api::logistics.ipo",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===(S=null===(N=null==A?void 0:A.notes)||void 0===N?void 0:N.data)||void 0===S?void 0:S.length)>0&&a.createElement(_,{item:!0,xs:12},a.createElement(D,{spacing:2},a.createElement(x,{variant:"h5"},"Notes"),a.createElement(p,{notes:A.notes.data}),a.createElement(j,null))),a.createElement(_,{item:!0,xs:12},a.createElement(D,{spacing:2},a.createElement(x,{variant:"h5"},"Items"),"placed"===A.status&&a.createElement(f,{severity:"warning"},"Items cannot be updated before order confirmation"),a.createElement("form",{action:R},a.createElement("input",{name:"id",type:"hidden",value:A.id}),a.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){return{id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity}}))}(J))}),a.createElement(D,{spacing:2},(null===(U=null==A?void 0:A.items)||void 0===U?void 0:U.data)&&A.items.data.map((function(e,t){var r,n;return a.createElement(k,{sx:{p: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(d,{item:e,index:t,handleUpdateQuantity:V,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,revalidateCallback:B}))})),"placed"!==A.status&&a.createElement(k,{sx:{p:2}},a.createElement(D,{direction:"row",justifyContent:"flex-end",spacing:2},P&&a.createElement(C,{onClick:P,variant:"outlined"},"Cancel"),a.createElement(v,{text:"Update Items",loadingText:"Updating...",variant:"contained"})))))))))}export{N as default};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__read as e,__spreadArray as t,__assign as r}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useState as a,useEffect as o}from"react";import{useFormState as i}from"react-dom";import{updateIpoAction as l}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualIPOItemUpdater.js";import s from"./ItemDisplay.js";import u from"../note/NotesDisplay.js";import p from"../note/NoteTakingComponent.js";import{SubmitButton as v}from"../../SubmitButton.js";import f from"@mui/material/Alert";import E from"@mui/material/Dialog";import g from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import h from"@mui/material/DialogTitle";import x from"@mui/material/Typography";import b from"@mui/material/Button";import C from"@mui/material/Grid";import w from"@mui/material/Box";import _ from"@mui/material/Paper";import I from"@mui/material/Stack";import k from"@mui/material/Divider";import{confirmationService as D}from"../../../data/services/common/confirmation-service.js";import{cancellationService as j}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as q,Checkbox as A,List as N,ListItem as S,TextField as F}from"@mui/material";import O from"@mui/icons-material/Numbers";import P from"@mui/icons-material/CalendarToday";import U from"@mui/icons-material/Business";import B from"@mui/icons-material/Description";import T from"@mui/icons-material/Update";import{IpoStatusIndicator as R}from"./IpoStatusIndicator.js";import{useSnackbar as W}from"../../../context/common/SnackbarContext.js";var M={zodErrors:null,strapiErrors:null,data:null,message:null};function z(e){var t=e.open,r=e.handleClose,a=e.orderID,o=e.currentStatus,i=e.revalidateCallback;return n.createElement(E,{open:t},n.createElement(h,null,"Confirm Order"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(x,null,"Are you sure you want to confirm this order?"),n.createElement(x,null,"Current status: ",o))),n.createElement(g,null,n.createElement(b,{variant:"contained",onClick:function(e){D("ipos",[a]),i&&i(),r()}},"Confirm"),n.createElement(b,{variant:"contained",onClick:r},"Cancel")))}function H(t){var r=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 n.createElement("form",null,n.createElement(E,{open:r},n.createElement(h,null,"Cancel Return"),n.createElement(y,null,n.createElement(I,{spacing:2},n.createElement(x,null,"Are you sure you want to cancel this return?"),n.createElement(N,null,n.createElement(S,null,"By cancelling this return order you will update it's status from requested to cancelled"),n.createElement(S,null,"Please provide a reason for the cancellation"),n.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),n.createElement(F,{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}))),n.createElement(g,null,n.createElement(b,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(j("ipos",i,m),l&&l(),o())}},"Yes"),n.createElement(b,{variant:"contained",onClick:o},"No"))))}function G(E){var g,y,h,D,j,N,S=E.data,F=E.sx,G=E.revalidateCallback,J=E.handleClose,L=E.role,Q=e(i(l,M),2),Y=Q[0],K=Q[1],V=e(a(S.items.data?S.items.data:[]),2),X=V[0],Z=V[1],$=e(a(!1),2),ee=$[0],te=$[1],re=e(a(!1),2),ne=re[0],ae=re[1],oe=e(a(["received","registered","released","reports"]),2),ie=oe[0],le=oe[1],ce=function(r,n,a){var o=t([],e(X),!1),i=o.findIndex((function(e){return e.id===n}));o[i][a]=r,Z(o)},me=function(n,a){var o,i,l,c=t([],e(X),!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),[n],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,Z(c)},de=function(r,n){var a,o,i=t([],e(X),!1),l=i.findIndex((function(e){return e.id===r})),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(n,1);var s=t(t([],e(m),!1),e(d),!1);i[l].reports.data=s,Z(i)},se=W().handleAddMessage;return o((function(){"Ipo Updated"===(null==Y?void 0:Y.message)&&(se({message:"Ipo Updated",severity:"success"}),J&&J(),G&&G())}),[Y]),o((function(){(null==Y?void 0:Y.strapiErrors)&&se({message:Y.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==Y?void 0:Y.strapiErrors]),o((function(){var e;console.log("data",S),(null===(e=S.items)||void 0===e?void 0:e.data)&&Z(S.items.data?S.items.data:[])}),[S]),n.createElement(w,{sx:t([],e(Array.isArray(F)?F:[F]),!1)},n.createElement(C,{container:!0,spacing:2},n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),n.createElement(x,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),n.createElement(p,{content:"",related:[{id:S.id,__type:"api::logistics.ipo"}],revalidateCallback:G})),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(x,{variant:"h5",sx:{py:1}},"Details")),n.createElement(C,{item:!0,xs:6},n.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(O,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.ipo_number)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(B,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.customer_reference)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(P,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),n.createElement(x,{variant:"body1",fontWeight:"medium"},S.order_date)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(U,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),n.createElement(x,{variant:"body1",fontWeight:"medium"},null===(y=null===(g=S.vendor_profile)||void 0===g?void 0:g.business_credentials)||void 0===y?void 0:y.company_name)),n.createElement(I,{direction:"row",spacing:2,alignItems:"center"},n.createElement(T,{color:"primary"}),n.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),n.createElement(R,{status:S.status}))))),"enduser"===L&&n.createElement(C,{item:!0,xs:6},n.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},n.createElement(I,{spacing:2},("placed"===S.status||"released_on_stock"===S.status)&&n.createElement(n.Fragment,null,n.createElement(b,{variant:"contained",color:"primary",onClick:function(){return te(!0)}},"Confirm order"),n.createElement(f,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),n.createElement(z,{open:ee,handleClose:function(){return te(!1)},orderID:S.id,currentStatus:S.status,revalidateCallback:G})),("placed"===S.status||"ordered"===S.status)&&n.createElement(n.Fragment,null,n.createElement(b,{variant:"contained",color:"error",onClick:function(){return ae(!0)}},"Cancel order"),n.createElement(H,{open:ne,handleClose:function(){return ae(!1)},orderID:S.id,revalidateCallback:G}))))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h5"},"Documents"),n.createElement(_,{sx:{p:2}},n.createElement(I,{spacing:1},"enduser"===L&&n.createElement(n.Fragment,null,S.order_confirmation?n.createElement(n.Fragment,null,n.createElement(x,{variant:"h6"},"Order Confirmation"),n.createElement(x,null,null===(h=S.order_confirmation)||void 0===h?void 0:h.name),n.createElement(b,{variant:"contained",onClick:function(){m("api/ipos/".concat(S.id),"order_confirmation")}},"Download")):n.createElement(n.Fragment,null,n.createElement(x,{variant:"h5"},"Order Confirmation"),n.createElement(x,{variant:"body1"},"Here you can upload the the order confirmation for this order"),n.createElement(x,{variant:"body1"},"FileUpload"),n.createElement(k,null),n.createElement(c,{reference:"api::logistics.ipo",refID:S.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:G}))),S.delivery_note?n.createElement(n.Fragment,null,n.createElement(x,{variant:"h6"},"Delivery Note"),n.createElement(x,null,null===(D=S.delivery_note)||void 0===D?void 0:D.name),n.createElement(b,{variant:"contained",onClick:function(){m("api/ipos/".concat(S.id),"delivery_note")}},"Download")):n.createElement(n.Fragment,null,n.createElement(x,{variant:"h5"},"Delivery Note"),n.createElement(x,{variant:"body1"},"Here you can upload the the delivery note for this order"),n.createElement(k,null),n.createElement(c,{reference:"api::logistics.ipo",refID:S.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:G})))))),(null===(N=null===(j=null==S?void 0:S.notes)||void 0===j?void 0:j.data)||void 0===N?void 0:N.length)>0&&n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:2},n.createElement(x,{variant:"h5"},"Notes"),n.createElement(u,{notes:S.notes.data}),n.createElement(k,null))),n.createElement(C,{item:!0,xs:12},n.createElement(I,{spacing:1},n.createElement(x,{variant:"h5"},"Items"),n.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},n.createElement(x,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return n.createElement(q,{key:r,control:n.createElement(A,{size:"small",checked:ie.includes(r),onChange:function(n){n.target.checked?le(t(t([],e(ie),!1),[r],!1)):le(ie.filter((function(e){return e!==r})))}}),label:n.createElement(x,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===S.status&&n.createElement(f,{severity:"warning"},"Before confirmation you cannot update the items"),n.createElement(k,null),n.createElement("form",{action:K},n.createElement("input",{name:"id",type:"hidden",value:S.id}),X&&X.map((function(e,t){var r,a;return n.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===S.status||"cancelled"===S.status||"done"===S.status?n.createElement(s,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):n.createElement(d,{item:e,index:t,handleUpdateQuantity:ce,handleAddReport:me,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:de,revalidateCallback:G,showing:ie}))})),n.createElement(_,{sx:{p:2}},n.createElement(I,{direction:"row",spacing:2,justifyContent:"end"},n.createElement(v,{text:"Update items",loadingText:"Loading..."}))),n.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,ordered_quantity:e.ordered_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}})))||[]}}))}(X))}))))))}export{G 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 o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{updateIpoAction as s}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{confirmationService as d}from"../../../data/services/common/confirmation-service.js";import{cancellationService as u}from"../../../data/services/common/cancellation-service.js";import p from"../../../data/loaders/common/media/downloadBase64File.js";import{UploadBase64MediaForm as v}from"../../common/media/UploadBase64MediaForm.js";import f from"../note/NoteTakingComponent.js";import E from"../note/NotesDisplay.js";import g from"./ItemDisplay.js";import y from"./TextualIPOItemUpdater.js";import{IpoStatusIndicator as h}from"./IpoStatusIndicator.js";import b from"@mui/material/Box";import x from"@mui/material/Stack";import C from"@mui/material/Paper";import w from"@mui/material/Dialog";import I from"@mui/material/DialogActions";import _ from"@mui/material/DialogContent";import k from"@mui/material/DialogTitle";import D from"@mui/material/Typography";import O from"@mui/material/Button";import j from"@mui/material/Grid";import F from"@mui/material/Divider";import P from"@mui/material/TextField";import A from"@mui/material/List";import q from"@mui/material/ListItem";import S from"@mui/material/Alert";import N from"@mui/material/Checkbox";import T from"@mui/material/FormControlLabel";import U from"@mui/icons-material/Numbers";import B from"@mui/icons-material/Description";import R from"@mui/icons-material/CalendarToday";import M from"@mui/icons-material/Business";import W from"@mui/icons-material/Update";import{SubmitButton as L}from"../../SubmitButton.js";var z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function H(e){var t=this,r=e.open,o=e.handleClose,l=e.orderID,c=e.currentStatus,s=e.revalidateCallback,u=m().handleAddMessage;return i.createElement(w,{open:r},i.createElement(k,null,"Confirm Order"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to confirm this order?"),i.createElement(D,null,"Current status: ",c),i.createElement(S,{severity:"info"},"Once confirmed, the order will be available for processing."))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:o},"Cancel"),i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return n(t,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,d("ipos",[l])];case 1:return e.sent(),u({message:"IPO confirmed successfully",severity:"success"}),s&&s(),o(),[3,3];case 2:return e.sent(),u({message:"Failed to confirm IPO",severity:"error"}),[3,3];case 3:return[2]}}))}))}},"Confirm Order")))}function G(t){var r=this,l=t.open,c=t.handleClose,s=t.orderID,d=t.revalidateCallback,p=e(o(""),2),v=p[0],f=p[1],E=e(o(""),2),g=E[0],y=E[1],h=m().handleAddMessage;return i.createElement(w,{open:l},i.createElement(k,null,"Cancel Return"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to cancel this return?"),i.createElement(A,null,i.createElement(q,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(q,null,"Please provide a reason for the cancellation"),i.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(P,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:v,onChange:function(e){return f(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!g,helperText:g}))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:c},"Cancel"),i.createElement(O,{variant:"contained",color:"error",onClick:function(){return n(r,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(v.length<5)return y("Please provide a reason for the cancellation (min 5 characters)"),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,u("ipos",s,v)];case 2:return e.sent(),h({message:"IPO cancelled successfully",severity:"success"}),d&&d(),c(),[3,4];case 3:return e.sent(),h({message:"Failed to cancel IPO",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation")))}function J(n){var a,d,u,w,I,_,k=n.data,P=n.sx,A=n.revalidateCallback,q=n.handleClose,J=n.role,Q=e(c((function(e,t){return s(k.id,e,t)}),z),2),K=Q[0],V=Q[1],X=m().handleAddMessage,Y=e(o(k.items.data?k.items.data:[]),2),Z=Y[0],$=Y[1],ee=e(o(!1),2),te=ee[0],re=ee[1],ne=e(o(!1),2),ae=ne[0],ie=ne[1],oe=e(o(["received","registered","released","reports"]),2),le=oe[0],ce=oe[1];l((function(){(null==K?void 0:K.message)&&(X({message:K.message,severity:K.severity||"error"}),"success"===K.severity&&(A&&A(),q&&q()))}),[null==K?void 0:K.message]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]);var me=function(r,n,a){var i=t([],e(Z),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,$(i)},se=function(n,a){var i,o,l,c=t([],e(Z),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[n],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=d,$(c)},de=function(r,n){var a,i,o=t([],e(Z),!1),l=o.findIndex((function(e){return e.id===r})),c=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,$(o)};return l((function(){"Ipo Updated"===(null==K?void 0:K.message)&&(X({message:"Ipo Updated",severity:"success"}),q&&q(),A&&A())}),[K]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]),l((function(){var e;console.log("data",k),(null===(e=k.items)||void 0===e?void 0:e.data)&&$(k.items.data?k.items.data:[])}),[k]),i.createElement(b,{sx:t([],e(Array.isArray(P)?P:[P]),!1)},i.createElement(j,{container:!0,spacing:2},i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),i.createElement(D,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),i.createElement(f,{content:"",related:[{id:k.id,__type:"api::logistics.ipo"}],revalidateCallback:A})),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(D,{variant:"h5",sx:{py:1}},"Details")),i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.ipo_number)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.customer_reference)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(R,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.order_date)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),i.createElement(D,{variant:"body1",fontWeight:"medium"},null===(d=null===(a=k.vendor_profile)||void 0===a?void 0:a.business_credentials)||void 0===d?void 0:d.company_name)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(W,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(h,{status:k.status}))))),"enduser"===J&&i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},("placed"===k.status||"released_on_stock"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return re(!0)}},"Confirm order"),i.createElement(S,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(H,{open:te,handleClose:function(){return re(!1)},orderID:k.id,currentStatus:k.status,revalidateCallback:A})),("placed"===k.status||"ordered"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"error",onClick:function(){return ie(!0)}},"Cancel order"),i.createElement(G,{open:ae,handleClose:function(){return ie(!1)},orderID:k.id,revalidateCallback:A}))))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Documents"),i.createElement(C,{sx:{p:2}},i.createElement(x,{spacing:1},"enduser"===J&&i.createElement(i.Fragment,null,k.order_confirmation?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Order Confirmation"),i.createElement(D,null,null===(u=k.order_confirmation)||void 0===u?void 0:u.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"order_confirmation")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Order Confirmation"),i.createElement(D,{variant:"body1"},"Here you can upload the the order confirmation for this order"),i.createElement(D,{variant:"body1"},"FileUpload"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:A}))),k.delivery_note?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Delivery Note"),i.createElement(D,null,null===(w=k.delivery_note)||void 0===w?void 0:w.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Delivery Note"),i.createElement(D,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.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===(_=null===(I=null==k?void 0:k.notes)||void 0===I?void 0:I.data)||void 0===_?void 0:_.length)>0&&i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Notes"),i.createElement(E,{notes:k.notes.data}),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:1},i.createElement(D,{variant:"h5"},"Items"),i.createElement(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:C,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(D,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(T,{key:r,control:i.createElement(N,{size:"small",checked:le.includes(r),onChange:function(n){n.target.checked?ce(t(t([],e(le),!1),[r],!1)):ce(le.filter((function(e){return e!==r})))}}),label:i.createElement(D,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===k.status&&i.createElement(S,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(F,null),i.createElement("form",{action:V},i.createElement("input",{name:"id",type:"hidden",value:k.id}),Z&&Z.map((function(e,t){var r,n;return i.createElement(C,{sx:{p:2,mb:2},key:t},"placed"===k.status||"cancelled"===k.status||"done"===k.status?i.createElement(g,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(y,{item:e,index:t,handleUpdateQuantity:me,handleAddReport:se,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:de,revalidateCallback:A,showing:le}))})),i.createElement(C,{sx:{p:2}},i.createElement(x,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(L,{text:"Update items",loadingText:"Loading..."}))),i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;return{id:e.id,ordered_quantity:e.ordered_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}})))||[]}}))}(Z))}))))))}export{J as default};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as n,useEffect as m}from"react";import a from"@mui/material/Box";import o from"@mui/material/Stack";import s from"@mui/material/Button";import i from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as l}from"../../SubmitButton.js";import{useFormState as d}from"react-dom";import{useSnackbar as u}from"../../../context/common/SnackbarContext.js";import{createVendorAction as p}from"../../../data/actions/logistics/vendor/createVendorAction.js";import E from"@mui/material/Grid";import{BusinessCredentialsFields as f}from"../../e-commerce/customer/BusinessCredentials.js";import{AddressFields as x}from"../../common/Address.js";import g from"../../e-commerce/products/ProductSelector.js";import{ContactsFields as v}from"../../common/Contacts.js";import b from"@mui/icons-material/Add";import{ContactType as y}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as h}from"../../ExplanatoryFoldOut.js";var C={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function j(j){var A=j.productNamesArr,_=j.revalidateCallback,k=j.handleClose,N=j.sx,V=e(d(p,C),2),B=V[0],R=V[1],S=u().handleAddMessage,w=e(n([]),2),P=w[0],T=w[1];return m((function(){(null==B?void 0:B.message)&&(S({message:B.message,severity:B.severity||"error"}),"success"===B.severity&&(_&&_(),k&&k()))}),[null==B?void 0:B.message]),m((function(){(null==B?void 0:B.strapiErrors)&&S({message:B.strapiErrors.message||"Error creating vendor",severity:"error"})}),[null==B?void 0:B.strapiErrors]),r.createElement(a,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},r.createElement("form",{action:R},r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h5"},"Add Vendor")),r.createElement(E,{item:!0,xs:12},r.createElement(h,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),r.createElement(E,{item:!0,xs:12,md:6},r.createElement(f,{componentName:"business_credentials",componentReference:"common.business-credentials"})),r.createElement(E,{item:!0,xs:12,md:6},r.createElement(o,{spacing:1,sx:{pt:1}},r.createElement(i,{id:"website_url",name:"website_url",label:"Website Url"}),r.createElement(i,{id:"phone_number",name:"phone_number",label:"Phone Number"}),r.createElement(i,{id:"email",name:"email",label:"Email"}))),r.createElement(E,{item:!0,xs:12,md:6},r.createElement(c,{variant:"h6"},"Address"),r.createElement(x,{componentName:"address",componentReference:"common.address"})),r.createElement(E,{item:!0,xs:12,sx:{mt:1}},r.createElement(c,{variant:"h6"},"Products"),r.createElement(g,{productNames:A,currentValue:[]})),r.createElement(E,{item:!0,xs:12,sx:{mt:1}},r.createElement(c,{variant:"h6"},"Contacts"),r.createElement(E,{container:!0,spacing:2},P.map((function(e,t){return r.createElement(E,{item:!0,xs:12,sm:6,md:4,lg:3,key:t},r.createElement(v,{key:t,data:e.data,componentName:e.componentName,componentReference:"logistics-elements.contact",deleteCallback:function(){!function(e){var t=P.filter((function(t,r){return r!==e}));T(t)}(t)}}))})),r.createElement(E,{item:!0,xs:12,sm:6,md:4,lg:3,sx:{justifyContent:"center",display:"flex",alignItems:"center"}},r.createElement(s,{variant:"contained",startIcon:r.createElement(b,null),onClick:function(){T(t(t([],e(P),!1),[{componentName:"contacts[".concat(P.length,"]"),componentReference:"logistics-elements.contact",data:{first_name:"",last_name:"",email:"",phone_number:"",type:y.Other}}],!1))},size:"large"},"Add contact"))))," ",r.createElement(E,{item:!0,xs:12},r.createElement(o,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{mt:2}},k&&r.createElement(s,{onClick:k,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Create Vendor",loadingText:"Creating..."}))))))}export{j as AddVendorForm};
|