umwd-components 0.1.649 → 0.1.650
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/patterns.md +145 -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/categories/AddCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/iro/CreateIROForm.js +1 -1
- package/dist/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
- package/dist/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/src/components/e-commerce/products/AddProductForm.js +1 -1
- package/dist/src/components/e-commerce/products/EditProductForm.js +1 -1
- package/dist/src/components/e-commerce/products/EditStockForm.js +1 -1
- package/dist/src/data/actions/e-commerce/categories/createCategoryAction.js +1 -1
- package/dist/src/data/actions/e-commerce/categories/updateCategoryAction.js +1 -1
- package/dist/src/data/actions/e-commerce/iro/requestRmaAction.js +2 -2
- package/dist/src/data/actions/e-commerce/opo/createOpoAction.js +1 -1
- package/dist/src/data/actions/e-commerce/opo/updateOpoAction.js +1 -1
- package/dist/src/data/actions/e-commerce/product/createProductAction.js +1 -1
- package/dist/src/data/actions/e-commerce/product/updateProductAction.js +1 -1
- package/dist/src/data/loaders/loaders.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/e-commerce/categories/AddCategoryForm.d.ts +2 -1
- package/dist/types/components/e-commerce/categories/CreateCategoryForm.d.ts +9 -0
- package/dist/types/components/e-commerce/categories/EditCategoryForm.d.ts +5 -1
- package/dist/types/components/e-commerce/iro/CreateIROForm.d.ts +4 -1
- package/dist/types/components/e-commerce/iro/RmaForm.d.ts +4 -1
- package/dist/types/components/e-commerce/iro/TextualManageIROForm.d.ts +4 -1
- package/dist/types/components/e-commerce/opo/TextualManageOpoForm.d.ts +4 -1
- package/dist/types/components/e-commerce/products/AddProductForm.d.ts +4 -2
- package/dist/types/components/e-commerce/products/EditProductForm.d.ts +4 -1
- package/package.json +1 -1
- package/src/components/e-commerce/categories/AddCategoryForm.tsx +33 -17
- package/src/components/e-commerce/categories/CreateCategoryForm.tsx +89 -0
- package/src/components/e-commerce/categories/EditCategoryForm.tsx +39 -7
- package/src/components/e-commerce/checkout/CheckoutForm.tsx +1 -0
- package/src/components/e-commerce/iro/CreateIROForm.tsx +27 -10
- package/src/components/e-commerce/iro/RmaForm.tsx +29 -12
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +4 -7
- package/src/components/e-commerce/opo/CreateOpoForm.tsx +23 -9
- package/src/components/e-commerce/opo/ManageOpoForm.tsx +25 -1
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +5 -9
- package/src/components/e-commerce/products/AddProductForm.tsx +36 -4
- package/src/components/e-commerce/products/EditProductForm.tsx +36 -6
- package/src/components/e-commerce/products/EditStockForm.tsx +26 -1
- package/src/data/actions/e-commerce/categories/createCategoryAction.tsx +4 -1
- package/src/data/actions/e-commerce/categories/updateCategoryAction.tsx +4 -1
- package/src/data/actions/e-commerce/checkout-action.ts +0 -1
- package/src/data/actions/e-commerce/iro/cancelIroAction.ts +2 -1
- package/src/data/actions/e-commerce/iro/requestRmaAction.ts +1 -6
- package/src/data/actions/e-commerce/opo/createOpoAction.ts +3 -0
- package/src/data/actions/e-commerce/opo/updateOpoAction.ts +4 -1
- package/src/data/actions/e-commerce/product/createProductAction.tsx +4 -1
- package/src/data/actions/e-commerce/product/updateProductAction.tsx +4 -1
- package/src/data/loaders/loaders.ts +1 -1
|
@@ -25,8 +25,6 @@ import Box from "@mui/material/Box";
|
|
|
25
25
|
import Paper from "@mui/material/Paper";
|
|
26
26
|
import Stack from "@mui/material/Stack";
|
|
27
27
|
import Divider from "@mui/material/Divider";
|
|
28
|
-
import Card from "@mui/material/Card";
|
|
29
|
-
import CardContent from "@mui/material/CardContent";
|
|
30
28
|
import { confirmationService } from "../../../data/services/common/confirmation-service";
|
|
31
29
|
import { cancellationService } from "../../../data/services/common/cancellation-service";
|
|
32
30
|
// TODO this should be futher removed from client side code, reimplement via action ??
|
|
@@ -45,12 +43,15 @@ import BusinessIcon from "@mui/icons-material/Business";
|
|
|
45
43
|
import DescriptionIcon from "@mui/icons-material/Description";
|
|
46
44
|
import UpdateIcon from "@mui/icons-material/Update";
|
|
47
45
|
import { OpoStatusIndicator } from "./OpoStatusIndicator";
|
|
46
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
47
|
+
import { SxProps } from "@mui/material/styles";
|
|
48
48
|
|
|
49
49
|
const INITIAL_STATE = {
|
|
50
50
|
zodErrors: null,
|
|
51
51
|
strapiErrors: null,
|
|
52
52
|
data: null,
|
|
53
53
|
message: null,
|
|
54
|
+
severity: null,
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
function ConfirmFormDialog({
|
|
@@ -171,7 +172,7 @@ export default function TextualManageOPOForm({
|
|
|
171
172
|
revalidateCallback,
|
|
172
173
|
handleClose,
|
|
173
174
|
role,
|
|
174
|
-
}: ManageOpoFormProps) {
|
|
175
|
+
}: ManageOpoFormProps & { sx?: SxProps }) {
|
|
175
176
|
// TODO bind to id of IPO
|
|
176
177
|
const [formState, formAction] = useFormState(updateOpoAction, INITIAL_STATE);
|
|
177
178
|
|
|
@@ -268,12 +269,7 @@ export default function TextualManageOPOForm({
|
|
|
268
269
|
}, [opo]);
|
|
269
270
|
|
|
270
271
|
return (
|
|
271
|
-
<Box
|
|
272
|
-
sx={[
|
|
273
|
-
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
274
|
-
...(Array.isArray(sx) ? sx : [sx]),
|
|
275
|
-
]}
|
|
276
|
-
>
|
|
272
|
+
<Box sx={[{ p: 2 }, ...(Array.isArray(sx) ? sx : [sx])]} component={Paper}>
|
|
277
273
|
<Grid container spacing={2}>
|
|
278
274
|
<Grid item xs={12}>
|
|
279
275
|
<Stack spacing={2}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React, { useState } from "react";
|
|
3
|
+
import React, { useState, useEffect } from "react";
|
|
4
4
|
import { useFormState } from "react-dom";
|
|
5
5
|
|
|
6
6
|
import Paper from "@mui/material/Paper";
|
|
@@ -25,26 +25,58 @@ import { DimensionsFields } from "../../../components/common/Dimensions";
|
|
|
25
25
|
import VendorSelector from "../../../components/logistics/vendor/VendorSelector";
|
|
26
26
|
import { VendorName } from "../../../types/logistics/Vendor";
|
|
27
27
|
import MarkdownEditor from "../../../components/common/markdown/MarkdownEditor";
|
|
28
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
28
29
|
|
|
29
30
|
const INITIAL_STATE = {
|
|
30
31
|
zodErrors: null,
|
|
31
32
|
strapiErrors: null,
|
|
33
|
+
severity: null,
|
|
32
34
|
data: null,
|
|
33
35
|
message: null,
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
export
|
|
38
|
+
export const AddProductForm = ({
|
|
37
39
|
vendorArr,
|
|
38
40
|
categories,
|
|
41
|
+
revalidateCallback,
|
|
42
|
+
handleClose,
|
|
39
43
|
}: {
|
|
40
44
|
vendorArr: VendorName[];
|
|
41
45
|
categories: CategoryName[];
|
|
42
|
-
|
|
46
|
+
revalidateCallback?: () => void;
|
|
47
|
+
handleClose?: () => void;
|
|
48
|
+
}) => {
|
|
49
|
+
const { state, dispatch } = useSnackbar();
|
|
43
50
|
const [formState, formAction] = useFormState(
|
|
44
51
|
createProductAction,
|
|
45
52
|
INITIAL_STATE
|
|
46
53
|
);
|
|
47
54
|
|
|
55
|
+
const { handleAddMessage } = useSnackbar();
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (formState?.message) {
|
|
59
|
+
handleAddMessage({
|
|
60
|
+
message: formState.message,
|
|
61
|
+
severity: formState.severity || "error",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (formState.severity === "success") {
|
|
65
|
+
revalidateCallback && revalidateCallback();
|
|
66
|
+
handleClose && handleClose();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, [formState?.message]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (formState?.strapiErrors) {
|
|
73
|
+
handleAddMessage({
|
|
74
|
+
message: formState.strapiErrors.message || "Error adding product",
|
|
75
|
+
severity: formState.severity || "error",
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, [formState?.strapiErrors]);
|
|
79
|
+
|
|
48
80
|
const [mediaDialogOpen, setMediaDialogOpen] = useState<
|
|
49
81
|
"image" | "gallery" | null
|
|
50
82
|
>(null);
|
|
@@ -224,4 +256,4 @@ export function AddProductForm({
|
|
|
224
256
|
</form>
|
|
225
257
|
</Box>
|
|
226
258
|
);
|
|
227
|
-
}
|
|
259
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React, { useState } from "react";
|
|
3
|
+
import React, { useState, useEffect } from "react";
|
|
4
4
|
import Paper from "@mui/material/Paper";
|
|
5
5
|
import Box from "@mui/material/Box";
|
|
6
6
|
import Stack from "@mui/material/Stack";
|
|
@@ -24,10 +24,13 @@ import { ExtendedProduct } from "../../../types/e-commerce/product/types";
|
|
|
24
24
|
import VendorSelector from "../../../components/logistics/vendor/VendorSelector";
|
|
25
25
|
import { VendorName } from "../../../types/logistics/Vendor";
|
|
26
26
|
import MarkdownEditor from "../../../components/common/markdown/MarkdownEditor";
|
|
27
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
28
|
+
import { SxProps } from "@mui/material/styles";
|
|
27
29
|
|
|
28
30
|
const INITIAL_STATE = {
|
|
29
31
|
zodErrors: null,
|
|
30
32
|
strapiErrors: null,
|
|
33
|
+
severity: null,
|
|
31
34
|
data: null,
|
|
32
35
|
message: null,
|
|
33
36
|
};
|
|
@@ -36,10 +39,14 @@ export function EditProductForm({
|
|
|
36
39
|
data,
|
|
37
40
|
vendorArr,
|
|
38
41
|
categoriesArray,
|
|
42
|
+
revalidateCallback,
|
|
43
|
+
sx,
|
|
39
44
|
}: {
|
|
40
45
|
data: ExtendedProduct;
|
|
41
46
|
vendorArr: VendorName[];
|
|
42
47
|
categoriesArray: CategoryName[];
|
|
48
|
+
revalidateCallback?: () => void;
|
|
49
|
+
sx?: SxProps;
|
|
43
50
|
}) {
|
|
44
51
|
const {
|
|
45
52
|
id,
|
|
@@ -58,11 +65,34 @@ export function EditProductForm({
|
|
|
58
65
|
const initialGallery = gallery?.data || [];
|
|
59
66
|
const initialCategories = categories?.data || [];
|
|
60
67
|
|
|
68
|
+
const { handleAddMessage } = useSnackbar();
|
|
61
69
|
const [formState, formAction] = useFormState(
|
|
62
70
|
updateProductAction,
|
|
63
71
|
INITIAL_STATE
|
|
64
72
|
);
|
|
65
73
|
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (formState?.message) {
|
|
76
|
+
handleAddMessage({
|
|
77
|
+
message: formState.message,
|
|
78
|
+
severity: formState.severity || "error",
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
if (formState.severity === "success") {
|
|
82
|
+
revalidateCallback && revalidateCallback();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [formState?.message]);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (formState?.strapiErrors) {
|
|
89
|
+
handleAddMessage({
|
|
90
|
+
message: formState.strapiErrors.message || "Error updating product",
|
|
91
|
+
severity: formState.severity || "error",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}, [formState?.strapiErrors]);
|
|
95
|
+
|
|
66
96
|
const [mediaDialogOpen, setMediaDialogOpen] = useState<
|
|
67
97
|
"image" | "gallery" | null
|
|
68
98
|
>(null);
|
|
@@ -97,12 +127,12 @@ export function EditProductForm({
|
|
|
97
127
|
|
|
98
128
|
return (
|
|
99
129
|
<Box
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
130
|
+
sx={[
|
|
131
|
+
{ p: 2 },
|
|
132
|
+
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
133
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
134
|
+
]}
|
|
104
135
|
component={Paper}
|
|
105
|
-
sx={{ p: 2 }}
|
|
106
136
|
>
|
|
107
137
|
<form action={formAction}>
|
|
108
138
|
{id && <input id="id" type="hidden" name="id" value={id} />}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React, { useState } from "react";
|
|
3
|
+
import React, { useState, useEffect } from "react";
|
|
4
4
|
import Paper from "@mui/material/Paper";
|
|
5
5
|
import Box from "@mui/material/Box";
|
|
6
6
|
import Stack from "@mui/material/Stack";
|
|
@@ -28,10 +28,12 @@ import {
|
|
|
28
28
|
import AmountIndicator from "../../../components/common/AmountIndicator";
|
|
29
29
|
import { IpoItem } from "../../../types/logistics/Ipo";
|
|
30
30
|
import { OpoItem } from "../../../types/e-commerce/opo/types";
|
|
31
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
31
32
|
|
|
32
33
|
const INITIAL_STATE = {
|
|
33
34
|
zodErrors: null,
|
|
34
35
|
strapiErrors: null,
|
|
36
|
+
severity: null,
|
|
35
37
|
data: null,
|
|
36
38
|
message: null,
|
|
37
39
|
};
|
|
@@ -51,6 +53,29 @@ export function EditStockForm({
|
|
|
51
53
|
updateProductAction,
|
|
52
54
|
INITIAL_STATE
|
|
53
55
|
);
|
|
56
|
+
const { handleAddMessage } = useSnackbar();
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (formState?.message) {
|
|
60
|
+
handleAddMessage({
|
|
61
|
+
message: formState.message,
|
|
62
|
+
severity: formState.severity || "error",
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (formState.severity === "success") {
|
|
66
|
+
revalidateCallback && revalidateCallback();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, [formState?.message]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (formState?.strapiErrors) {
|
|
73
|
+
handleAddMessage({
|
|
74
|
+
message: formState.strapiErrors.message || "Error updating stock",
|
|
75
|
+
severity: formState.severity || "error",
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, [formState?.strapiErrors]);
|
|
54
79
|
|
|
55
80
|
return (
|
|
56
81
|
<Box
|
|
@@ -26,6 +26,7 @@ export async function createCategoryAction(prevState: any, formData: FormData) {
|
|
|
26
26
|
if (!responseData) {
|
|
27
27
|
return {
|
|
28
28
|
...prevState,
|
|
29
|
+
severity: "error",
|
|
29
30
|
strapiErrors: null,
|
|
30
31
|
message: "Ops! Something went wrong. Please try again.",
|
|
31
32
|
};
|
|
@@ -34,6 +35,7 @@ export async function createCategoryAction(prevState: any, formData: FormData) {
|
|
|
34
35
|
if (responseData.error) {
|
|
35
36
|
return {
|
|
36
37
|
...prevState,
|
|
38
|
+
severity: "error",
|
|
37
39
|
strapiErrors: responseData.error,
|
|
38
40
|
message: "Failed to Create Category.",
|
|
39
41
|
};
|
|
@@ -43,7 +45,8 @@ export async function createCategoryAction(prevState: any, formData: FormData) {
|
|
|
43
45
|
|
|
44
46
|
return {
|
|
45
47
|
...prevState,
|
|
46
|
-
|
|
48
|
+
severity: "success",
|
|
49
|
+
message: "Category Created Successfully",
|
|
47
50
|
data: flattenedData,
|
|
48
51
|
strapiErrors: null,
|
|
49
52
|
};
|
|
@@ -26,6 +26,7 @@ export async function updateCategoryAction(prevState: any, formData: FormData) {
|
|
|
26
26
|
if (!responseData) {
|
|
27
27
|
return {
|
|
28
28
|
...prevState,
|
|
29
|
+
severity: "error",
|
|
29
30
|
strapiErrors: null,
|
|
30
31
|
message: "Ops! Something went wrong. Please try again.",
|
|
31
32
|
};
|
|
@@ -34,6 +35,7 @@ export async function updateCategoryAction(prevState: any, formData: FormData) {
|
|
|
34
35
|
if (responseData.error) {
|
|
35
36
|
return {
|
|
36
37
|
...prevState,
|
|
38
|
+
severity: "error",
|
|
37
39
|
strapiErrors: responseData.error,
|
|
38
40
|
message: "Failed to Update Category.",
|
|
39
41
|
};
|
|
@@ -43,7 +45,8 @@ export async function updateCategoryAction(prevState: any, formData: FormData) {
|
|
|
43
45
|
|
|
44
46
|
return {
|
|
45
47
|
...prevState,
|
|
46
|
-
|
|
48
|
+
severity: "success",
|
|
49
|
+
message: "Category Updated Successfully",
|
|
47
50
|
data: flattenedData,
|
|
48
51
|
strapiErrors: null,
|
|
49
52
|
};
|
|
@@ -13,7 +13,6 @@ export async function cancelIroAction(prevState: any, formData: FormData) {
|
|
|
13
13
|
const rawFormData = Object.fromEntries(formData);
|
|
14
14
|
|
|
15
15
|
const parsedFormData = parseFormData(formData);
|
|
16
|
-
console.log("parsedFormData", parsedFormData);
|
|
17
16
|
|
|
18
17
|
const responseData = await mutateData(
|
|
19
18
|
"PUT",
|
|
@@ -24,6 +23,7 @@ export async function cancelIroAction(prevState: any, formData: FormData) {
|
|
|
24
23
|
if (!responseData) {
|
|
25
24
|
return {
|
|
26
25
|
...prevState,
|
|
26
|
+
severity: "error",
|
|
27
27
|
strapiErrors: null,
|
|
28
28
|
message: "Ops! Something went wrong. Please try again.",
|
|
29
29
|
};
|
|
@@ -32,6 +32,7 @@ export async function cancelIroAction(prevState: any, formData: FormData) {
|
|
|
32
32
|
if (responseData.error) {
|
|
33
33
|
return {
|
|
34
34
|
...prevState,
|
|
35
|
+
severity: "error",
|
|
35
36
|
strapiErrors: responseData.error,
|
|
36
37
|
message: "Failed to Cancel Iro.",
|
|
37
38
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"use
|
|
2
|
-
//"use server";
|
|
1
|
+
"use server";
|
|
3
2
|
|
|
4
3
|
import { mutateData } from "../../../services/mutate-data";
|
|
5
4
|
import { flattenAttributes } from "../../../../lib/utils";
|
|
@@ -10,10 +9,8 @@ import { parseFormData } from "../../../../lib/parseFormData";
|
|
|
10
9
|
*/
|
|
11
10
|
export async function requestRmaAction(prevState: any, formData: FormData) {
|
|
12
11
|
const rawFormData = Object.fromEntries(formData);
|
|
13
|
-
console.log(rawFormData);
|
|
14
12
|
|
|
15
13
|
const parsedFormData = parseFormData(formData);
|
|
16
|
-
console.log(parsedFormData);
|
|
17
14
|
|
|
18
15
|
if (parsedFormData.data.iro_items) {
|
|
19
16
|
parsedFormData.data.iro_items = JSON.parse(parsedFormData.data.iro_items);
|
|
@@ -23,8 +20,6 @@ export async function requestRmaAction(prevState: any, formData: FormData) {
|
|
|
23
20
|
parsedFormData.data.opos = JSON.parse(parsedFormData.data.opos);
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
console.log("parsedFormData", parsedFormData);
|
|
27
|
-
|
|
28
23
|
const responseData = await mutateData("POST", `/api/iros`, parsedFormData);
|
|
29
24
|
|
|
30
25
|
if (!responseData) {
|
|
@@ -22,6 +22,7 @@ export async function createOpoAction(prevState: any, formData: FormData) {
|
|
|
22
22
|
if (!responseData) {
|
|
23
23
|
return {
|
|
24
24
|
...prevState,
|
|
25
|
+
severity: "error",
|
|
25
26
|
strapiErrors: null,
|
|
26
27
|
message: "Ops! Something went wrong. Please try again.",
|
|
27
28
|
};
|
|
@@ -30,6 +31,7 @@ export async function createOpoAction(prevState: any, formData: FormData) {
|
|
|
30
31
|
if (responseData.error) {
|
|
31
32
|
return {
|
|
32
33
|
...prevState,
|
|
34
|
+
severity: "error",
|
|
33
35
|
strapiErrors: responseData.error,
|
|
34
36
|
message: "Failed to Create Opo.",
|
|
35
37
|
};
|
|
@@ -39,6 +41,7 @@ export async function createOpoAction(prevState: any, formData: FormData) {
|
|
|
39
41
|
|
|
40
42
|
return {
|
|
41
43
|
...prevState,
|
|
44
|
+
severity: "success",
|
|
42
45
|
message: "Opo Created Successfully",
|
|
43
46
|
data: flattenedData,
|
|
44
47
|
strapiErrors: null,
|
|
@@ -19,6 +19,7 @@ export async function updateOpoAction(prevState: any, formData: FormData) {
|
|
|
19
19
|
if (!responseData) {
|
|
20
20
|
return {
|
|
21
21
|
...prevState,
|
|
22
|
+
severity: "error",
|
|
22
23
|
strapiErrors: null,
|
|
23
24
|
message: "Ops! Something went wrong. Please try again.",
|
|
24
25
|
};
|
|
@@ -27,6 +28,7 @@ export async function updateOpoAction(prevState: any, formData: FormData) {
|
|
|
27
28
|
if (responseData.error) {
|
|
28
29
|
return {
|
|
29
30
|
...prevState,
|
|
31
|
+
severity: "error",
|
|
30
32
|
strapiErrors: responseData.error,
|
|
31
33
|
message: "Failed to Update Opo.",
|
|
32
34
|
};
|
|
@@ -36,7 +38,8 @@ export async function updateOpoAction(prevState: any, formData: FormData) {
|
|
|
36
38
|
|
|
37
39
|
return {
|
|
38
40
|
...prevState,
|
|
39
|
-
|
|
41
|
+
severity: "success",
|
|
42
|
+
message: "Opo Updated Successfully",
|
|
40
43
|
data: flattenedData,
|
|
41
44
|
strapiErrors: null,
|
|
42
45
|
};
|
|
@@ -41,6 +41,7 @@ export async function createProductAction(prevState: any, formData: FormData) {
|
|
|
41
41
|
if (!responseData) {
|
|
42
42
|
return {
|
|
43
43
|
...prevState,
|
|
44
|
+
severity: "error",
|
|
44
45
|
strapiErrors: null,
|
|
45
46
|
message: "Ops! Something went wrong. Please try again.",
|
|
46
47
|
};
|
|
@@ -49,6 +50,7 @@ export async function createProductAction(prevState: any, formData: FormData) {
|
|
|
49
50
|
if (responseData.error) {
|
|
50
51
|
return {
|
|
51
52
|
...prevState,
|
|
53
|
+
severity: "error",
|
|
52
54
|
strapiErrors: responseData.error,
|
|
53
55
|
message: "Failed to Create Product.",
|
|
54
56
|
};
|
|
@@ -58,7 +60,8 @@ export async function createProductAction(prevState: any, formData: FormData) {
|
|
|
58
60
|
|
|
59
61
|
return {
|
|
60
62
|
...prevState,
|
|
61
|
-
|
|
63
|
+
severity: "success",
|
|
64
|
+
message: "Product Created Successfully",
|
|
62
65
|
data: flattenedData,
|
|
63
66
|
strapiErrors: null,
|
|
64
67
|
};
|
|
@@ -40,6 +40,7 @@ export async function updateProductAction(prevState: any, formData: FormData) {
|
|
|
40
40
|
if (!responseData) {
|
|
41
41
|
return {
|
|
42
42
|
...prevState,
|
|
43
|
+
severity: "error",
|
|
43
44
|
strapiErrors: null,
|
|
44
45
|
message: "Ops! Something went wrong. Please try again.",
|
|
45
46
|
};
|
|
@@ -48,6 +49,7 @@ export async function updateProductAction(prevState: any, formData: FormData) {
|
|
|
48
49
|
if (responseData.error) {
|
|
49
50
|
return {
|
|
50
51
|
...prevState,
|
|
52
|
+
severity: "error",
|
|
51
53
|
strapiErrors: responseData.error,
|
|
52
54
|
message: "Failed to Update Product.",
|
|
53
55
|
};
|
|
@@ -57,7 +59,8 @@ export async function updateProductAction(prevState: any, formData: FormData) {
|
|
|
57
59
|
|
|
58
60
|
return {
|
|
59
61
|
...prevState,
|
|
60
|
-
|
|
62
|
+
severity: "success",
|
|
63
|
+
message: "Product Updated Successfully",
|
|
61
64
|
data: flattenedData,
|
|
62
65
|
strapiErrors: null,
|
|
63
66
|
};
|