umwd-components 0.1.783 → 0.1.784

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 (33) hide show
  1. package/dist/cjs/src/components/common/AmountUpdater.js +1 -1
  2. package/dist/cjs/src/components/common/NumberInput.js +1 -1
  3. package/dist/cjs/src/components/common/TextualAmountUpdater.js +1 -1
  4. package/dist/cjs/src/components/common/media/minio/UploadMinioMediaForm.js +1 -1
  5. package/dist/cjs/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
  6. package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
  7. package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
  8. package/dist/cjs/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
  9. package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
  10. package/dist/cjs/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
  11. package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
  12. package/dist/cjs/src/data/actions/media/minio/uploadMinioMediaAction.js +1 -1
  13. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  14. package/dist/esm/src/components/common/AmountUpdater.js +10 -10
  15. package/dist/esm/src/components/common/NumberInput.js +13 -13
  16. package/dist/esm/src/components/common/TextualAmountUpdater.js +11 -11
  17. package/dist/esm/src/components/common/media/minio/UploadMinioMediaForm.js +97 -55
  18. package/dist/esm/src/components/e-commerce/iro/IroItemUpdater.js +3 -3
  19. package/dist/esm/src/components/e-commerce/iro/RmaForm.js +14 -5
  20. package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +3 -3
  21. package/dist/esm/src/components/e-commerce/opo/OpoItemUpdater.js +3 -3
  22. package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +3 -3
  23. package/dist/esm/src/components/logistics/ipo/IPOItemUpdater.js +3 -3
  24. package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +3 -3
  25. package/dist/esm/src/components/logistics/report/SimpleReportFields.js +1 -1
  26. package/dist/esm/src/data/actions/media/minio/uploadMinioMediaAction.js +82 -56
  27. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  28. package/dist/esm/types/components/common/AmountUpdater.d.ts +1 -1
  29. package/dist/esm/types/components/common/NumberInput.d.ts +2 -2
  30. package/dist/esm/types/components/common/TextualAmountUpdater.d.ts +1 -1
  31. package/dist/esm/types/components/common/media/minio/UploadMinioMediaForm.d.ts +7 -1
  32. package/dist/esm/types/types/common/AmountUpdater.d.ts +4 -4
  33. package/package.json +1 -1
@@ -15,7 +15,7 @@ import RemoveCircleIcon from '@mui/icons-material/RemoveCircle';
15
15
  import AddCircleIcon from '@mui/icons-material/AddCircle';
16
16
  import { useTheme, styled } from '@mui/material/styles';
17
17
 
18
- function AmountUpdater({ currentValue, totalValue, minNewValue, maxNewValue, color, handleChange, offsetEnd, // offsetEnd is the offset of the end of the slider
18
+ function AmountUpdater({ currentValue, totalValue, minnewvalue, maxnewvalue, color, handleChange, offsetEnd, // offsetEnd is the offset of the end of the slider
19
19
  }) {
20
20
  const percentage = (100 / totalValue) * currentValue;
21
21
  const [newValue, setNewValue] = useState(currentValue);
@@ -24,25 +24,25 @@ function AmountUpdater({ currentValue, totalValue, minNewValue, maxNewValue, col
24
24
  const offSetPercentage = offsetEnd ? (100 / totalValue) * offsetEnd * -1 : 0;
25
25
  const theme = useTheme();
26
26
  const addOne = () => {
27
- if (newValue + 1 <= maxNewValue) {
27
+ if (newValue + 1 <= maxnewvalue) {
28
28
  setNewValue(newValue + 1);
29
29
  handleChange(newValue + 1);
30
30
  }
31
31
  };
32
32
  const substractOne = () => {
33
- if (newValue - 1 >= minNewValue) {
33
+ if (newValue - 1 >= minnewvalue) {
34
34
  setNewValue(newValue - 1);
35
35
  handleChange(newValue - 1);
36
36
  }
37
37
  };
38
38
  const addStep = (step) => {
39
- if (newValue + step <= maxNewValue) {
39
+ if (newValue + step <= maxnewvalue) {
40
40
  setNewValue(newValue + step);
41
41
  handleChange(newValue + step);
42
42
  }
43
43
  };
44
44
  const substractStep = (step) => {
45
- if (newValue - step >= minNewValue) {
45
+ if (newValue - step >= minnewvalue) {
46
46
  setNewValue(newValue - step);
47
47
  handleChange(newValue - step);
48
48
  }
@@ -105,19 +105,19 @@ function AmountUpdater({ currentValue, totalValue, minNewValue, maxNewValue, col
105
105
  offsetEnd < 0 && {
106
106
  background: `linear-gradient(-90deg, ${theme.palette.error.main} ${offSetPercentage}%, ${theme.palette[color].main}66 ${offSetPercentage}%)`,
107
107
  },
108
- ], children: [jsxs(Box, { children: [newValue - 100 >= minNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(100), children: jsx(StyledBadge, { badgeContent: 100, max: 100, anchorOrigin: {
108
+ ], children: [jsxs(Box, { children: [newValue - 100 >= minnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(100), children: jsx(StyledBadge, { badgeContent: 100, max: 100, anchorOrigin: {
109
109
  vertical: "bottom",
110
110
  horizontal: "left",
111
- }, children: jsx(RemoveCircleIcon, {}) }) })), newValue - 25 >= minNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(25), children: jsx(StyledBadge, { badgeContent: 25, anchorOrigin: {
111
+ }, children: jsx(RemoveCircleIcon, {}) }) })), newValue - 25 >= minnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(25), children: jsx(StyledBadge, { badgeContent: 25, anchorOrigin: {
112
112
  vertical: "bottom",
113
113
  horizontal: "left",
114
- }, children: jsx(RemoveCircleIcon, {}) }) })), newValue - 10 >= minNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(10), children: jsx(StyledBadge, { badgeContent: 10, anchorOrigin: {
114
+ }, children: jsx(RemoveCircleIcon, {}) }) })), newValue - 10 >= minnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(10), children: jsx(StyledBadge, { badgeContent: 10, anchorOrigin: {
115
115
  vertical: "bottom",
116
116
  horizontal: "left",
117
- }, children: jsx(RemoveCircleIcon, {}) }) })), newValue - 5 >= minNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(5), children: jsx(StyledBadge, { badgeContent: 5, anchorOrigin: {
117
+ }, children: jsx(RemoveCircleIcon, {}) }) })), newValue - 5 >= minnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => substractStep(5), children: jsx(StyledBadge, { badgeContent: 5, anchorOrigin: {
118
118
  vertical: "bottom",
119
119
  horizontal: "left",
120
- }, children: jsx(RemoveCircleIcon, {}) }) })), jsx(StyledIconButton, { size: "small", onClick: () => substractOne(), disabled: newValue - 1 < minNewValue, children: jsx(RemoveCircleIcon, {}) })] }), jsxs(Stack, { direction: "row", spacing: 1, children: [currentValue !== totalValue ? (jsx(Typography, { variant: "body2", children: `${currentValue} / ${totalValue}` })) : (jsx(Typography, { variant: "body2", children: `${currentValue}` })), newValue !== currentValue && (jsx(Typography, { variant: "body2", children: `+ (${newValue - currentValue}) = ${newValue}` }))] }), jsxs(Box, { children: [jsx(StyledIconButton, { size: "small", onClick: () => addOne(), disabled: newValue + 1 > maxNewValue, children: jsx(AddCircleIcon, {}) }), newValue + 5 <= maxNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(5), children: jsx(StyledBadge, { badgeContent: 5, children: jsx(AddCircleIcon, {}) }) })), newValue + 10 <= maxNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(10), children: jsx(StyledBadge, { badgeContent: 10, children: jsx(AddCircleIcon, {}) }) })), newValue + 25 <= maxNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(25), children: jsx(StyledBadge, { badgeContent: 25, children: jsx(AddCircleIcon, {}) }) })), newValue + 100 <= maxNewValue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(100), children: jsx(StyledBadge, { badgeContent: 100, max: 100, children: jsx(AddCircleIcon, {}) }) }))] })] }));
120
+ }, children: jsx(RemoveCircleIcon, {}) }) })), jsx(StyledIconButton, { size: "small", onClick: () => substractOne(), disabled: newValue - 1 < minnewvalue, children: jsx(RemoveCircleIcon, {}) })] }), jsxs(Stack, { direction: "row", spacing: 1, children: [currentValue !== totalValue ? (jsx(Typography, { variant: "body2", children: `${currentValue} / ${totalValue}` })) : (jsx(Typography, { variant: "body2", children: `${currentValue}` })), newValue !== currentValue && (jsx(Typography, { variant: "body2", children: `+ (${newValue - currentValue}) = ${newValue}` }))] }), jsxs(Box, { children: [jsx(StyledIconButton, { size: "small", onClick: () => addOne(), disabled: newValue + 1 > maxnewvalue, children: jsx(AddCircleIcon, {}) }), newValue + 5 <= maxnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(5), children: jsx(StyledBadge, { badgeContent: 5, children: jsx(AddCircleIcon, {}) }) })), newValue + 10 <= maxnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(10), children: jsx(StyledBadge, { badgeContent: 10, children: jsx(AddCircleIcon, {}) }) })), newValue + 25 <= maxnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(25), children: jsx(StyledBadge, { badgeContent: 25, children: jsx(AddCircleIcon, {}) }) })), newValue + 100 <= maxnewvalue && (jsx(StyledIconButton, { size: "small", onClick: (e) => addStep(100), children: jsx(StyledBadge, { badgeContent: 100, max: 100, children: jsx(AddCircleIcon, {}) }) }))] })] }));
121
121
  }
