umwd-components 0.1.630 → 0.1.631

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.
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
2
  import { SxProps, Theme } from "@mui/material/styles";
3
- interface SubmitButtonProps {
3
+ import { ButtonProps } from "@mui/material/Button";
4
+ interface SubmitButtonProps extends ButtonProps {
4
5
  text: string;
5
6
  loadingText: string;
6
7
  loading?: boolean;
7
8
  sx?: SxProps<Theme>;
8
9
  }
9
- export declare function SubmitButton({ text, loadingText, loading, sx, }: Readonly<SubmitButtonProps>): React.JSX.Element;
10
+ export declare function SubmitButton({ text, loadingText, loading, sx, ...props }: Readonly<SubmitButtonProps>): React.JSX.Element;
10
11
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umwd-components",
3
- "version": "0.1.630",
3
+ "version": "0.1.631",
4
4
  "description": "UMWD Component library",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/src/index.js",
@@ -2,20 +2,24 @@
2
2
  import React from "react";
3
3
  import { useFormStatus } from "react-dom";
4
4
  import Button from "@mui/material/Button";
5
- import { SxProps, Theme } from "@mui/material/styles";
5
+ import { ComponentsProps, SxProps, Theme } from "@mui/material/styles";
6
+ import { ButtonProps } from "@mui/material/Button";
6
7
 
7
- interface SubmitButtonProps {
8
+ interface SubmitButtonProps extends ButtonProps {
8
9
  text: string;
9
10
  loadingText: string;
10
11
  loading?: boolean;
11
12
  sx?: SxProps<Theme>;
12
13
  }
13
14
 
15
+ // TODO at props so disabled can be set from the outside
16
+
14
17
  export function SubmitButton({
15
18
  text,
16
19
  loadingText,
17
20
  loading,
18
21
  sx = {},
22
+ ...props
19
23
  }: Readonly<SubmitButtonProps>) {
20
24
  const status = useFormStatus();
21
25
  return (
@@ -28,6 +32,7 @@ export function SubmitButton({
28
32
  // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
29
33
  ...(Array.isArray(sx) ? sx : [sx]),
30
34
  ]}
35
+ {...props}
31
36
  >
32
37
  {status.pending || loading ? loadingText : text}
33
38
  </Button>
@@ -24,6 +24,11 @@ import TextualAmountUpdater from "../../../components/common/TextualAmountUpdate
24
24
  import { OpoItem } from "../../../types/e-commerce/opo/types";
25
25
  import { ProductName } from "../../../types/e-commerce/product/types";
26
26
  import { IroItem, NewIroItem } from "../../../types/e-commerce/iro/types";
27
+ import Dialog from "@mui/material/Dialog";
28
+ import DialogActions from "@mui/material/DialogActions";
29
+ import DialogContent from "@mui/material/DialogContent";
30
+ import DialogContentText from "@mui/material/DialogContentText";
31
+ import DialogTitle from "@mui/material/DialogTitle";
27
32
 
28
33
  const INITIAL_STATE = {
29
34
  zodErrors: null,
@@ -41,6 +46,7 @@ const ItemLines: React.FC<ItemLinesProps> = ({ items }) => {
41
46
  const [selectedItems, setSelectedItems] = useState<number[]>([]);
42
47
 
43
48
  const [showCustomReason, setShowCustomReason] = useState(false);
49
+ const [unopenedConfirmation, setUnopenedConfirmation] = useState(false);
44
50
 
45
51
  const updateItemsToReturn = (
46
52
  index: number,
@@ -162,7 +168,7 @@ const ItemLines: React.FC<ItemLinesProps> = ({ items }) => {
162
168
  updateItemsToReturn(index, "reason", reason as ReturnReason);
163
169
  }}
164
170
  >
165
- <option value="damaged">Damaged</option>
171
+ <option value="damaged">Damaged on arrival</option>
166
172
  <option value="not_as_described">Not as described</option>
167
173
  <option value="wrong_item">Wrong item</option>
168
174
  <option value="other">Other</option>
@@ -179,6 +185,16 @@ const ItemLines: React.FC<ItemLinesProps> = ({ items }) => {
179
185
  }}
180
186
  />
181
187
  )}
188
+ {/* TODO ??? <Checkbox
189
+ checked={selectedItems.includes(index)}
190
+ onChange={(e) => {
191
+ if (e.target.checked) {
192
+ setSelectedItems([...selectedItems, index]);
193
+ } else {
194
+ setSelectedItems(selectedItems.filter((i) => i !== index));
195
+ }
196
+ }}
197
+ /> */}
182
198
  <Divider />
183
199
  </Stack>
184
200
  ))}
@@ -188,11 +204,53 @@ const ItemLines: React.FC<ItemLinesProps> = ({ items }) => {
188
204
  );
189
205
  };
190
206
 
207
+ /* interface ConfirmRMADialogProps {
208
+ data: any;
209
+ } */
210
+
191
211
  interface ConfirmRMADialogProps {
212
+ open: boolean;
213
+ onClose: () => void;
192
214
  data: any;
193
215
  }
