umwd-components 0.1.781 → 0.1.783
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/cjs/src/components/common/media/UploadBase64MediaForm.js +1 -1
- package/dist/cjs/src/components/common/media/UploadMediaForm.js +1 -1
- package/dist/cjs/src/components/common/media/minio/MinioDisplay.js +7 -0
- package/dist/cjs/src/components/common/media/minio/UploadMinioMediaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/data/actions/media/minio/uploadMinioMediaAction.js +1 -1
- package/dist/cjs/src/data/loaders/e-commerce/iros/getSingleIro.js +1 -1
- package/dist/cjs/src/data/loaders/logistics/getSingleIpo.js +1 -1
- package/dist/cjs/src/data/services/common/media/minio/minioUploadService.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/common/media/UploadBase64MediaForm.js +5 -7
- package/dist/esm/src/components/common/media/UploadMediaForm.js +1 -1
- package/dist/esm/src/components/common/media/minio/MinioDisplay.js +17 -0
- package/dist/esm/src/components/common/media/minio/UploadMinioMediaForm.js +25 -22
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +2 -1
- package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +6 -5
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +2 -5
- package/dist/esm/src/data/actions/media/minio/deleteMinioMediaAction.js +0 -11
- package/dist/esm/src/data/actions/media/minio/uploadMinioMediaAction.js +76 -27
- package/dist/esm/src/data/loaders/e-commerce/iros/getSingleIro.js +1 -0
- package/dist/esm/src/data/loaders/logistics/getSingleIpo.js +5 -2
- package/dist/esm/src/data/services/common/media/minio/minioUploadService.js +5 -2
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/components/common/media/minio/MinioDisplay.d.ts +9 -0
- package/dist/esm/types/components/common/media/minio/UploadMinioMediaForm.d.ts +1 -10
- package/dist/esm/types/data/services/common/media/minio/minioUploadService.d.ts +1 -1
- package/dist/esm/types/types/common/media/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/src/data/services/common/media/minio/minio-service.js +0 -6
- package/dist/esm/src/data/services/common/media/minio/minio-service.js +0 -76
- package/dist/esm/types/data/services/common/media/minio/minio-service.d.ts +0 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import { useState, useActionState, useRef, useEffect } from 'react';
|
|
10
10
|
import Stack from '@mui/material/Stack';
|
|
11
11
|
import Typography from '@mui/material/Typography';
|
|
@@ -41,17 +41,15 @@ function UploadBase64MediaForm({ reference, refID, field, multiple = true, accep
|
|
|
41
41
|
width: "100%",
|
|
42
42
|
border: "1px dashed white",
|
|
43
43
|
minHeight: "100px",
|
|
44
|
-
}, children:
|
|
45
|
-
return (jsx("img", { src:
|
|
46
|
-
}) })) : (jsx(
|
|
47
|
-
return jsx(Typography, { children: file.name }, index);
|
|
48
|
-
}) })) })) : (jsx(Box, { onClick: () => fileInput.current?.click(), sx: {
|
|
44
|
+
}, children: jsx(Stack, { spacing: 1, justifyContent: "flex-end", children: filePreviews.map((file, index) => {
|
|
45
|
+
return (jsxs(Fragment, { children: [jsx(Typography, { children: file.name }, index), jsx("img", { src: file.url, alt: file.name, style: { width: "100px" } }, index)] }));
|
|
46
|
+
}) }) })) : (jsx(Box, { onClick: () => fileInput.current?.click(), sx: {
|
|
49
47
|
p: 2,
|
|
50
48
|
width: "100%",
|
|
51
49
|
border: "1px dashed white",
|
|
52
50
|
minHeight: "100px",
|
|
53
51
|
cursor: "pointer",
|
|
54
|
-
}, children: jsxs(Typography, { children: ["No file", `${multiple ? "s" : ""}`, " selected for upload"] }) })), 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: "pictureInput", children: jsx("input", { id: "pictureInput", accept: accept, multiple: multiple, type: "file", name: "files", ref: fileInput, onChange: (e) => {
|
|
52
|
+
}, children: jsxs(Typography, { children: ["No file", `${multiple ? "s" : ""}`, " selected for upload"] }) })), 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: "pictureInput", children: jsx("input", { id: "pictureInput", accept: accept.toString(), multiple: multiple, type: "file", name: "files", ref: fileInput, onChange: (e) => {
|
|
55
53
|
const selectedFiles = e.target.files;
|
|
56
54
|
if (selectedFiles === null) {
|
|
57
55
|
return;
|
|
@@ -58,7 +58,7 @@ function UploadMediaForm({ reference, refID, field, multiple = true, accept = "i
|
|
|
58
58
|
border: "1px dashed white",
|
|
59
59
|
minHeight: "100px",
|
|
60
60
|
cursor: "pointer",
|
|
61
|
-
}, 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: "pictureInput", children: jsx("input", { id: "pictureInput", accept: accept, multiple: multiple, type: "file", name: "files", ref: fileInput, onChange: (e) => {
|
|
61
|
+
}, 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: "pictureInput", children: jsx("input", { id: "pictureInput", accept: accept.toString(), multiple: multiple, type: "file", name: "files", ref: fileInput, onChange: (e) => {
|
|
62
62
|
const selectedFiles = e.target.files;
|
|
63
63
|
if (selectedFiles === null) {
|
|
64
64
|
return;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
9
|
+
import { Stack, Typography } from '@mui/material';
|
|
10
|
+
import { MinioDownloadButton } from './MinioDownloadButton.js';
|
|
11
|
+
import { MinioDeleteFormButton } from './MinioDeleteFormButton.js';
|
|
12
|
+
|
|
13
|
+
const MinioDisplay = ({ fileSize, mimeType, fileName, bucketName, revalidateCallback, }) => {
|
|
14
|
+
return (jsxs(Stack, { spacing: 1, marginTop: 1, children: [jsxs(Typography, { children: ["File: ", fileName] }), jsxs(Typography, { variant: "body2", color: "text.secondary", children: ["Size: ", fileSize, " bytes"] }), jsxs(Typography, { variant: "body2", color: "text.secondary", children: ["Type: ", mimeType] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(MinioDownloadButton, { bucketName: bucketName || "umwd", fileName: fileName || "" }), jsx(MinioDeleteFormButton, { bucketName: bucketName || "umwd", fileName: fileName || "", revalidateCallback: revalidateCallback })] })] }));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { MinioDisplay };
|
|
@@ -23,30 +23,33 @@ const INITIAL_STATE = {
|
|
|
23
23
|
data: null,
|
|
24
24
|
message: null,
|
|
25
25
|
};
|
|
26
|
-
function UploadMinioMediaForm({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
function UploadMinioMediaForm({ bucketName = process.env.MINIO_BUCKET_NAME || "umwd", multiple = false, accept = process.env.MINIO_ACCEPTED_FILE_TYPES || [
|
|
27
|
+
"image/jpeg",
|
|
28
|
+
"image/jpg",
|
|
29
|
+
"image/png",
|
|
30
|
+
"image/webp",
|
|
31
|
+
"image/gif",
|
|
32
|
+
"application/msword",
|
|
33
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
34
|
+
"application/vnd.ms-excel",
|
|
35
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
36
|
+
"application/vnd.ms-powerpoint",
|
|
37
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
38
|
+
"application/pdf",
|
|
39
|
+
"text/plain",
|
|
40
|
+
"text/markdown",
|
|
41
|
+
"text/csv",
|
|
42
|
+
"application/vnd.oasis.opendocument.text",
|
|
43
|
+
"application/vnd.oasis.opendocument.spreadsheet",
|
|
44
|
+
"application/vnd.oasis.opendocument.presentation",
|
|
45
|
+
],
|
|
46
|
+
// "image/*", // should be dependent on config files
|
|
35
47
|
reference, refID, field, revalidateCallback, }) {
|
|
48
|
+
console.log("UploadMinioMediaForm render", reference, refID, field);
|
|
49
|
+
console.log("accept:", accept);
|
|
36
50
|
const [filePreviews, setFilePreviews] = useState(null);
|
|
37
51
|
const [fileList, setFileList] = useState(null);
|
|
38
52
|
const [selectedFileName, setSelectedFileName] = useState(null);
|
|
39
|
-
/* const formAction = uploadMinioMediaAction;
|
|
40
|
-
|
|
41
|
-
if (reference && refID && field) {
|
|
42
|
-
// Attach the media information to the entity
|
|
43
|
-
const boundAction = uploadMinioMediaAction.bind(null, {
|
|
44
|
-
reference,
|
|
45
|
-
refID,
|
|
46
|
-
field,
|
|
47
|
-
});
|
|
48
|
-
formAction = boundAction;
|
|
49
|
-
} */
|
|
50
53
|
const [formState, formAction] = useActionState(uploadMinioMediaAction, INITIAL_STATE);
|
|
51
54
|
const fileInput = useRef(null);
|
|
52
55
|
useEffect(() => {
|
|
@@ -54,7 +57,7 @@ reference, refID, field, revalidateCallback, }) {
|
|
|
54
57
|
revalidateCallback?.();
|
|
55
58
|
}
|
|
56
59
|
}, [formState.message]);
|
|
57
|
-
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: "
|
|
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: {
|
|
58
61
|
p: 2,
|
|
59
62
|
width: "100%",
|
|
60
63
|
border: "1px dashed white",
|
|
@@ -79,7 +82,7 @@ reference, refID, field, revalidateCallback, }) {
|
|
|
79
82
|
border: "1px dashed white",
|
|
80
83
|
minHeight: "100px",
|
|
81
84
|
cursor: "pointer",
|
|
82
|
-
}, 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: "
|
|
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) => {
|
|
83
86
|
const selectedFiles = e.target.files;
|
|
84
87
|
if (selectedFiles === null) {
|
|
85
88
|
return;
|
|
@@ -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 'next/headers';
|
|
29
30
|
|
|
30
31
|
const INITIAL_STATE = {
|
|
31
32
|
zodErrors: null,
|
|
@@ -138,7 +139,7 @@ function RmaForm({ opo, sx, revalidateCallback, handleClose, }) {
|
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
141
|
}, [formState?.strapiErrors]);
|
|
141
|
-
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: 12, children: jsx(Typography, { variant: "h6", children: "RMA Form" }) }), jsx("input", { type: "hidden", name: "opos", value: opo.documentId }), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body1", children: "Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned." }), jsx(Alert, { severity: "warning", children: "We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items." })] }) }), jsx(Grid, { size: 12, children: opo.opo_items ? (jsx(Stack, { spacing: 1, children: opo.opo_items && (jsx(ItemLines, { items: opo.opo_items, itemsToReturn: itemsToReturn, setItemsToReturn: setItemsToReturn, selectedItems: selectedItems, setSelectedItems: setSelectedItems })) })) : (jsx(Typography, { variant: "body1", children: "No items" })) }), jsx(ConfirmRMADialog, { formState: formState, open: open, items: itemsToReturn.filter((item) => item.returned_quantity > 0), onClose: () => setOpen(!open), submitCallback: () => {
|
|
142
|
+
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: 12, children: jsx(Typography, { variant: "h6", children: "RMA Form" }) }), jsx("input", { type: "hidden", name: "opos", value: opo.documentId }), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "body1", children: "Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned." }), jsx(Alert, { severity: "warning", children: "We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items." })] }) }), jsx(Grid, { size: 12, children: opo.opo_items ? (jsx(Stack, { spacing: 1, children: opo.opo_items && (jsx(ItemLines, { items: opo.opo_items, itemsToReturn: itemsToReturn, setItemsToReturn: setItemsToReturn, selectedItems: selectedItems, setSelectedItems: setSelectedItems }, opo.documentId)) })) : (jsx(Typography, { variant: "body1", children: "No items" })) }), jsx(ConfirmRMADialog, { formState: formState, open: open, items: itemsToReturn.filter((item) => item.returned_quantity > 0), onClose: () => setOpen(!open), submitCallback: () => {
|
|
142
143
|
console.log("submit callback");
|
|
143
144
|
const formElement = document.querySelector("form");
|
|
144
145
|
if (formElement) {
|
|
@@ -23,23 +23,24 @@ function TextualIPOItemUpdater({ item, index, handleAddReport, handleUpdateQuant
|
|
|
23
23
|
const { line_item_number, product, ordered_quantity, received_quantity, registered_quantity, released_quantity, reports, } = item;
|
|
24
24
|
const [open, setOpen] = useState(false);
|
|
25
25
|
// these values where wrapped with useMemo before but that did not work well while updating values
|
|
26
|
-
reports
|
|
26
|
+
reports && reports.length > 0
|
|
27
27
|
? reports
|
|
28
28
|
.filter((report) => report.type === "received")
|
|
29
29
|
.reduce((a, b) => a + b.quantity, 0)
|
|
30
30
|
: 0;
|
|
31
|
-
const registered_reports_quantity = reports
|
|
31
|
+
const registered_reports_quantity = reports && reports.length > 0
|
|
32
32
|
? reports
|
|
33
33
|
.filter((report) => report.type === "registered")
|
|
34
34
|
.reduce((a, b) => a + b.quantity, 0)
|
|
35
35
|
: 0;
|
|
36
|
-
reports
|
|
36
|
+
reports && reports.length > 0
|
|
37
37
|
? reports
|
|
38
38
|
.filter((report) => report.type === "released")
|
|
39
39
|
.reduce((a, b) => a + b.quantity, 0)
|
|
40
40
|
: 0;
|
|
41
|
-
const dbReports = item.reports?.filter((report) => "
|
|
42
|
-
|
|
41
|
+
const dbReports = item.reports?.filter((report) => "documentId" in report) ||
|
|
42
|
+
[];
|
|
43
|
+
const preReports = item.reports?.filter((report) => !("documentId" in report)) ||
|
|
43
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
46
|
handleUpdateQuantity(newValue, item.documentId, "received_quantity");
|
|
@@ -11,8 +11,6 @@ import { updateIpoAction } from '../../../data/actions/logistics/ipo/updateIpoAc
|
|
|
11
11
|
import { confirmationService } from '../../../data/services/common/confirmation-service.js';
|
|
12
12
|
import { cancellationService } from '../../../data/services/common/cancellation-service.js';
|
|
13
13
|
import { UploadMinioMediaForm } from '../../common/media/minio/UploadMinioMediaForm.js';
|
|
14
|
-
import { MinioDeleteFormButton } from '../../common/media/minio/MinioDeleteFormButton.js';
|
|
15
|
-
import { MinioDownloadButton } from '../../common/media/minio/MinioDownloadButton.js';
|
|
16
14
|
import NoteTakingComponent from '../note/NoteTakingComponent.js';
|
|
17
15
|
import NotesDisplay from '../note/NotesDisplay.js';
|
|
18
16
|
import ItemDisplay from './ItemDisplay.js';
|
|
@@ -41,6 +39,7 @@ import CalendarTodayIcon from '@mui/icons-material/CalendarToday';
|
|
|
41
39
|
import BusinessIcon from '@mui/icons-material/Business';
|
|
42
40
|
import UpdateIcon from '@mui/icons-material/Update';
|
|
43
41
|
import { SubmitButton } from '../../SubmitButton.js';
|
|
42
|
+
import { MinioDisplay } from '../../common/media/minio/MinioDisplay.js';
|
|
44
43
|
|
|
45
44
|
const INITIAL_STATE = {
|
|
46
45
|
zodErrors: null,
|
|
@@ -211,9 +210,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
211
210
|
{ id: data.documentId, __type: "api::logistics.ipo" },
|
|
212
211
|
], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { size: 12, children: jsx(Typography, { variant: "h5", sx: { py: 1 }, children: "Details" }) }), jsx(Grid, { size: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(NumbersIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.ipo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Custom Reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(CalendarTodayIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Supplier" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.vendor_profile?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(UpdateIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Status" }), jsx(IpoStatusIndicator, { status: data.internal_status })] })] }) }) }), role === "enduser" && (jsx(Grid, { size: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [(data.internal_status === "placed" ||
|
|
213
212
|
data.internal_status === "released_on_stock") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback })] })), (data.internal_status === "placed" ||
|
|
214
|
-
data.internal_status === "ordered") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(CancelIpoDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: data.documentId, revalidateCallback: revalidateCallback })] }))] }) }) })), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsxs(Stack, { spacing: 4, children: [role === "enduser" && (jsx(Fragment, { children: data.minio_order_confirmation ? (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }),
|
|
215
|
-
"umwd", fileName: data.minio_order_confirmation?.fileName || "" }), jsx(MinioDeleteFormButton, { bucketName: data.minio_order_confirmation?.bucketName ||
|
|
216
|
-
"umwd", fileName: data.minio_order_confirmation?.fileName || "", revalidateCallback: revalidateCallback })] })] }) })) : (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { variant: "body2", children: "Upload the order confirmation document for this purchase order" }), jsx(UploadMinioMediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "minio_order_confirmation", bucketName: "umwd", multiple: false, accept: "application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/*", revalidateCallback: revalidateCallback })] }) })) })), data.minio_delivery_note ? (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsxs(Typography, { children: ["File: ", data.minio_delivery_note?.fileName] }), jsxs(Typography, { variant: "body2", color: "text.secondary", children: ["Size: ", data.minio_delivery_note?.fileSize, " bytes"] }), jsxs(Typography, { variant: "body2", color: "text.secondary", children: ["Type: ", data.minio_delivery_note?.mimeType] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(MinioDownloadButton, { bucketName: data.minio_delivery_note?.bucketName || "umwd", fileName: data.minio_delivery_note?.fileName || "" }), jsx(MinioDeleteFormButton, { bucketName: data.minio_delivery_note?.bucketName || "umwd", fileName: data.minio_delivery_note?.fileName || "", revalidateCallback: revalidateCallback })] })] }) })) : (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { variant: "body2", children: "Upload the delivery note document for this purchase order" }), jsx(UploadMinioMediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "minio_delivery_note", bucketName: "umwd", multiple: false, accept: "application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/*", revalidateCallback: revalidateCallback })] }) }))] }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1, sx: {
|
|
213
|
+
data.internal_status === "ordered") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(CancelIpoDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: data.documentId, revalidateCallback: revalidateCallback })] }))] }) }) })), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsxs(Stack, { spacing: 4, children: [role === "enduser" && (jsx(Fragment, { children: data.minio_order_confirmation ? (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(MinioDisplay, { fileSize: data.minio_order_confirmation?.fileSize, mimeType: data.minio_order_confirmation?.mimeType, fileName: data.minio_order_confirmation?.fileName, bucketName: data.minio_order_confirmation?.bucketName, revalidateCallback: revalidateCallback })] }) })) : (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { variant: "body2", children: "Upload the order confirmation document for this purchase order" }), jsx(UploadMinioMediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "minio_order_confirmation", bucketName: "umwd", multiple: false, revalidateCallback: revalidateCallback })] }) })) })), data.minio_delivery_note ? (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(MinioDisplay, { fileSize: data.minio_delivery_note?.fileSize, mimeType: data.minio_delivery_note?.mimeType, fileName: data.minio_delivery_note?.fileName, bucketName: data.minio_delivery_note?.bucketName, revalidateCallback: revalidateCallback })] }) })) : (jsx(Fragment, { children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { variant: "body2", children: "Upload the delivery note document for this purchase order" }), jsx(UploadMinioMediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "minio_delivery_note", bucketName: "umwd", multiple: false, revalidateCallback: revalidateCallback })] }) }))] }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { size: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1, sx: {
|
|
217
214
|
bgcolor: "background.default",
|
|
218
215
|
border: "1px solid",
|
|
219
216
|
borderColor: "divider",
|
|
@@ -7,17 +7,6 @@
|
|
|
7
7
|
import { minioDeleteService } from '../../../services/common/media/minio/minioDeleteService.js';
|
|
8
8
|
import { flattenAttributes } from '../../../../lib/utils.js';
|
|
9
9
|
|
|
10
|
-
/*
|
|
11
|
-
TODO
|
|
12
|
-
|
|
13
|
-
const MAX_FILE_SIZE = 5000000;
|
|
14
|
-
|
|
15
|
-
const ACCEPTED_IMAGE_TYPES = [
|
|
16
|
-
"image/jpeg",
|
|
17
|
-
"image/jpg",
|
|
18
|
-
"image/png",
|
|
19
|
-
"image/webp",
|
|
20
|
-
]; */
|
|
21
10
|
async function deleteMinioMediaAction(bucketName, fileName, prevState) {
|
|
22
11
|
console.log("bucketName:", bucketName, " fileName:", fileName, "prevState:", prevState);
|
|
23
12
|
if (!bucketName || !fileName) {
|
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
import { minioUploadService } from '../../../services/common/media/minio/minioUploadService.js';
|
|
8
8
|
import { flattenAttributes } from '../../../../lib/utils.js';
|
|
9
9
|
|
|
10
|
+
/* const MAX_FILE_SIZE = 5000000;
|
|
11
|
+
|
|
12
|
+
const ACCEPTED_IMAGE_TYPES = [
|
|
13
|
+
"image/jpeg",
|
|
14
|
+
"image/jpg",
|
|
15
|
+
"image/png",
|
|
16
|
+
"image/webp",
|
|
17
|
+
]; */
|
|
10
18
|
// VALIDATE IMAGE WITH ZOD
|
|
11
19
|
/* const imageSchema = z.object({
|
|
12
20
|
image: z
|
|
@@ -23,43 +31,84 @@ import { flattenAttributes } from '../../../../lib/utils.js';
|
|
|
23
31
|
.refine((file) => file.size <= MAX_FILE_SIZE, `Max file size is 5MB.`),
|
|
24
32
|
}); */
|
|
25
33
|
async function uploadMinioMediaAction(prevState, formData) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
try {
|
|
35
|
+
// CONVERT FORM DATA TO OBJEC
|
|
36
|
+
const rawFormData = Object.fromEntries(formData);
|
|
37
|
+
const bucketName = rawFormData.bucketName;
|
|
38
|
+
const fileName = rawFormData.fileName;
|
|
39
|
+
const files = rawFormData.files;
|
|
40
|
+
const reference = rawFormData.reference;
|
|
41
|
+
const refID = rawFormData.refID;
|
|
42
|
+
const field = rawFormData.field;
|
|
43
|
+
console.log("files:", files);
|
|
44
|
+
console.log("files type:", typeof files);
|
|
45
|
+
console.log("files instanceof File:", files instanceof File);
|
|
46
|
+
console.log("fileName:", fileName);
|
|
47
|
+
console.log("bucketName:", bucketName);
|
|
48
|
+
console.log("reference:", reference);
|
|
49
|
+
console.log("refID:", refID);
|
|
50
|
+
console.log("field:", field);
|
|
51
|
+
// Check if files is a File object
|
|
52
|
+
if (!(files instanceof File)) {
|
|
53
|
+
return {
|
|
54
|
+
...prevState,
|
|
55
|
+
strapiErrors: null,
|
|
56
|
+
zodErrors: null,
|
|
57
|
+
message: "No valid file provided",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Convert file to ArrayBuffer first, then to Buffer, then to base64 string
|
|
61
|
+
const arrayBuffer = await files.arrayBuffer();
|
|
62
|
+
console.log("arrayBuffer:", arrayBuffer);
|
|
63
|
+
const fileContent = Buffer.from(arrayBuffer).toString("base64");
|
|
64
|
+
console.log("fileContent length:", fileContent.length);
|
|
65
|
+
// VALIDATE THE IMAGE
|
|
66
|
+
const validatedFields = {
|
|
67
|
+
success: true,
|
|
68
|
+
};
|
|
69
|
+
/* imageSchema.safeParse({
|
|
70
|
+
image: rawFormData.files,
|
|
71
|
+
}); */
|
|
72
|
+
if (!validatedFields.success) ;
|
|
73
|
+
console.log("Uploading file:", fileName, "Size:", Math.round(fileContent.length / 1024 / 1024), "MB");
|
|
74
|
+
// UPLOAD NEW IMAGE TO MINIO
|
|
75
|
+
const fileUploadResponse = reference && refID && field
|
|
76
|
+
? await minioUploadService(bucketName, fileName, fileContent, reference, refID, field)
|
|
77
|
+
: await minioUploadService(bucketName, fileName, fileContent);
|
|
78
|
+
if (!fileUploadResponse) {
|
|
79
|
+
return {
|
|
80
|
+
...prevState,
|
|
81
|
+
strapiErrors: null,
|
|
82
|
+
zodErrors: null,
|
|
83
|
+
message: "Ops! Something went wrong. Please try again.",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (fileUploadResponse.error) {
|
|
87
|
+
return {
|
|
88
|
+
...prevState,
|
|
89
|
+
strapiErrors: fileUploadResponse.error,
|
|
90
|
+
zodErrors: null,
|
|
91
|
+
message: "Failed to Upload File.",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const flattenedData = flattenAttributes(fileUploadResponse);
|
|
40
95
|
return {
|
|
41
96
|
...prevState,
|
|
42
|
-
|
|
97
|
+
data: flattenedData,
|
|
43
98
|
zodErrors: null,
|
|
44
|
-
|
|
99
|
+
strapiErrors: null,
|
|
100
|
+
message: "Image Uploaded",
|
|
45
101
|
};
|
|
46
102
|
}
|
|
47
|
-
|
|
103
|
+
catch (error) {
|
|
104
|
+
console.error("Upload action error:", error);
|
|
48
105
|
return {
|
|
49
106
|
...prevState,
|
|
50
|
-
strapiErrors:
|
|
107
|
+
strapiErrors: null,
|
|
51
108
|
zodErrors: null,
|
|
52
|
-
message: "Failed to
|
|
109
|
+
message: "Failed to process file upload",
|
|
53
110
|
};
|
|
54
111
|
}
|
|
55
|
-
const flattenedData = flattenAttributes(fileUploadResponse);
|
|
56
|
-
return {
|
|
57
|
-
...prevState,
|
|
58
|
-
data: flattenedData,
|
|
59
|
-
zodErrors: null,
|
|
60
|
-
strapiErrors: null,
|
|
61
|
-
message: "Image Uploaded",
|
|
62
|
-
};
|
|
63
112
|
}
|
|
64
113
|
|
|
65
114
|
export { uploadMinioMediaAction };
|
|
@@ -44,10 +44,13 @@ async function getSingleIpo(documentId) {
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
|
+
minio_order_confirmation: true,
|
|
48
|
+
minio_delivery_note: true,
|
|
47
49
|
},
|
|
48
50
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const responseData = await fetchData(url.href);
|
|
52
|
+
console.log("Raw IPO data:", responseData);
|
|
53
|
+
return responseData;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export { getSingleIpo };
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
import { getAuthToken } from '../../../get-token.js';
|
|
9
9
|
import { getStrapiURL } from '../../../../../lib/utils.js';
|
|
10
10
|
|
|
11
|
-
async function minioUploadService(bucketName, fileName, fileContent) {
|
|
11
|
+
async function minioUploadService(bucketName, fileName, fileContent, reference, refID, field) {
|
|
12
12
|
const authToken = await getAuthToken();
|
|
13
13
|
if (!authToken)
|
|
14
14
|
throw new Error("No auth token found");
|
|
15
15
|
const baseUrl = getStrapiURL();
|
|
16
|
-
const url = new URL("/api/minio-plugin/
|
|
16
|
+
const url = new URL("/api/minio-plugin/uploadbyreference", baseUrl);
|
|
17
17
|
try {
|
|
18
18
|
const response = await fetch(url, {
|
|
19
19
|
headers: { Authorization: `Bearer ${authToken}` },
|
|
@@ -23,6 +23,9 @@ async function minioUploadService(bucketName, fileName, fileContent) {
|
|
|
23
23
|
bucketName,
|
|
24
24
|
fileName,
|
|
25
25
|
fileContent,
|
|
26
|
+
reference,
|
|
27
|
+
refID,
|
|
28
|
+
field,
|
|
26
29
|
},
|
|
27
30
|
}),
|
|
28
31
|
});
|