122
122
 
123
123
  export { AmountUpdater, AmountUpdater as default };
@@ -9,35 +9,35 @@ import React, { useEffect } from 'react';
9
9
  import TextField from '@mui/material/TextField';
10
10
 
11
11
  const NumberInput = (props) => {
12
- const { label, minNewValue, maxNewValue } = props;
12
+ const { label, minnewvalue, maxnewvalue, setValueCallback } = props;
13
13
  const [value, setValue] = React.useState(0);
14
14
  useEffect(() => {
15
- props.setValueCallback && props.setValueCallback(value);
15
+ setValueCallback && setValueCallback(value);
16
16
  }, [value]);
17
- return (jsx(TextField, { ...props, type: "number", label: label, size: "small", value: value, onChange: (event) => {
17
+ return (jsx(TextField, { type: "number", label: label, size: "small", value: value, onChange: (event) => {
18
18
  const newValue = Number(event.target.value);
19
- if (minNewValue !== undefined && maxNewValue !== undefined) {
20
- setValue(Math.max(minNewValue, Math.min(newValue, maxNewValue)));
19
+ if (minnewvalue !== undefined && maxnewvalue !== undefined) {
20
+ setValue(Math.max(minnewvalue, Math.min(newValue, maxnewvalue)));
21
21
  }
22
- else if (minNewValue !== undefined) {
23
- setValue(Math.max(newValue, minNewValue));
22
+ else if (minnewvalue !== undefined) {
23
+ setValue(Math.max(newValue, minnewvalue));
24
24
  }
25
- else if (maxNewValue !== undefined) {
26
- setValue(Math.min(newValue, maxNewValue));
25
+ else if (maxnewvalue !== undefined) {
26
+ setValue(Math.min(newValue, maxnewvalue));
27
27
  }
28
28
  else {
29
29
  setValue(newValue);
30
30
  }
31
31
  }, inputProps: {
32
32
  step: 1,
33
- min: minNewValue ?? undefined,
34
- max: maxNewValue ?? undefined,
33
+ min: minnewvalue ?? undefined,
34
+ max: maxnewvalue ?? undefined,
35
35
  }, onWheel: (event) => {
36
36
  // `event.currentTarget` is a callable type but is targetting the MUI element
37
37
  // whereas `event.target` targets the input element but does not have the callable type, so casting
38
38
  event.target.blur();
39
- }, helperText: `min: ${minNewValue}, max: ${maxNewValue}`, error: (minNewValue !== undefined && value < minNewValue) ||
40
- (maxNewValue !== undefined && value > maxNewValue) ||
39
+ }, helperText: `min: ${minnewvalue}, max: ${maxnewvalue}`, error: (minnewvalue !== undefined && value < minnewvalue) ||
40
+ (maxnewvalue !== undefined && value > maxnewvalue) ||
41
41
  props.error, sx: [
42
42
  // You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
43
43
  { width: "9rem" },
@@ -11,33 +11,33 @@ import Stack from '@mui/material/Stack';
11
11
  import TextField from '@mui/material/TextField';
12
12
  import Button from '@mui/material/Button';
13
13
 
14
- function TextualAmountUpdater({ label, currentValue, totalValue, minNewValue, maxNewValue, handleChange, }) {
14
+ function TextualAmountUpdater({ label, currentValue, totalValue, minnewvalue, maxnewvalue, handleChange, }) {
15
15
  const [value, setValue] = useState(currentValue);
16
16
  const [error, setError] = useState(false);
17
17
  return (jsxs(Stack, { direction: "row", spacing: 1, justifyContent: "space-between", alignItems: "center", children: [currentValue !== totalValue ? (jsx(Typography, { variant: "body2", children: `${currentValue} / ${totalValue}` })) : (jsx(Typography, { variant: "body2", children: `${currentValue}` })), jsx(TextField, { type: "number", label: label, size: "small", value: value, onChange: (event) => {
18
18
  const newValue = Number(event.target.value);
19
- if (minNewValue !== undefined && maxNewValue !== undefined) {
20
- setValue(Math.max(minNewValue, Math.min(newValue, maxNewValue)));
19
+ if (minnewvalue !== undefined && maxnewvalue !== undefined) {
20
+ setValue(Math.max(minnewvalue, Math.min(newValue, maxnewvalue)));
21
21
  }
22
- else if (minNewValue !== undefined) {
23
- setValue(Math.max(newValue, minNewValue));
22
+ else if (minnewvalue !== undefined) {
23
+ setValue(Math.max(newValue, minnewvalue));
24
24
  }
25
- else if (maxNewValue !== undefined) {
26
- setValue(Math.min(newValue, maxNewValue));
25
+ else if (maxnewvalue !== undefined) {
26
+ setValue(Math.min(newValue, maxnewvalue));
27
27
  }
28
28
  else {
29
29
  setValue(newValue);
30
30
  }
31
31
  }, inputProps: {
32
32
  step: 1,
33
- min: minNewValue ?? undefined,
34
- max: maxNewValue ?? undefined,
33
+ min: minnewvalue ?? undefined,
34
+ max: maxnewvalue ?? undefined,
35
35
  }, onWheel: (event) => {
36
36
  // `event.currentTarget` is a callable type but is targetting the MUI element
37
37
  // whereas `event.target` targets the input element but does not have the callable type, so casting
38
38
  event.target.blur();
39
- }, helperText: `min: ${minNewValue}, max: ${maxNewValue}`, error: error, sx: { width: "9rem" } }), jsx(Button, { variant: "contained", color: "primary", onClick: () => {
40
- if (value < minNewValue || value > maxNewValue) {
39
+ }, helperText: `min: ${minnewvalue}, max: ${maxnewvalue}`, error: error, sx: { width: "9rem" } }), jsx(Button, { variant: "contained", color: "primary", onClick: () => {
40
+ if (value < minnewvalue || value > maxnewvalue) {
41
41
  setError(true);
42
42
  }
43
43
  else {
@@ -6,8 +6,10 @@
6
6
  */
7
7
 
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
- import { useState, useActionState, useRef, useEffect } from 'react';
9
+ import { useState, useRef, useEffect } from 'react';
10
+ import { useFormState } from 'react-dom';
10
11
  import { uploadMinioMediaAction } from '../../../../data/actions/media/minio/uploadMinioMediaAction.js';
12
+ import { useSnackbar } from '../../../../context/common/SnackbarContext.js';
11
13
  import { StrapiErrors } from '../../../StrapiErrors.js';
12
14
  import { ZodErrors } from '../../../ZodErrors.js';
13
15
  import { SubmitButton } from '../../../SubmitButton.js';
@@ -15,13 +17,14 @@ import Stack from '@mui/material/Stack';
15
17
  import Typography from '@mui/material/Typography';
16
18
  import Box from '@mui/material/Box';
17
19
  import Grid from '@mui/material/Grid';
18
- import Alert from '@mui/material/Alert';
20
+ import Button from '@mui/material/Button';
19
21
 
20
22
  const INITIAL_STATE = {
21
23
  zodErrors: null,
22
24
  strapiErrors: null,
23
25
  data: null,
24
26
  message: null,
27
+ severity: null,
25
28
  };
26
29
  function UploadMinioMediaForm({ bucketName = process.env.MINIO_BUCKET_NAME || "umwd", multiple = false, accept = process.env.MINIO_ACCEPTED_FILE_TYPES || [
27
30
  "image/jpeg",
@@ -42,64 +45,103 @@ function UploadMinioMediaForm({ bucketName = process.env.MINIO_BUCKET_NAME || "u
42
45
  "application/vnd.oasis.opendocument.text",
43
46
  "application/vnd.oasis.opendocument.spreadsheet",
44
47
  "application/vnd.oasis.opendocument.presentation",
45
- ],
46
- // "image/*", // should be dependent on config files
47
- reference, refID, field, revalidateCallback, }) {
48
- console.log("UploadMinioMediaForm render", reference, refID, field);
49
- console.log("accept:", accept);
48
+ ], reference, refID, field, revalidateCallback, sx, handleClose, }) {
50
49
  const [filePreviews, setFilePreviews] = useState(null);
51
50
  const [fileList, setFileList] = useState(null);
52
- const [selectedFileName, setSelectedFileName] = useState(null);
53
- const [formState, formAction] = useActionState(uploadMinioMediaAction, INITIAL_STATE);
51
+ const [formState, formAction] = useFormState(uploadMinioMediaAction, INITIAL_STATE);
54
52
  const fileInput = useRef(null);
53
+ const { handleAddMessage } = useSnackbar();
55
54
  useEffect(() => {
56
- if (formState.message && formState.message.type === "success") {
57
- revalidateCallback?.();
55
+ if (formState?.message) {
56
+ handleAddMessage({
57
+ message: formState.message,
58
+ severity: formState.severity || "error",
59
+ });
60
+ if (formState.severity === "success") {
61
+ revalidateCallback && revalidateCallback();
62
+ handleClose && handleClose();
63
+ // Reset form state
64
+ setFileList(null);
65
+ setFilePreviews(null);
66
+ if (fileInput.current) {
67
+ fileInput.current.value = "";
68
+ }
69
+ }
58
70
  }
59
- }, [formState.message]);
60
- return (jsx("form", { action: formAction, children: jsxs(Stack, { spacing: 1, sx: { flex: 1 }, children: [reference && refID && field && (jsxs(Fragment, { children: [jsx("input", { type: "text", name: "reference", value: reference, style: { display: "none" }, readOnly: true }), jsx("input", { type: "text", name: "refID", value: refID, style: { display: "none" }, readOnly: true }), jsx("input", { type: "text", name: "field", value: field, style: { display: "none" }, readOnly: true })] })), bucketName && (jsx("input", { type: "text", name: "bucketName", value: bucketName, style: { display: "none" }, readOnly: true })), selectedFileName && (jsx("input", { type: "text", name: "fileName", value: selectedFileName, style: { display: "none" }, readOnly: true })), filePreviews !== null ? (jsx(Box, { onClick: () => fileInput.current?.click(), sx: {
61
- p: 2,
62
- width: "100%",
63
- border: "1px dashed white",
64
- minHeight: "100px",
65
- }, children: accept === undefined || accept === "image/*" ? (jsx(Grid, { container: true, children: filePreviews.map((image, index) => {
66
- return (jsx(Grid, { size: {
67
- xs: 12,
68
- sm: 6,
69
- md: 4,
70
- lg: 2,
71
- }, children: jsx("img", { src: image.url, alt: image.name, style: { width: "100px" } }, index) }, index));
72
- }) })) : (jsx(Grid, { container: true, children: filePreviews.map((file, index) => {
73
- return (jsx(Grid, { size: {
74
- xs: 12,
75
- sm: 6,
76
- md: 4,
77
- lg: 2,
78
- }, children: jsx(Typography, { children: file.name }) }, index));
79
- }) })) })) : (jsx(Box, { onClick: () => fileInput.current?.click(), sx: {
80
- p: 2,
81
- width: "100%",
82
- border: "1px dashed white",
83
- minHeight: "100px",
84
- cursor: "pointer",
85
- }, children: jsxs(Typography, { children: ["No file", `${multiple ? "s" : ""}`, " selected, click here to start uploading new files"] }) })), jsxs(Stack, { direction: "column", spacing: 2, alignItems: "center", justifyContent: "space-between", children: [jsx(StrapiErrors, { error: formState.strapiErrors }), jsx(ZodErrors, { error: formState.zodErrors?.image }), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message })), jsxs(Box, { children: [jsx("label", { htmlFor: "minioInput", children: jsx("input", { id: "minioInput", accept: typeof accept === "string" ? accept : accept.join(","), multiple: multiple, type: "file", name: "files", ref: fileInput, onChange: (e) => {
86
- const selectedFiles = e.target.files;
87
- if (selectedFiles === null) {
88
- return;
89
- }
90
- // Use the first file's name for single file uploads
91
- if (selectedFiles.length > 0) {
92
- setSelectedFileName(selectedFiles[0].name);
93
- }
94
- const filePreviews = Object.keys(selectedFiles).map((item, index) => {
95
- return {
96
- url: URL.createObjectURL(selectedFiles[index]),
97
- name: selectedFiles[index].name,
98
- };
99
- });
100
- setFileList(selectedFiles);
101
- setFilePreviews(filePreviews);
102
- }, style: { display: "none" } }) }), fileList !== null && (jsx(SubmitButton, { text: "upload", loadingText: "loading" }))] })] })] }) }));
71
+ }, [formState?.message, handleAddMessage, revalidateCallback, handleClose]);
72
+ useEffect(() => {
73
+ if (formState?.strapiErrors) {
74
+ handleAddMessage({
75
+ message: formState.strapiErrors.message || "Error uploading files",
76
+ severity: "error",
77
+ });
78
+ }
79
+ }, [formState?.strapiErrors, handleAddMessage]);
80
+ const isImageFile = (file) => {
81
+ const imageExtensions = [
82
+ ".jpg",
83
+ ".jpeg",
84
+ ".png",
85
+ ".gif",
86
+ ".webp",
87
+ ".svg",
88
+ ".bmp",
89
+ ];
90
+ return imageExtensions.some((ext) => file.name.toLowerCase().endsWith(ext));
91
+ };
92
+ const shouldShowImagePreviews = () => {
93
+ if (accept === "image/*")
94
+ return true;
95
+ if (Array.isArray(accept) &&
96
+ accept.some((type) => type.startsWith("image/"))) {
97
+ return filePreviews?.every((file) => isImageFile(file)) || false;
98
+ }
99
+ return false;
100
+ };
101
+ return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { size: { xs: 12 }, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Upload Files" }), jsxs(Typography, { variant: "body2", children: ["Select ", multiple ? "one or more files" : "a file", " to upload"] })] }) }), jsxs(Grid, { size: { xs: 12 }, children: [reference && refID && field && (jsxs(Fragment, { children: [jsx("input", { type: "text", name: "reference", value: reference, style: { display: "none" }, readOnly: true }), jsx("input", { type: "text", name: "refID", value: refID, style: { display: "none" }, readOnly: true }), jsx("input", { type: "text", name: "field", value: field, style: { display: "none" }, readOnly: true })] })), bucketName && (jsx("input", { type: "text", name: "bucketName", value: bucketName, style: { display: "none" }, readOnly: true })), filePreviews !== null ? (jsx(Box, { onClick: () => fileInput.current?.click(), sx: {
102
+ p: 2,
103
+ width: "100%",
104
+ border: "1px dashed white",
105
+ minHeight: "100px",
106
+ cursor: "pointer",
107
+ }, children: shouldShowImagePreviews() ? (jsx(Grid, { container: true, spacing: 1, children: filePreviews.map((file, index) => {
108
+ return (jsxs(Grid, { size: {
109
+ xs: 12,
110
+ sm: 6,
111
+ md: 4,
112
+ lg: 2,
113
+ }, children: [jsx("img", { src: file.url, alt: file.name, style: {
114
+ width: "100px",
115
+ height: "100px",
116
+ objectFit: "cover",
117
+ } }), jsx(Typography, { variant: "caption", sx: { display: "block", mt: 1 }, children: file.name })] }, index));
118
+ }) })) : (jsx(Grid, { container: true, spacing: 1, children: filePreviews.map((file, index) => {
119
+ return (jsx(Grid, { size: {
120
+ xs: 12,
121
+ sm: 6,
122
+ md: 4,
123
+ lg: 2,
124
+ }, children: jsx(Typography, { children: file.name }) }, index));
125
+ }) })) })) : (jsx(Box, { onClick: () => fileInput.current?.click(), sx: {
126
+ p: 2,
127
+ width: "100%",
128
+ border: "1px dashed white",
129
+ minHeight: "100px",
130
+ cursor: "pointer",
131
+ }, children: jsxs(Typography, { children: ["No file", `${multiple ? "s" : ""}`, " selected, click here to start uploading new files"] }) })), jsx("input", { id: "minioInput", accept: typeof accept === "string" ? accept : accept.join(","), multiple: multiple, type: "file", name: "files", ref: fileInput, onChange: (e) => {
132
+ const selectedFiles = e.target.files;
133
+ if (selectedFiles === null || selectedFiles.length === 0) {
134
+ return;
135
+ }
136
+ const filePreviews = Array.from(selectedFiles).map((file) => {
137
+ return {
138
+ url: URL.createObjectURL(file),
139
+ name: file.name,
140
+ };
141
+ });
142
+ setFileList(selectedFiles);
143
+ setFilePreviews(filePreviews);
144
+ }, style: { display: "none" } })] }), jsxs(Grid, { size: { xs: 12 }, children: [jsx(StrapiErrors, { error: formState.strapiErrors }), jsx(ZodErrors, { error: formState.zodErrors?.files })] }), jsx(Grid, { size: { xs: 12 }, children: jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), fileList !== null && (jsx(SubmitButton, { text: `Upload ${fileList.length} file${fileList.length > 1 ? "s" : ""}`, loadingText: "Uploading...", variant: "contained" }))] }) })] }) }) }));
103
145
  }
104
146
 
105
147
  export { UploadMinioMediaForm };
@@ -30,9 +30,9 @@ function IroItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCa
30
30
  .reduce((a, b) => a + b.quantity, 0)
31
31
  : 0;
32
32
  const [open, setOpen] = useState(false);
33
- return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product && product.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product && product.title }) }))] }), jsx(Typography, { variant: "body1", children: "Reason" }), jsx(Typography, { variant: "body2", children: "Received" }), jsx(AmountUpdater, { currentValue: received_quantity, totalValue: returned_quantity + received_bad_quantity, minNewValue: 0 + registered_quantity + -registered_bad_quantity, maxNewValue: returned_quantity + received_bad_quantity, color: "info", handleChange: (newValue) => {
33
+ return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product && product.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product && product.title }) }))] }), jsx(Typography, { variant: "body1", children: "Reason" }), jsx(Typography, { variant: "body2", children: "Received" }), jsx(AmountUpdater, { currentValue: received_quantity, totalValue: returned_quantity + received_bad_quantity, minnewvalue: 0 + registered_quantity + -registered_bad_quantity, maxnewvalue: returned_quantity + received_bad_quantity, color: "info", handleChange: (newValue) => {
34
34
  handleUpdateQuantity(newValue, item.documentId, "received_quantity");
35
- } }), jsx(Typography, { variant: "body2", children: "Registered" }), jsx(AmountUpdater, { currentValue: registered_quantity, totalValue: returned_quantity + received_bad_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_bad_quantity, color: "info", handleChange: (newValue) => {
35
+ } }), jsx(Typography, { variant: "body2", children: "Registered" }), jsx(AmountUpdater, { currentValue: registered_quantity, totalValue: returned_quantity + received_bad_quantity, minnewvalue: 0 + released_quantity, maxnewvalue: received_quantity + registered_bad_quantity, color: "info", handleChange: (newValue) => {
36
36
  handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
37
37
  }, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "registered", minValue: -(received_quantity + registered_bad_quantity), maxValue: received_quantity, related: [
38
38
  {
@@ -41,7 +41,7 @@ function IroItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCa
41
41
  },
42
42
  ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: returned_quantity +
43
43
  received_bad_quantity +
44
- registered_bad_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
44
+ registered_bad_quantity, minnewvalue: 0, maxnewvalue: registered_quantity, color: "info", handleChange: (newValue) => {
45
45
  handleUpdateQuantity(newValue, item.documentId, "released_quantity");
46
46
  } })] })) }, index));
