umwd-components 0.1.779 → 0.1.781

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cjs/src/components/common/media/minio/MinioDeleteFormButton.js +7 -0
  2. package/dist/cjs/src/components/common/media/minio/MinioDownloadButton.js +7 -0
  3. package/dist/cjs/src/components/common/media/minio/UploadMinioMediaForm.js +1 -1
  4. package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
  5. package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
  6. package/dist/cjs/src/data/actions/media/minio/deleteMinioMediaAction.js +6 -0
  7. package/dist/cjs/src/data/actions/media/minio/uploadMinioMediaAction.js +1 -1
  8. package/dist/cjs/src/data/loaders/common/media/minio/downloadMinioItemClient.js +7 -0
  9. package/dist/cjs/src/data/loaders/common/media/minio/getMinioSignedUrl.js +7 -0
  10. package/dist/cjs/src/data/services/common/media/minio/minio-service.js +1 -1
  11. package/dist/cjs/src/data/services/common/media/minio/minioDeleteService.js +7 -0
  12. package/dist/cjs/src/data/services/common/media/minio/minioUploadService.js +7 -0
  13. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  14. package/dist/esm/src/components/common/media/minio/MinioDeleteFormButton.js +41 -0
  15. package/dist/esm/src/components/common/media/minio/MinioDownloadButton.js +23 -0
  16. package/dist/esm/src/components/common/media/minio/UploadMinioMediaForm.js +22 -5
  17. package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +2 -1
  18. package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +6 -7
  19. package/dist/esm/src/data/actions/media/minio/deleteMinioMediaAction.js +59 -0
  20. package/dist/esm/src/data/actions/media/minio/uploadMinioMediaAction.js +8 -6
  21. package/dist/esm/src/data/loaders/common/media/minio/downloadMinioItemClient.js +39 -0
  22. package/dist/esm/src/data/loaders/common/media/minio/getMinioSignedUrl.js +52 -0
  23. package/dist/esm/src/data/services/common/media/minio/minio-service.js +10 -5
  24. package/dist/esm/src/data/services/common/media/minio/minioDeleteService.js +34 -0
  25. package/dist/esm/src/data/services/common/media/minio/minioUploadService.js +38 -0
  26. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  27. package/dist/esm/types/components/common/media/minio/MinioDeleteButton.d.ts +7 -0
  28. package/dist/esm/types/components/common/media/minio/MinioDeleteFormButton.d.ts +7 -0
  29. package/dist/esm/types/components/common/media/minio/MinioDownloadButton.d.ts +6 -0
  30. package/dist/esm/types/components/common/media/minio/UploadMinioMediaForm.d.ts +2 -1
  31. package/dist/esm/types/data/actions/media/minio/deleteMinioMediaAction.d.ts +1 -0
  32. package/dist/esm/types/data/loaders/common/media/minio/downloadMinioItemClient.d.ts +13 -0
  33. package/dist/esm/types/data/loaders/common/media/minio/getAllMinioMedia.d.ts +1 -0
  34. package/dist/esm/types/data/loaders/common/media/minio/getMinioSignedUrl.d.ts +6 -0
  35. package/dist/esm/types/data/services/common/media/minio/minioDeleteService.d.ts +1 -0
  36. package/dist/esm/types/data/services/common/media/minio/minioUploadService.d.ts +1 -0
  37. package/dist/esm/types/types/common/media/types.d.ts +3 -3
  38. package/dist/esm/types/types/data/actions/types.d.ts +7 -0
  39. package/dist/esm/types/types/logistics/Ipo.d.ts +10 -0
  40. package/package.json +1 -1
