umwd-components 0.1.643 → 0.1.644
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/dist/src/components/e-commerce/invoice/InvoicePDF.js +1 -1
- package/dist/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/src/context/common/SnackbarContext.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/context/common/SnackbarContext.d.ts +6 -0
- package/package.json +1 -1
- package/src/components/e-commerce/invoice/InvoicePDF.tsx +1 -1
- package/src/components/e-commerce/iro/CreateIROForm.tsx +0 -1
- package/src/components/e-commerce/iro/TextualManageIROForm.tsx +17 -4
- package/src/context/common/SnackbarContext.tsx +30 -56
- package/src/data/actions/e-commerce/iro/cancelIroAction.ts +1 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { SnackbarState } from "../../types/common/snackbar/Snackbar";
|
|
3
|
+
import { SnackbarCloseReason } from "@mui/material";
|
|
3
4
|
export declare const SnackbarProvider: ({ children }: {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
}) => React.JSX.Element;
|
|
@@ -10,4 +11,9 @@ export declare const useSnackbar: () => {
|
|
|
10
11
|
message: string;
|
|
11
12
|
severity: "success" | "error" | "info" | "warning";
|
|
12
13
|
}) => void;
|
|
14
|
+
handleAddMessages: (value: {
|
|
15
|
+
message: string;
|
|
16
|
+
severity: "success" | "error" | "info" | "warning";
|
|
17
|
+
}[]) => void;
|
|
18
|
+
handleClose: (event: Event | React.SyntheticEvent<any, Event>, reason: SnackbarCloseReason, id: string) => void;
|
|
13
19
|
};
|
package/package.json
CHANGED
|
@@ -338,7 +338,7 @@ function InvoicePDF({ props }: { props: { invoice: Invoice } }) {
|
|
|
338
338
|
<Text
|
|
339
339
|
style={{ ...styles.h3, border: "2px solid black", padding: 10 }}
|
|
340
340
|
>
|
|
341
|
-
Total
|
|
341
|
+
Total: € {invoice?.total_incl_vat?.toFixed(2)}
|
|
342
342
|
</Text>
|
|
343
343
|
</View>
|
|
344
344
|
|
|
@@ -17,7 +17,6 @@ import TextField from "@mui/material/TextField";
|
|
|
17
17
|
import Checkbox from "@mui/material/Checkbox";
|
|
18
18
|
import Alert from "@mui/material/Alert";
|
|
19
19
|
import Stack from "@mui/material/Stack";
|
|
20
|
-
import IroItemDisplay from "./IroItemDisplay";
|
|
21
20
|
|
|
22
21
|
const INITIAL_STATE = {
|
|
23
22
|
zodErrors: null,
|
|
@@ -52,6 +52,7 @@ import { Iro } from "../../../types/e-commerce/iro/types";
|
|
|
52
52
|
import { queryAllProducts } from "../../../data/loaders/e-commerce/queryAllProducts";
|
|
53
53
|
import qs from "qs";
|
|
54
54
|
import { Product } from "../../../types/e-commerce/product/types";
|
|
55
|
+
import { useSnackbar } from "../../../context/common/SnackbarContext";
|
|
55
56
|
|
|
56
57
|
const INITIAL_STATE = {
|
|
57
58
|
zodErrors: null,
|
|
@@ -583,12 +584,28 @@ export default function TextualManageIROForm({
|
|
|
583
584
|
setItems(newItems);
|
|
584
585
|
};
|
|
585
586
|
|
|
587
|
+
const { handleAddMessage } = useSnackbar();
|
|
588
|
+
|
|
586
589
|
useEffect(() => {
|
|
587
590
|
if (formState?.message === "Iro Updated") {
|
|
591
|
+
handleAddMessage({
|
|
592
|
+
message: "Iro Updated",
|
|
593
|
+
severity: "success",
|
|
594
|
+
});
|
|
595
|
+
handleClose && handleClose();
|
|
588
596
|
revalidateCallback && revalidateCallback();
|
|
589
597
|
}
|
|
590
598
|
}, [formState]);
|
|
591
599
|
|
|
600
|
+
useEffect(() => {
|
|
601
|
+
if (formState?.strapiErrors) {
|
|
602
|
+
handleAddMessage({
|
|
603
|
+
message: formState.strapiErrors.message || "Error updating IRO",
|
|
604
|
+
severity: "error",
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
}, [formState?.strapiErrors]);
|
|
608
|
+
|
|
592
609
|
useEffect(() => {
|
|
593
610
|
console.log("data", data);
|
|
594
611
|
if (data.iro_items?.data) {
|
|
@@ -881,10 +898,6 @@ export default function TextualManageIROForm({
|
|
|
881
898
|
<Paper sx={{ p: 2 }}>
|
|
882
899
|
<Stack direction="row" spacing={2} justifyContent={"end"}>
|
|
883
900
|
<SubmitButton text="Update items" loadingText="Loading..." />
|
|
884
|
-
<StrapiErrors error={formState?.strapiErrors} />
|
|
885
|
-
{formState?.message && (
|
|
886
|
-
<Alert severity="error">{formState?.message}</Alert>
|
|
887
|
-
)}
|
|
888
901
|
</Stack>
|
|
889
902
|
</Paper>
|
|
890
903
|
<input
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React, {
|
|
4
|
-
createContext,
|
|
5
|
-
useContext,
|
|
6
|
-
useReducer,
|
|
7
|
-
useEffect,
|
|
8
|
-
ReactNode,
|
|
9
|
-
} from "react";
|
|
3
|
+
import React, { createContext, useContext, useReducer, ReactNode } from "react";
|
|
10
4
|
import {
|
|
11
5
|
snackbarMessage,
|
|
12
6
|
SnackbarState,
|
|
@@ -18,7 +12,6 @@ const initialState: SnackbarState = {
|
|
|
18
12
|
messages: [],
|
|
19
13
|
};
|
|
20
14
|
|
|
21
|
-
// TODO this is a work in progress
|
|
22
15
|
const SnackbarContext = createContext<{
|
|
23
16
|
state: SnackbarState;
|
|
24
17
|
dispatch: React.Dispatch<any>;
|
|
@@ -26,32 +19,23 @@ const SnackbarContext = createContext<{
|
|
|
26
19
|
message: string;
|
|
27
20
|
severity: "success" | "error" | "info" | "warning";
|
|
28
21
|
}) => void;
|
|
29
|
-
/* messages: snackbarMessage[];
|
|
30
|
-
handleAddMessage: (value: {
|
|
31
|
-
message: string;
|
|
32
|
-
severity: "success" | "error" | "info" | "warning";
|
|
33
|
-
}) => void;
|
|
34
22
|
handleAddMessages: (
|
|
35
23
|
value: {
|
|
36
24
|
message: string;
|
|
37
25
|
severity: "success" | "error" | "info" | "warning";
|
|
38
26
|
}[]
|
|
39
27
|
) => void;
|
|
40
|
-
handleOpen: (value: boolean, index: number) => void;
|
|
41
28
|
handleClose: (
|
|
42
29
|
event: Event | React.SyntheticEvent<any, Event>,
|
|
43
30
|
reason: SnackbarCloseReason,
|
|
44
31
|
id: string
|
|
45
|
-
) => void;
|
|
32
|
+
) => void;
|
|
46
33
|
}>({
|
|
47
34
|
state: initialState,
|
|
48
35
|
dispatch: () => undefined,
|
|
49
36
|
handleAddMessage: () => undefined,
|
|
50
|
-
/* messages: [],
|
|
51
|
-
handleAddMessage: () => undefined,
|
|
52
37
|
handleAddMessages: () => undefined,
|
|
53
|
-
|
|
54
|
-
handleClose: () => undefined, */
|
|
38
|
+
handleClose: () => undefined,
|
|
55
39
|
});
|
|
56
40
|
|
|
57
41
|
const snackbarReducer = (state: SnackbarState, action: any): SnackbarState => {
|
|
@@ -62,6 +46,8 @@ const snackbarReducer = (state: SnackbarState, action: any): SnackbarState => {
|
|
|
62
46
|
};
|
|
63
47
|
case "ADD_MESSAGE":
|
|
64
48
|
return { ...state, messages: [...state.messages, action.payload] };
|
|
49
|
+
case "UPDATE_MESSAGES":
|
|
50
|
+
return { ...state, messages: action.payload };
|
|
65
51
|
default:
|
|
66
52
|
throw new Error(`No case for type ${action.type}`);
|
|
67
53
|
}
|
|
@@ -70,30 +56,22 @@ const snackbarReducer = (state: SnackbarState, action: any): SnackbarState => {
|
|
|
70
56
|
export const SnackbarProvider = ({ children }: { children: ReactNode }) => {
|
|
71
57
|
const [state, dispatch] = useReducer(snackbarReducer, initialState);
|
|
72
58
|
|
|
73
|
-
|
|
74
|
-
const newMessages = [...state.messages];
|
|
75
|
-
newMessages[index].open = value;
|
|
76
|
-
|
|
77
|
-
dispatch({ type: "ADD_MESSAGE", payload: newMessages });
|
|
78
|
-
}; */
|
|
79
|
-
|
|
80
|
-
/* const handleClose = (
|
|
59
|
+
const handleClose = (
|
|
81
60
|
event: Event | React.SyntheticEvent<any, Event>,
|
|
82
61
|
reason: SnackbarCloseReason,
|
|
83
62
|
id: string
|
|
84
63
|
) => {
|
|
85
|
-
console.log(event, reason, id);
|
|
86
64
|
if (reason === "clickaway") {
|
|
87
65
|
return;
|
|
88
66
|
}
|
|
89
67
|
|
|
90
68
|
const newMessages = [...state.messages];
|
|
91
|
-
|
|
92
69
|
const index = newMessages.findIndex((message) => message.id === id);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
70
|
+
if (index !== -1) {
|
|
71
|
+
newMessages[index].open = false;
|
|
72
|
+
dispatch({ type: "UPDATE_MESSAGES", payload: newMessages });
|
|
73
|
+
}
|
|
74
|
+
};
|
|
97
75
|
|
|
98
76
|
const handleAddMessage = React.useCallback(
|
|
99
77
|
(value: {
|
|
@@ -106,35 +84,31 @@ export const SnackbarProvider = ({ children }: { children: ReactNode }) => {
|
|
|
106
84
|
[dispatch]
|
|
107
85
|
);
|
|
108
86
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}, [initialState]); */
|
|
87
|
+
const handleAddMessages = React.useCallback(
|
|
88
|
+
(
|
|
89
|
+
value: {
|
|
90
|
+
message: string;
|
|
91
|
+
severity: "success" | "error" | "info" | "warning";
|
|
92
|
+
}[]
|
|
93
|
+
) => {
|
|
94
|
+
const newMessages = value.map((item) => ({
|
|
95
|
+
...item,
|
|
96
|
+
open: true,
|
|
97
|
+
id: uuidV4(),
|
|
98
|
+
}));
|
|
99
|
+
newMessages.forEach((message) => {
|
|
100
|
+
dispatch({ type: "ADD_MESSAGE", payload: message });
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
[dispatch]
|
|
104
|
+
);
|
|
128
105
|
|
|
129
106
|
const value = {
|
|
130
107
|
state,
|
|
131
108
|
dispatch,
|
|
132
109
|
handleAddMessage,
|
|
133
|
-
/* messages: state.messages,
|
|
134
|
-
handleAddMessage,
|
|
135
110
|
handleAddMessages,
|
|
136
|
-
|
|
137
|
-
handleClose, */
|
|
111
|
+
handleClose,
|
|
138
112
|
};
|
|
139
113
|
|
|
140
114
|
return (
|