47
47
  }
@@ -5,8 +5,8 @@
5
5
  * @license MIT
6
6
  */
7
7
 
8
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
- import { useActionState, useState, useEffect, Suspense } from 'react';
8
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
9
+ import { useActionState, useState, useEffect, Suspense, Fragment, useTransition } from 'react';
10
10
  import { useSnackbar } from '../../../context/common/SnackbarContext.js';
11
11
  import { requestRmaAction } from '../../../data/actions/e-commerce/iro/requestRmaAction.js';
12
12
  import { StrapiErrors } from '../../StrapiErrors.js';
@@ -26,6 +26,7 @@ import DialogContent from '@mui/material/DialogContent';
26
26
  import DialogContentText from '@mui/material/DialogContentText';
27
27
  import DialogTitle from '@mui/material/DialogTitle';
28
28
  import NumberInput from '../../common/NumberInput.js';
29
+ import 'react-dom';
29
30
  import 'next/headers';
30
31
 
31
32
  const INITIAL_STATE = {
@@ -86,7 +87,7 @@ const ItemLines = ({ items, itemsToReturn, setItemsToReturn, selectedItems, setS
86
87
  else {
87
88
  setSelectedItems(selectedItems.filter((i) => i !== index));
88
89
  }
89
- } }), jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", item.line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", item.product?.product_number] }), jsxs(Typography, { variant: "body1", children: ["Quantity Ordered: ", item.ordered_quantity] })] }), selectedItems.includes(index) && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(NumberInput, { label: "Quantity to return", minNewValue: 0, maxNewValue: item.ordered_quantity, setValueCallback: (newValue) => {
90
+ } }), jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", item.line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", item.product?.product_number] }), jsxs(Typography, { variant: "body1", children: ["Quantity Ordered: ", item.ordered_quantity] })] }), selectedItems.includes(index) && (jsxs(Fragment$1, { children: [jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(NumberInput, { label: "Quantity to return", minnewvalue: 0, maxnewvalue: item.ordered_quantity, setValueCallback: (newValue) => {
90
91
  updateItemsToReturn(index, "returned_quantity", newValue);
91
92
  }, sx: { width: "12rem" } }), jsx(Divider, { orientation: "vertical", flexItem: true }), jsx(Typography, { variant: "body1", sx: { width: "12rem" }, children: "Reason for return:" }), jsxs(TextField, { value: itemsToReturn[index]?.reason, select: true, SelectProps: {
92
93
  native: true,
@@ -102,11 +103,19 @@ const ItemLines = ({ items, itemsToReturn, setItemsToReturn, selectedItems, setS
102
103
  }, children: [jsx("option", { value: "damaged", children: "Damaged on arrival" }), jsx("option", { value: "not_as_described", children: "Not as described" }), jsx("option", { value: "wrong_item", children: "Wrong item" }), jsx("option", { value: "other", children: "Other" })] })] }), showCustomReason && (jsx(TextField, { value: itemsToReturn[index].other_reason, label: "Custom reason", variant: "outlined", fullWidth: true, onChange: (e) => {
103
104
  const customReason = e.target.value;
104
105
  updateItemsToReturn(index, "other_reason", customReason);
105
- } }))] })), jsx(Divider, {})] }))) })] }) }));
106
+ } }))] })), jsx(Divider, {})] }, index))) })] }) }));
106
107
  };
