umwd-components 0.1.784 → 0.1.786
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/minio/MinioDisplay.js +1 -1
- package/dist/cjs/src/components/common/media/minio/MinioDownloadButton.js +1 -1
- package/dist/cjs/src/components/common/media/minio/MinioItemList.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/e-commerce/iro/TextualManageIROForm.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/services/common/media/minio/minioUploadService.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/common/media/minio/MinioDisplay.js +7 -2
- package/dist/esm/src/components/common/media/minio/MinioDownloadButton.js +3 -2
- package/dist/esm/src/components/common/media/minio/MinioItemList.js +27 -0
- package/dist/esm/src/components/common/media/minio/UploadMinioMediaForm.js +2 -3
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +0 -1
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +2 -1
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/esm/src/data/actions/media/minio/uploadMinioMediaAction.js +33 -48
- package/dist/esm/src/data/services/common/media/minio/minioUploadService.js +21 -13
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/components/common/media/minio/MinioDisplay.d.ts +7 -1
- package/dist/esm/types/components/common/media/minio/MinioItemList.d.ts +24 -0
- package/dist/esm/types/data/services/common/media/minio/minioUploadService.d.ts +5 -1
- package/dist/esm/types/types/e-commerce/iro/types.d.ts +5 -0
- package/package.json +1 -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"),i=require("@mui/material"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),i=require("@mui/material"),t=require("./MinioDownloadButton.js"),r=require("./MinioDeleteFormButton.js");exports.MinioDisplay=({fileSize:n,mimeType:a,fileName:o,bucketName:c,direction:l="column",revalidateCallback:s})=>e.jsxs(i.Stack,{direction:l,spacing:1,marginTop:1,alignItems:"column"===l?"flex-start":"center",children:[e.jsxs(i.Typography,{children:["File: ",o]}),e.jsxs(i.Typography,{variant:"body2",color:"text.secondary",children:["Size: ",n," bytes"]}),e.jsxs(i.Typography,{variant:"body2",color:"text.secondary",children:["Type: ",a]}),e.jsxs(i.Stack,{direction:"row",spacing:2,alignItems:"center",justifyContent:"center",width:"min-content",children:[e.jsx(t.MinioDownloadButton,{bucketName:c||"umwd",fileName:o||""}),e.jsx(r.MinioDeleteFormButton,{bucketName:c||"umwd",fileName:o||"",revalidateCallback:s})]})]});
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var i=require("react/jsx-runtime"),e=require("@mui/material"),
|
|
7
|
+
"use strict";var i=require("react/jsx-runtime"),e=require("@mui/material"),o=require("../../../../data/loaders/common/media/minio/getMinioSignedUrl.js"),n=require("../../../../data/loaders/common/media/minio/downloadMinioItemClient.js"),a=require("@mui/icons-material/Download");exports.MinioDownloadButton=({bucketName:r,fileName:t})=>i.jsx(e.IconButton,{onClick:async()=>{const{signedUrl:i}=await o.getMinioSignedUrl(r,t);i&&n.downloadMinioItemClient(i,t)},children:i.jsx(a,{})});
|
|
@@ -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"),t=require("./MinioDisplay.js");exports.MinioItemList=({items:a,emptyMessage:m="No attachments found.",bucketName:r="umwd",direction:s="row",revalidateCallback:l})=>a&&0!==a.length?e.jsx(i.List,{children:a.map((a,m)=>e.jsx(i.ListItem,{children:e.jsx(t.MinioDisplay,{fileName:a.fileName,fileSize:a.fileSize,bucketName:a.bucketName||r,mimeType:a.mimeType||"application/octet-stream",direction:s,revalidateCallback:l})},a.documentId||m))}):e.jsx(i.List,{children:e.jsx(i.ListItem,{children:e.jsx(i.ListItemText,{primary:m})})});
|
|
@@ -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("
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../../data/actions/media/minio/uploadMinioMediaAction.js"),n=require("../../../../context/common/SnackbarContext.js"),s=require("../../../StrapiErrors.js"),t=require("../../../ZodErrors.js"),a=require("../../../SubmitButton.js"),l=require("@mui/material/Stack"),o=require("@mui/material/Typography"),c=require("@mui/material/Box"),p=require("@mui/material/Grid"),d=require("@mui/material/Button");const m={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.UploadMinioMediaForm=function({bucketName:u=process.env.MINIO_BUCKET_NAME||"umwd",multiple:x=!1,accept:h=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:y,sx:v,handleClose:E}){const[b,w]=r.useState(null),[k,C]=r.useState(null),[q,S]=r.useActionState(i.uploadMinioMediaAction,m),A=r.useRef(null),{handleAddMessage:M}=n.useSnackbar();return r.useEffect(()=>{q?.message&&(M({message:q.message,severity:q.severity||"error"}),"success"===q.severity&&(y&&y(),E&&E(),C(null),w(null),A.current&&(A.current.value="")))},[q?.message,M,y,E]),r.useEffect(()=>{q?.strapiErrors&&M({message:q.strapiErrors.message||"Error uploading files",severity:"error"})},[q?.strapiErrors,M]),e.jsx(c,{sx:[...Array.isArray(v)?v:[v]],children:e.jsx("form",{action:S,children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:{xs:12},children:e.jsxs(l,{spacing:2,children:[e.jsx(o,{variant:"h3",component:"h1",children:"Upload Files"}),e.jsxs(o,{variant:"body2",children:["Select ",x?"one or more files":"a file"," to upload"]})]})}),e.jsxs(p,{size:{xs:12},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})]}),u&&e.jsx("input",{type:"text",name:"bucketName",value:u,style:{display:"none"},readOnly:!0}),null!==b?e.jsx(c,{onClick:()=>A.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:"image/*"===h||Array.isArray(h)&&h.some(e=>e.startsWith("image/"))&&b?.every(e=>(e=>[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"].some(r=>e.name.toLowerCase().endsWith(r)))(e))||!1?e.jsx(p,{container:!0,spacing:1,children:b.map((r,i)=>e.jsxs(p,{size:{xs:12,sm:6,md:4,lg:2},children:[e.jsx("img",{src:r.url,alt:r.name,style:{width:"100px",height:"100px",objectFit:"cover"}}),e.jsx(o,{variant:"caption",sx:{display:"block",mt:1},children:r.name})]},i))}):e.jsx(p,{container:!0,spacing:1,children:b.map((r,i)=>e.jsx(p,{size:{xs:12,sm:6,md:4,lg:2},children:e.jsx(o,{children:r.name})},i))})}):e.jsx(c,{onClick:()=>A.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(o,{children:["No file",""+(x?"s":"")," selected, click here to start uploading new files"]})}),e.jsx("input",{id:"minioInput",accept:"string"==typeof h?h:h.join(","),multiple:x,type:"file",name:"files",ref:A,onChange:e=>{const r=e.target.files;if(null===r||0===r.length)return;const i=Array.from(r).map(e=>({url:URL.createObjectURL(e),name:e.name}));C(r),w(i)},style:{display:"none"}})]}),e.jsxs(p,{size:{xs:12},children:[e.jsx(s.StrapiErrors,{error:q.strapiErrors}),e.jsx(t.ZodErrors,{error:q.zodErrors?.files})]}),e.jsx(p,{size:{xs:12},children:e.jsxs(l,{direction:"row",justifyContent:"space-between",children:[E&&e.jsx(d,{onClick:E,variant:"outlined",children:"Cancel"}),null!==k&&e.jsx(a.SubmitButton,{text:`Upload ${k.length} file${k.length>1?"s":""}`,loadingText:"Uploading...",variant:"contained"})]})})]})})})};
|
|
@@ -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"),n=require("../../SubmitButton.js"),a=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"),v=require("@mui/material/DialogTitle"),b=require("../../common/NumberInput.js");require("
|
|
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"),n=require("../../SubmitButton.js"),a=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"),v=require("@mui/material/DialogTitle"),b=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:n,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(a,{variant:"h6",children:"Items"}),e.jsx(a,{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((t,s)=>e.jsxs(r.Fragment,{children:[e.jsxs(h,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(d,{checked:n.includes(s),onChange:e=>{e.target.checked?o([...n,s]):o(n.filter(e=>e!==s))}}),e.jsxs(a,{variant:"body1",children:["Line Item Number: ",t.line_item_number]}),e.jsxs(a,{variant:"body1",children:["Part Number: ",t.product?.product_number]}),e.jsxs(a,{variant:"body1",children:["Quantity Ordered: ",t.ordered_quantity]})]}),n.includes(s)&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(b.default,{label:"Quantity to return",minnewvalue:0,maxnewvalue:t.ordered_quantity,setValueCallback:e=>{m(s,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(x.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(a,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(l,{value:i[s]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;c("other"===r),m(s,"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[s].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;m(s,"other_reason",r)}})]}),e.jsx(x.Divider,{})]},s))})]})})},_=({open:t,onClose:i,items:o,formState:u,submitCallback:l})=>{const[h,b]=r.useState(!0),[f,q]=r.useTransition();return e.jsxs(g,{open:t,onClose:i,children:[e.jsx(v,{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=>b(!e.target.checked)}),e.jsx(a,{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:[e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:h,onClick:()=>{l&&q(()=>{l()})},loading:f}),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:n,sx:l,revalidateCallback:d,handleClose:x}){const[g,j]=r.useActionState(i.requestRmaAction,f),{handleAddMessage:p}=t.useSnackbar(),[y,v]=r.useState(!1),[b,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(a,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:n.documentId}),e.jsx(o,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(a,{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:n.opo_items?e.jsx(h,{spacing:1,children:n.opo_items&&e.jsx(q,{items:n.opo_items,itemsToReturn:b,setItemsToReturn:S,selectedItems:C,setSelectedItems:I},n.documentId)}):e.jsx(a,{variant:"body1",children:"No items"})}),e.jsx(_,{formState:g,open:y,items:b.filter(e=>e.returned_quantity>0),onClose:()=>v(!y),submitCallback:()=>{console.log("submit callback");const e=document.querySelector("form");j(e?new FormData(e):new FormData),v(!y)}}),e.jsxs(o,{size:12,children:[e.jsx(c,{onClick:()=>{console.log(g),v(!y)},disabled:0===C.length||0===C.reduce((e,r)=>e+b[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("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),_=require("@mui/material/Divider"),y=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),F=require("../../../../node_modules/qs/lib/index.js"),D=require("../../../context/common/SnackbarContext.js");const R={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function P({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{o(!0);const e=F.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:e=>{y.confirmationService("iros",[a.documentId],n),i()},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function W({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=D.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await y.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function z({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=D.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested 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:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:y}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),R),[F,E]=r.useState(c.iro_items?c.iro_items:[]),[O,M]=r.useState(!1),[B,L]=r.useState(!1),[N,U]=r.useState(!1),[V,Q]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[Y,G]=r.useState(["received","registered","released","reports"]),J=(e,r,t)=>{const i=[...F],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,E(i)},$=(e,r)=>{const t=[...F],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,E(t)},H=(e,r)=>{const t=[...F],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"id"in e),a=n.filter(e=>!("id"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,E(t)},{handleAddMessage:K}=D.useSnackbar();return r.useEffect(()=>{f?.message&&(K({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&K({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{console.log("data",c),c.iro_items&&E(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.documentId,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===y&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>M(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(W,{open:O,handleClose:()=>M(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>U(!0)}),e.jsx(P,{open:N,handleClose:()=>U(!1),overwrites:V,setOverwrites:Q,iro:c}),e.jsx(z,{open:B,handleClose:()=>L(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:Y.includes(r),onChange:e=>{e.target.checked?G([...Y,r]):G(Y.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_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}))||[]})))(F))}),F&&F.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:J,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:H,revalidateCallback:u,showing:Y})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),_=require("@mui/material/Divider"),y=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),F=require("../../../../node_modules/qs/lib/index.js"),D=require("../../../context/common/SnackbarContext.js"),R=require("../../common/media/minio/MinioItemList.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{o(!0);const e=F.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:e=>{y.confirmationService("iros",[a.documentId],n),i()},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function z({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=D.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await y.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function E({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=D.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested 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:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:y}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),P),[F,M]=r.useState(c.iro_items?c.iro_items:[]),[O,L]=r.useState(!1),[N,B]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...F],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...F],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,M(t)},K=(e,r)=>{const t=[...F],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"id"in e),a=n.filter(e=>!("id"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,M(t)},{handleAddMessage:X}=D.useSnackbar();return r.useEffect(()=>{f?.message&&(X({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&X({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{console.log("data",c),c.iro_items&&M(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.documentId,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===y&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>B(!0),children:"Cancel order"}),e.jsx(z,{open:O,handleClose:()=>L(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:c}),e.jsx(E,{open:N,handleClose:()=>B(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Customer Attachements"}),e.jsx(v,{sx:{p:1},children:e.jsx(R.MinioItemList,{items:c.customer_attachment,emptyMessage:"No customer attachments found.",direction:"row",revalidateCallback:u})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_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}))||[]})))(F))}),F&&F.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:u,showing:G})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Save changes",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("../../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))})]})]})})]})})};
|
|
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"),y=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),g=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"),z=require("@mui/icons-material/Business"),A=require("@mui/icons-material/Update"),E=require("../../SubmitButton.js"),M=require("../../common/media/minio/MinioDisplay.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function T({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(v,{children:"Confirm Order"}),e.jsx(y,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to confirm this order?"}),e.jsxs(g,{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 U({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(v,{children:"Cancel Return"}),e.jsx(y,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{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:y}){const[v,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:q}=i.useSnackbar(),[I,F]=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(()=>{v?.message&&(q({message:v.message,severity:v.severity||"error"}),"success"===v.severity&&(x&&x(),j&&j()))},[v?.message]),r.useEffect(()=>{v?.strapiErrors&&q({message:v.strapiErrors.message||"Error updating IPO",severity:"error"})},[v?.strapiErrors]);const Q=(e,r,i)=>{const n=[...I],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(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,F(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,F(i)};return r.useEffect(()=>{"Ipo Updated"===v?.message&&(q({message:"Ipo Updated",severity:"success"}),j&&j(),x&&x())},[v]),r.useEffect(()=>{v?.strapiErrors&&q({message:v.strapiErrors.message||"Error updating IPO",severity:"error"})},[v?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&F(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(g,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(g,{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(g,{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(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(g,{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(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(g,{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(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(z,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===y&&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(T,{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(U,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:x})]})]})})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",children:"Documents"})}),"enduser"===y&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(M.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(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(g,{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})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(M.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(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(g,{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(g,{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(g,{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(g,{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(g,{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(E.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 r=require("../../../services/common/media/minio/minioUploadService.js"),e=require("../../../../lib/utils.js");exports.uploadMinioMediaAction=async function(s,o){try{const l=Object.fromEntries(o),i=l.bucketName,t=o.getAll("files"),n=l.reference,a=l.refID,u=l.field,d=t.filter(r=>r instanceof File&&r.size>0&&void 0!==r.name);if(0===d.length)return{...s,strapiErrors:null,zodErrors:null,message:"No valid files provided",severity:"error"};console.log(`Uploading ${d.length} file(s):`);const f=[];for(const r of d){const e=await r.arrayBuffer(),s=Buffer.from(e).toString("base64");f.push({fileName:r.name,fileContent:s}),console.log("Prepared file:",r.name,"Size:",Math.round(s.length/1024/1024),"MB")}const c=await r.minioUploadService(i,f,n,a,u);if(!c)return{...s,strapiErrors:null,zodErrors:null,message:"Failed to upload files",severity:"error"};if(c.error)return{...s,strapiErrors:c.error,zodErrors:null,message:"Failed to upload files",severity:"error"};if(c.errors&&c.errors.length>0){const r=c.uploadResults?.length||0,e=c.errors.length;return{...s,data:c.uploadResults,zodErrors:null,strapiErrors:null,message:`Uploaded ${r} file(s) successfully. ${e} file(s) failed.`,severity:r>0?"warning":"error"}}const p=e.flattenAttributes(c);return{...s,data:p,zodErrors:null,strapiErrors:null,message:`Successfully uploaded ${d.length} file(s)`,severity:"success"}}catch(r){return console.error("Upload action error:",r),{...s,strapiErrors:null,zodErrors:null,message:"Failed to process file upload",severity:"error"}}};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("../../../get-token.js"),
|
|
7
|
+
"use strict";var e=require("../../../get-token.js"),o=require("../../../../../lib/utils.js");exports.minioUploadService=async function(t,r,n,i,s){const a=await e.getAuthToken();if(!a)throw new Error("No auth token found");const c=o.getStrapiURL(),l=new URL("/api/minio-plugin/uploadbyreference",c);try{const e={bucketName:t,files:r,reference:n,refID:i,field:s};console.log("Sending request body:",JSON.stringify(e,null,2));const o=await fetch(l,{headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST",body:JSON.stringify(e)});if(!o.ok){const e=await o.text();throw console.error("Upload service error:",o.status,e),new Error(`Upload failed with status ${o.status}: ${e}`)}const c=await o.json();return console.log("Upload service response:",c),c}catch(e){throw console.error("Error uploading files:",e),e}};
|