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.
Files changed (32) hide show
  1. package/.ai/{patterns.md → form-patterns.md} +39 -2
  2. package/dist/src/components/e-commerce/categories/AddCategoryForm.js +1 -1
  3. package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
  4. package/dist/src/components/e-commerce/invoice/CreateInvoiceForm.js +1 -1
  5. package/dist/src/components/e-commerce/iro/CreateIROForm.js +1 -1
  6. package/dist/src/components/e-commerce/iro/RmaForm.js +1 -1
  7. package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
  8. package/dist/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
  9. package/dist/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
  10. package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  11. package/dist/src/components/e-commerce/products/AddProductForm.js +1 -1
  12. package/dist/src/components/e-commerce/products/EditProductForm.js +1 -1
  13. package/dist/src/components/e-commerce/products/EditStockForm.js +1 -1
  14. package/dist/tsconfig.build.tsbuildinfo +1 -1
  15. package/dist/types/components/e-commerce/invoice/CreateInvoiceForm.d.ts +2 -1
  16. package/dist/types/components/e-commerce/products/AddProductForm.d.ts +3 -1
  17. package/dist/types/components/e-commerce/products/EditProductForm.d.ts +2 -1
  18. package/dist/types/components/e-commerce/products/EditStockForm.d.ts +2 -1
  19. package/package.json +1 -1
  20. package/src/components/e-commerce/categories/AddCategoryForm.tsx +3 -6
  21. package/src/components/e-commerce/categories/CreateCategoryForm.tsx +2 -2
  22. package/src/components/e-commerce/categories/EditCategoryForm.tsx +3 -10
  23. package/src/components/e-commerce/invoice/CreateInvoiceForm.tsx +51 -49
  24. package/src/components/e-commerce/iro/CreateIROForm.tsx +1 -1
  25. package/src/components/e-commerce/iro/RmaForm.tsx +1 -1
  26. package/src/components/e-commerce/iro/TextualManageIROForm.tsx +16 -11
  27. package/src/components/e-commerce/opo/CreateOpoForm.tsx +21 -8
  28. package/src/components/e-commerce/opo/ManageOpoForm.tsx +11 -6
  29. package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +12 -13
  30. package/src/components/e-commerce/products/AddProductForm.tsx +24 -25
  31. package/src/components/e-commerce/products/EditProductForm.tsx +24 -28
  32. 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
- </Grid>
280
- <Grid item xs={12}>
281
- <Stack
282
- direction="row-reverse"
283
- spacing={2}
284
- alignItems={"center"}
285
- sx={{
286
- py: 1,
287
- }}
288
- >
289
- <SubmitButton text="update product" loadingText="loading" />
290
- {formState?.strapiErrors && (
291
- <StrapiErrors error={formState?.strapiErrors} />
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
- Table,
20
- TableBody,
21
- TableCell,
22
- TableContainer,
23
- TableFooter,
24
- TableHead,
25
- TableRow,
26
- Tooltip,
27
- } from "@mui/material";
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: formState.severity || "error",
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-reverse"
402
- spacing={2}
403
- alignItems={"center"}
404
- sx={{
405
- py: 1,
406
- }}
394
+ direction="row"
395
+ justifyContent="space-between"
396
+ alignItems="center"
397
+ sx={{ py: 1 }}
407
398
  >
408
- <SubmitButton text="update stock" loadingText="loading" />
409
- {formState?.strapiErrors && (
410
- <StrapiErrors error={formState?.strapiErrors} />
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>