107
108
  const ConfirmRMADialog = ({ open, onClose, items, formState, submitCallback, }) => {
108
109
  const [missingConfirmations, setMissingConfirmations] = useState(true);
109
- return (jsxs(Dialog, { open: open, onClose: onClose, children: [jsx(DialogTitle, { children: "Confirm RMA" }), jsxs(DialogContent, { children: [jsx(DialogContentText, { children: "Summary of items to be returned:" }), jsx(List, { children: items.map((item, index) => (jsx(ListItem, { children: `Product with ID ${item.product} - Quantity: ${item.returned_quantity}` }, index))) }), jsx(DialogContentText, { children: "Are you sure you want to request a return merchandise authorization for these items?" }), jsx(Checkbox, { onChange: (e) => setMissingConfirmations(!e.target.checked) }), jsx(Typography, { variant: "body1", children: "I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration." })] }), jsxs(DialogActions, { children: [submitCallback ? (jsx(SubmitButton, { text: "Yes", loadingText: "Loading...", disabled: missingConfirmations, onClick: submitCallback })) : (jsx(SubmitButton, { text: "Yes", loadingText: "Loading...", disabled: missingConfirmations })), jsx(Button, { onClick: onClose, children: "No" }), formState?.strapiErrors !== null && (jsx(StrapiErrors, { error: formState?.strapiErrors })), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message }))] })] }));
110
+ const [isPending, startTransition] = useTransition();
111
+ const handleSubmit = () => {
112
+ if (submitCallback) {
113
+ startTransition(() => {
114
+ submitCallback();
115
+ });
116
+ }
117
+ };
118
+ return (jsxs(Dialog, { open: open, onClose: onClose, children: [jsx(DialogTitle, { children: "Confirm RMA" }), jsxs(DialogContent, { children: [jsx(DialogContentText, { children: "Summary of items to be returned:" }), jsx(List, { children: items.map((item, index) => (jsx(ListItem, { children: `Product with ID ${item.product} - Quantity: ${item.returned_quantity}` }, index))) }), jsx(DialogContentText, { children: "Are you sure you want to request a return merchandise authorization for these items?" }), jsx(Checkbox, { onChange: (e) => setMissingConfirmations(!e.target.checked) }), jsx(Typography, { variant: "body1", children: "I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration." })] }), jsxs(DialogActions, { children: [jsx(SubmitButton, { text: "Yes", loadingText: "Loading...", disabled: missingConfirmations, onClick: handleSubmit, loading: isPending }), jsx(Button, { onClick: onClose, children: "No" }), formState?.strapiErrors !== null && (jsx(StrapiErrors, { error: formState?.strapiErrors })), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message }))] })] }));
110
119
  };
