umwd-components 0.1.660 → 0.1.661
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/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/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/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/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/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 -21
- package/src/components/logistics/ipo/ManageIPOForm.tsx +95 -133
- package/src/components/logistics/ipo/TextualManageIPOForm.tsx +165 -118
- 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/index.ts +3 -0
- package/src/types/e-commerce/enduser/types.ts +15 -0
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { useFormState } from "react-dom";
|
|
3
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
3
4
|
import { updateIpoAction } from "../../../data/actions/logistics/ipo/updateIpoAction";
|
|
4
|
-
import { UploadBase64MediaForm } from "../../../components/common/media/UploadBase64MediaForm";
|
|
5
|
-
import downloadBase64File from "../../../data/loaders/common/media/downloadBase64File";
|
|
6
|
-
import TextualIPOItemUpdater from "./TextualIPOItemUpdater";
|
|
7
|
-
import ItemDisplay from "./ItemDisplay";
|
|
8
5
|
import { IpoItem, ManageIpoFormProps } from "../../../types/logistics/Ipo";
|
|
9
|
-
import
|
|
6
|
+
import { confirmationService } from "../../../data/services/common/confirmation-service";
|
|
7
|
+
import { cancellationService } from "../../../data/services/common/cancellation-service";
|
|
8
|
+
import downloadBase64File from "../../../data/loaders/common/media/downloadBase64File";
|
|
9
|
+
import { UploadBase64MediaForm } from "../../common/media/UploadBase64MediaForm";
|
|
10
10
|
import NoteTakingComponent from "../note/NoteTakingComponent";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
11
|
+
import NotesDisplay from "../note/NotesDisplay";
|
|
12
|
+
import ItemDisplay from "./ItemDisplay";
|
|
13
|
+
import TextualIPOItemUpdater from "./TextualIPOItemUpdater";
|
|
14
|
+
import { IpoStatusIndicator } from "./IpoStatusIndicator";
|
|
15
|
+
|
|
16
|
+
import Box from "@mui/material/Box";
|
|
17
|
+
import Stack from "@mui/material/Stack";
|
|
18
|
+
import Paper from "@mui/material/Paper";
|
|
14
19
|
import Dialog from "@mui/material/Dialog";
|
|
15
20
|
import DialogActions from "@mui/material/DialogActions";
|
|
16
21
|
import DialogContent from "@mui/material/DialogContent";
|
|
@@ -18,56 +23,65 @@ import DialogTitle from "@mui/material/DialogTitle";
|
|
|
18
23
|
import Typography from "@mui/material/Typography";
|
|
19
24
|
import Button from "@mui/material/Button";
|
|
20
25
|
import Grid from "@mui/material/Grid";
|
|
21
|
-
import Box from "@mui/material/Box";
|
|
22
|
-
import Paper from "@mui/material/Paper";
|
|
23
|
-
import Stack from "@mui/material/Stack";
|
|
24
26
|
import Divider from "@mui/material/Divider";
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
ListItem,
|
|
33
|
-
TextField,
|
|
34
|
-
DialogContentText,
|
|
35
|
-
CircularProgress,
|
|
36
|
-
} from "@mui/material";
|
|
27
|
+
import TextField from "@mui/material/TextField";
|
|
28
|
+
import List from "@mui/material/List";
|
|
29
|
+
import ListItem from "@mui/material/ListItem";
|
|
30
|
+
import Alert from "@mui/material/Alert";
|
|
31
|
+
import Checkbox from "@mui/material/Checkbox";
|
|
32
|
+
import FormControlLabel from "@mui/material/FormControlLabel";
|
|
33
|
+
|
|
37
34
|
import NumbersIcon from "@mui/icons-material/Numbers";
|
|
38
|
-
import
|
|
35
|
+
import DescriptionIcon from "@mui/icons-material/Description";
|
|
39
36
|
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
|
|
40
37
|
import BusinessIcon from "@mui/icons-material/Business";
|
|
41
|
-
import DescriptionIcon from "@mui/icons-material/Description";
|
|
42
38
|
import UpdateIcon from "@mui/icons-material/Update";
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
import {
|
|
46
|
-
import { queryAllProducts } from "../../../data/loaders/e-commerce/queryAllProducts";
|
|
47
|
-
import qs from "qs";
|
|
48
|
-
import { Product } from "../../../types/e-commerce/product/types";
|
|
49
|
-
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
39
|
+
import { SubmitButton } from "../../SubmitButton";
|
|
40
|
+
|
|
41
|
+
import { PreReport } from "../../../types/logistics/Report";
|
|
50
42
|
|
|
51
43
|
const INITIAL_STATE = {
|
|
52
44
|
zodErrors: null,
|
|
53
45
|
strapiErrors: null,
|
|
54
46
|
data: null,
|
|
55
47
|
message: null,
|
|
48
|
+
severity: null,
|
|
56
49
|
};
|
|
57
50
|
|
|
51
|
+
interface ConfirmFormDialogProps {
|
|
52
|
+
open: boolean;
|
|
53
|
+
handleClose: () => void;
|
|
54
|
+
orderID: number;
|
|
55
|
+
currentStatus: "placed" | "released_on_stock";
|
|
56
|
+
revalidateCallback?: () => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
58
59
|
function ConfirmFormDialog({
|
|
59
60
|
open,
|
|
60
61
|
handleClose,
|
|
61
62
|
orderID,
|
|
62
63
|
currentStatus,
|
|
63
64
|
revalidateCallback,
|
|
64
|
-
}: {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
}: ConfirmFormDialogProps): React.ReactElement {
|
|
66
|
+
const { handleAddMessage } = useSnackbar();
|
|
67
|
+
|
|
68
|
+
const handleConfirm = async () => {
|
|
69
|
+
try {
|
|
70
|
+
await confirmationService("ipos", [orderID]);
|
|
71
|
+
handleAddMessage({
|
|
72
|
+
message: "IPO confirmed successfully",
|
|
73
|
+
severity: "success",
|
|
74
|
+
});
|
|
75
|
+
revalidateCallback && revalidateCallback();
|
|
76
|
+
handleClose();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
handleAddMessage({
|
|
79
|
+
message: "Failed to confirm IPO",
|
|
80
|
+
severity: "error",
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
71
85
|
return (
|
|
72
86
|
<Dialog open={open}>
|
|
73
87
|
<DialogTitle>Confirm Order</DialogTitle>
|
|
@@ -75,109 +89,121 @@ function ConfirmFormDialog({
|
|
|
75
89
|
<Stack spacing={2}>
|
|
76
90
|
<Typography>Are you sure you want to confirm this order?</Typography>
|
|
77
91
|
<Typography>Current status: {currentStatus}</Typography>
|
|
92
|
+
<Alert severity="info">
|
|
93
|
+
Once confirmed, the order will be available for processing.
|
|
94
|
+
</Alert>
|
|
78
95
|
</Stack>
|
|
79
96
|
</DialogContent>
|
|
80
97
|
<DialogActions>
|
|
81
|
-
<Button
|
|
82
|
-
variant="contained"
|
|
83
|
-
onClick={(e) => {
|
|
84
|
-
confirmationService("ipos", [orderID]);
|
|
85
|
-
revalidateCallback && revalidateCallback();
|
|
86
|
-
handleClose();
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
89
|
-
Confirm
|
|
90
|
-
</Button>
|
|
91
|
-
<Button variant="contained" onClick={handleClose}>
|
|
98
|
+
<Button variant="outlined" onClick={handleClose}>
|
|
92
99
|
Cancel
|
|
93
100
|
</Button>
|
|
101
|
+
<Button variant="contained" color="primary" onClick={handleConfirm}>
|
|
102
|
+
Confirm Order
|
|
103
|
+
</Button>
|
|
94
104
|
</DialogActions>
|
|
95
105
|
</Dialog>
|
|
96
106
|
);
|
|
97
107
|
}
|
|
98
108
|
|
|
109
|
+
interface CancelIpoDialogProps {
|
|
110
|
+
open: boolean;
|
|
111
|
+
handleClose: () => void;
|
|
112
|
+
orderID: number;
|
|
113
|
+
revalidateCallback?: () => void;
|
|
114
|
+
}
|
|
115
|
+
|
|
99
116
|
function CancelIpoDialog({
|
|
100
117
|
open,
|
|
101
118
|
handleClose,
|
|
102
119
|
orderID,
|
|
103
120
|
revalidateCallback,
|
|
104
|
-
}: {
|
|
105
|
-
|
|
106
|
-
handleClose: () => void;
|
|
107
|
-
orderID: number;
|
|
108
|
-
revalidateCallback?: () => void;
|
|
109
|
-
}) {
|
|
110
|
-
const [reason, setRoason] = useState<string>("");
|
|
121
|
+
}: CancelIpoDialogProps): React.ReactElement {
|
|
122
|
+
const [reason, setReason] = useState<string>("");
|
|
111
123
|
const [reasonError, setReasonError] = useState<string>("");
|
|
124
|
+
const { handleAddMessage } = useSnackbar();
|
|
125
|
+
|
|
126
|
+
const handleCancel = async () => {
|
|
127
|
+
if (reason.length < 5) {
|
|
128
|
+
setReasonError(
|
|
129
|
+
"Please provide a reason for the cancellation (min 5 characters)"
|
|
130
|
+
);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
await cancellationService("ipos", orderID, reason);
|
|
135
|
+
handleAddMessage({
|
|
136
|
+
message: "IPO cancelled successfully",
|
|
137
|
+
severity: "success",
|
|
138
|
+
});
|
|
139
|
+
revalidateCallback && revalidateCallback();
|
|
140
|
+
handleClose();
|
|
141
|
+
} catch (error) {
|
|
142
|
+
handleAddMessage({
|
|
143
|
+
message: "Failed to cancel IPO",
|
|
144
|
+
severity: "error",
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
112
149
|
return (
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
cancellationService("ipos", orderID, reason);
|
|
156
|
-
revalidateCallback && revalidateCallback();
|
|
157
|
-
handleClose();
|
|
158
|
-
}}
|
|
159
|
-
>
|
|
160
|
-
Yes
|
|
161
|
-
</Button>
|
|
162
|
-
<Button variant="contained" onClick={handleClose}>
|
|
163
|
-
No
|
|
164
|
-
</Button>
|
|
165
|
-
</DialogActions>
|
|
166
|
-
</Dialog>
|
|
167
|
-
</form>
|
|
150
|
+
<Dialog open={open}>
|
|
151
|
+
<DialogTitle>Cancel Return</DialogTitle>
|
|
152
|
+
<DialogContent>
|
|
153
|
+
<Stack spacing={2}>
|
|
154
|
+
<Typography>Are you sure you want to cancel this return?</Typography>
|
|
155
|
+
<List>
|
|
156
|
+
<ListItem>
|
|
157
|
+
By cancelling this return order you will update it's status from
|
|
158
|
+
requested to cancelled
|
|
159
|
+
</ListItem>
|
|
160
|
+
<ListItem>Please provide a reason for the cancellation</ListItem>
|
|
161
|
+
<ListItem>
|
|
162
|
+
The customer will be notified about the cancellation and of the
|
|
163
|
+
reason for the cancellation
|
|
164
|
+
</ListItem>
|
|
165
|
+
</List>
|
|
166
|
+
<TextField
|
|
167
|
+
label="Cancellation reason"
|
|
168
|
+
name="reason"
|
|
169
|
+
multiline
|
|
170
|
+
rows={4}
|
|
171
|
+
fullWidth
|
|
172
|
+
variant="outlined"
|
|
173
|
+
value={reason}
|
|
174
|
+
onChange={(e) => setReason(e.target.value)}
|
|
175
|
+
placeholder="Please provide a reason for the cancellation"
|
|
176
|
+
error={!!reasonError}
|
|
177
|
+
helperText={reasonError}
|
|
178
|
+
/>
|
|
179
|
+
</Stack>
|
|
180
|
+
</DialogContent>
|
|
181
|
+
<DialogActions>
|
|
182
|
+
<Button variant="outlined" onClick={handleClose}>
|
|
183
|
+
Cancel
|
|
184
|
+
</Button>
|
|
185
|
+
<Button variant="contained" color="error" onClick={handleCancel}>
|
|
186
|
+
Confirm Cancellation
|
|
187
|
+
</Button>
|
|
188
|
+
</DialogActions>
|
|
189
|
+
</Dialog>
|
|
168
190
|
);
|
|
169
191
|
}
|
|
170
192
|
|
|
171
193
|
export default function TextualManageIPOForm({
|
|
172
194
|
data,
|
|
173
195
|
sx,
|
|
174
|
-
// revalidates the selectedOpo from the database
|
|
175
196
|
revalidateCallback,
|
|
176
197
|
handleClose,
|
|
177
198
|
role,
|
|
178
|
-
}: ManageIpoFormProps) {
|
|
179
|
-
|
|
180
|
-
|
|
199
|
+
}: ManageIpoFormProps): React.ReactElement {
|
|
200
|
+
const [formState, formAction] = useFormState(
|
|
201
|
+
(prevState: any, formData: FormData) =>
|
|
202
|
+
updateIpoAction(data.id, prevState, formData),
|
|
203
|
+
INITIAL_STATE
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
const { handleAddMessage } = useSnackbar();
|
|
181
207
|
|
|
182
208
|
const [items, setItems] = useState<IpoItem[]>(
|
|
183
209
|
data.items.data ? data.items.data : []
|
|
@@ -197,6 +223,29 @@ export default function TextualManageIPOForm({
|
|
|
197
223
|
"reports",
|
|
198
224
|
];
|
|
199
225
|
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (formState?.message) {
|
|
228
|
+
handleAddMessage({
|
|
229
|
+
message: formState.message,
|
|
230
|
+
severity: formState.severity || "error",
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
if (formState.severity === "success") {
|
|
234
|
+
revalidateCallback && revalidateCallback();
|
|
235
|
+
handleClose && handleClose();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, [formState?.message]);
|
|
239
|
+
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
if (formState?.strapiErrors) {
|
|
242
|
+
handleAddMessage({
|
|
243
|
+
message: formState.strapiErrors.message || "Error updating IPO",
|
|
244
|
+
severity: "error",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}, [formState?.strapiErrors]);
|
|
248
|
+
|
|
200
249
|
const parseItems = (items: IpoItem[]) => {
|
|
201
250
|
return items.map((item) => {
|
|
202
251
|
return {
|
|
@@ -260,8 +309,6 @@ export default function TextualManageIPOForm({
|
|
|
260
309
|
setItems(newItems);
|
|
261
310
|
};
|
|
262
311
|
|
|
263
|
-
const { handleAddMessage } = useSnackbar();
|
|
264
|
-
|
|
265
312
|
useEffect(() => {
|
|
266
313
|
if (formState?.message === "Ipo Updated") {
|
|
267
314
|
handleAddMessage({
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
|
|
3
|
+
import { mutateData } from "../../../services/mutate-data";
|
|
4
|
+
import { flattenAttributes } from "../../../../lib/utils";
|
|
5
|
+
import { parseFormData } from "../../../../lib/parseFormData";
|
|
6
|
+
|
|
7
|
+
export async function updateEnduserProfileAction(
|
|
8
|
+
id: number,
|
|
9
|
+
prevState: any,
|
|
10
|
+
formData: FormData
|
|
11
|
+
) {
|
|
12
|
+
const parsedFormData = parseFormData(formData);
|
|
13
|
+
|
|
14
|
+
const responseData = await mutateData(
|
|
15
|
+
"PUT",
|
|
16
|
+
`/api/enduser-profiles/${id}`,
|
|
17
|
+
parsedFormData
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
if (!responseData) {
|
|
21
|
+
return {
|
|
22
|
+
...prevState,
|
|
23
|
+
severity: "error",
|
|
24
|
+
strapiErrors: null,
|
|
25
|
+
message: "Ops! Something went wrong. Please try again.",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (responseData.error) {
|
|
30
|
+
return {
|
|
31
|
+
...prevState,
|
|
32
|
+
severity: "error",
|
|
33
|
+
strapiErrors: responseData.error,
|
|
34
|
+
message: "Failed to update profile.",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const flattenedData = flattenAttributes(responseData);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
...prevState,
|
|
42
|
+
severity: "success",
|
|
43
|
+
message: "Profile Updated Successfully",
|
|
44
|
+
data: flattenedData,
|
|
45
|
+
strapiErrors: null,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -5,24 +5,21 @@ import { flattenAttributes } from "../../../../lib/utils";
|
|
|
5
5
|
import { parseFormData } from "../../../../lib/parseFormData";
|
|
6
6
|
|
|
7
7
|
export async function updateDispatcherProfileAction(
|
|
8
|
+
id: number,
|
|
8
9
|
prevState: any,
|
|
9
10
|
formData: FormData
|
|
10
11
|
) {
|
|
11
|
-
const rawFormData = Object.fromEntries(formData);
|
|
12
|
-
|
|
13
12
|
const parsedFormData = parseFormData(formData);
|
|
14
13
|
|
|
15
|
-
const id = rawFormData.id;
|
|
16
|
-
|
|
17
14
|
const responseData = await mutateData(
|
|
18
15
|
"PUT",
|
|
19
16
|
`/api/dispatcher-profiles/${id}`,
|
|
20
17
|
parsedFormData
|
|
21
18
|
);
|
|
22
|
-
|
|
23
19
|
if (!responseData) {
|
|
24
20
|
return {
|
|
25
21
|
...prevState,
|
|
22
|
+
severity: "error",
|
|
26
23
|
strapiErrors: null,
|
|
27
24
|
message: "Ops! Something went wrong. Please try again.",
|
|
28
25
|
};
|
|
@@ -31,16 +28,17 @@ export async function updateDispatcherProfileAction(
|
|
|
31
28
|
if (responseData.error) {
|
|
32
29
|
return {
|
|
33
30
|
...prevState,
|
|
31
|
+
severity: "error",
|
|
34
32
|
strapiErrors: responseData.error,
|
|
35
|
-
message: "Failed to
|
|
33
|
+
message: "Failed to update profile.",
|
|
36
34
|
};
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
const flattenedData = flattenAttributes(responseData);
|
|
40
|
-
|
|
41
38
|
return {
|
|
42
39
|
...prevState,
|
|
43
|
-
|
|
40
|
+
severity: "success",
|
|
41
|
+
message: "Profile Updated Successfully",
|
|
44
42
|
data: flattenedData,
|
|
45
43
|
strapiErrors: null,
|
|
46
44
|
};
|
|
@@ -6,13 +6,12 @@ import { parseFormData } from "../../../../lib/parseFormData";
|
|
|
6
6
|
// import { format } from "date-fns";
|
|
7
7
|
import dayjs from "dayjs";
|
|
8
8
|
export async function createIPOAction(prevState: any, formData: FormData) {
|
|
9
|
-
const rawFormData = Object.fromEntries(formData);
|
|
10
|
-
|
|
11
9
|
const parsedFormData = parseFormData(formData);
|
|
12
10
|
|
|
13
11
|
if (!parsedFormData.data.order_date) {
|
|
14
12
|
return {
|
|
15
13
|
...prevState,
|
|
14
|
+
severity: "error",
|
|
16
15
|
strapiErrors: null,
|
|
17
16
|
message: "Please select an Order Date.",
|
|
18
17
|
};
|
|
@@ -23,7 +22,6 @@ export async function createIPOAction(prevState: any, formData: FormData) {
|
|
|
23
22
|
vendor_profile: parsedFormData.data.vendors,
|
|
24
23
|
customer_reference: parsedFormData.data.customer_reference,
|
|
25
24
|
order_date: dayjs(parsedFormData.data.order_date).format("YYYY-MM-DD"),
|
|
26
|
-
// format(parsedFormData.data.order_date, "yyyy-MM-dd"),
|
|
27
25
|
items: parsedFormData.data.ipo_items,
|
|
28
26
|
},
|
|
29
27
|
};
|
|
@@ -31,31 +29,31 @@ export async function createIPOAction(prevState: any, formData: FormData) {
|
|
|
31
29
|
const items = JSON.parse(parsedFormData.data.ipo_items);
|
|
32
30
|
|
|
33
31
|
if (items.length === 0) {
|
|
34
|
-
console.log("No items in IPO");
|
|
35
32
|
return {
|
|
36
33
|
...prevState,
|
|
34
|
+
severity: "error",
|
|
37
35
|
strapiErrors: null,
|
|
38
36
|
message: "Please add items to the IPO.",
|
|
39
37
|
};
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
console.log("ipoData", ipoData);
|
|
43
|
-
|
|
44
40
|
const responseData = await mutateData("POST", `/api/ipos`, ipoData);
|
|
45
41
|
|
|
46
42
|
if (!responseData) {
|
|
47
43
|
return {
|
|
48
44
|
...prevState,
|
|
45
|
+
severity: "error",
|
|
49
46
|
strapiErrors: null,
|
|
50
|
-
message: "
|
|
47
|
+
message: "Failed to create IPO. Please try again.",
|
|
51
48
|
};
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
if (responseData.error) {
|
|
55
52
|
return {
|
|
56
53
|
...prevState,
|
|
54
|
+
severity: "error",
|
|
57
55
|
strapiErrors: responseData.error,
|
|
58
|
-
message: "Failed to
|
|
56
|
+
message: "Failed to create IPO.",
|
|
59
57
|
};
|
|
60
58
|
}
|
|
61
59
|
|
|
@@ -63,7 +61,8 @@ export async function createIPOAction(prevState: any, formData: FormData) {
|
|
|
63
61
|
|
|
64
62
|
return {
|
|
65
63
|
...prevState,
|
|
66
|
-
|
|
64
|
+
severity: "success",
|
|
65
|
+
message: "IPO Created Successfully",
|
|
67
66
|
data: flattenedData,
|
|
68
67
|
strapiErrors: null,
|
|
69
68
|
};
|
|
@@ -4,30 +4,34 @@ import { mutateData } from "../../../services/mutate-data";
|
|
|
4
4
|
import { flattenAttributes } from "../../../../lib/utils";
|
|
5
5
|
import { parseFormData } from "../../../../lib/parseFormData";
|
|
6
6
|
|
|
7
|
-
export async function updateIpoAction(
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export async function updateIpoAction(
|
|
8
|
+
id: number,
|
|
9
|
+
prevState: any,
|
|
10
|
+
formData: FormData
|
|
11
|
+
) {
|
|
10
12
|
const parsedFormData = parseFormData(formData);
|
|
11
13
|
|
|
12
14
|
const responseData = await mutateData(
|
|
13
15
|
"PUT",
|
|
14
|
-
`/api/ipos/${
|
|
16
|
+
`/api/ipos/${id}`,
|
|
15
17
|
parsedFormData
|
|
16
18
|
);
|
|
17
19
|
|
|
18
20
|
if (!responseData) {
|
|
19
21
|
return {
|
|
20
22
|
...prevState,
|
|
23
|
+
severity: "error",
|
|
21
24
|
strapiErrors: null,
|
|
22
|
-
message: "
|
|
25
|
+
message: "Failed to update IPO. Please try again.",
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
if (responseData.error) {
|
|
27
30
|
return {
|
|
28
31
|
...prevState,
|
|
32
|
+
severity: "error",
|
|
29
33
|
strapiErrors: responseData.error,
|
|
30
|
-
message: "Failed to
|
|
34
|
+
message: "Failed to update IPO.",
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
37
|
|
|
@@ -35,7 +39,8 @@ export async function updateIpoAction(prevState: any, formData: FormData) {
|
|
|
35
39
|
|
|
36
40
|
return {
|
|
37
41
|
...prevState,
|
|
38
|
-
|
|
42
|
+
severity: "success",
|
|
43
|
+
message: "IPO Updated Successfully",
|
|
39
44
|
data: flattenedData,
|
|
40
45
|
strapiErrors: null,
|
|
41
46
|
};
|
package/src/index.ts
CHANGED
|
@@ -289,6 +289,9 @@ export { default as ReportsWarning } from "./components/logistics/report/Reports
|
|
|
289
289
|
export { default as DispatcherProfileDisplay } from "./components/logistics/dispatcher/DispatcherProfileDisplay";
|
|
290
290
|
export { default as DispatcherProfileEditForm } from "./components/logistics/dispatcher/DispatcherProfileEditForm";
|
|
291
291
|
|
|
292
|
+
export { default as EnduserProfileEditForm } from "./components/e-commerce/enduser/EnduserProfileEditForm";
|
|
293
|
+
export { default as EnduserProfileDisplay } from "./components/e-commerce/enduser/EnduserProfileDisplay";
|
|
294
|
+
|
|
292
295
|
export { updateDispatcherProfileAction as updateDispatcherProfileAction } from "./data/actions/logistics/dispatcher/profile-actions";
|
|
293
296
|
export { getExtendedDispatcherMeLoader as getExtendedDispatcherMeLoader } from "./data/services/logistics/dispatcher/get-dispatcher-me-loader";
|
|
294
297
|
export { getDispatcherMeLoader as getDispatcherMeLoader } from "./data/services/logistics/dispatcher/get-dispatcher-me-loader";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BusinessCredentialsWithJSONProps } from "../BusinessCredentialsProps";
|
|
2
|
+
import { AddressProps } from "../../AddressProps";
|
|
3
|
+
|
|
4
|
+
export interface EnduserProfileProps {
|
|
5
|
+
id: string;
|
|
6
|
+
uuid: string;
|
|
7
|
+
enduser_number: string;
|
|
8
|
+
first_name: string;
|
|
9
|
+
last_name: string;
|
|
10
|
+
email: string;
|
|
11
|
+
phone: string;
|
|
12
|
+
private_address: AddressProps;
|
|
13
|
+
company_address: AddressProps;
|
|
14
|
+
business_credentials: BusinessCredentialsWithJSONProps;
|
|
15
|
+
}
|