umwd-components 0.1.798 → 0.1.800
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/e-commerce/iro/TextualIROItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/AddIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/iro/updateIroAction.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/opo/createOpoAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/ipo/createIPOAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/ipo/updateIpoAction.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +6 -3
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +41 -35
- package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +2 -2
- package/dist/esm/src/components/logistics/ipo/AddIPOForm.js +0 -1
- package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +8 -5
- package/dist/esm/src/data/actions/e-commerce/iro/updateIroAction.js +3 -3
- package/dist/esm/src/data/actions/e-commerce/opo/createOpoAction.js +0 -1
- package/dist/esm/src/data/actions/logistics/ipo/createIPOAction.js +0 -1
- package/dist/esm/src/data/actions/logistics/ipo/updateIpoAction.js +0 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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=>"id"in e),s=t.filter(e=>!("id"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)
|
|
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),D=Array.isArray(_)&&_.length>0?_.filter(e=>"picked"===e.type).reduce((e,r)=>e+r.quantity,0):0,P=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 V=x.reports?.filter(e=>"id"in e)||[],T=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+D,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+P,minnewvalue:0+A,maxnewvalue:I+P,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:V}),e.jsx(u.default,{itemID:x.documentId,reports:T,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:x.documentId,content:"",type:"packed",minValue:-(I-k+P),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+P,minnewvalue:0,maxnewvalue:k,color:"info",handleChange:e=>{y(e,x.documentId,"shipped_quantity")}})]})]})},h)};
|
|
@@ -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("@mui/material/Box"),t=require("@mui/material/Stack"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/Box"),t=require("@mui/material/Stack"),a=require("@mui/material/TextField"),s=require("@mui/material/Typography"),n=require("@mui/material/Divider"),o=require("@mui/material/Button"),d=require("@mui/material/Checkbox"),c=require("../../SubmitButton.js"),l=require("../../../data/actions/logistics/ipo/createIPOAction.js"),u=require("@mui/material/Grid"),m=require("../vendor/VendorSelector.js"),x=require("../../../data/loaders/logistics/getSingleVendor.js"),h=require("./IPOItemFields.js"),j=require("@mui/x-date-pickers/AdapterDayjs"),f=require("@mui/x-date-pickers/LocalizationProvider"),p=require("@mui/x-date-pickers/DatePicker"),v=require("../../../context/common/SnackbarContext.js");const g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.AddIPOForm=function({vendorNamesArr:y,sx:b,revalidateCallback:q,handleClose:k}){const[A,C]=r.useActionState(l.createIPOAction,g),[I,P]=r.useState([]),[S,z]=r.useState(null),{handleAddMessage:O}=v.useSnackbar();return r.useEffect(()=>{A?.message&&(O({message:A.message,severity:A.severity||"error"}),"success"===A.severity&&(q&&q(),k&&k()))},[A?.message]),r.useEffect(()=>{A?.strapiErrors&&O({message:A.strapiErrors.message||"Error performing action",severity:"error"})},[A?.strapiErrors]),e.jsx(i,{sx:[...Array.isArray(b)?b:[b]],children:e.jsx("form",{action:C,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{size:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(s,{variant:"h3",component:"h1",children:"Add IPO"}),e.jsx(s,{variant:"body1",children:"Create a new incoming purchase order"})]})}),e.jsx(u,{sx:{mt:1},size:{xs:12,md:6},children:y?e.jsx(m.default,{vendorNames:y,currentValue:null,onSelectVendor:async e=>{if(z(e),!e)return void P([]);const r=await x.getSingleVendor(e),i=r?.products.filter(e=>!e.product_number.startsWith("r"))||[];P(i)}}):e.jsx(s,{children:"No vendors on file, you need to create a vendor first before you are able to create incoming purchase orders"})}),e.jsx(u,{size:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(s,{variant:"h5",children:"Order Details"}),e.jsx(s,{variant:"body1",children:"The orderdate should be the official date of the order, don't worry, you can also set days in the past or future"}),e.jsx(f.LocalizationProvider,{dateAdapter:j.AdapterDayjs,children:e.jsx(p.DatePicker,{name:"order_date",label:"Order Date"})}),e.jsx(s,{variant:"body1",children:"Please enter a custom reference for this order"}),e.jsx(a,{id:"customer_reference",name:"customer_reference",type:"text",label:"Custom Reference"}),e.jsx(n,{})]})}),e.jsx(u,{size:12,children:e.jsx(h.IPOItemFields,{productsArr:I,vendorID:S})}),e.jsxs(u,{size:12,children:[e.jsx(d,{name:"confirmation",defaultChecked:!0}),e.jsx(s,{variant:"body2",children:"I confirm that the information provided is accurate to the best of my knowledge and like to confirm immediately."})]}),e.jsx(u,{size:12,children:e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:2},children:[k&&e.jsx(o,{onClick:k,variant:"outlined",children:"Cancel"}),e.jsx(c.SubmitButton,{text:"Create IPO",loadingText:"Creating...",variant:"contained",disabled:null===S})]})})]})})})};
|
|
@@ -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
|
|
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)};
|
|
@@ -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"),x=require("@mui/material/Paper"),p=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),g=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"),I=require("@mui/material/List"),q=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"),M=require("@mui/icons-material/Business"),z=require("@mui/icons-material/Update"),A=require("../../SubmitButton.js"),E=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(p,{open:r,onClose:n,children:[e.jsx(g,{children:"Confirm Order"}),e.jsx(y,{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 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(p,{open:n,onClose:t,children:[e.jsx(g,{children:"Cancel Return"}),e.jsx(y,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(q,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(q,{children:"Please provide a reason for the cancellation"}),e.jsx(q,{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:p,handleClose:j,role:y}){console.log("TextualManageIPOForm data",t);const[g,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:I}=i.useSnackbar(),[q,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(()=>{g?.message&&(I({message:g.message,severity:g.severity||"error"}),"success"===g.severity&&(p&&p(),j&&j()))},[g?.message]),r.useEffect(()=>{g?.strapiErrors&&I({message:g.strapiErrors.message||"Error updating IPO",severity:"error"})},[g?.strapiErrors]);const Q=(e,r,i)=>{const n=[...q],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...q],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=[...q],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"===g?.message&&(I({message:"Ipo Updated",severity:"success"}),j&&j(),p&&p())},[g]),r.useEffect(()=>{g?.strapiErrors&&I({message:g.strapiErrors.message||"Error updating IPO",severity:"error"})},[g?.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(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:p})]}),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(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(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(M,{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(z,{color:"primary"}),e.jsx(v,{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(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(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:p})]}),("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:p})]})]})})}),e.jsx(b,{size:12,children:e.jsx(v,{variant:"h5",children:"Documents"})}),"enduser"===y&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(E.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:p})]})}):e.jsx(x,{sx:{p:2},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:p})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(E.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:p})]})}):e.jsx(x,{sx:{p:2},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:p})]})})}),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:x,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:[q&&q.map((r,i)=>e.jsx(x,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(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:p,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(A.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId: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}))||[]})))(q))})]})]})})]})})};
|
|
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"),x=require("@mui/material/Paper"),p=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),v=require("@mui/material/DialogContent"),y=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"),I=require("@mui/material/List"),q=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"),M=require("@mui/icons-material/Business"),z=require("@mui/icons-material/Update"),A=require("../../SubmitButton.js"),E=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(p,{open:r,onClose:n,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(v,{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(p,{open:n,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(q,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(q,{children:"Please provide a reason for the cancellation"}),e.jsx(q,{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:p,handleClose:j,role:v}){console.log("TextualManageIPOForm data",t);const[y,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:I}=i.useSnackbar(),[q,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(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(p&&p(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const Q=(e,r,i)=>{const n=[...q],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...q],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=[...q],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"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),"success"===y.severity&&(p&&p(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.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:p})]}),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(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(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(M,{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(z,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===v&&e.jsx(b,{size:6,children:e.jsx(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(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:p})]}),("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:p})]})]})})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",children:"Documents"})}),"enduser"===v&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(E.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:p})]})}):e.jsx(x,{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:p})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(E.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:p})]})}):e.jsx(x,{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:p})]})})}),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:x,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:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId: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=>({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}))||[]})))(q))}),q&&q.map((r,i)=>e.jsx(x,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(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:p,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(A.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]})]})]})})]})})};
|
|
@@ -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."
|
|
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}};
|
|
@@ -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.createOpoAction=async function(s,a){Object.fromEntries(a);const
|
|
7
|
+
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.createOpoAction=async function(s,a){Object.fromEntries(a);const i=t.parseFormData(a),o=await r.mutateData("POST","/api/opos/createAdmin",i);if(!o)return{...s,severity:"error",strapiErrors:null,message:"Ops! Something went wrong. Please try again."};if(o.error)return{...s,severity:"error",strapiErrors:o.error,message:"Failed to Create Opo."};const n=e.flattenAttributes(o);return{...s,severity:"success",message:"Opo Created Successfully",data:n,strapiErrors:null}};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("../../../services/mutate-data.js"),r=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js"),a=require("../../../../../node_modules/dayjs/dayjs.min.js");exports.createIPOAction=async function(s,
|
|
7
|
+
"use strict";var e=require("../../../services/mutate-data.js"),r=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js"),a=require("../../../../../node_modules/dayjs/dayjs.min.js");exports.createIPOAction=async function(s,i){const o=t.parseFormData(i);if(!o.data.order_date)return{...s,severity:"error",strapiErrors:null,message:"Please select an Order Date."};const d={data:{vendor_profile:o.data.vendors,customer_reference:o.data.customer_reference,order_date:a.default(o.data.order_date).format("YYYY-MM-DD"),items:o.data.ipo_items,internal_status:o.data.confirmation?"ordered":"placed"}};if(0===JSON.parse(o.data.ipo_items).length)return{...s,severity:"error",strapiErrors:null,message:"Please add items to the IPO."};const n=await e.mutateData("POST","/api/ipos",d);if(!n)return{...s,severity:"error",strapiErrors:null,message:"Failed to create IPO. Please try again."};if(n.error)return{...s,severity:"error",strapiErrors:n.error,message:"Failed to create IPO."};const u=r.flattenAttributes(n);return{...s,severity:"success",message:"IPO Created Successfully",data:u,strapiErrors:null}};
|
|
@@ -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.updateIpoAction=async function(s,a,i){const
|
|
7
|
+
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.updateIpoAction=async function(s,a,i){const u=t.parseFormData(i),o=await r.mutateData("PUT",`/api/ipos/${s}`,u);if(!o)return{...a,severity:"error",strapiErrors:null,message:"Failed to update IPO. Please try again."};if(o.error)return{...a,severity:"error",strapiErrors:o.error,message:"Failed to update IPO."};const l=e.flattenAttributes(o);return{...a,severity:"success",message:"IPO Updated Successfully",data:l,strapiErrors:null}};
|