111
120
  /* INFO Request RMA Return Merchandise Authorization for customers*/
112
121
  function RmaForm({ opo, sx, revalidateCallback, handleClose, }) {
@@ -44,13 +44,13 @@ function TextualIroItemUpdater({ item, index, handleAddReport, handleUpdateQuant
44
44
  [];
45
45
  return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsxs(Typography, { variant: "body1", children: ["Reason: ", reason, reason === "other" &&
46
46
  other_reason !== undefined &&
47
- `, ${other_reason}`] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: returned_quantity, minNewValue: 0 + registered_quantity, maxNewValue: returned_quantity, color: "info", handleChange: (newValue) => {
47
+ `, ${other_reason}`] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: returned_quantity, minnewvalue: 0 + registered_quantity, maxnewvalue: returned_quantity, color: "info", handleChange: (newValue) => {
48
48
  handleUpdateQuantity(newValue, item.documentId, "received_quantity");
49
- } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("registered") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Registered" }), jsx(TextualAmountUpdater, { label: "Registered", currentValue: registered_quantity, totalValue: returned_quantity + registered_reports_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
49
+ } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("registered") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Registered" }), jsx(TextualAmountUpdater, { label: "Registered", currentValue: registered_quantity, totalValue: returned_quantity + registered_reports_quantity, minnewvalue: 0 + released_quantity, maxnewvalue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
50
50
  handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
51
51
  } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("reports") && (jsxs(Box, { sx: { mb: 2 }, children: [jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: dbReports }), jsx(PreReportsDisplay, { itemID: item.documentId, reports: preReports, handleRemoveReportAtIndex: handleRemoveReportAtIndex }), jsx(SimpleReportFields, { itemID: item.documentId, content: "", type: "registered", minValue: -(received_quantity -
52
52
  registered_quantity +
53
- registered_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("released") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Released" }), jsx(TextualAmountUpdater, { label: "Released", currentValue: released_quantity, totalValue: returned_quantity + registered_reports_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
53
+ registered_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("released") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Released" }), jsx(TextualAmountUpdater, { label: "Released", currentValue: released_quantity, totalValue: returned_quantity + registered_reports_quantity, minnewvalue: 0, maxnewvalue: registered_quantity, color: "info", handleChange: (newValue) => {
54
54
  handleUpdateQuantity(newValue, item.documentId, "released_quantity");
55
55
  } })] }))] })) }, index));