@@ -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"),s=require("@mui/material"),r=require("react"),t=require("@mui/icons-material/Delete"),i=require("../../../../data/actions/media/minio/deleteMinioMediaAction.js"),a=require("../../../../context/common/SnackbarContext.js");const n={zodErrors:null,strapiErrors:null,data:null,message:null};exports.MinioDeleteFormButton=({bucketName:o,fileName:l,revalidateCallback:c})=>{const u=i.deleteMinioMediaAction.bind(null,o,l),[m,d]=r.useActionState(u,n),{handleAddMessage:g}=a.useSnackbar();return r.useEffect(()=>{m.message&&g({message:m.message,severity:m.severity||"info"})},[m.message]),r.useEffect(()=>{m.message&&"success"===m.message.type&&c?.()},[m.message]),e.jsx("form",{action:d,children:e.jsx(s.IconButton,{type:"submit",color:"error",size:"small",children:e.jsx(t,{})})})};
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+ "use strict";var i=require("react/jsx-runtime"),e=require("@mui/material"),n=require("../../../../data/loaders/common/media/minio/getMinioSignedUrl.js"),o=require("../../../../data/loaders/common/media/minio/downloadMinioItemClient.js");exports.MinioDownloadButton=({bucketName:a,fileName:t})=>i.jsx(e.Button,{variant:"text",onClick:async()=>{const{signedUrl:i}=await n.getMinioSignedUrl(a,t);i&&o.downloadMinioItemClient(i,t)},children:i.jsx(e.Typography,{variant:"body1",children:t})});
@@ -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/minio/uploadMinioMediaAction.js"),t=require("../../../StrapiErrors.js"),n=require("../../../ZodErrors.js"),s=require("../../../SubmitButton.js"),a=require("@mui/material/Stack"),l=require("@mui/material/Typography"),u=require("@mui/material/Box"),o=require("@mui/material/Grid"),c=require("@mui/material/Alert");const d={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadMinioMediaForm=function({bucketName:m="umwd",fileName:p=Date.now().toString(),multiple:x=!1,accept:j="image/*",revalidateCallback:h}){const[g,y]=r.useState(null),[f,b]=r.useState(null),[q,k]=r.useActionState(i.uploadMinioMediaAction,d),w=r.useRef(null);return r.useEffect(()=>{q.data&&h?.()},[q.data]),e.jsx("form",{action:k,children:e.jsxs(a,{spacing:1,sx:{flex:1},children:[m&&e.jsx("input",{type:"text",name:"bucketName",value:m,style:{display:"none"},readOnly:!0}),p&&e.jsx("input",{type:"text",name:"fileName",value:p,style:{display:"none"},readOnly:!0}),null!==g?e.jsx(u,{onClick:()=>w.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"},children:void 0===j||"image/*"===j?e.jsx(o,{container:!0,children:g.map((r,i)=>e.jsx(o,{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(o,{container:!0,children:g.map((r,i)=>e.jsx(o,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx(l,{children:r.name})},i))})}):e.jsx(u,{onClick:()=>w.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(l,{children:["No file",""+(x?"s":"")," selected, click here to start uploading new files"]})}),e.jsxs(a,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between",children:[e.jsx(t.StrapiErrors,{error:q.strapiErrors}),e.jsx(n.ZodErrors,{error:q.zodErrors?.image}),q?.message&&e.jsx(c,{severity:"error",children:q?.message}),e.jsxs(u,{children:[e.jsx("label",{htmlFor:"pictureInput",children:e.jsx("input",{id:"pictureInput",accept:j,multiple:x,type:"file",name:"files",ref:w,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),y(i)},style:{display:"none"}})}),null!==f&&e.jsx(s.SubmitButton,{text:"upload",loadingText:"loading"})]})]})]})})};
7
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../../data/actions/media/minio/uploadMinioMediaAction.js"),t=require("../../../StrapiErrors.js"),n=require("../../../ZodErrors.js"),s=require("../../../SubmitButton.js"),l=require("@mui/material/Stack"),a=require("@mui/material/Typography"),u=require("@mui/material/Box"),o=require("@mui/material/Grid"),c=require("@mui/material/Alert");const d={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadMinioMediaForm=function({bucketName:m="umwd",fileName:p=Date.now().toString(),multiple:x=!1,accept:j="image/*",reference:y,refID:h,field:g,revalidateCallback:f}){const[b,q]=r.useState(null),[k,S]=r.useState(null),[v,w]=r.useState(null),[E,O]=r.useActionState(i.uploadMinioMediaAction,d),M=r.useRef(null);return r.useEffect(()=>{E.message&&"success"===E.message.type&&f?.()},[E.message]),e.jsx("form",{action:O,children:e.jsxs(l,{spacing:1,sx:{flex:1},children:[y&&h&&g&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",name:"ref",value:y,style:{display:"none"},readOnly:!0}),e.jsx("input",{type:"text",name:"refId",value:h,style:{display:"none"},readOnly:!0}),e.jsx("input",{type:"text",name:"field",value:g,style:{display:"none"},readOnly:!0})]}),m&&e.jsx("input",{type:"text",name:"bucketName",value:m,style:{display:"none"},readOnly:!0}),v&&e.jsx("input",{type:"text",name:"fileName",value:v,style:{display:"none"},readOnly:!0}),null!==b?e.jsx(u,{onClick:()=>M.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"},children:void 0===j||"image/*"===j?e.jsx(o,{container:!0,children:b.map((r,i)=>e.jsx(o,{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(o,{container:!0,children:b.map((r,i)=>e.jsx(o,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx(a,{children:r.name})},i))})}):e.jsx(u,{onClick:()=>M.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(a,{children:["No file",""+(x?"s":"")," selected, click here to start uploading new files"]})}),e.jsxs(l,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between",children:[e.jsx(t.StrapiErrors,{error:E.strapiErrors}),e.jsx(n.ZodErrors,{error:E.zodErrors?.image}),E?.message&&e.jsx(c,{severity:"error",children:E?.message}),e.jsxs(u,{children:[e.jsx("label",{htmlFor:"pictureInput",children:e.jsx("input",{id:"pictureInput",accept:j,multiple:x,type:"file",name:"files",ref:M,onChange:e=>{const r=e.target.files;if(null===r)return;r.length>0&&w(r[0].name);const i=Object.keys(r).map((e,i)=>({url:URL.createObjectURL(r[i]),name:r[i].name}));S(r),q(i)},style:{display:"none"}})}),null!==k&&e.jsx(s.SubmitButton,{text:"upload",loadingText:"loading"})]})]})]})})};
@@ -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("../../../data/actions/e-commerce/opo/updateOpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),n=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),_=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},F=["picked","packed","shipped","reports"];function N({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",n]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{_.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function E({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[c,l]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:t,children:[e.jsx(p,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this order?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!c,helperText:c})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(x,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)l("Please provide a reason for the cancellation (min 5 characters)");else{l("");try{await C.cancellationService("opos",n,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:_}){const C=i.updateOpoAction.bind(null,d.documentId),[P,T]=r.useActionState(C,B),{handleAddMessage:z}=O.useSnackbar(),[M,U]=r.useState(d.opo_items?d.opo_items:[]),[L,R]=r.useState(!1),[W,G]=r.useState(!1),[H,J]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{P?.message&&(z({message:P.message,severity:P.severity||"info"}),"success"===P.severity&&(m?.(),p?.()))},[P?.message]),r.useEffect(()=>{P?.strapiErrors&&z({message:P.strapiErrors.message||"Error updating OPO",severity:"error"})},[P?.strapiErrors]),r.useEffect(()=>{d.opo_items&&U(d.opo_items?d.opo_items:[])},[d]);const Q=(e,r,i)=>{const t=[...M],n=t.findIndex(e=>e.documentId===r);t[n][i]=e,U(t)},Y=(e,r)=>{const i=[...M],t=i.findIndex(e=>e.documentId===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,U(i)},$=(e,r)=>{const i=[...M],t=i.findIndex(r=>r.documentId===e),n=i[t]?.reports||[],a=n.filter(e=>"documentId"in e),s=n.filter(e=>!("documentId"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,U(i)};return e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:d.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_number})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===_&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(l,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(N,{open:L,handleClose:()=>R(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(E,{open:W,handleClose:()=>G(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{n.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(t.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(y,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,children:[e.jsx(h,{variant:"body1",children:"Show:"}),F.map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===d.internal_status&&e.jsx(l,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:T,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(M))}),M&&M.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:Y,image:r?.product?.image,handleRemoveReportAtIndex:$,revalidateCallback:m,showing:H})},i))," ",e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),_=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js"),F=require("../../common/media/minio/UploadMinioMediaForm.js");const M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},B=["picked","packed","shipped","reports"];function N({open:r,handleClose:i,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",t]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{C.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function z({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[c,l]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:n,children:[e.jsx(p,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this order?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!c,helperText:c})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"outlined",onClick:n,children:"Close"}),e.jsx(x,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)l("Please provide a reason for the cancellation (min 5 characters)");else{l("");try{await _.cancellationService("opos",t,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),n()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:C}){const _=i.updateOpoAction.bind(null,d.documentId),[E,P]=r.useActionState(_,M),{handleAddMessage:T}=O.useSnackbar(),[U,L]=r.useState(d.opo_items?d.opo_items:[]),[R,W]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{E?.message&&(T({message:E.message,severity:E.severity||"info"}),"success"===E.severity&&(m?.(),p?.()))},[E?.message]),r.useEffect(()=>{E?.strapiErrors&&T({message:E.strapiErrors.message||"Error updating OPO",severity:"error"})},[E?.strapiErrors]),r.useEffect(()=>{d.opo_items&&L(d.opo_items?d.opo_items:[])},[d]);const Y=(e,r,i)=>{const n=[...U],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,L(n)},$=(e,r)=>{const i=[...U],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,L(i)},K=(e,r)=>{const i=[...U],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"documentId"in e),s=t.filter(e=>!("documentId"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,L(i)};return e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:d.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_number})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===C&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>W(!0),children:"Confirm order"}),e.jsx(l,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(N,{open:R,handleClose:()=>W(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(z,{open:G,handleClose:()=>H(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{t.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Minio Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(F.UploadMinioMediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"minio",multiple:!1,revalidateCallback:m})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(y,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,children:[e.jsx(h,{variant:"body1",children:"Show:"}),B.map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===d.internal_status&&e.jsx(l,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:P,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(U))}),U&&U.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
@@ -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("../../../data/loaders/common/media/downloadBase64File.js"),o=require("../../common/media/UploadBase64MediaForm.js"),c=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),d=require("./ItemDisplay.js"),u=require("./TextualIPOItemUpdater.js"),m=require("./IpoStatusIndicator.js"),p=require("@mui/material/Box"),h=require("@mui/material/Stack"),x=require("@mui/material/Paper"),j=require("@mui/material/Dialog"),g=require("@mui/material/DialogActions"),v=require("@mui/material/DialogContent"),f=require("@mui/material/DialogTitle"),y=require("@mui/material/Typography"),b=require("@mui/material/Button"),C=require("@mui/material/Grid"),I=require("@mui/material/Divider"),q=require("@mui/material/TextField"),_=require("@mui/material/List"),w=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),S=require("@mui/material/Checkbox"),D=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),F=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),E=require("@mui/icons-material/Business"),P=require("@mui/icons-material/Update"),B=require("../../SubmitButton.js");const U={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function N({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:c}=i.useSnackbar();return e.jsxs(j,{open:r,onClose:n,children:[e.jsx(f,{children:"Confirm Order"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(y,{children:"Are you sure you want to confirm this order?"}),e.jsxs(y,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(g,{children:[e.jsx(b,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(b,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),c({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){c({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function z({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[c,l]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(j,{open:n,onClose:t,children:[e.jsx(f,{children:"Cancel Return"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(y,{children:"Are you sure you want to cancel this return?"}),e.jsxs(_,{children:[e.jsx(w,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(w,{children:"Please provide a reason for the cancellation"}),e.jsx(w,{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:c,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(g,{children:[e.jsx(b,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(b,{variant:"contained",color:"error",onClick:async()=>{if(c.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,c),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:j,handleClose:g,role:v}){const[f,q]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),U),{handleAddMessage:_}=i.useSnackbar(),[w,M]=r.useState(t.items?t.items:[]),[T,R]=r.useState(!1),[W,L]=r.useState(!1),[H,$]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{f?.message&&(_({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(j&&j(),g&&g()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&_({message:f.strapiErrors.message||"Error updating IPO",severity:"error"})},[f?.strapiErrors]);const G=(e,r,i)=>{const n=[...w],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,M(n)},J=(e,r)=>{const i=[...w],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,M(i)},Q=(e,r)=>{const i=[...w],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,M(i)};return r.useEffect(()=>{"Ipo Updated"===f?.message&&(_({message:"Ipo Updated",severity:"success"}),g&&g(),j&&j())},[f]),r.useEffect(()=>{f?.strapiErrors&&_({message:f.strapiErrors.message||"Error updating IPO",severity:"error"})},[f?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&M(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(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(y,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(y,{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:j})]}),e.jsx(I,{})]})}),e.jsx(C,{size:12,children:e.jsx(y,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(C,{size:6,children:e.jsx(x,{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(O,{color:"primary"}),e.jsx(y,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(y,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(F,{color:"primary"}),e.jsx(y,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(y,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(y,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(y,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(y,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(y,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(y,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(m.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===v&&e.jsx(C,{size:6,children:e.jsx(x,{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(b,{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(N,{open:T,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:j})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(z,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:j})]})]})})}),e.jsx(C,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(y,{variant:"h5",children:"Documents"}),e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:1,children:["enduser"===v&&e.jsx(e.Fragment,{children:t.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"h6",children:"Order Confirmation"}),e.jsx(y,{children:t.order_confirmation?.name}),e.jsx(b,{variant:"contained",onClick:()=>{s.default(`api/ipos/${t.documentId}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"h5",children:"Order Confirmation"}),e.jsx(y,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(y,{variant:"body1",children:"FileUpload"}),e.jsx(I,{}),e.jsx(o.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:j})]})}),t.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"h6",children:"Delivery Note"}),e.jsx(y,{children:t.delivery_note?.name}),e.jsx(b,{variant:"contained",onClick:()=>{s.default(`api/ipos/${t.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"h5",children:"Delivery Note"}),e.jsx(y,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(I,{}),e.jsx(o.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:j})]})]})})]})}),t?.notes?.length>0&&e.jsx(C,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(y,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(I,{})]})}),e.jsx(C,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(y,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:x,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(y,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(D,{control:e.jsx(S,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?$([...H,r]):$(H.filter(e=>e!==r))}}),label:e.jsx(y,{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(I,{}),e.jsxs("form",{action:q,children:[w&&w.map((r,i)=>e.jsx(x,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(d.default,{item:r,index:i,image:r?.product?.image}):e.jsx(u.default,{item:r,index:i,handleUpdateQuantity:G,handleAddReport:J,image:r?.product?.image,handleRemoveReportAtIndex:Q,revalidateCallback:j,showing:H})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[g&&e.jsx(b,{onClick:g,variant:"outlined",children:"Cancel"}),e.jsx(B.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}))||[]})))(w))})]})]})})]})})};
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))})]})]})})]})})};
@@ -0,0 +1,6 @@
1
+ /*
2
+ * UMWD-Components
3
+ * @copyright Jelle Paulus
4
+ * @license MIT
5
+ */
6
+ "use strict";var e=require("../../../services/common/media/minio/minioDeleteService.js"),r=require("../../../../lib/utils.js");exports.deleteMinioMediaAction=async function(s,t,i){if(console.log("bucketName:",s," fileName:",t,"prevState:",i),!s||!t)return{...i,strapiErrors:null,data:null,message:"Invalid Image"};const l=await e.minioDeleteService(s,t);if(!l)return{...i,strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."};if(l.error)return{...i,strapiErrors:l.error,zodErrors:null,message:"Failed to Delete File."};const a=r.flattenAttributes(l);return{...i,data:a,zodErrors:null,strapiErrors:null,message:"Image Deleted Successfully"}};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";var e=require("../../../services/common/media/minio/minio-service.js"),r=require("../../../../lib/utils.js");exports.uploadMinioMediaAction=async function(o,s){const i=Object.fromEntries(s);console.log(i.bucketName),console.log(i.fileName),console.log(i.files);const l=i.bucketName,n=i.fileName,t=i.files,a=t instanceof File?t:Buffer.from(t,"base64"),c=await e.minioUploadService(l,n,a);if(!c)return{...o,strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."};if(c.error)return{...o,strapiErrors:c.error,zodErrors:null,message:"Failed to Upload File."};const u=r.flattenAttributes(c);return{...o,data:u,zodErrors:null,strapiErrors:null,message:"Image Uploaded"}};
6
+ "use strict";var r=require("../../../services/common/media/minio/minioUploadService.js"),e=require("../../../../lib/utils.js");exports.uploadMinioMediaAction=async function(o,i){const s=Object.fromEntries(i),t=s.bucketName,n=s.fileName,l=s.files;console.log("files:",l);const a=await l.arrayBuffer(),u=Buffer.from(a).toString("base64");console.log("fileContent length:",u.length),console.log(t,n,u);const c=await r.minioUploadService(t,n,u);if(!c)return{...o,strapiErrors:null,zodErrors:null,message:"Ops! Something went wrong. Please try again."};if(c.error)return{...o,strapiErrors:c.error,zodErrors:null,message:"Failed to Upload File."};const m=e.flattenAttributes(c);return{...o,data:m,zodErrors:null,strapiErrors:null,message:"Image Uploaded"}};
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+ "use strict";exports.downloadMinioItemClient=async function(e,t){try{const o=await fetch(e);if(!o.ok)throw new Error(`Failed to download file: ${o.statusText}`);const r=await o.blob(),c=URL.createObjectURL(r),n=document.createElement("a");return n.href=c,n.setAttribute("download",t),document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(c),{success:!0,fileName:t}}catch(e){throw console.error("Error downloading file:",e),e}};
@@ -0,0 +1,7 @@
1
+ "use server";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+ "use strict";var e=require("../../../../../lib/utils.js"),i=require("../../../../services/get-token.js");const t=e.getStrapiURL();exports.getMinioSignedUrl=async function(e,o){if(console.log("minio bucket:",e),console.log("minio fileName:",o),!e||!o)throw new Error("Bucket name and file name are required");const r=await i.getAuthToken(),n={method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({bucketName:e,fileName:o})},a=new URL("/api/minio-plugin/minio/signed-url",t);try{const i=await fetch(a,r?n:{});if(!i.ok)throw new Error(`Failed to fetch signed URL: ${i.statusText}`);return{success:!0,signedUrl:(await i.json()).url,fileName:o,bucketName:e}}catch(e){throw console.error("Error downloading file:",e),e}};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";var e=require("../../../get-token.js"),t=require("../../../../../lib/utils.js");exports.minioUploadService=async function(o,i,r){const n=await e.getAuthToken();if(!n)throw new Error("No auth token found");const a=t.getStrapiURL(),s=new URL("/api/minio-plugin/minio/upload",a);try{const e=await fetch(s,{headers:{Authorization:`Bearer ${n}`},method:"POST",body:JSON.stringify({bucketName:o,fileName:i,fileContent:r})});return await e.json()}catch(e){throw console.error("Error uploading image:",e),e}};
6
+ "use strict";var e=require("../../../get-token.js"),t=require("../../../../../lib/utils.js");exports.minioUploadService=async function(i,o,n){const r=await e.getAuthToken();if(!r)throw new Error("No auth token found");const a=t.getStrapiURL(),s=new URL("/api/minio-plugin/minio/upload",a);console.log("Sending to strapi minio-plugin:",{bucketName:i,fileName:o,fileContent:n});try{const e=await fetch(s,{headers:{Authorization:`Bearer ${r}`},method:"POST",body:JSON.stringify({data:{bucketName:i,fileName:o,fileContent:n}})});return await e.json()}catch(e){throw console.error("Error uploading image:",e),e}};
@@ -0,0 +1,7 @@
1
+ "use server";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+ "use strict";var e=require("../../../get-token.js"),t=require("../../../../../lib/utils.js");exports.minioDeleteService=async function(o,r){console.log(o,r);const i=await e.getAuthToken();if(!i)throw new Error("No auth token found");const n=t.getStrapiURL(),a=new URL(`/api/minio-plugin/minio/delete/${o}/${r}`,n);console.log(a.toString());try{const e=await fetch(a,{headers:{Authorization:`Bearer ${i}`},method:"DELETE"});return await e.json()}catch(e){throw console.error("Error deleting file:",e),new Error("Failed to delete file")}};
@@ -0,0 +1,7 @@
1
+ "use server";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+ "use strict";var t=require("../../../get-token.js"),e=require("../../../../../lib/utils.js");exports.minioUploadService=async function(o,i,r){const n=await t.getAuthToken();if(!n)throw new Error("No auth token found");const a=e.getStrapiURL(),s=new URL("/api/minio-plugin/minio/upload",a);try{const t=await fetch(s,{headers:{Authorization:`Bearer ${n}`},method:"POST",body:JSON.stringify({data:{bucketName:o,fileName:i,fileContent:r}})});return await t.json()}catch(t){throw console.error("Error uploading image:",t),t}};