umwd-components 0.1.722 → 0.1.723
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/TextualManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +2 -2
- package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +2 -2
- package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +2 -2
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/data/services/common/cancellation-service.d.ts +1 -1
- package/dist/esm/types/data/services/common/confirmation-service.d.ts +1 -1
- package/dist/esm/types/types/e-commerce/iro/types.d.ts +2 -0
- package/dist/esm/types/types/e-commerce/opo/types.d.ts +2 -0
- package/dist/esm/types/types/logistics/Ipo.d.ts +2 -0
- 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("react-dom"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),n=require("./TextualIROItemUpdater.js"),s=require("./IroItemDisplay.js"),a=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),o=require("../../SubmitButton.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),x=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),p=require("@mui/material/Button"),j=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),_=require("@mui/material/Stack"),y=require("@mui/material/Divider"),f=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),C=require("@mui/material"),q=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),S=require("@mui/icons-material/Business"),k=require("@mui/icons-material/Description"),T=require("@mui/icons-material/Update"),A=require("./IroStatusIndicator.js"),F=require("../../../data/loaders/e-commerce/queryAllProducts.js"),D=require("../../../../node_modules/qs/lib/index.js"),R=require("../../../context/common/SnackbarContext.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=D.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.id,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(d,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(x,{children:"Check or overwrite value for the return payment"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(C.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(C.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(C.CircularProgress,{}):e.jsxs(_,{spacing:2,children:[e.jsx(C.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(C.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(C.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(C.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(_,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(h,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(h,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(h,{sx:{minWidth:200},children:r.product?.title}),e.jsx(C.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(C.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(C.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(C.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.id))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{f.confirmationService("iros",[a.id],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=R.useSnackbar();return e.jsxs(d,{open:r,onClose:t,children:[e.jsx(x,{children:"Confirm Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this return?"}),e.jsxs(C.List,{children:["requested"===n&&e.jsx(C.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(C.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(C.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(h,{children:["Current status: ",n]})]})}),e.jsxs(u,{children:[e.jsx(p,{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 f.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(p,{variant:"contained",onClick:t,children:"No"})]})]})}function O({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,c]=r.useState(""),{handleAddMessage:j}=R.useSnackbar();return e.jsx("form",{children:e.jsxs(d,{open:t,onClose:i,children:[e.jsx(x,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this return?"}),e.jsxs(C.List,{children:[e.jsx(C.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(C.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(C.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C.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(u,{children:[e.jsx(p,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(p,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.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:d,sx:u,revalidateCallback:m,handleClose:x,role:f}){const[b,F]=t.useFormState(i.updateIroAction,P),[D,M]=r.useState(d.iro_items?d.iro_items:[]),[B,L]=r.useState(!1),[N,z]=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=[...D],n=i.findIndex(e=>e.id===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.id===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=[...D],i=t.findIndex(r=>r.id===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}=R.useSnackbar();return r.useEffect(()=>{b?.message&&(X({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(m&&m(),x&&x()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&X({message:b.strapiErrors.message||"Error updating IRO",severity:b.severity||"error"})},[b?.strapiErrors]),r.useEffect(()=>{console.log("data",d),d.iro_items&&M(d.iro_items?d.iro_items:[])},[d]),e.jsx(v,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.rma_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_date})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{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(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(T,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(A.IroStatusIndicator,{status:d.internal_status})]})]})})}),("requested"===d.internal_status||"finalising_process"===d.internal_status)&&"enduser"===f&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.internal_status&&e.jsx(c,{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"===d.internal_status&&e.jsx(c,{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"===d.internal_status&&e.jsx(p,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(p,{variant:"contained",color:"error",onClick:()=>z(!0),children:"Cancel order"}),e.jsx(E,{open:B,handleClose:()=>L(!1),orderID:d.id,currentStatus:d.internal_status,revalidateCallback:m,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:d}),e.jsx(O,{open:N,handleClose:()=>z(!1),orderID:d.id,revalidateCallback:m})]})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(_,{spacing:1})})]})}),d?.notes?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(a.default,{notes:d.notes}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:g,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(C.FormControlLabel,{control:e.jsx(C.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.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))]}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(y,{}),e.jsxs("form",{action:F,children:[e.jsx("input",{name:"id",type:"hidden",value:d.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,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,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.internal_status||"cancelled"===d.internal_status||"done"===d.internal_status?e.jsx(s.default,{item:r,index:t,image:r?.product?.image}):e.jsx(n.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:G})},t)),e.jsxs(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[x&&e.jsx(p,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(o.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("react-dom"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),n=require("./TextualIROItemUpdater.js"),s=require("./IroItemDisplay.js"),a=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),o=require("../../SubmitButton.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),x=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),p=require("@mui/material/Button"),j=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),_=require("@mui/material/Stack"),y=require("@mui/material/Divider"),f=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),C=require("@mui/material"),q=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),S=require("@mui/icons-material/Business"),k=require("@mui/icons-material/Description"),T=require("@mui/icons-material/Update"),A=require("./IroStatusIndicator.js"),F=require("../../../data/loaders/e-commerce/queryAllProducts.js"),D=require("../../../../node_modules/qs/lib/index.js"),R=require("../../../context/common/SnackbarContext.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=D.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.id,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(d,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(x,{children:"Check or overwrite value for the return payment"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(C.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(C.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(C.CircularProgress,{}):e.jsxs(_,{spacing:2,children:[e.jsx(C.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(C.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(C.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(C.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(_,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(h,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(h,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(h,{sx:{minWidth:200},children:r.product?.title}),e.jsx(C.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(C.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(C.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(C.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.id))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{f.confirmationService("iros",[a.documentId],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=R.useSnackbar();return e.jsxs(d,{open:r,onClose:t,children:[e.jsx(x,{children:"Confirm Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this return?"}),e.jsxs(C.List,{children:["requested"===n&&e.jsx(C.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(C.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(C.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(h,{children:["Current status: ",n]})]})}),e.jsxs(u,{children:[e.jsx(p,{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 f.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(p,{variant:"contained",onClick:t,children:"No"})]})]})}function O({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,c]=r.useState(""),{handleAddMessage:j}=R.useSnackbar();return e.jsx("form",{children:e.jsxs(d,{open:t,onClose:i,children:[e.jsx(x,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this return?"}),e.jsxs(C.List,{children:[e.jsx(C.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(C.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(C.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C.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(u,{children:[e.jsx(p,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(p,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.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:d,sx:u,revalidateCallback:m,handleClose:x,role:f}){const[b,F]=t.useFormState(i.updateIroAction,P),[D,M]=r.useState(d.iro_items?d.iro_items:[]),[B,L]=r.useState(!1),[N,z]=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=[...D],n=i.findIndex(e=>e.id===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.id===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=[...D],i=t.findIndex(r=>r.id===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}=R.useSnackbar();return r.useEffect(()=>{b?.message&&(X({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(m&&m(),x&&x()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&X({message:b.strapiErrors.message||"Error updating IRO",severity:b.severity||"error"})},[b?.strapiErrors]),r.useEffect(()=>{console.log("data",d),d.iro_items&&M(d.iro_items?d.iro_items:[])},[d]),e.jsx(v,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.rma_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_date})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{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(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(T,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(A.IroStatusIndicator,{status:d.internal_status})]})]})})}),("requested"===d.internal_status||"finalising_process"===d.internal_status)&&"enduser"===f&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.internal_status&&e.jsx(c,{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"===d.internal_status&&e.jsx(c,{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"===d.internal_status&&e.jsx(p,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(p,{variant:"contained",color:"error",onClick:()=>z(!0),children:"Cancel order"}),e.jsx(E,{open:B,handleClose:()=>L(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:d}),e.jsx(O,{open:N,handleClose:()=>z(!1),orderID:d.documentId,revalidateCallback:m})]})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(_,{spacing:1})})]})}),d?.notes?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(a.default,{notes:d.notes}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:g,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(C.FormControlLabel,{control:e.jsx(C.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.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))]}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(y,{}),e.jsxs("form",{action:F,children:[e.jsx("input",{name:"id",type:"hidden",value:d.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,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,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.internal_status||"cancelled"===d.internal_status||"done"===d.internal_status?e.jsx(s.default,{item:r,index:t,image:r?.product?.image}):e.jsx(n.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:G})},t)),e.jsxs(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[x&&e.jsx(p,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(o.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"),i=require("react"),r=require("react-dom"),n=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),a=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),a=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),m=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),j=require("@mui/material/Typography"),y=require("@mui/material/Button"),v=require("@mui/material/Grid"),g=require("@mui/material/Box"),f=require("@mui/material/Paper"),b=require("@mui/material/Stack"),_=require("@mui/material/Divider"),q=require("../../../data/services/common/confirmation-service.js"),C=require("../../../context/common/SnackbarContext.js");const w={zodErrors:null,strapiErrors:null,message:null};function k({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(m,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{children:"Are you sure you want to confirm this order?"}),e.jsxs(j,{children:["Current status: ",a]})]})}),e.jsxs(p,{children:[e.jsx(y,{variant:"contained",onClick:e=>{q.confirmationService("opos",[n]),t&&t()},children:"Confirm"}),e.jsx(y,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:m,sx:p,revalidateCallback:x,handleClose:h,role:q}){const[D,O]=r.useFormState((e,i)=>n.updateOpoAction(m.id,e,i),w),{handleAddMessage:S}=C.useSnackbar(),[E,A]=i.useState(m.opo_items?m.opo_items:[]),[B,I]=i.useState(!1),N=(e,i,r)=>{const n=[...E],a=n.findIndex(e=>e.id===i);n[a][r]=e,A(n)};return i.useEffect(()=>{m.opo_items&&A(m.opo_items)},[m]),i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(x&&x(),h&&h()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error updating OPO",severity:D.severity||"error"})},[D?.strapiErrors]),e.jsx(g,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(v,{container:!0,spacing:2,children:[e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h3",component:"h1",children:"Manage Outbound Purchase Order"}),e.jsx(j,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:m.id,__type:"api::e-commerce.opo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:6,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Details"}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(j,{variant:"body2",children:m.opo_number})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(j,{variant:"body2",children:m.customer_reference})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(j,{variant:"body2",children:m.order_date})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(j,{variant:"body2",children:m.customer?.business_credentials?.company_name})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(j,{variant:"body2",width:"250px",children:m.internal_status})]}),("placed"===m.internal_status||"external_shipping_process"===m.internal_status)&&"enduser"===q&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"contained",color:"primary",onClick:()=>I(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(k,{open:B,handleClose:()=>I(!1),orderID:m.documentId,currentStatus:m.internal_status,revalidateCallback:x})]})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Documents"}),e.jsx(f,{sx:{p:2},children:e.jsx(b,{spacing:1,children:m.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h6",children:"Delivery Note"}),e.jsx(j,{children:m.delivery_note?.name}),e.jsx(y,{variant:"contained",onClick:()=>{t.default(`api/opos/${m.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h5",children:"Delivery Note"}),e.jsx(j,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(a.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:m.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:x})]})})})]})}),m?.notes?.length>0&&e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:m.notes}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Items"}),"placed"===m.internal_status&&e.jsx(u,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:O,children:[e.jsx("input",{name:"id",type:"hidden",value:m.id}),E&&E.map((i,r)=>(console.log("item",i),e.jsx(f,{sx:{p:2,mb:2},children:"placed"===m.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:N,image:i?.product?.image,revalidateCallback:x})},r))),e.jsx(f,{sx:{p:2},children:e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(y,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(E))})]})]})})]})})};
|
|
@@ -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("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),l=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),k=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.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(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{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 b.cancellationService("opos",n,s),d({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.id),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items?u.opo_items:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items&&R(u.opo_items?u.opo_items:[])},[u]);const Y=(e,r,i)=>{const t=[...L],n=t.findIndex(e=>e.id===r);t[n][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),n=i[t]?.reports||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.id,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.id,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/ipos/${u.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.id,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})]})})})]})}),u?.notes?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:u.notes}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.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"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,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,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.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("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),l=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),k=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.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(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{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 b.cancellationService("opos",n,s),d({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.id),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items?u.opo_items:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items&&R(u.opo_items?u.opo_items:[])},[u]);const Y=(e,r,i)=>{const t=[...L],n=t.findIndex(e=>e.id===r);t[n][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),n=i[t]?.reports||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.documentId,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.documentId,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/ipos/${u.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.id,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})]})})})]})}),u?.notes?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:u.notes}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.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"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,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,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.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"),i=require("react"),r=require("react-dom"),n=require("../../../context/common/SnackbarContext.js"),a=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),s=require("../../../data/loaders/common/media/downloadBase64File.js"),o=require("./IPOItemUpdater.js"),d=require("./ItemDisplay.js"),c=require("../note/NotesDisplay.js"),l=require("../note/NoteTakingComponent.js"),m=require("../../SubmitButton.js"),p=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),x=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),j=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),f=require("@mui/material/Typography"),g=require("@mui/material/Button"),y=require("@mui/material/Grid"),b=require("@mui/material/Box"),_=require("@mui/material/Paper"),q=require("@mui/material/Stack"),C=require("@mui/material/Divider");const w={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(x,{open:i,children:[e.jsx(v,{children:"Confirm Order"}),e.jsx(j,{children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{children:"Are you sure you want to confirm this order?"}),e.jsxs(f,{children:["Current status: ",a]})]})}),e.jsxs(h,{children:[e.jsx(g,{variant:"contained",onClick:e=>{p.confirmationService("ipos",[n]),t&&t(),r()},children:"Confirm"}),e.jsx(g,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:p,sx:x,revalidateCallback:h,handleClose:j,role:v}){const[D,I]=r.useFormState((e,i)=>a.updateIpoAction(p.id,e,i),w),{handleAddMessage:S}=n.useSnackbar(),[O,U]=i.useState(p.items?p.items:[]),[N,A]=i.useState(!1);i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(h&&h(),j&&j()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error performing action",severity:"error"})},[D?.strapiErrors]);const B=(e,i,r)=>{const n=[...O],a=n.findIndex(e=>e.id===i);n[a][r]=e,U(n)};return e.jsx(b,{sx:[...Array.isArray(x)?x:[x]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsxs(q,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(f,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(l.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:6,children:e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h5",children:"Details"}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(f,{variant:"body2",children:p.ipo_number})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(f,{variant:"body2",children:p.customer_reference})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(f,{variant:"body2",children:p.order_date})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(f,{variant:"body2",children:p.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(f,{variant:"body2",width:"250px",children:p.internal_status})]}),("placed"===p.internal_status||"released_on_stock"===p.internal_status)&&"enduser"===v&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"contained",color:"primary",onClick:()=>A(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher."}),e.jsx(k,{open:N,handleClose:()=>A(!1),orderID:p.
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../context/common/SnackbarContext.js"),a=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),s=require("../../../data/loaders/common/media/downloadBase64File.js"),o=require("./IPOItemUpdater.js"),d=require("./ItemDisplay.js"),c=require("../note/NotesDisplay.js"),l=require("../note/NoteTakingComponent.js"),m=require("../../SubmitButton.js"),p=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),x=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),j=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),f=require("@mui/material/Typography"),g=require("@mui/material/Button"),y=require("@mui/material/Grid"),b=require("@mui/material/Box"),_=require("@mui/material/Paper"),q=require("@mui/material/Stack"),C=require("@mui/material/Divider");const w={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(x,{open:i,children:[e.jsx(v,{children:"Confirm Order"}),e.jsx(j,{children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{children:"Are you sure you want to confirm this order?"}),e.jsxs(f,{children:["Current status: ",a]})]})}),e.jsxs(h,{children:[e.jsx(g,{variant:"contained",onClick:e=>{p.confirmationService("ipos",[n]),t&&t(),r()},children:"Confirm"}),e.jsx(g,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:p,sx:x,revalidateCallback:h,handleClose:j,role:v}){const[D,I]=r.useFormState((e,i)=>a.updateIpoAction(p.id,e,i),w),{handleAddMessage:S}=n.useSnackbar(),[O,U]=i.useState(p.items?p.items:[]),[N,A]=i.useState(!1);i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(h&&h(),j&&j()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error performing action",severity:"error"})},[D?.strapiErrors]);const B=(e,i,r)=>{const n=[...O],a=n.findIndex(e=>e.id===i);n[a][r]=e,U(n)};return e.jsx(b,{sx:[...Array.isArray(x)?x:[x]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsxs(q,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(f,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(l.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:6,children:e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h5",children:"Details"}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(f,{variant:"body2",children:p.ipo_number})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(f,{variant:"body2",children:p.customer_reference})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(f,{variant:"body2",children:p.order_date})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(f,{variant:"body2",children:p.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(f,{variant:"body2",width:"250px",children:p.internal_status})]}),("placed"===p.internal_status||"released_on_stock"===p.internal_status)&&"enduser"===v&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"contained",color:"primary",onClick:()=>A(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher."}),e.jsx(k,{open:N,handleClose:()=>A(!1),orderID:p.documentId,currentStatus:p.internal_status,revalidateCallback:h})]})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Documents"}),e.jsx(_,{sx:{p:2},children:e.jsxs(q,{spacing:1,children:["enduser"===v&&e.jsx(e.Fragment,{children:p.order_confirmation?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{children:p.order_confirmation?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})}),p.delivery_note?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{children:p.delivery_note?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{variant:"body1",children:"Upload the delivery note for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,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:h})]})]})})]})}),p?.notes?.length>0&&e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:p.notes}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Items"}),"placed"===p.internal_status&&e.jsx(u,{severity:"warning",children:"Items cannot be updated before order confirmation"}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(O))}),e.jsxs(q,{spacing:2,children:[p?.items&&p.items.map((i,r)=>e.jsx(_,{sx:{p:2},children:"placed"===p.internal_status?e.jsx(d.default,{item:i,index:r,image:i?.product?.image}):e.jsx(o.default,{item:i,index:r,handleUpdateQuantity:B,image:i?.product?.image,revalidateCallback:h})},r)),"placed"!==p.internal_status&&e.jsx(_,{sx:{p:2},children:e.jsxs(q,{direction:"row",justifyContent:"flex-end",spacing:2,children:[j&&e.jsx(g,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Update Items",loadingText:"Updating...",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("react-dom"),a=require("../../../context/common/SnackbarContext.js"),t=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),l=require("../../common/media/UploadBase64MediaForm.js"),c=require("../note/NoteTakingComponent.js"),d=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),_=require("@mui/material/Divider"),w=require("@mui/material/TextField"),I=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:t,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=a.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[t]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:t,orderID:n,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=a.useSnackbar();return e.jsxs(g,{open:i,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(w,{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(v,{children:[e.jsx(C,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,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:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,w]=i.useFormState((e,r)=>t.updateIpoAction(n.id,e,r),N),{handleAddMessage:I}=a.useSnackbar(),[k,R]=r.useState(n.items?n.items:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const a=[...k],t=a.findIndex(e=>e.id===r);a[t][i]=e,R(a)},Q=(e,r)=>{const i=[...k],a=i.findIndex(e=>e.id===r),t=[...i[a]?.reports||[],e];null==i[a]?.reports&&(i[a]={...i[a],reports:[]}),i[a].reports=t,R(i)},K=(e,r)=>{const i=[...k],a=i.findIndex(r=>r.id===e),t=i[a]?.reports||[],n=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[a].reports=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items&&R(n.items?n.items:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.internal_status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.internal_status||"released_on_stock"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.id,currentStatus:n.internal_status,revalidateCallback:g})]}),("placed"===n.internal_status||"ordered"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.id,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,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:g})]})]})})]})}),n?.notes?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:n.notes}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:w,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.internal_status||"cancelled"===n.internal_status||"done"===n.internal_status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,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,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../context/common/SnackbarContext.js"),a=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),l=require("../../common/media/UploadBase64MediaForm.js"),c=require("../note/NoteTakingComponent.js"),d=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),_=require("@mui/material/Divider"),w=require("@mui/material/TextField"),I=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=t.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:a,orderID:n,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=t.useSnackbar();return e.jsxs(g,{open:i,onClose:a,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(w,{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(v,{children:[e.jsx(C,{variant:"outlined",onClick:a,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),a()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,w]=i.useFormState((e,r)=>a.updateIpoAction(n.id,e,r),N),{handleAddMessage:I}=t.useSnackbar(),[k,R]=r.useState(n.items?n.items:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const t=[...k],a=t.findIndex(e=>e.id===r);t[a][i]=e,R(t)},Q=(e,r)=>{const i=[...k],t=i.findIndex(e=>e.id===r),a=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=a,R(i)},K=(e,r)=>{const i=[...k],t=i.findIndex(r=>r.id===e),a=i[t]?.reports||[],n=a.filter(e=>"id"in e),s=a.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[t].reports=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items&&R(n.items?n.items:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.internal_status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.internal_status||"released_on_stock"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.documentId,currentStatus:n.internal_status,revalidateCallback:g})]}),("placed"===n.internal_status||"ordered"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.documentId,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,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:g})]})]})})]})}),n?.notes?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:n.notes}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:w,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.internal_status||"cancelled"===n.internal_status||"done"===n.internal_status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,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,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
|