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
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/Box"),s=require("../../../data/actions/media/uploadBase64MediaAction.js"),a=require("../../StrapiErrors.js"),l=require("../../ZodErrors.js"),o=require("@mui/material/Alert"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/Box"),s=require("../../../data/actions/media/uploadBase64MediaAction.js"),a=require("../../StrapiErrors.js"),l=require("../../ZodErrors.js"),o=require("@mui/material/Alert"),u=require("../../SubmitButton.js");const d={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadBase64MediaForm=function({reference:c,refID:p,field:m,multiple:x=!0,accept:j="image/*",path:h="api/ipos",componentName:f="",componentReference:y,revalidateCallback:g}){const[b,q]=r.useState(null),[E,S]=r.useState(null),k=s.uploadBase64MediaAction.bind(null,h,p||"",f),[v,w]=r.useActionState(k,d),B=r.useRef(null);return r.useEffect(()=>{v.data&&g&&g()},[v.data]),e.jsx("form",{action:w,id:m,children:e.jsx(n,{sx:[b&&b.length>0&&{border:"2px solid red",p:1}],children:e.jsxs(t,{spacing:1,sx:{flex:1},children:[c&&e.jsx("input",{type:"text",name:"ref",value:c,style:{display:"none"},readOnly:!0}),p&&e.jsx("input",{type:"text",name:"refId",value:p,style:{display:"none"},readOnly:!0})," ",m&&e.jsx("input",{type:"text",name:"field",value:m,style:{display:"none"},readOnly:!0}),e.jsx("input",{id:"component_name",type:"hidden",name:`${f}.__component`,value:y}),null!==b?e.jsx(n,{onClick:()=>B.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"},children:e.jsx(t,{spacing:1,justifyContent:"flex-end",children:b.map((r,t)=>e.jsxs(e.Fragment,{children:[e.jsx(i,{children:r.name},t),e.jsx("img",{src:r.url,alt:r.name,style:{width:"100px"}},t)]}))})}):e.jsx(n,{onClick:()=>B.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(i,{children:["No file",""+(x?"s":"")," selected for upload"]})}),e.jsxs(t,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between",children:[e.jsx(a.StrapiErrors,{error:v.strapiErrors}),e.jsx(l.ZodErrors,{error:v.zodErrors?.image}),v?.message&&e.jsx(o,{severity:"error",children:v?.message}),e.jsxs(n,{children:[e.jsx("label",{htmlFor:"pictureInput",children:e.jsx("input",{id:"pictureInput",accept:j.toString(),multiple:x,type:"file",name:"files",ref:B,onChange:e=>{const r=e.target.files;if(null===r)return;const t=Object.keys(r).map((e,t)=>({url:URL.createObjectURL(r[t]),name:r[t].name}));S(r),q(t)},style:{display:"none"}})}),null!==E&&e.jsx(u.SubmitButton,{text:"upload",loadingText:"loading"})]})]})]})})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/media/uploadMediaAction.js"),t=require("../../StrapiErrors.js"),s=require("../../ZodErrors.js"),l=require("../../SubmitButton.js"),n=require("@mui/material/Stack"),a=require("@mui/material/Typography"),u=require("@mui/material/Box"),c=require("@mui/material/Grid"),d=require("@mui/material/Alert");const o={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadMediaForm=function({reference:p,refID:m,field:x,multiple:j=!0,accept:h="image/*",revalidateCallback:
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/media/uploadMediaAction.js"),t=require("../../StrapiErrors.js"),s=require("../../ZodErrors.js"),l=require("../../SubmitButton.js"),n=require("@mui/material/Stack"),a=require("@mui/material/Typography"),u=require("@mui/material/Box"),c=require("@mui/material/Grid"),d=require("@mui/material/Alert");const o={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadMediaForm=function({reference:p,refID:m,field:x,multiple:j=!0,accept:h="image/*",revalidateCallback:g}){const[y,f]=r.useState(null),[q,b]=r.useState(null),[E,S]=r.useActionState(i.uploadMediaAction,o),k=r.useRef(null);return r.useEffect(()=>{E.data&&g?.()},[E.data]),e.jsx("form",{action:S,children:e.jsxs(n,{spacing:1,sx:{flex:1},children:[p&&e.jsx("input",{type:"text",name:"ref",value:p,style:{display:"none"},readOnly:!0}),m&&e.jsx("input",{type:"text",name:"refId",value:m,style:{display:"none"},readOnly:!0}),x&&e.jsx("input",{type:"text",name:"field",value:x,style:{display:"none"},readOnly:!0}),null!==y?e.jsx(u,{onClick:()=>k.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"},children:void 0===h||"image/*"===h?e.jsx(c,{container:!0,children:y.map((r,i)=>e.jsx(c,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx("img",{src:r.url,alt:r.name,style:{width:"100px"}},i)},i))}):e.jsx(c,{container:!0,children:y.map((r,i)=>e.jsx(c,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx(a,{children:r.name})},i))})}):e.jsx(u,{onClick:()=>k.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(a,{children:["No file",""+(j?"s":"")," selected, click here to start uploading new files"]})}),e.jsxs(n,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between",children:[e.jsx(t.StrapiErrors,{error:E.strapiErrors}),e.jsx(s.ZodErrors,{error:E.zodErrors?.image}),E?.message&&e.jsx(d,{severity:"error",children:E?.message}),e.jsxs(u,{children:[e.jsx("label",{htmlFor:"pictureInput",children:e.jsx("input",{id:"pictureInput",accept:h.toString(),multiple:j,type:"file",name:"files",ref:k,onChange:e=>{const r=e.target.files;if(null===r)return;const i=Object.keys(r).map((e,i)=>({url:URL.createObjectURL(r[i]),name:r[i].name}));b(r),f(i)},style:{display:"none"}})}),null!==q&&e.jsx(l.SubmitButton,{text:"upload",loadingText:"loading"})]})]})]})})};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),i=require("@mui/material"),a=require("./MinioDownloadButton.js"),r=require("./MinioDeleteFormButton.js");exports.MinioDisplay=({fileSize:t,mimeType:o,fileName:n,bucketName:l,revalidateCallback:s})=>e.jsxs(i.Stack,{spacing:1,marginTop:1,children:[e.jsxs(i.Typography,{children:["File: ",n]}),e.jsxs(i.Typography,{variant:"body2",color:"text.secondary",children:["Size: ",t," bytes"]}),e.jsxs(i.Typography,{variant:"body2",color:"text.secondary",children:["Type: ",o]}),e.jsxs(i.Stack,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(a.MinioDownloadButton,{bucketName:l||"umwd",fileName:n||""}),e.jsx(r.MinioDeleteFormButton,{bucketName:l||"umwd",fileName:n||"",revalidateCallback:s})]})]});
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("react/jsx-runtime"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),i=require("react"),n=require("../../../../data/actions/media/minio/uploadMinioMediaAction.js"),t=require("../../../StrapiErrors.js"),r=require("../../../ZodErrors.js"),a=require("../../../SubmitButton.js"),s=require("@mui/material/Stack"),l=require("@mui/material/Typography"),o=require("@mui/material/Box"),p=require("@mui/material/Grid"),c=require("@mui/material/Alert");const d={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadMinioMediaForm=function({bucketName:m=process.env.MINIO_BUCKET_NAME||"umwd",multiple:u=!1,accept:x=process.env.MINIO_ACCEPTED_FILE_TYPES||["image/jpeg","image/jpg","image/png","image/webp","image/gif","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/pdf","text/plain","text/markdown","text/csv","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation"],reference:g,refID:j,field:f,revalidateCallback:h}){console.log("UploadMinioMediaForm render",g,j,f),console.log("accept:",x);const[y,v]=i.useState(null),[E,w]=i.useState(null),[b,k]=i.useState(null),[q,M]=i.useActionState(n.uploadMinioMediaAction,d),I=i.useRef(null);return i.useEffect(()=>{q.message&&"success"===q.message.type&&h?.()},[q.message]),e.jsx("form",{action:M,children:e.jsxs(s,{spacing:1,sx:{flex:1},children:[g&&j&&f&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",name:"reference",value:g,style:{display:"none"},readOnly:!0}),e.jsx("input",{type:"text",name:"refID",value:j,style:{display:"none"},readOnly:!0}),e.jsx("input",{type:"text",name:"field",value:f,style:{display:"none"},readOnly:!0})]}),m&&e.jsx("input",{type:"text",name:"bucketName",value:m,style:{display:"none"},readOnly:!0}),b&&e.jsx("input",{type:"text",name:"fileName",value:b,style:{display:"none"},readOnly:!0}),null!==y?e.jsx(o,{onClick:()=>I.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"},children:void 0===x||"image/*"===x?e.jsx(p,{container:!0,children:y.map((i,n)=>e.jsx(p,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx("img",{src:i.url,alt:i.name,style:{width:"100px"}},n)},n))}):e.jsx(p,{container:!0,children:y.map((i,n)=>e.jsx(p,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx(l,{children:i.name})},n))})}):e.jsx(o,{onClick:()=>I.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(l,{children:["No file",""+(u?"s":"")," selected, click here to start uploading new files"]})}),e.jsxs(s,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between",children:[e.jsx(t.StrapiErrors,{error:q.strapiErrors}),e.jsx(r.ZodErrors,{error:q.zodErrors?.image}),q?.message&&e.jsx(c,{severity:"error",children:q?.message}),e.jsxs(o,{children:[e.jsx("label",{htmlFor:"minioInput",children:e.jsx("input",{id:"minioInput",accept:"string"==typeof x?x:x.join(","),multiple:u,type:"file",name:"files",ref:I,onChange:e=>{const i=e.target.files;if(null===i)return;i.length>0&&k(i[0].name);const n=Object.keys(i).map((e,n)=>({url:URL.createObjectURL(i[n]),name:i[n].name}));w(i),v(n)},style:{display:"none"}})}),null!==E&&e.jsx(a.SubmitButton,{text:"upload",loadingText:"loading"})]})]})]})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../../context/common/SnackbarContext.js"),i=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),s=require("../../StrapiErrors.js"),a=require("../../SubmitButton.js"),n=require("@mui/material/Typography"),o=require("@mui/material/Grid"),u=require("@mui/material/Box"),l=require("@mui/material/TextField"),d=require("@mui/material/Checkbox"),c=require("@mui/material/Button"),m=require("@mui/material/Alert"),h=require("@mui/material/Stack"),x=require("@mui/material"),g=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),p=require("@mui/material/DialogContent"),y=require("@mui/material/DialogContentText"),b=require("@mui/material/DialogTitle"),v=require("../../common/NumberInput.js");const f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},q=({items:t,itemsToReturn:i,setItemsToReturn:s,selectedItems:a,setSelectedItems:o})=>{const[u,c]=r.useState(!1),m=(e,r,t)=>{s(i.map((i,s)=>s===e?{...i,[r]:t}:i))};r.useEffect(()=>{t&&s(t.map(e=>({line_item_number:e.line_item_number||"",product:e.product?.documentId||"",ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[g,j]=r.useState([]);return r.useEffect(()=>{i&&j((e=>e.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:e.product,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))(i))},[i]),e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsxs(h,{spacing:2,children:[e.jsx(n,{variant:"h6",children:"Items"}),e.jsx(n,{variant:"body1",children:"from the items in the original order please select the items you'd like to return"}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(g)}),e.jsx(h,{spacing:1,children:t.map((r,t)=>e.jsxs(e.Fragment,{children:[e.jsxs(h,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(d,{checked:a.includes(t),onChange:e=>{e.target.checked?o([...a,t]):o(a.filter(e=>e!==t))}}),e.jsxs(n,{variant:"body1",children:["Line Item Number: ",r.line_item_number]}),e.jsxs(n,{variant:"body1",children:["Part Number: ",r.product?.product_number]}),e.jsxs(n,{variant:"body1",children:["Quantity Ordered: ",r.ordered_quantity]})]}),a.includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(v.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(x.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(n,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(l,{value:i[t]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;c("other"===r),m(t,"reason",r)},children:[e.jsx("option",{value:"damaged",children:"Damaged on arrival"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]})]}),u&&e.jsx(l,{value:i[t].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;m(t,"other_reason",r)}})]}),e.jsx(x.Divider,{})]}))})]})})},_=({open:t,onClose:i,items:o,formState:u,submitCallback:l})=>{const[h,v]=r.useState(!0);return e.jsxs(g,{open:t,onClose:i,children:[e.jsx(b,{children:"Confirm RMA"}),e.jsxs(p,{children:[e.jsx(y,{children:"Summary of items to be returned:"}),e.jsx(x.List,{children:o.map((r,t)=>e.jsx(x.ListItem,{children:`Product with ID ${r.product} - Quantity: ${r.returned_quantity}`},t))}),e.jsx(y,{children:"Are you sure you want to request a return merchandise authorization for these items?"}),e.jsx(d,{onChange:e=>v(!e.target.checked)}),e.jsx(n,{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."})]}),e.jsxs(j,{children:[l?e.jsx(a.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:h,onClick:l}):e.jsx(a.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:h}),e.jsx(c,{onClick:i,children:"No"}),null!==u?.strapiErrors&&e.jsx(s.StrapiErrors,{error:u?.strapiErrors}),u?.message&&e.jsx(m,{severity:"error",children:u?.message})]})]})};exports.default=function({opo:a,sx:l,revalidateCallback:d,handleClose:x}){const[g,j]=r.useActionState(i.requestRmaAction,f),{handleAddMessage:p}=t.useSnackbar(),[y,b]=r.useState(!1),[v,S]=r.useState([]),[C,
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../../context/common/SnackbarContext.js"),i=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),s=require("../../StrapiErrors.js"),a=require("../../SubmitButton.js"),n=require("@mui/material/Typography"),o=require("@mui/material/Grid"),u=require("@mui/material/Box"),l=require("@mui/material/TextField"),d=require("@mui/material/Checkbox"),c=require("@mui/material/Button"),m=require("@mui/material/Alert"),h=require("@mui/material/Stack"),x=require("@mui/material"),g=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),p=require("@mui/material/DialogContent"),y=require("@mui/material/DialogContentText"),b=require("@mui/material/DialogTitle"),v=require("../../common/NumberInput.js");require("next/headers");const f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},q=({items:t,itemsToReturn:i,setItemsToReturn:s,selectedItems:a,setSelectedItems:o})=>{const[u,c]=r.useState(!1),m=(e,r,t)=>{s(i.map((i,s)=>s===e?{...i,[r]:t}:i))};r.useEffect(()=>{t&&s(t.map(e=>({line_item_number:e.line_item_number||"",product:e.product?.documentId||"",ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[g,j]=r.useState([]);return r.useEffect(()=>{i&&j((e=>e.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:e.product,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))(i))},[i]),e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsxs(h,{spacing:2,children:[e.jsx(n,{variant:"h6",children:"Items"}),e.jsx(n,{variant:"body1",children:"from the items in the original order please select the items you'd like to return"}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(g)}),e.jsx(h,{spacing:1,children:t.map((r,t)=>e.jsxs(e.Fragment,{children:[e.jsxs(h,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(d,{checked:a.includes(t),onChange:e=>{e.target.checked?o([...a,t]):o(a.filter(e=>e!==t))}}),e.jsxs(n,{variant:"body1",children:["Line Item Number: ",r.line_item_number]}),e.jsxs(n,{variant:"body1",children:["Part Number: ",r.product?.product_number]}),e.jsxs(n,{variant:"body1",children:["Quantity Ordered: ",r.ordered_quantity]})]}),a.includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(v.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(x.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(n,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(l,{value:i[t]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;c("other"===r),m(t,"reason",r)},children:[e.jsx("option",{value:"damaged",children:"Damaged on arrival"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]})]}),u&&e.jsx(l,{value:i[t].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;m(t,"other_reason",r)}})]}),e.jsx(x.Divider,{})]}))})]})})},_=({open:t,onClose:i,items:o,formState:u,submitCallback:l})=>{const[h,v]=r.useState(!0);return e.jsxs(g,{open:t,onClose:i,children:[e.jsx(b,{children:"Confirm RMA"}),e.jsxs(p,{children:[e.jsx(y,{children:"Summary of items to be returned:"}),e.jsx(x.List,{children:o.map((r,t)=>e.jsx(x.ListItem,{children:`Product with ID ${r.product} - Quantity: ${r.returned_quantity}`},t))}),e.jsx(y,{children:"Are you sure you want to request a return merchandise authorization for these items?"}),e.jsx(d,{onChange:e=>v(!e.target.checked)}),e.jsx(n,{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."})]}),e.jsxs(j,{children:[l?e.jsx(a.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:h,onClick:l}):e.jsx(a.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:h}),e.jsx(c,{onClick:i,children:"No"}),null!==u?.strapiErrors&&e.jsx(s.StrapiErrors,{error:u?.strapiErrors}),u?.message&&e.jsx(m,{severity:"error",children:u?.message})]})]})};exports.default=function({opo:a,sx:l,revalidateCallback:d,handleClose:x}){const[g,j]=r.useActionState(i.requestRmaAction,f),{handleAddMessage:p}=t.useSnackbar(),[y,b]=r.useState(!1),[v,S]=r.useState([]),[C,I]=r.useState([]);return r.useEffect(()=>{g?.message&&(p({message:g.message,severity:g.severity||"error"}),"success"===g.severity&&(d&&d(),x&&x()))},[g?.message]),r.useEffect(()=>{g?.strapiErrors&&p({message:g.strapiErrors.message||"Error requesting RMA",severity:g.severity||"error"})},[g?.strapiErrors]),e.jsx(u,{sx:[...Array.isArray(l)?l:[l]],children:e.jsx("form",{action:j,children:e.jsxs(o,{container:!0,spacing:2,children:[e.jsx(o,{size:12,children:e.jsx(n,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:a.documentId}),e.jsx(o,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(n,{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."}),e.jsx(m,{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."})]})}),e.jsx(o,{size:12,children:a.opo_items?e.jsx(h,{spacing:1,children:a.opo_items&&e.jsx(q,{items:a.opo_items,itemsToReturn:v,setItemsToReturn:S,selectedItems:C,setSelectedItems:I},a.documentId)}):e.jsx(n,{variant:"body1",children:"No items"})}),e.jsx(_,{formState:g,open:y,items:v.filter(e=>e.returned_quantity>0),onClose:()=>b(!y),submitCallback:()=>{console.log("submit callback");const e=document.querySelector("form");j(e?new FormData(e):new FormData),b(!y)}}),e.jsxs(o,{size:12,children:[e.jsx(c,{onClick:()=>{console.log(g),b(!y)},disabled:0===C.length||0===C.reduce((e,r)=>e+v[r].returned_quantity,0),children:"Request RMA"}),null!==g?.strapiErrors&&e.jsx(s.StrapiErrors,{error:g?.strapiErrors}),g?.message&&e.jsx(m,{severity:"error",children:g?.message})]})]})})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),d=require("../../common/TextualAmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),u=require("../report/ReportsDisplay.js"),c=require("../report/PreReportsDisplay.js"),m=require("../report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),d=require("../../common/TextualAmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),u=require("../report/ReportsDisplay.js"),c=require("../report/PreReportsDisplay.js"),m=require("../report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:f,product:w,ordered_quantity:I,received_quantity:v,registered_quantity:R,released_quantity:V,reports:_}=p,[C,A]=r.useState(!1);_&&_.length>0&&_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const D=_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;_&&_.length>0&&_.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const N=p.reports?.filter(e=>"documentId"in e)||[],T=p.reports?.filter(e=>!("documentId"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",f]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",w?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:y,label:p.product?.title})})]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(d.TextualAmountUpdater,{label:"Received",currentValue:v,totalValue:I,minNewValue:0+R,maxNewValue:I,color:"info",handleChange:e=>{g(e,p.documentId,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(d.TextualAmountUpdater,{label:"Registered",currentValue:R,totalValue:I+D,minNewValue:0+V,maxNewValue:v+D,color:"info",handleChange:e=>{g(e,p.documentId,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>A(!C),children:e.jsx(l,{})})]})}),e.jsx(s,{in:C,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:N}),e.jsx(c.default,{itemID:p.documentId,reports:T,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.documentId,content:"",type:"registered",minValue:-(v-R+D),handleAddReport:h})]})})]}),q&&q.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(d.TextualAmountUpdater,{label:"Released",currentValue:V,totalValue:I+D,minNewValue:0,maxNewValue:R,color:"info",handleChange:e=>{g(e,p.documentId,"released_quantity")}})]})]})},j)};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../../common/media/minio/MinioDeleteFormButton.js"),l=require("../../common/media/minio/MinioDownloadButton.js"),c=require("../note/NoteTakingComponent.js"),d=require("../note/NotesDisplay.js"),m=require("./ItemDisplay.js"),u=require("./TextualIPOItemUpdater.js"),h=require("./IpoStatusIndicator.js"),p=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),f=require("@mui/material/Dialog"),g=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),_=require("@mui/material/Button"),C=require("@mui/material/Grid"),I=require("@mui/material/Divider"),q=require("@mui/material/TextField"),w=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),N=require("@mui/material/Checkbox"),D=require("@mui/material/FormControlLabel"),F=require("@mui/icons-material/Numbers"),M=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),A=require("@mui/icons-material/Business"),E=require("@mui/icons-material/Update"),z=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function P({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(f,{open:r,onClose:n,children:[e.jsx(v,{children:"Confirm Order"}),e.jsx(y,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(g,{children:[e.jsx(_,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(_,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,m]=r.useState(""),{handleAddMessage:u}=i.useSnackbar();return e.jsxs(f,{open:n,onClose:t,children:[e.jsx(v,{children:"Cancel Return"}),e.jsx(y,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(w,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(g,{children:[e.jsx(_,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(_,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)m("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,l),u({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){u({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:t,sx:a,revalidateCallback:f,handleClose:g,role:y}){const[v,q]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),B),{handleAddMessage:w}=i.useSnackbar(),[k,U]=r.useState(t.items?t.items:[]),[R,W]=r.useState(!1),[L,G]=r.useState(!1),[J,Q]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{v?.message&&(w({message:v.message,severity:v.severity||"error"}),"success"===v.severity&&(f&&f(),g&&g()))},[v?.message]),r.useEffect(()=>{v?.strapiErrors&&w({message:v.strapiErrors.message||"Error updating IPO",severity:"error"})},[v?.strapiErrors]);const H=(e,r,i)=>{const n=[...k],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,U(n)},K=(e,r)=>{const i=[...k],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,U(i)},V=(e,r)=>{const i=[...k],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,U(i)};return r.useEffect(()=>{"Ipo Updated"===v?.message&&(w({message:"Ipo Updated",severity:"success"}),g&&g(),f&&f())},[v]),r.useEffect(()=>{v?.strapiErrors&&w({message:v.strapiErrors.message||"Error updating IPO",severity:"error"})},[v?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&U(t.items?t.items:[])},[t]),e.jsx(p,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(C,{container:!0,spacing:2,children:[e.jsx(C,{size:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:t.documentId,__type:"api::logistics.ipo"}],revalidateCallback:f})]}),e.jsx(I,{})]})}),e.jsx(C,{size:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(C,{size:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(F,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(M,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(h.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===y&&e.jsx(C,{size:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"contained",color:"primary",onClick:()=>W(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(P,{open:R,handleClose:()=>W(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:f})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(T,{open:L,handleClose:()=>G(!1),orderID:t.documentId,revalidateCallback:f})]})]})})}),e.jsx(C,{size:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:4,children:["enduser"===y&&e.jsx(e.Fragment,{children:t.minio_order_confirmation?e.jsx(e.Fragment,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsxs(b,{children:["File: ",t.minio_order_confirmation?.fileName]}),e.jsxs(b,{variant:"body2",color:"text.secondary",children:["Size: ",t.minio_order_confirmation?.fileSize," ","bytes"]}),e.jsxs(b,{variant:"body2",color:"text.secondary",children:["Type: ",t.minio_order_confirmation?.mimeType]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(l.MinioDownloadButton,{bucketName:t.minio_order_confirmation?.bucketName||"umwd",fileName:t.minio_order_confirmation?.fileName||""}),e.jsx(o.MinioDeleteFormButton,{bucketName:t.minio_order_confirmation?.bucketName||"umwd",fileName:t.minio_order_confirmation?.fileName||"",revalidateCallback:f})]})]})}):e.jsx(e.Fragment,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,accept:"application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/*",revalidateCallback:f})]})})}),t.minio_delivery_note?e.jsx(e.Fragment,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsxs(b,{children:["File: ",t.minio_delivery_note?.fileName]}),e.jsxs(b,{variant:"body2",color:"text.secondary",children:["Size: ",t.minio_delivery_note?.fileSize," bytes"]}),e.jsxs(b,{variant:"body2",color:"text.secondary",children:["Type: ",t.minio_delivery_note?.mimeType]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(l.MinioDownloadButton,{bucketName:t.minio_delivery_note?.bucketName||"umwd",fileName:t.minio_delivery_note?.fileName||""}),e.jsx(o.MinioDeleteFormButton,{bucketName:t.minio_delivery_note?.bucketName||"umwd",fileName:t.minio_delivery_note?.fileName||"",revalidateCallback:f})]})]})}):e.jsx(e.Fragment,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,accept:"application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/*",revalidateCallback:f})]})})]})})]})}),t?.notes?.length>0&&e.jsx(C,{size:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:t.notes}),e.jsx(I,{})]})}),e.jsx(C,{size:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(D,{control:e.jsx(N,{size:"small",checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(I,{}),e.jsxs("form",{action:q,children:[k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(m.default,{item:r,index:i,image:r?.product?.image}):e.jsx(u.default,{item:r,index:i,handleUpdateQuantity:H,handleAddReport:K,image:r?.product?.image,handleRemoveReportAtIndex:V,revalidateCallback:f,showing:J})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[g&&e.jsx(_,{onClick:g,variant:"outlined",children:"Cancel"}),e.jsx(z.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),c=require("./ItemDisplay.js"),d=require("./TextualIPOItemUpdater.js"),u=require("./IpoStatusIndicator.js"),m=require("@mui/material/Box"),h=require("@mui/material/Stack"),p=require("@mui/material/Paper"),x=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),g=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),v=require("@mui/material/Typography"),f=require("@mui/material/Button"),b=require("@mui/material/Grid"),_=require("@mui/material/Divider"),C=require("@mui/material/TextField"),q=require("@mui/material/List"),I=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),w=require("@mui/material/Checkbox"),S=require("@mui/material/FormControlLabel"),D=require("@mui/icons-material/Numbers"),N=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),A=require("@mui/icons-material/Business"),E=require("@mui/icons-material/Update"),M=require("../../SubmitButton.js"),F=require("../../common/media/minio/MinioDisplay.js");const z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function P({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(x,{open:r,onClose:n,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(g,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{children:"Are you sure you want to confirm this order?"}),e.jsxs(v,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(f,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(x,{open:n,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(g,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{children:"Are you sure you want to cancel this return?"}),e.jsxs(q,{children:[e.jsx(I,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(I,{children:"Please provide a reason for the cancellation"}),e.jsx(I,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(f,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:t,sx:a,revalidateCallback:x,handleClose:j,role:g}){const[y,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),z),{handleAddMessage:q}=i.useSnackbar(),[I,U]=r.useState(t.items?t.items:[]),[B,R]=r.useState(!1),[W,L]=r.useState(!1),[G,J]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(q({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(x&&x(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&q({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const Q=(e,r,i)=>{const n=[...I],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,U(n)},H=(e,r)=>{const i=[...I],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,U(i)},K=(e,r)=>{const i=[...I],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,U(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(q({message:"Ipo Updated",severity:"success"}),j&&j(),x&&x())},[y]),r.useEffect(()=>{y?.strapiErrors&&q({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&U(t.items?t.items:[])},[t]),e.jsx(m,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(b,{container:!0,spacing:2,children:[e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(v,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(o.default,{content:"",related:[{id:t.documentId,__type:"api::logistics.ipo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsx(v,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(N,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===g&&e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(k,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(P,{open:B,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:x})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(T,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:x})]})]})})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Documents"}),e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:4,children:["enduser"===g&&e.jsx(e.Fragment,{children:t.minio_order_confirmation?e.jsx(e.Fragment,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(F.MinioDisplay,{fileSize:t.minio_order_confirmation?.fileSize,mimeType:t.minio_order_confirmation?.mimeType,fileName:t.minio_order_confirmation?.fileName,bucketName:t.minio_order_confirmation?.bucketName,revalidateCallback:x})]})}):e.jsx(e.Fragment,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(v,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})}),t.minio_delivery_note?e.jsx(e.Fragment,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(F.MinioDisplay,{fileSize:t.minio_delivery_note?.fileSize,mimeType:t.minio_delivery_note?.mimeType,fileName:t.minio_delivery_note?.fileName,bucketName:t.minio_delivery_note?.bucketName,revalidateCallback:x})]})}):e.jsx(e.Fragment,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(v,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})]})})]})}),t?.notes?.length>0&&e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(v,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:p,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(v,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(S,{control:e.jsx(w,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(v,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(k,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:C,children:[I&&I.map((r,i)=>e.jsx(p,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(c.default,{item:r,index:i,image:r?.product?.image}):e.jsx(d.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:x,showing:G})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[j&&e.jsx(f,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(M.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(I))})]})]})})]})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var
|
|
6
|
+
"use strict";var e=require("../../../services/common/media/minio/minioUploadService.js"),o=require("../../../../lib/utils.js");exports.uploadMinioMediaAction=async function(r,l){try{const s=Object.fromEntries(l),i=s.bucketName,n=s.fileName,t=s.files,a=s.reference,c=s.refID,f=s.field;if(console.log("files:",t),console.log("files type:",typeof t),console.log("files instanceof File:",t instanceof File),console.log("fileName:",n),console.log("bucketName:",i),console.log("reference:",a),console.log("refID:",c),console.log("field:",f),!(t instanceof File))return{...r,strapiErrors:null,zodErrors:null,message:"No valid file provided"};const u=await t.arrayBuffer();console.log("arrayBuffer:",u);const d=Buffer.from(u).toString("base64");console.log("fileContent length:",d.length);({success:!0}).success,console.log("Uploading file:",n,"Size:",Math.round(d.length/1024/1024),"MB");const g=a&&c&&f?await e.minioUploadService(i,n,d,a,c,f):await e.minioUploadService(i,n,d);if(!g)return{...r,strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."};if(g.error)return{...r,strapiErrors:g.error,zodErrors:null,message:"Failed to Upload File."};const m=o.flattenAttributes(g);return{...r,data:m,zodErrors:null,strapiErrors:null,message:"Image Uploaded"}}catch(e){return console.error("Upload action error:",e),{...r,strapiErrors:null,zodErrors:null,message:"Failed to process file upload"}}};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("../../../../../node_modules/qs/lib/index.js"),t=require("../../loaders.js"),r=require("../../../../lib/utils.js"),s=require("next/cache");const
|
|
7
|
+
"use strict";var e=require("../../../../../node_modules/qs/lib/index.js"),t=require("../../loaders.js"),r=require("../../../../lib/utils.js"),s=require("next/cache");const a=r.getStrapiURL();exports.getSingleIro=async function(r,o={}){s.unstable_noStore();const i=new URL(`/api/iros/${r}`,a);return i.search=e.default.stringify({populate:{iro_items:{populate:{product:{populate:{image:!0}},reports:{populate:{author:!0}}}},customer:{populate:["business_credentials"]},notes:{populate:{author:!0}},customer_attachment:!0},filters:{...o}}),await t.fetchData(i.href)};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("../../../../node_modules/qs/lib/index.js"),
|
|
7
|
+
"use strict";var e=require("../../../../node_modules/qs/lib/index.js"),o=require("../loaders.js"),t=require("../../../lib/utils.js"),r=require("next/cache");const i=t.getStrapiURL();exports.getSingleIpo=async function(t){r.unstable_noStore();const a=new URL(`/api/ipos/${t}`,i);a.search=e.default.stringify({populate:{vendor_profile:{populate:{business_credentials:!0}},items:{populate:{product:{populate:{image:!0}},reports:{populate:{author:!0}}}},order_confirmation:!0,delivery_note:!0,notes:{populate:{author:{populate:!0}}},minio_order_confirmation:!0,minio_delivery_note:!0}});const n=await o.fetchData(a.href);return console.log("Raw IPO data:",n),n};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var
|
|
7
|
+
"use strict";var e=require("../../../get-token.js"),r=require("../../../../../lib/utils.js");exports.minioUploadService=async function(t,o,i,n,a,c){const s=await e.getAuthToken();if(!s)throw new Error("No auth token found");const u=r.getStrapiURL(),f=new URL("/api/minio-plugin/uploadbyreference",u);try{const e=await fetch(f,{headers:{Authorization:`Bearer ${s}`},method:"POST",body:JSON.stringify({data:{bucketName:t,fileName:o,fileContent:i,reference:n,refID:a,field:c}})});return await e.json()}catch(e){throw console.error("Error uploading image:",e),e}};
|