194
216
 
195
- const ConfirmRMADialog = ({ data }: ConfirmRMADialogProps) => {
217
+ const ConfirmRMADialog: React.FC<ConfirmRMADialogProps> = ({
218
+ open,
219
+ onClose,
220
+ data,
221
+ }) => {
222
+ const [missingConfirmations, setMissingConfirmations] = useState(true);
223
+
224
+ return (
225
+ <Dialog open={open} onClose={onClose}>
226
+ <DialogTitle>Confirm RMA</DialogTitle>
227
+ <DialogContent>
228
+ <DialogContentText>
229
+ Are you sure you want to request a return merchandise authorization
230
+ for the selected items?
231
+ </DialogContentText>
232
+ <Checkbox
233
+ onChange={(e) => setMissingConfirmations(!e.target.checked)}
234
+ />
235
+ <Typography variant="body1">
236
+ I understand that all returned items must be unused and unopened
237
+ </Typography>
238
+ </DialogContent>
239
+ <DialogActions>
240
+ <SubmitButton
241
+ text="Yes"
242
+ loadingText="Loading..."
243
+ disabled={missingConfirmations}
244
+ />
245
+ <Button onClick={onClose}>No</Button>
246
+ </DialogActions>
247
+ </Dialog>
248
+ );
249
+ };
250
+
251
+ /* const ConfirmRMADialog = ({ data }: ConfirmRMADialogProps) => {
252
+ const [missingConfirmations, setMissingConfirmations] = useState(true);
253
+
196
254
  return (
197
255
  <Stack spacing={2}>
198
256
  <Typography variant="h6">Confirm RMA</Typography>
@@ -200,13 +258,21 @@ const ConfirmRMADialog = ({ data }: ConfirmRMADialogProps) => {
200
258
  Are you sure you want to request a return merchandise authorization for
201
259
  the selected items?
202
260
  </Typography>
261
+ <Checkbox onChange={(e) => setMissingConfirmations(!e.target.checked)} />
262
+ <Typography variant="body1">
263
+ I understand that all returned items must be unused and unopened
264
+ </Typography>
203
265
  <Stack direction="row" spacing={2}>
204
- <SubmitButton text="Yes" loadingText="Loading..." />
266
+ <SubmitButton
267
+ text="Yes"
268
+ loadingText="Loading..."
269
+ disabled={missingConfirmations}
270
+ />
205
271
  <Button>No</Button>
206
272
  </Stack>
207
273
  </Stack>
208
274
  );
209
- };
275
+ }; */
210
276
 
211
277
  /* type parsedIroItem = {
212
278
  line_item_number: string;
@@ -230,18 +296,14 @@ export default function RmaForm({
230
296
  setItems(newItems);
231
297
  }; */
232
298
 
299
+ const [open, setOpen] = useState(false);
300
+
233
301
  useEffect(() => {
234
302
  if (formState?.data && revalidateCallback) {
235
303
  revalidateCallback();
236
304
  }
237
305
  }, [formState.data]);
238
306
 
239
- console.log("opo", opo);
240
-
241
- useEffect(() => {
242
- console.log("formState", formState);
243
- }, [formState]);
244
-
245
307
  return (
246
308
  <Box
247
309
  sx={[
@@ -266,31 +328,29 @@ export default function RmaForm({
266
328
  </Grid>
267
329
  <Grid item xs={12}>
268
330
  {opo.opo_items?.data ? (
269
- <Stack spacing={2}>
270
- <Typography variant="h6">Items</Typography>
271
- <Typography variant="body1">
272
- from the items in the original order please select the items
273
- you'd like to return
274
- </Typography>
275
- <Stack spacing={1}>
276
- {opo.opo_items?.data && (
277
- <ItemLines items={opo.opo_items?.data} />
278
- )}
279
- </Stack>
331
+ <Stack spacing={1}>
332
+ {opo.opo_items?.data && (
333
+ <ItemLines items={opo.opo_items?.data} />
334
+ )}
280
335
  </Stack>
281
336
  ) : (
282
337
  <Typography variant="body1">No items</Typography>
283
338
  )}
284
339
  </Grid>
285
- <ConfirmRMADialog data={formState} />
340
+ <ConfirmRMADialog
341
+ data={formState}
342
+ open={open}
343
+ onClose={() => setOpen(!open)}
344
+ />
286
345
  <Grid item xs={12}>
287
- <SubmitButton text="Request RMA" loadingText="Loading..." />
346
+ <Button onClick={() => setOpen(!open)}>Request RMA</Button>
347
+ {/* <SubmitButton text="Request RMA" loadingText="Loading..." />
288
348
  {formState?.strapiErrors !== null && (
289
349
  <StrapiErrors error={formState?.strapiErrors} />
290
350
  )}
291
351
  {formState?.message && (
292
352
  <Alert severity="error">{formState?.message}</Alert>
293
- )}
353
+ )} */}
294
354
  </Grid>
295
355
  </Grid>
296
356
  </form>