umwd-components 0.1.652 → 0.1.654
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 → form-patterns.md} +39 -2
- 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/invoice/CreateInvoiceForm.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/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/e-commerce/invoice/CreateInvoiceForm.d.ts +2 -1
- package/dist/types/components/e-commerce/products/AddProductForm.d.ts +3 -1
- package/dist/types/components/e-commerce/products/EditProductForm.d.ts +2 -1
- package/dist/types/components/e-commerce/products/EditStockForm.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/e-commerce/categories/AddCategoryForm.tsx +3 -6
- package/src/components/e-commerce/categories/CreateCategoryForm.tsx +2 -2
- package/src/components/e-commerce/categories/EditCategoryForm.tsx +3 -10
- package/src/components/e-commerce/invoice/CreateInvoiceForm.tsx +51 -49
- package/src/components/e-commerce/iro/CreateIROForm.tsx +1 -1
- package/src/components/e-commerce/iro/RmaForm.tsx +1 -1
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +16 -11
- package/src/components/e-commerce/opo/CreateOpoForm.tsx +21 -8
- package/src/components/e-commerce/opo/ManageOpoForm.tsx +11 -6
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +12 -13
- package/src/components/e-commerce/products/AddProductForm.tsx +24 -25
- package/src/components/e-commerce/products/EditProductForm.tsx +24 -28
- package/src/components/e-commerce/products/EditStockForm.tsx +32 -39
|
@@ -40,12 +40,14 @@ export function EditProductForm({
|
|
|
40
40
|
vendorArr,
|
|
41
41
|
categoriesArray,
|
|
42
42
|
revalidateCallback,
|
|
43
|
+
handleClose,
|
|
43
44
|
sx,
|
|
44
45
|
}: {
|
|
45
46
|
data: ExtendedProduct;
|
|
46
47
|
vendorArr: VendorName[];
|
|
47
48
|
categoriesArray: CategoryName[];
|
|
48
49
|
revalidateCallback?: () => void;
|
|
50
|
+
handleClose?: () => void;
|
|
49
51
|
sx?: SxProps;
|
|
50
52
|
}) {
|
|
51
53
|
const {
|
|
@@ -60,7 +62,6 @@ export function EditProductForm({
|
|
|
60
62
|
categories,
|
|
61
63
|
vendors,
|
|
62
64
|
} = data;
|
|
63
|
-
console.log("data", data);
|
|
64
65
|
|
|
65
66
|
const initialGallery = gallery?.data || [];
|
|
66
67
|
const initialCategories = categories?.data || [];
|
|
@@ -80,6 +81,7 @@ export function EditProductForm({
|
|
|
80
81
|
|
|
81
82
|
if (formState.severity === "success") {
|
|
82
83
|
revalidateCallback && revalidateCallback();
|
|
84
|
+
handleClose && handleClose();
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
}, [formState?.message]);
|
|
@@ -126,17 +128,15 @@ export function EditProductForm({
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
return (
|
|
129
|
-
<Box
|
|
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
|
-
]}
|
|
135
|
-
component={Paper}
|
|
136
|
-
>
|
|
131
|
+
<Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
|
|
137
132
|
<form action={formAction}>
|
|
138
133
|
{id && <input id="id" type="hidden" name="id" value={id} />}
|
|
139
134
|
<Grid container spacing={2}>
|
|
135
|
+
<Grid item xs={12}>
|
|
136
|
+
<Typography variant="h3" component="h1">
|
|
137
|
+
Edit Product
|
|
138
|
+
</Typography>
|
|
139
|
+
</Grid>
|
|
140
140
|
<Grid item xs={12}>
|
|
141
141
|
<Stack spacing={2}>
|
|
142
142
|
<TextField
|
|
@@ -276,25 +276,21 @@ export function EditProductForm({
|
|
|
276
276
|
currentValue={vendors.data?.[0]?.id}
|
|
277
277
|
/>
|
|
278
278
|
</Grid>
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
<
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
{formState?.message && (
|
|
295
|
-
<Alert severity="error">{formState?.message}</Alert>
|
|
296
|
-
)}
|
|
297
|
-
</Stack>
|
|
279
|
+
<Grid item xs={12}>
|
|
280
|
+
<Stack
|
|
281
|
+
direction="row"
|
|
282
|
+
justifyContent="space-between"
|
|
283
|
+
alignItems="center"
|
|
284
|
+
sx={{ py: 1 }}
|
|
285
|
+
>
|
|
286
|
+
{handleClose && (
|
|
287
|
+
<Button onClick={handleClose} variant="outlined">
|
|
288
|
+
Cancel
|
|
289
|
+
</Button>
|
|
290
|
+
)}
|
|
291
|
+
<SubmitButton text="update product" loadingText="loading" />
|
|
292
|
+
</Stack>
|
|
293
|
+
</Grid>
|
|
298
294
|
</Grid>
|
|
299
295
|
</form>
|
|
300
296
|
</Box>
|
|
@@ -4,56 +4,55 @@ 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";
|
|
7
|
-
import Alert from "@mui/material/Alert";
|
|
8
7
|
import Typography from "@mui/material/Typography";
|
|
9
8
|
import { SubmitButton } from "../../SubmitButton";
|
|
10
9
|
import { useFormState } from "react-dom";
|
|
11
|
-
import { StrapiErrors } from "../../StrapiErrors";
|
|
12
10
|
import { updateProductAction } from "../../../data/actions/e-commerce/product/updateProductAction";
|
|
13
11
|
import Grid from "@mui/material/Grid";
|
|
14
12
|
import { ProductStock } from "../../../types/e-commerce/product/types";
|
|
15
13
|
import { SxProps } from "@mui/material/styles";
|
|
16
14
|
import ReportsDisplay from "../../logistics/report/ReportsDisplay";
|
|
17
15
|
import ReportMakingComponent from "../../logistics/report/ReportMakingComponent";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
17
|
+
import Table from "@mui/material/Table";
|
|
18
|
+
import TableBody from "@mui/material/TableBody";
|
|
19
|
+
import TableCell from "@mui/material/TableCell";
|
|
20
|
+
import TableContainer from "@mui/material/TableContainer";
|
|
21
|
+
import TableFooter from "@mui/material/TableFooter";
|
|
22
|
+
import TableHead from "@mui/material/TableHead";
|
|
23
|
+
import TableRow from "@mui/material/TableRow";
|
|
24
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
25
|
+
import Button from "@mui/material/Button";
|
|
28
26
|
import AmountIndicator from "../../../components/common/AmountIndicator";
|
|
29
27
|
import { IpoItem } from "../../../types/logistics/Ipo";
|
|
30
28
|
import { OpoItem } from "../../../types/e-commerce/opo/types";
|
|
31
|
-
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
32
29
|
|
|
33
30
|
const INITIAL_STATE = {
|
|
34
31
|
zodErrors: null,
|
|
35
32
|
strapiErrors: null,
|
|
36
|
-
severity: null,
|
|
37
33
|
data: null,
|
|
38
34
|
message: null,
|
|
35
|
+
severity: null,
|
|
39
36
|
};
|
|
40
37
|
|
|
41
38
|
export function EditStockForm({
|
|
42
39
|
data,
|
|
43
40
|
revalidateCallback,
|
|
41
|
+
handleClose,
|
|
44
42
|
sx,
|
|
45
43
|
}: {
|
|
46
44
|
data: ProductStock;
|
|
47
45
|
revalidateCallback: () => void;
|
|
46
|
+
handleClose?: () => void;
|
|
48
47
|
sx?: SxProps;
|
|
49
48
|
}) {
|
|
50
49
|
const { id, title, product_number, stock, ipos, opos, reports } = data;
|
|
50
|
+
const { handleAddMessage } = useSnackbar();
|
|
51
51
|
|
|
52
52
|
const [formState, formAction] = useFormState(
|
|
53
53
|
updateProductAction,
|
|
54
54
|
INITIAL_STATE
|
|
55
55
|
);
|
|
56
|
-
const { handleAddMessage } = useSnackbar();
|
|
57
56
|
|
|
58
57
|
useEffect(() => {
|
|
59
58
|
if (formState?.message) {
|
|
@@ -64,28 +63,22 @@ export function EditStockForm({
|
|
|
64
63
|
|
|
65
64
|
if (formState.severity === "success") {
|
|
66
65
|
revalidateCallback && revalidateCallback();
|
|
66
|
+
handleClose && handleClose();
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
}, [formState?.message]);
|
|
69
|
+
}, [formState?.message, handleAddMessage, revalidateCallback, handleClose]);
|
|
70
70
|
|
|
71
71
|
useEffect(() => {
|
|
72
72
|
if (formState?.strapiErrors) {
|
|
73
73
|
handleAddMessage({
|
|
74
74
|
message: formState.strapiErrors.message || "Error updating stock",
|
|
75
|
-
severity:
|
|
75
|
+
severity: "error",
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
}, [formState?.strapiErrors]);
|
|
78
|
+
}, [formState?.strapiErrors, handleAddMessage]);
|
|
79
79
|
|
|
80
80
|
return (
|
|
81
|
-
<Box
|
|
82
|
-
sx={[
|
|
83
|
-
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
84
|
-
{ p: 2 },
|
|
85
|
-
...(Array.isArray(sx) ? sx : [sx]),
|
|
86
|
-
]}
|
|
87
|
-
component={Paper}
|
|
88
|
-
>
|
|
81
|
+
<Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
|
|
89
82
|
<Grid container spacing={2}>
|
|
90
83
|
<Grid item xs={12}>
|
|
91
84
|
<Typography variant="h6">{title}</Typography>
|
|
@@ -398,21 +391,21 @@ export function EditStockForm({
|
|
|
398
391
|
</Grid>
|
|
399
392
|
<Grid item xs={12}>
|
|
400
393
|
<Stack
|
|
401
|
-
direction="row
|
|
402
|
-
|
|
403
|
-
alignItems=
|
|
404
|
-
sx={{
|
|
405
|
-
py: 1,
|
|
406
|
-
}}
|
|
394
|
+
direction="row"
|
|
395
|
+
justifyContent="space-between"
|
|
396
|
+
alignItems="center"
|
|
397
|
+
sx={{ py: 1 }}
|
|
407
398
|
>
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
{formState?.message && (
|
|
414
|
-
<Alert severity="error">{formState?.message}</Alert>
|
|
399
|
+
{handleClose && (
|
|
400
|
+
<Button onClick={handleClose} variant="outlined">
|
|
401
|
+
Close
|
|
402
|
+
</Button>
|
|
415
403
|
)}
|
|
404
|
+
<SubmitButton
|
|
405
|
+
text="Update Stock"
|
|
406
|
+
loadingText="Updating..."
|
|
407
|
+
variant="contained"
|
|
408
|
+
/>
|
|
416
409
|
</Stack>
|
|
417
410
|
</Grid>
|
|
418
411
|
</Grid>
|