56
56
  }
@@ -43,9 +43,9 @@ revalidateCallback, }) {
43
43
  .reduce((a, b) => a + b.quantity, 0)
44
44
  : 0;
45
45
  }, [reports]);
46
- return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Typography, { variant: "body2", children: "Picked" }), jsx(AmountUpdater, { currentValue: picked_quantity, totalValue: ordered_quantity + -packed_reports_quantity, minNewValue: 0 + packed_quantity + -packed_reports_quantity, maxNewValue: ordered_quantity + -packed_reports_quantity, color: "info", handleChange: (newValue) => {
46
+ return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Typography, { variant: "body2", children: "Picked" }), jsx(AmountUpdater, { currentValue: picked_quantity, totalValue: ordered_quantity + -packed_reports_quantity, minnewvalue: 0 + packed_quantity + -packed_reports_quantity, maxnewvalue: ordered_quantity + -packed_reports_quantity, color: "info", handleChange: (newValue) => {
47
47
  handleUpdateQuantity(newValue, item.documentId, "picked_quantity");
48
- } }), jsx(Typography, { variant: "body2", children: "Packed" }), jsx(AmountUpdater, { currentValue: packed_quantity, totalValue: ordered_quantity, minNewValue: 0 + shipped_quantity, maxNewValue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
48
+ } }), jsx(Typography, { variant: "body2", children: "Packed" }), jsx(AmountUpdater, { currentValue: packed_quantity, totalValue: ordered_quantity, minnewvalue: 0 + shipped_quantity, maxnewvalue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
49
49
  handleUpdateQuantity(newValue, item.documentId, "packed_quantity");
50
50
  }, offsetEnd: packed_reports_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports.filter((report) => "documentId" in report &&
51
51
  typeof report.documentId === "string") }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "packed", minValue: -(picked_quantity + packed_reports_quantity), maxValue: 0, related: [
@@ -53,7 +53,7 @@ revalidateCallback, }) {
53
53
  documentId: item.documentId,
54
54
  __type: "api::e-commerce.opo-item",
55
55
  },
