umwd-components 0.1.798 → 0.1.799

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.
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),o=require("@mui/icons-material/ArrowDropDown"),d=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportsDisplay.js"),c=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:v}){console.log("TextualIROItemUpdater",p);const{line_item_number:q,product:f,returned_quantity:w,received_quantity:I,registered_quantity:R,released_quantity:_,reports:C,reason:A,other_reason:D}=p,[T,V]=r.useState(!1);null!=C&&C.length>0&&C.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const U=null!=C&&C.length>0?C.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;null!=C&&C.length>0&&C.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const F=p.reports?.filter(e=>"id"in e)||[],P=p.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",q]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(d.default,{image:y,label:p.product?.title})})]}),e.jsxs(i,{variant:"body1",children:["Reason: ",A,"other"===A&&void 0!==D&&`, ${D}`]}),e.jsx(a,{sx:{mb:1}}),v&&v.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.TextualAmountUpdater,{label:"Received",currentValue:I,totalValue:w,minnewvalue:0+R,maxnewvalue:w,color:"info",handleChange:e=>{g(e,p.documentId,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.TextualAmountUpdater,{label:"Registered",currentValue:R,totalValue:w+U,minnewvalue:0+_,maxnewvalue:I+U,color:"info",handleChange:e=>{g(e,p.documentId,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>V(!T),children:e.jsx(o,{})})]})}),e.jsx(s,{in:T,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:F}),e.jsx(c.default,{itemID:p.documentId,reports:P,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.documentId,content:"",type:"registered",minValue:-(I-R+U),handleAddReport:h})]})})]}),v&&v.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.TextualAmountUpdater,{label:"Released",currentValue:_,totalValue:w+U,minnewvalue:0,maxnewvalue:R,color:"info",handleChange:e=>{g(e,p.documentId,"released_quantity")}})]})]})},j)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),o=require("@mui/icons-material/ArrowDropDown"),d=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportsDisplay.js"),c=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:v}){console.log("TextualIROItemUpdater",p);const{line_item_number:q,product:f,returned_quantity:w,received_quantity:I,registered_quantity:R,released_quantity:_,reports:C,reason:A,other_reason:D}=p,[T,V]=r.useState(!1);null!=C&&C.length>0&&C.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const U=null!=C&&C.length>0?C.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;null!=C&&C.length>0&&C.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const F=p.reports?.filter(e=>"id"in e)||[],P=p.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",q]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(d.default,{image:y,label:p.product?.title})})]}),e.jsxs(i,{variant:"body1",children:["Reason: ",A,"other"===A&&void 0!==D&&`, ${D}`]}),e.jsx(a,{sx:{mb:1}}),v&&v.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.TextualAmountUpdater,{label:"Received",currentValue:I,totalValue:w,minnewvalue:0,maxnewvalue:w,color:"info",handleChange:e=>{g(e,p.documentId,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.TextualAmountUpdater,{label:"Registered",currentValue:R,totalValue:w+U,minnewvalue:0+_,maxnewvalue:I+U,color:"info",handleChange:e=>{g(e,p.documentId,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>V(!T),children:e.jsx(o,{})})]})}),e.jsx(s,{in:T,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:F}),e.jsx(c.default,{itemID:p.documentId,reports:P,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.documentId,content:"",type:"registered",minValue:-(I-R+U),handleAddReport:h})]})})]}),v&&v.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.TextualAmountUpdater,{label:"Released",currentValue:_,totalValue:w+U,minnewvalue:0,maxnewvalue:R,color:"info",handleChange:e=>{g(e,p.documentId,"released_quantity")}})]})]})},j)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),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"})]})]})]})})]})})};
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=>"documentId"in e),a=n.filter(e=>!("documentId"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(()=>{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=>({id:"id"in e?e.id:void 0,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("../../../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=>({id:"id"in e?e.id:void 0,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"})]})]})]})})]})})};
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"),l=require("../../logistics/note/NoteTakingComponent.js"),c=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"),b=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),_=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},z=["picked","packed","shipped","reports"];function B({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=>{b.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function N({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=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(_.List,{children:[e.jsx(_.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(_.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(_.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(_.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:!!l,helperText:l})]})}),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)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await C.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:b}){const C=i.updateOpoAction.bind(null,d.documentId),[E,T]=r.useActionState(C,M),[U,P]=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"]),Q=(e,r,i)=>{const n=[...U],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,P(n)},Y=(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,P(i)},$=(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,P(i)},{handleAddMessage:K}=O.useSnackbar();return r.useEffect(()=>{E?.message&&(K({message:E.message,severity:E.severity||"error"}),"success"===E.severity&&(m&&m(),p&&p()))},[E?.message]),r.useEffect(()=>{E?.strapiErrors&&K({message:E.strapiErrors.message||"Error updating OPO",severity:E.severity||"error"})},[E?.strapiErrors]),r.useEffect(()=>{d.opo_items&&P(d.opo_items?d.opo_items:[])},[d]),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 Sales Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.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"===b&&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(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(B,{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(N,{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:()=>{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,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),z.map(r=>e.jsx(_.FormControlLabel,{control:e.jsx(_.Checkbox,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===d.internal_status&&e.jsx(c,{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=>({id:"id"in e?e.id:void 0,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: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"})]})]})]})})]})})};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportsDisplay.js"),u=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),p=require("@mui/material/Box");exports.default=function({item:x,index:h,handleAddReport:j,handleUpdateQuantity:y,image:g,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:f,product:w,ordered_quantity:v,picked_quantity:I,packed_quantity:k,shipped_quantity:A,reports:_}=x,[C,R]=r.useState(!1);Array.isArray(_)&&_.length>0&&_.filter(e=>"picked"===e.type).reduce((e,r)=>e+r.quantity,0);const D=Array.isArray(_)&&_.length>0?_.filter(e=>"packed"===e.type).reduce((e,r)=>e+r.quantity,0):0;Array.isArray(_)&&_.length>0&&_.filter(e=>"shipped"===e.type).reduce((e,r)=>e+r.quantity,0);const P=x.reports?.filter(e=>"id"in e)||[],V=x.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:x&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",f]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",w?.product_number]}),g&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:g,label:w?.title})})]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("picked")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(l.TextualAmountUpdater,{label:"Picked",currentValue:I,totalValue:v,minnewvalue:0+k,maxnewvalue:v,color:"info",handleChange:e=>{y(e,x.documentId,"picked_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("packed")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(l.TextualAmountUpdater,{label:"Packed",currentValue:k,totalValue:v+D,minnewvalue:0+A,maxnewvalue:I+D,color:"info",handleChange:e=>{y(e,x.documentId,"packed_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(p,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>R(!C),children:e.jsx(d,{})})]})}),e.jsx(s,{in:C,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:P}),e.jsx(u.default,{itemID:x.documentId,reports:V,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:x.documentId,content:"",type:"packed",minValue:-(I-k+D),handleAddReport:j})]})})]}),q&&q.includes("shipped")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(l.TextualAmountUpdater,{label:"Shipped",currentValue:A,totalValue:v+D,minnewvalue:0,maxnewvalue:k,color:"info",handleChange:e=>{y(e,x.documentId,"shipped_quantity")}})]})]})},h)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportsDisplay.js"),u=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),p=require("@mui/material/Box");exports.default=function({item:x,index:h,handleAddReport:j,handleUpdateQuantity:y,image:g,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:f,product:w,ordered_quantity:v,picked_quantity:I,packed_quantity:k,shipped_quantity:A,reports:_}=x,[C,R]=r.useState(!1);Array.isArray(_)&&_.length>0&&_.filter(e=>"picked"===e.type).reduce((e,r)=>e+r.quantity,0);const D=Array.isArray(_)&&_.length>0?_.filter(e=>"packed"===e.type).reduce((e,r)=>e+r.quantity,0):0;Array.isArray(_)&&_.length>0&&_.filter(e=>"shipped"===e.type).reduce((e,r)=>e+r.quantity,0);const P=x.reports?.filter(e=>"id"in e)||[],V=x.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:x&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",f]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",w?.product_number]}),g&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:g,label:w?.title})})]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("picked")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(l.TextualAmountUpdater,{label:"Picked",currentValue:I,totalValue:v,minnewvalue:0,maxnewvalue:v,color:"info",handleChange:e=>{y(e,x.documentId,"picked_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("packed")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(l.TextualAmountUpdater,{label:"Packed",currentValue:k,totalValue:v+D,minnewvalue:0+A,maxnewvalue:I+D,color:"info",handleChange:e=>{y(e,x.documentId,"packed_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(p,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>R(!C),children:e.jsx(d,{})})]})}),e.jsx(s,{in:C,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:P}),e.jsx(u.default,{itemID:x.documentId,reports:V,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:x.documentId,content:"",type:"packed",minValue:-(I-k+D),handleAddReport:j})]})})]}),q&&q.includes("shipped")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(l.TextualAmountUpdater,{label:"Shipped",currentValue:A,totalValue:v+D,minnewvalue:0,maxnewvalue:k,color:"info",handleChange:e=>{y(e,x.documentId,"shipped_quantity")}})]})]})},h)};
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),n=require("@mui/material/Typography"),i=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),d=require("../../common/TextualAmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),u=require("../report/ReportsDisplay.js"),c=require("../report/PreReportsDisplay.js"),m=require("../report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:v}){const{line_item_number:q,product:f,ordered_quantity:w,received_quantity:I,registered_quantity:R,released_quantity:_,reports:C}=p,[A,D]=r.useState(!1);C&&C.length>0&&C.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const V=C&&C.length>0?C.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;C&&C.length>0&&C.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const T=p.reports?.filter(e=>"documentId"in e)||[],F=p.reports?.filter(e=>!("documentId"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(n,{variant:"body1",children:["Line Item Number: ",q]}),e.jsxs(n,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:y,label:p.product?.title})})]}),e.jsx(a,{sx:{mb:1}}),v&&v.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(n,{variant:"body2",children:"Received"}),e.jsx(d.TextualAmountUpdater,{label:"Received",currentValue:I,totalValue:w,minnewvalue:0+R,maxnewvalue:w,color:"info",handleChange:e=>{g(e,p.documentId,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(n,{variant:"body2",children:"Registered"}),e.jsx(d.TextualAmountUpdater,{label:"Registered",currentValue:R,totalValue:w+V,minnewvalue:0+_,maxnewvalue:I+V,color:"info",handleChange:e=>{g(e,p.documentId,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(n,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(i,{onClick:()=>D(!A),children:e.jsx(l,{})})]})}),e.jsx(s,{in:A,children:e.jsxs(t,{spacing:2,children:[e.jsx(n,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:T}),e.jsx(c.default,{itemID:p.documentId,reports:F,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.documentId,content:"",type:"registered",minValue:-(I-R+V),handleAddReport:h})]})})]}),v&&v.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(n,{variant:"body2",children:"Released"}),e.jsx(d.TextualAmountUpdater,{label:"Released",currentValue:_,totalValue:w+V,minnewvalue:0,maxnewvalue:R,color:"info",handleChange:e=>{g(e,p.documentId,"released_quantity")}})]})]})},j)};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),n=require("@mui/material/Typography"),i=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),d=require("../../common/TextualAmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),u=require("../report/ReportsDisplay.js"),c=require("../report/PreReportsDisplay.js"),m=require("../report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:v}){const{line_item_number:q,product:f,ordered_quantity:w,received_quantity:I,registered_quantity:R,released_quantity:_,reports:C}=p,[A,D]=r.useState(!1);C&&C.length>0&&C.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const V=C&&C.length>0?C.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;C&&C.length>0&&C.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const T=p.reports?.filter(e=>"documentId"in e)||[],F=p.reports?.filter(e=>!("documentId"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(n,{variant:"body1",children:["Line Item Number: ",q]}),e.jsxs(n,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:y,label:p.product?.title})})]}),e.jsx(a,{sx:{mb:1}}),v&&v.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(n,{variant:"body2",children:"Received"}),e.jsx(d.TextualAmountUpdater,{label:"Received",currentValue:I,totalValue:w,minnewvalue:0,maxnewvalue:w,color:"info",handleChange:e=>{g(e,p.documentId,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(n,{variant:"body2",children:"Registered"}),e.jsx(d.TextualAmountUpdater,{label:"Registered",currentValue:R,totalValue:w+V,minnewvalue:0+_,maxnewvalue:I+V,color:"info",handleChange:e=>{g(e,p.documentId,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),v&&v.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(n,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(i,{onClick:()=>D(!A),children:e.jsx(l,{})})]})}),e.jsx(s,{in:A,children:e.jsxs(t,{spacing:2,children:[e.jsx(n,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:T}),e.jsx(c.default,{itemID:p.documentId,reports:F,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.documentId,content:"",type:"registered",minValue:-(I-R+V),handleAddReport:h})]})})]}),v&&v.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(n,{variant:"body2",children:"Released"}),e.jsx(d.TextualAmountUpdater,{label:"Released",currentValue:_,totalValue:w+V,minnewvalue:0,maxnewvalue:R,color:"info",handleChange:e=>{g(e,p.documentId,"released_quantity")}})]})]})},j)};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.updateIroAction=async function(s,a,o){Object.fromEntries(o);const i=t.parseFormData(o);console.log("parsedFormData",i);const n=await r.mutateData("PUT",`/api/iros/${s}`,i);if(!n)return{...a,strapiErrors:null,message:"Ops! Something went wrong. Please try again.",severity:"error"};if(n.error)return{...a,strapiErrors:n.error,message:"Failed to Update Iro.",severity:"error"};const u=e.flattenAttributes(n);return{...a,message:"Iro Updated",severity:"success",data:u,strapiErrors:null}};
7
+ "use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.updateIroAction=async function(s,a,o){Object.fromEntries(o);const i=t.parseFormData(o);console.log("parsedFormData",i);const n=await r.mutateData("PUT",`/api/iros/${s}`,i);if(!n)return{...a,severity:"error",strapiErrors:null,message:"Ops! Something went wrong. Please try again."};if(n.error)return{...a,severity:"error",strapiErrors:n.error,message:"Failed to Update Iro."};const u=e.flattenAttributes(n);return{...a,severity:"success",message:"Iro Updated",data:u,strapiErrors:null}};