umwd-components 0.1.653 → 0.1.655

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 (24) hide show
  1. package/.ai/{patterns.md → form-patterns.md} +39 -2
  2. package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
  3. package/dist/src/components/e-commerce/invoice/CreateInvoiceForm.js +1 -1
  4. package/dist/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
  5. package/dist/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
  6. package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  7. package/dist/src/components/e-commerce/products/AddProductForm.js +1 -1
  8. package/dist/src/components/e-commerce/products/EditProductForm.js +1 -1
  9. package/dist/src/components/e-commerce/products/EditStockForm.js +1 -1
  10. package/dist/tsconfig.build.tsbuildinfo +1 -1
  11. package/dist/types/components/e-commerce/invoice/CreateInvoiceForm.d.ts +2 -1
  12. package/dist/types/components/e-commerce/products/AddProductForm.d.ts +1 -1
  13. package/dist/types/components/e-commerce/products/EditProductForm.d.ts +2 -1
  14. package/dist/types/components/e-commerce/products/EditStockForm.d.ts +2 -1
  15. package/package.json +1 -1
  16. package/src/components/e-commerce/categories/CreateCategoryForm.tsx +13 -12
  17. package/src/components/e-commerce/categories/EditCategoryForm.tsx +13 -20
  18. package/src/components/e-commerce/invoice/CreateInvoiceForm.tsx +51 -49
  19. package/src/components/e-commerce/opo/CreateOpoForm.tsx +21 -8
  20. package/src/components/e-commerce/opo/ManageOpoForm.tsx +11 -6
  21. package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +12 -13
  22. package/src/components/e-commerce/products/AddProductForm.tsx +21 -18
  23. package/src/components/e-commerce/products/EditProductForm.tsx +23 -19
  24. package/src/components/e-commerce/products/EditStockForm.tsx +31 -31
@@ -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,18 +63,19 @@ 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
81
  <Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
@@ -391,21 +391,21 @@ export function EditStockForm({
391
391
  </Grid>
392
392
  <Grid item xs={12}>
393
393
  <Stack
394
- direction="row-reverse"
395
- spacing={2}
396
- alignItems={"center"}
397
- sx={{
398
- py: 1,
399
- }}
394
+ direction="row"
395
+ justifyContent="space-between"
396
+ alignItems="center"
397
+ sx={{ py: 1 }}
400
398
  >
401
- <SubmitButton text="update stock" loadingText="loading" />
402
- {formState?.strapiErrors && (
403
- <StrapiErrors error={formState?.strapiErrors} />
404
- )}
405
-
406
- {formState?.message && (
407
- <Alert severity="error">{formState?.message}</Alert>
399
+ {handleClose && (
400
+ <Button onClick={handleClose} variant="outlined">
401
+ Close
402
+ </Button>
408
403
  )}
404
+ <SubmitButton
405
+ text="Update Stock"
406
+ loadingText="Updating..."
407
+ variant="contained"
408
+ />
409
409
  </Stack>
410
410
  </Grid>
411
411
  </Grid>