umwd-components 0.1.642 → 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/node_modules/base64-js/index.js +1 -1
- package/dist/node_modules/ieee754/index.js +1 -1
- 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 +476 -2
- 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,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 (
|