56
- ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(AmountUpdater, { currentValue: shipped_quantity, totalValue: ordered_quantity, minNewValue: 0, maxNewValue: packed_quantity, color: "info", handleChange: (newValue) => {
56
+ ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(AmountUpdater, { currentValue: shipped_quantity, totalValue: ordered_quantity, minnewvalue: 0, maxnewvalue: packed_quantity, color: "info", handleChange: (newValue) => {
57
57
  handleUpdateQuantity(newValue, item.documentId, "shipped_quantity");
58
58
  } })] })) }, index));
59
59
  }
@@ -41,13 +41,13 @@ function TextualOpoItemUpdater({ item, index, handleAddReport, handleUpdateQuant
41
41
  const dbReports = item.reports?.filter((report) => "id" in report) || [];
42
42
  const preReports = item.reports?.filter((report) => Boolean("id" in report) === false) ||
43
43
  [];
44
- return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("picked") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Picked" }), jsx(TextualAmountUpdater, { label: "Picked", currentValue: picked_quantity, totalValue: ordered_quantity, minNewValue: 0 + packed_quantity, maxNewValue: ordered_quantity, color: "info", handleChange: (newValue) => {
44
+ return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("picked") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Picked" }), jsx(TextualAmountUpdater, { label: "Picked", currentValue: picked_quantity, totalValue: ordered_quantity, minnewvalue: 0 + packed_quantity, maxnewvalue: ordered_quantity, color: "info", handleChange: (newValue) => {
45
45
  handleUpdateQuantity(newValue, item.documentId, "picked_quantity");
46
- } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("packed") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Packed" }), jsx(TextualAmountUpdater, { label: "Packed", currentValue: packed_quantity, totalValue: ordered_quantity + packed_reports_quantity, minNewValue: 0 + shipped_quantity, maxNewValue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
46
+ } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("packed") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Packed" }), jsx(TextualAmountUpdater, { label: "Packed", currentValue: packed_quantity, totalValue: ordered_quantity + packed_reports_quantity, minnewvalue: 0 + shipped_quantity, maxnewvalue: picked_quantity + packed_reports_quantity, color: "info", handleChange: (newValue) => {
47
47
  handleUpdateQuantity(newValue, item.documentId, "packed_quantity");
48
48
  } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("reports") && (jsxs(Box, { sx: { mb: 2 }, children: [jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: dbReports }), jsx(PreReportsDisplay, { itemID: item.documentId, reports: preReports, handleRemoveReportAtIndex: handleRemoveReportAtIndex }), jsx(SimpleReportFields, { itemID: item.documentId, content: "", type: "packed", minValue: -(picked_quantity -
49
49
  packed_quantity +
50
- packed_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("shipped") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(TextualAmountUpdater, { label: "Shipped", currentValue: shipped_quantity, totalValue: ordered_quantity + packed_reports_quantity, minNewValue: 0, maxNewValue: packed_quantity, color: "info", handleChange: (newValue) => {
50
+ packed_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("shipped") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Shipped" }), jsx(TextualAmountUpdater, { label: "Shipped", currentValue: shipped_quantity, totalValue: ordered_quantity + packed_reports_quantity, minnewvalue: 0, maxnewvalue: packed_quantity, color: "info", handleChange: (newValue) => {
51
51
  handleUpdateQuantity(newValue, item.documentId, "shipped_quantity");
52
52
  } })] }))] })) }, index));
53
53
  }
