umwd-components 0.1.657 → 0.1.660
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/instructions/form-patterns.instructions.md +140 -0
- package/.ai/prompts/form-patterns.prompt.md +156 -0
- package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/customer/CustomerProfileEditForm.js +1 -1
- package/dist/src/components/e-commerce/invoice/CreateInvoiceForm.js +1 -1
- package/dist/src/components/e-commerce/iro/CreateIROForm.js +1 -1
- package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/src/components/logistics/dispatcher/DispatcherProfileEditForm.js +1 -1
- package/dist/src/data/actions/e-commerce/opo/updateOpoAction.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/e-commerce/customer/CustomerProfileEditForm.d.ts +3 -1
- package/dist/types/components/logistics/dispatcher/DispatcherProfileEditForm.d.ts +3 -1
- package/dist/types/data/actions/e-commerce/opo/updateOpoAction.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/e-commerce/categories/EditCategoryForm.tsx +2 -0
- package/src/components/e-commerce/customer/CustomerProfileEditForm.tsx +167 -121
- package/src/components/e-commerce/invoice/CreateInvoiceForm.tsx +7 -2
- package/src/components/e-commerce/iro/CreateIROForm.tsx +12 -7
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +24 -16
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +54 -28
- package/src/components/logistics/dispatcher/DispatcherProfileEditForm.tsx +90 -63
- package/src/data/actions/e-commerce/opo/updateOpoAction.ts +6 -2
|
@@ -4,10 +4,12 @@ import Divider from "@mui/material/Divider";
|
|
|
4
4
|
import Paper from "@mui/material/Paper";
|
|
5
5
|
import Box from "@mui/material/Box";
|
|
6
6
|
import Stack from "@mui/material/Stack";
|
|
7
|
+
import Grid from "@mui/material/Grid";
|
|
7
8
|
import Alert from "@mui/material/Alert";
|
|
8
9
|
import TextField from "@mui/material/TextField";
|
|
9
10
|
import Typography from "@mui/material/Typography";
|
|
10
11
|
import Checkbox from "@mui/material/Checkbox";
|
|
12
|
+
import Button from "@mui/material/Button";
|
|
11
13
|
|
|
12
14
|
import { AddressFields } from "../../common/Address";
|
|
13
15
|
import { AddressProps } from "@/types/AddressProps";
|
|
@@ -15,9 +17,9 @@ import { BusinessCredentialsProps } from "@/types/e-commerce/BusinessCredentials
|
|
|
15
17
|
import { SubmitButton } from "../../SubmitButton";
|
|
16
18
|
import { useFormState } from "react-dom";
|
|
17
19
|
import { updateDispatcherProfileAction } from "../../../data/actions/logistics/dispatcher/profile-actions"; //"@/data/actions/profile-actions";
|
|
18
|
-
import { StrapiErrors } from "../../StrapiErrors"; //"@/components/StrapiErrors";
|
|
19
20
|
import { BusinessCredentialsFields } from "../../e-commerce/customer/BusinessCredentials";
|
|
20
21
|
import { useSession } from "../../../context/auth/SessionContext";
|
|
22
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
21
23
|
import React, { useEffect, useState } from "react";
|
|
22
24
|
import { DispatcherProfileProps } from "../../../types/logistics/dispatcher/types";
|
|
23
25
|
import { SxProps } from "@mui/material";
|
|
@@ -27,89 +29,114 @@ const INITIAL_STATE = {
|
|
|
27
29
|
strapiErrors: null,
|
|
28
30
|
data: null,
|
|
29
31
|
message: null,
|
|
32
|
+
severity: null,
|
|
30
33
|
};
|
|
31
34
|
|
|
32
|
-
/* interface DispatcherProfileProps {
|
|
33
|
-
id: string;
|
|
34
|
-
uuid: string;
|
|
35
|
-
dispatcher_number: string;
|
|
36
|
-
first_name: string;
|
|
37
|
-
last_name: string;
|
|
38
|
-
email: string;
|
|
39
|
-
phone: string;
|
|
40
|
-
company_address: AddressProps;
|
|
41
|
-
delivery_address: AddressProps;
|
|
42
|
-
billing_address: AddressProps;
|
|
43
|
-
business_credentials: BusinessCredentialsProps;
|
|
44
|
-
} */
|
|
45
|
-
|
|
46
35
|
export default function DispatcherProfileEditForm({
|
|
47
36
|
data,
|
|
48
37
|
sx,
|
|
38
|
+
revalidateCallback,
|
|
39
|
+
handleClose,
|
|
49
40
|
}: {
|
|
50
41
|
readonly data: DispatcherProfileProps;
|
|
51
42
|
sx?: SxProps;
|
|
43
|
+
revalidateCallback?: () => void;
|
|
44
|
+
handleClose?: () => void;
|
|
52
45
|
}) {
|
|
53
46
|
const { id, uuid, dispatcher_number, address, business_credentials } = data;
|
|
54
|
-
|
|
55
47
|
const [formState, formAction] = useFormState(
|
|
56
48
|
updateDispatcherProfileAction,
|
|
57
49
|
INITIAL_STATE
|
|
58
50
|
);
|
|
51
|
+
const { handleAddMessage } = useSnackbar();
|
|
52
|
+
const { refreshSession } = useSession();
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (formState?.message) {
|
|
56
|
+
handleAddMessage({
|
|
57
|
+
message: formState.message,
|
|
58
|
+
severity: formState.severity || "error",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (formState.severity === "success") {
|
|
62
|
+
refreshSession();
|
|
63
|
+
revalidateCallback && revalidateCallback();
|
|
64
|
+
handleClose && handleClose();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, [formState?.message]);
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (formState?.strapiErrors) {
|
|
71
|
+
handleAddMessage({
|
|
72
|
+
message: formState.strapiErrors.message || "Error performing action",
|
|
73
|
+
severity: "error",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}, [formState?.strapiErrors]);
|
|
67
77
|
|
|
68
78
|
return (
|
|
69
|
-
<Box
|
|
70
|
-
sx={[
|
|
71
|
-
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
72
|
-
{ p: 2 },
|
|
73
|
-
...(Array.isArray(sx) ? sx : [sx]),
|
|
74
|
-
]}
|
|
75
|
-
component={Paper}
|
|
76
|
-
>
|
|
79
|
+
<Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
|
|
77
80
|
<form action={formAction}>
|
|
78
|
-
<
|
|
79
|
-
|
|
81
|
+
<Grid container spacing={2}>
|
|
82
|
+
<Grid item xs={12}>
|
|
83
|
+
<Stack spacing={2}>
|
|
84
|
+
<Typography variant="h3" component="h1" gutterBottom>
|
|
85
|
+
Edit Profile
|
|
86
|
+
</Typography>
|
|
87
|
+
</Stack>
|
|
88
|
+
</Grid>
|
|
80
89
|
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/>
|
|
90
|
+
<Grid item xs={12}>
|
|
91
|
+
<input type="hidden" name="id" value={id} />
|
|
92
|
+
<Paper sx={{ p: 2 }}>
|
|
93
|
+
<Typography variant="h6" gutterBottom>
|
|
94
|
+
Business Credentials
|
|
95
|
+
</Typography>
|
|
96
|
+
<Divider sx={{ mb: 2 }} />
|
|
97
|
+
<BusinessCredentialsFields
|
|
98
|
+
componentName="business_credentials"
|
|
99
|
+
componentReference="business.credentials"
|
|
100
|
+
data={business_credentials}
|
|
101
|
+
/>
|
|
102
|
+
</Paper>
|
|
103
|
+
</Grid>
|
|
96
104
|
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
<Grid item xs={12}>
|
|
106
|
+
<Paper sx={{ p: 2 }}>
|
|
107
|
+
<Typography variant="h6" gutterBottom>
|
|
108
|
+
Company Address
|
|
109
|
+
</Typography>
|
|
110
|
+
<Divider sx={{ mb: 2 }} />
|
|
111
|
+
<AddressFields
|
|
112
|
+
componentName="address"
|
|
113
|
+
componentReference="common.address"
|
|
114
|
+
data={address}
|
|
115
|
+
/>
|
|
116
|
+
</Paper>
|
|
117
|
+
</Grid>
|
|
107
118
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
<Grid item xs={12}>
|
|
120
|
+
<Stack
|
|
121
|
+
direction="row"
|
|
122
|
+
justifyContent="space-between"
|
|
123
|
+
spacing={2}
|
|
124
|
+
alignItems="center"
|
|
125
|
+
sx={{ mt: 2 }}
|
|
126
|
+
>
|
|
127
|
+
{handleClose && (
|
|
128
|
+
<Button onClick={handleClose} variant="outlined">
|
|
129
|
+
Cancel
|
|
130
|
+
</Button>
|
|
131
|
+
)}
|
|
132
|
+
<SubmitButton
|
|
133
|
+
text="Save Changes"
|
|
134
|
+
loadingText="Saving..."
|
|
135
|
+
variant="contained"
|
|
136
|
+
/>
|
|
137
|
+
</Stack>
|
|
138
|
+
</Grid>
|
|
139
|
+
</Grid>
|
|
113
140
|
</form>
|
|
114
141
|
</Box>
|
|
115
142
|
);
|
|
@@ -4,7 +4,11 @@ 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 updateOpoAction(
|
|
7
|
+
export async function updateOpoAction(
|
|
8
|
+
id: number,
|
|
9
|
+
prevState: any,
|
|
10
|
+
formData: FormData
|
|
11
|
+
) {
|
|
8
12
|
const rawFormData = Object.fromEntries(formData);
|
|
9
13
|
|
|
10
14
|
const parsedFormData = parseFormData(formData);
|
|
@@ -12,7 +16,7 @@ export async function updateOpoAction(prevState: any, formData: FormData) {
|
|
|
12
16
|
|
|
13
17
|
const responseData = await mutateData(
|
|
14
18
|
"PUT",
|
|
15
|
-
`/api/opos/${
|
|
19
|
+
`/api/opos/${id}`,
|
|
16
20
|
parsedFormData
|
|
17
21
|
);
|
|
18
22
|
|