@@ -30,16 +30,16 @@ function ItemUpdater({ item, index, handleUpdateQuantity, image, revalidateCallb
30
30
  .reduce((a, b) => a + b.quantity, 0)
31
31
  : 0;
32
32
  const [open, setOpen] = useState(false);
33
- return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product.title }) }))] }), jsx(Typography, { variant: "body2", children: "Received" }), jsx(AmountUpdater, { currentValue: received_quantity, totalValue: ordered_quantity + received_bad_quantity, minNewValue: 0 + registered_quantity + -registered_bad_quantity, maxNewValue: ordered_quantity + received_bad_quantity, color: "info", handleChange: (newValue) => {
33
+ return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsxs(Stack, { spacing: 1, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product.product_number] })] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product.title }) }))] }), jsx(Typography, { variant: "body2", children: "Received" }), jsx(AmountUpdater, { currentValue: received_quantity, totalValue: ordered_quantity + received_bad_quantity, minnewvalue: 0 + registered_quantity + -registered_bad_quantity, maxnewvalue: ordered_quantity + received_bad_quantity, color: "info", handleChange: (newValue) => {
34
34
  handleUpdateQuantity(newValue, item.documentId, "received_quantity");
35
- } }), jsx(Typography, { variant: "body2", children: "Registered" }), jsx(AmountUpdater, { currentValue: registered_quantity, totalValue: ordered_quantity + received_bad_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_bad_quantity, color: "info", handleChange: (newValue) => {
35
+ } }), jsx(Typography, { variant: "body2", children: "Registered" }), jsx(AmountUpdater, { currentValue: registered_quantity, totalValue: ordered_quantity + received_bad_quantity, minnewvalue: 0 + released_quantity, maxnewvalue: received_quantity + registered_bad_quantity, color: "info", handleChange: (newValue) => {
36
36
  handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
37
37
  }, offsetEnd: registered_bad_quantity }), jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: reports }), jsx(ReportMakingComponent, { content: "content", quantity: 0, type: "registered", minValue: -(received_quantity + registered_bad_quantity), maxValue: received_quantity, related: [
38
38
  {
39
39
  documentId: item.documentId,
40
40
  __type: "api::logistics.ipo-item",
41
41
  },
42
- ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: ordered_quantity + received_bad_quantity + registered_bad_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
42
+ ], revalidateCallback: revalidateCallback })] }) }), jsx(Typography, { variant: "body2", children: "Released" }), jsx(AmountUpdater, { currentValue: released_quantity || 0, totalValue: ordered_quantity + received_bad_quantity + registered_bad_quantity, minnewvalue: 0, maxnewvalue: registered_quantity, color: "info", handleChange: (newValue) => {
43
43
  handleUpdateQuantity(newValue, item.documentId, "released_quantity");
44
44
  } })] })) }, index));
45
45
  }
@@ -42,13 +42,13 @@ function TextualIPOItemUpdater({ item, index, handleAddReport, handleUpdateQuant
42
42
  [];
43
43
  const preReports = item.reports?.filter((report) => !("documentId" in report)) ||
44
44
  [];
45
- return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: ordered_quantity, minNewValue: 0 + registered_quantity, maxNewValue: ordered_quantity, color: "info", handleChange: (newValue) => {
45
+ return (jsx(Stack, { spacing: 1, children: item && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsxs(Typography, { variant: "body1", children: ["Line Item Number: ", line_item_number] }), jsxs(Typography, { variant: "body1", children: ["Part Number: ", product?.product_number] }), image && (jsx(Fragment, { children: jsx(ImagePreviewTooltip, { image: image, label: item.product?.title }) }))] }), jsx(Divider, { sx: { mb: 1 } }), showing && showing.includes("received") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Received" }), jsx(TextualAmountUpdater, { label: "Received", currentValue: received_quantity, totalValue: ordered_quantity, minnewvalue: 0 + registered_quantity, maxnewvalue: ordered_quantity, color: "info", handleChange: (newValue) => {
46
46
  handleUpdateQuantity(newValue, item.documentId, "received_quantity");
47
- } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("registered") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Registered" }), jsx(TextualAmountUpdater, { label: "Registered", currentValue: registered_quantity, totalValue: ordered_quantity + registered_reports_quantity, minNewValue: 0 + released_quantity, maxNewValue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
47
+ } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("registered") && (jsxs(Fragment, { children: [jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Registered" }), jsx(TextualAmountUpdater, { label: "Registered", currentValue: registered_quantity, totalValue: ordered_quantity + registered_reports_quantity, minnewvalue: 0 + released_quantity, maxnewvalue: received_quantity + registered_reports_quantity, color: "info", handleChange: (newValue) => {
48
48
  handleUpdateQuantity(newValue, item.documentId, "registered_quantity");
49
49
  } })] }), jsx(Divider, { sx: { mb: 2 } })] })), showing && showing.includes("reports") && (jsxs(Box, { sx: { mb: 2 }, children: [jsx(Divider, { sx: { p: 0 }, children: jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [jsx(Typography, { variant: "body2", children: "Irregularities / Corrections" }), jsx(IconButton, { onClick: () => setOpen(!open), children: jsx(ArrowButtonDownIcon, {}) })] }) }), jsx(Collapse, { in: open, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body2", children: "Here you can report and correct for damages wrong items etc. Do not forget to click the button!" }), jsx(ReportsDisplay, { reports: dbReports }), jsx(PreReportsDisplay, { itemID: item.documentId, reports: preReports, handleRemoveReportAtIndex: handleRemoveReportAtIndex }), jsx(SimpleReportFields, { itemID: item.documentId, content: "", type: "registered", minValue: -(received_quantity -
50
50
  registered_quantity +
51
- registered_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("released") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Released" }), jsx(TextualAmountUpdater, { label: "Released", currentValue: released_quantity, totalValue: ordered_quantity + registered_reports_quantity, minNewValue: 0, maxNewValue: registered_quantity, color: "info", handleChange: (newValue) => {
51
+ registered_reports_quantity), handleAddReport: handleAddReport })] }) })] })), showing && showing.includes("released") && (jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 1 }, children: [jsx(Typography, { variant: "body2", children: "Released" }), jsx(TextualAmountUpdater, { label: "Released", currentValue: released_quantity, totalValue: ordered_quantity + registered_reports_quantity, minnewvalue: 0, maxnewvalue: registered_quantity, color: "info", handleChange: (newValue) => {
52
52
  handleUpdateQuantity(newValue, item.documentId, "released_quantity");
53
53
  } })] }))] })) }, index));
54
54
  }
@@ -33,7 +33,7 @@ type, minValue, maxValue, related, handleAddReport, }) {
33
33
  setQuantity(0);
34
34
  },
35
35
  /* onClick={() => {
36
- if (value < minNewValue || value > maxNewValue) {
36
+ if (value < minnewvalue || value > maxnewvalue) {
37
37
  setError(true);
38
38
  } else {
39
39
  handleChange(value);