umwd-components 0.1.800 → 0.1.802
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/products/EditStockForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/vendor/EditVendorForm.js +1 -1
- package/dist/cjs/src/data/actions/logistics/note/createNoteAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/report/createReportAction.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +17 -5
- package/dist/esm/src/components/e-commerce/products/EditStockForm.js +2 -2
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +0 -1
- package/dist/esm/src/components/logistics/vendor/EditVendorForm.js +3 -2
- package/dist/esm/src/data/actions/logistics/note/createNoteAction.js +2 -0
- package/dist/esm/src/data/actions/logistics/report/createReportAction.js +7 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/data/actions/logistics/note/createNoteAction.d.ts +2 -1
- package/dist/esm/types/data/actions/logistics/report/createReportAction.d.ts +2 -1
- package/dist/esm/types/types/e-commerce/product/types.d.ts +1 -0
- package/dist/esm/types/types/logistics/Note.d.ts +1 -1
- package/dist/esm/types/types/logistics/Report.d.ts +1 -1
- package/dist/esm/types/types/logistics/Vendor.d.ts +1 -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("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),_=require("@mui/material/Divider"),y=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),F=require("../../../../node_modules/qs/lib/index.js"),D=require("../../../context/common/SnackbarContext.js"),R=require("../../common/media/minio/MinioItemList.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{o(!0);const e=F.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:e=>{y.confirmationService("iros",[a.documentId],n),i()},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function z({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=D.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await y.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function E({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=D.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:y}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),P),[F,M]=r.useState(c.iro_items?c.iro_items:[]),[O,L]=r.useState(!1),[N,B]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...F],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...F],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,M(t)},K=(e,r)=>{const t=[...F],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"documentId"in e),a=n.filter(e=>!("documentId"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,M(t)},{handleAddMessage:X}=D.useSnackbar();return r.useEffect(()=>{f?.message&&(X({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&X({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{c.iro_items&&M(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.documentId,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===y&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>B(!0),children:"Cancel order"}),e.jsx(z,{open:O,handleClose:()=>L(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:c}),e.jsx(E,{open:N,handleClose:()=>B(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Customer Attachements"}),e.jsx(v,{sx:{p:1},children:e.jsx(R.MinioItemList,{items:c.customer_attachment,emptyMessage:"No customer attachments found.",direction:"row",revalidateCallback:u})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(F))}),F&&F.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:u,showing:G})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),_=require("@mui/material/Divider"),y=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),F=require("../../../../node_modules/qs/lib/index.js"),D=require("../../../context/common/SnackbarContext.js"),R=require("../../common/media/minio/MinioItemList.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a,revalidateCallback:l}){const[o,p]=r.useState(!1),{handleAddMessage:j}=D.useSnackbar();return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{p(!0);const e=F.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),p(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),o?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{try{await y.confirmationService("iros",[a.documentId],n),l&&l(),i()}catch(e){j({message:"Failed to confirm return order",severity:"error"})}},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function z({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=D.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await y.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function M({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=D.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:y}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),P),[F,E]=r.useState(c.iro_items?c.iro_items:[]),[O,L]=r.useState(!1),[N,B]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...F],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,E(i)},H=(e,r)=>{const t=[...F],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,E(t)},K=(e,r)=>{const t=[...F],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"documentId"in e),a=n.filter(e=>!("documentId"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,E(t)},{handleAddMessage:X}=D.useSnackbar();return r.useEffect(()=>{f?.message&&(X({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&X({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{c.iro_items&&E(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.documentId,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===y&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>B(!0),children:"Cancel order"}),e.jsx(z,{open:O,handleClose:()=>L(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:c}),e.jsx(M,{open:N,handleClose:()=>B(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Customer Attachements"}),e.jsx(v,{sx:{p:1},children:e.jsx(R.MinioItemList,{items:c.customer_attachment,emptyMessage:"No customer attachments found.",direction:"row",revalidateCallback:u})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(F))}),F&&F.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:u,showing:G})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/Paper"),t=require("@mui/material/Box"),n=require("@mui/material/Stack"),s=require("@mui/material/Typography"),a=require("../../../data/actions/e-commerce/product/updateProductAction.js"),d=require("@mui/material/Grid"),c=require("../../logistics/report/ReportsDisplay.js"),l=require("../../logistics/report/ReportMakingComponent.js"),o=require("../../../context/common/SnackbarContext.js"),u=require("@mui/material/Table"),x=require("@mui/material/TableBody"),m=require("@mui/material/TableCell"),h=require("@mui/material/TableContainer"),j=require("@mui/material/TableFooter"),y=require("@mui/material/TableHead"),p=require("@mui/material/TableRow"),g=require("@mui/material/Tooltip"),q=require("@mui/material/Button"),_=require("../../common/AmountIndicator.js");const A={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.EditStockForm=function({data:k,revalidateCallback:b,handleClose:v,sx:f}){const{
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/Paper"),t=require("@mui/material/Box"),n=require("@mui/material/Stack"),s=require("@mui/material/Typography"),a=require("../../../data/actions/e-commerce/product/updateProductAction.js"),d=require("@mui/material/Grid"),c=require("../../logistics/report/ReportsDisplay.js"),l=require("../../logistics/report/ReportMakingComponent.js"),o=require("../../../context/common/SnackbarContext.js"),u=require("@mui/material/Table"),x=require("@mui/material/TableBody"),m=require("@mui/material/TableCell"),h=require("@mui/material/TableContainer"),j=require("@mui/material/TableFooter"),y=require("@mui/material/TableHead"),p=require("@mui/material/TableRow"),g=require("@mui/material/Tooltip"),q=require("@mui/material/Button"),_=require("../../common/AmountIndicator.js");const A={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.EditStockForm=function({data:k,revalidateCallback:b,handleClose:v,sx:f}){const{id:I,documentId:T,title:S,product_number:C,stock:E,ipos:z,opos:Q,opoItems:V,reports:N}=k,{handleAddMessage:O}=o.useSnackbar(),R=a.updateProductAction.bind(null,T),[P,w]=r.useActionState(R,A);return r.useEffect(()=>{P?.message&&(O({message:P.message,severity:P.severity||"error"}),"success"===P.severity&&(b&&b(),v&&v()))},[P?.message,O,b,v]),r.useEffect(()=>{P?.strapiErrors&&O({message:P.strapiErrors.message||"Error updating stock",severity:"error"})},[P?.strapiErrors,O]),e.jsxs(t,{sx:[...Array.isArray(f)?f:[f]],children:[e.jsxs(d,{container:!0,spacing:2,children:[e.jsx(d,{size:12,children:e.jsx(s,{variant:"h6",children:S})}),e.jsx(d,{size:12,children:e.jsxs(h,{component:i,children:[e.jsx(s,{variant:"h6",sx:{pl:2},children:"Incoming orders"}),e.jsxs(u,{size:"small",children:[e.jsx(y,{children:e.jsxs(p,{children:[e.jsx(m,{children:"Number"}),e.jsx(m,{children:"Order Date"}),e.jsx(m,{children:"Line Item Number"}),e.jsx(m,{children:"Ordered Quantity"}),e.jsx(m,{children:"Received Quantity"}),e.jsx(m,{children:"Registered Quantity"}),e.jsx(m,{children:"Released Quantity"})]})}),e.jsx(x,{children:Array.isArray(z)?z.map(r=>r.items.map(i=>e.jsxs(p,{children:[e.jsx(m,{children:r.ipo_number}),e.jsx(m,{children:r.order_date}),e.jsx(m,{children:i.line_item_number}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.ordered_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.received_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.registered_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.released_quantity,maxValue:i.ordered_quantity,color:"primary"})})]},r.documentId))):e.jsx(p,{children:e.jsx(m,{colSpan:7,align:"center",children:"No incoming orders found."})})}),e.jsx(j,{children:e.jsxs(p,{children:[e.jsx(m,{colSpan:6,align:"right",children:"Total added to stock:"}),e.jsx(m,{children:Array.isArray(z)?z.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0):0})]})})]}),e.jsx(s,{variant:"h6",sx:{pl:2},children:"Outgoing orders"}),e.jsxs(u,{size:"small",children:[e.jsx(y,{children:e.jsxs(p,{children:[e.jsx(m,{children:"Number"}),e.jsx(m,{children:"Order Date"}),e.jsx(m,{children:"Line Item Number"}),e.jsx(m,{children:"Ordered Quantity"}),e.jsx(m,{children:"Picked Quantity"}),e.jsx(m,{children:"Packed Quantity"}),e.jsx(m,{children:"Shipped Quantity"})]})}),e.jsx(x,{children:Array.isArray(Q)?Q.map(r=>r.opo_items.map(i=>e.jsxs(p,{children:[e.jsx(m,{children:r.opo_number}),e.jsx(m,{children:r.order_date}),e.jsx(m,{children:i.line_item_number}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.ordered_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.picked_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.packed_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(m,{children:e.jsx(_.AmountIndicator,{value:i.shipped_quantity,maxValue:i.ordered_quantity,color:"primary"})})]},r.documentId))):e.jsx(p,{children:e.jsx(m,{colSpan:7,align:"center",children:"No outgoing orders found"})})}),e.jsx(j,{children:e.jsxs(p,{children:[e.jsx(m,{colSpan:3,align:"right",children:"Total reduced from stock:"}),e.jsx(m,{children:Array.isArray(Q)?Q.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0):0})]})})]}),e.jsx(u,{size:"small",children:e.jsxs(x,{children:[e.jsxs(p,{children:[e.jsx(m,{align:"right",children:"Total added to stock:"}),e.jsx(m,{children:Array.isArray(z)&&z.length>0?z.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0):0})]}),e.jsxs(p,{children:[e.jsx(m,{align:"right",children:"Total reduced from stock:"}),e.jsx(m,{children:Array.isArray(Q)&&Q.length>0?Q.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0):0})]}),e.jsxs(p,{children:[e.jsx(m,{align:"right",children:"Corrections:"}),e.jsx(m,{children:e.jsx(g,{title:"Total stock corrections",children:e.jsx(s,{children:N?N.reduce((e,r)=>e+r.quantity,0):0})})}),e.jsx(m,{children:e.jsx(g,{title:"Total stock corrections after updating",children:e.jsx("b",{children:N?N.reduce((e,r)=>e+r.quantity,0):0})})})]}),e.jsxs(p,{children:[e.jsx(m,{align:"right",children:"Stock:"}),e.jsx(m,{children:e.jsx(g,{title:"Total stock",children:e.jsx(s,{children:(Array.isArray(z)&&z.length>0?z.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0):0)-(Array.isArray(Q)&&Q.length>0?Q.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0):0)+(N?N.reduce((e,r)=>e+r.quantity,0):0)})})}),e.jsx(m,{children:e.jsx(g,{title:"Total stock after updating",children:e.jsx("b",{children:(Array.isArray(z)&&z.length>0?z.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0):0)-(Array.isArray(Q)&&Q.length>0?Q.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0):0)+(N?N.reduce((e,r)=>e+r.quantity,0):0)})})})]})]})})]})})]}),e.jsxs("form",{action:w,children:[e.jsx("input",{id:"stock_reports",type:"hidden",name:"stock_reports",value:JSON.stringify(N)}),e.jsxs(d,{container:!0,spacing:2,children:[e.jsx(d,{size:12,sx:{mt:2},children:e.jsxs(n,{spacing:2,children:[e.jsx(s,{variant:"h5",children:"Stock corrections"}),e.jsx(s,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:N}),e.jsx(n,{direction:"row",justifyContent:"flex-end",children:e.jsx(l.default,{content:"content",quantity:0,type:"stock",related:[{id:I,__type:"api::e-commerce.product"}],revalidateCallback:b,biggerButton:!0})})]})}),e.jsx(d,{size:12,children:e.jsx(n,{direction:"row",justifyContent:"flex-end",alignItems:"center",sx:{py:1},children:v&&e.jsx(q,{onClick:v,variant:"outlined",children:"Close"})})})]})]})]})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),c=require("./ItemDisplay.js"),d=require("./TextualIPOItemUpdater.js"),u=require("./IpoStatusIndicator.js"),m=require("@mui/material/Box"),h=require("@mui/material/Stack"),x=require("@mui/material/Paper"),p=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),v=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),g=require("@mui/material/Typography"),f=require("@mui/material/Button"),b=require("@mui/material/Grid"),_=require("@mui/material/Divider"),C=require("@mui/material/TextField"),I=require("@mui/material/List"),q=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),w=require("@mui/material/Checkbox"),S=require("@mui/material/FormControlLabel"),D=require("@mui/icons-material/Numbers"),N=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),M=require("@mui/icons-material/Business"),z=require("@mui/icons-material/Update"),A=require("../../SubmitButton.js"),E=require("../../common/media/minio/MinioDisplay.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function T({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(p,{open:r,onClose:n,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to confirm this order?"}),e.jsxs(g,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(f,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function U({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(p,{open:n,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(q,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(q,{children:"Please provide a reason for the cancellation"}),e.jsx(q,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(f,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:t,sx:a,revalidateCallback:p,handleClose:j,role:v}){console.log("TextualManageIPOForm data",t);const[y,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:I}=i.useSnackbar(),[q,F]=r.useState(t.items?t.items:[]),[B,R]=r.useState(!1),[W,L]=r.useState(!1),[G,J]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(p&&p(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const Q=(e,r,i)=>{const n=[...q],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...q],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,F(i)},K=(e,r)=>{const i=[...q],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,F(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),"success"===y.severity&&(p&&p(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&F(t.items?t.items:[])},[t]),e.jsx(m,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(b,{container:!0,spacing:2,children:[e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(g,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(o.default,{content:"",related:[{id:t.documentId,__type:"api::logistics.ipo"}],revalidateCallback:p})]}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(b,{size:6,children:e.jsx(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(N,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(M,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(z,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===v&&e.jsx(b,{size:6,children:e.jsx(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(k,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(T,{open:B,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:p})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(U,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:p})]})]})})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",children:"Documents"})}),"enduser"===v&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(E.MinioDisplay,{fileSize:t.minio_order_confirmation?.fileSize,mimeType:t.minio_order_confirmation?.mimeType,fileName:t.minio_order_confirmation?.fileName,bucketName:t.minio_order_confirmation?.bucketName,revalidateCallback:p})]})}):e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(g,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,revalidateCallback:p})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(E.MinioDisplay,{fileSize:t.minio_delivery_note?.fileSize,mimeType:t.minio_delivery_note?.mimeType,fileName:t.minio_delivery_note?.fileName,bucketName:t.minio_delivery_note?.bucketName,revalidateCallback:p})]})}):e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(g,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,revalidateCallback:p})]})})}),t?.notes?.length>0&&e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(g,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:x,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(g,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(S,{control:e.jsx(w,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(g,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(k,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:C,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(q))}),q&&q.map((r,i)=>e.jsx(x,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(c.default,{item:r,index:i,image:r?.product?.image}):e.jsx(d.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:p,showing:G})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[j&&e.jsx(f,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(A.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),c=require("./ItemDisplay.js"),d=require("./TextualIPOItemUpdater.js"),u=require("./IpoStatusIndicator.js"),m=require("@mui/material/Box"),h=require("@mui/material/Stack"),p=require("@mui/material/Paper"),x=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),v=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),g=require("@mui/material/Typography"),f=require("@mui/material/Button"),b=require("@mui/material/Grid"),_=require("@mui/material/Divider"),C=require("@mui/material/TextField"),I=require("@mui/material/List"),q=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),w=require("@mui/material/Checkbox"),S=require("@mui/material/FormControlLabel"),D=require("@mui/icons-material/Numbers"),N=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),z=require("@mui/icons-material/Business"),A=require("@mui/icons-material/Update"),E=require("../../SubmitButton.js"),M=require("../../common/media/minio/MinioDisplay.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function T({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(x,{open:r,onClose:n,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to confirm this order?"}),e.jsxs(g,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(f,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function U({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(x,{open:n,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(q,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(q,{children:"Please provide a reason for the cancellation"}),e.jsx(q,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(f,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:t,sx:a,revalidateCallback:x,handleClose:j,role:v}){const[y,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:I}=i.useSnackbar(),[q,F]=r.useState(t.items?t.items:[]),[B,R]=r.useState(!1),[W,L]=r.useState(!1),[G,J]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(x&&x(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const Q=(e,r,i)=>{const n=[...q],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...q],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,F(i)},K=(e,r)=>{const i=[...q],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,F(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),"success"===y.severity&&(x&&x(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&F(t.items?t.items:[])},[t]),e.jsx(m,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(b,{container:!0,spacing:2,children:[e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(g,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(o.default,{content:"",related:[{id:t.documentId,__type:"api::logistics.ipo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(N,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(z,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===v&&e.jsx(b,{size:6,children:e.jsx(p,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(k,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(T,{open:B,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:x})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(U,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:x})]})]})})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",children:"Documents"})}),"enduser"===v&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(M.MinioDisplay,{fileSize:t.minio_order_confirmation?.fileSize,mimeType:t.minio_order_confirmation?.mimeType,fileName:t.minio_order_confirmation?.fileName,bucketName:t.minio_order_confirmation?.bucketName,revalidateCallback:x})]})}):e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(g,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(M.MinioDisplay,{fileSize:t.minio_delivery_note?.fileSize,mimeType:t.minio_delivery_note?.mimeType,fileName:t.minio_delivery_note?.fileName,bucketName:t.minio_delivery_note?.bucketName,revalidateCallback:x})]})}):e.jsx(p,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(g,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,revalidateCallback:x})]})})}),t?.notes?.length>0&&e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(g,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:p,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(g,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(S,{control:e.jsx(w,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(g,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(k,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:C,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(q))}),q&&q.map((r,i)=>e.jsx(p,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(c.default,{item:r,index:i,image:r?.product?.image}):e.jsx(d.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:x,showing:G})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[j&&e.jsx(f,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(E.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]})]})]})})]})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),s=require("@mui/material/Paper"),n=require("@mui/material/Box"),r=require("@mui/material/Stack"),i=require("@mui/material/Button"),a=require("@mui/material/TextField"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),s=require("@mui/material/Paper"),n=require("@mui/material/Box"),r=require("@mui/material/Stack"),i=require("@mui/material/Button"),a=require("@mui/material/TextField"),o=require("@mui/material/Typography"),c=require("../../SubmitButton.js"),l=require("../../../context/common/SnackbarContext.js"),d=require("../../../data/actions/logistics/vendor/updateVendorAction.js"),m=require("@mui/material/Grid"),u=require("../../e-commerce/customer/BusinessCredentials.js"),x=require("../../common/Address.js"),p=require("../../e-commerce/products/ProductSelector.js"),j=require("../../common/Contacts.js"),h=require("@mui/icons-material/Add"),g=require("../../../types/common/Contact.js"),f=require("../../ExplanatoryFoldOut.js"),y=require("../note/NoteTakingComponent.js"),C=require("../note/NotesDisplay.js");const b={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.EditVendorForm=function({data:q,productNamesArr:v,revalidateCallback:I,handleClose:z,sx:N}){console.log("EditVendorForm data",q);const{id:_,documentId:A,website_url:E,phone_number:V,email:k,business_credentials:w,address:S,products:F,contacts:B,notes:R}=q,[P,T]=t.useActionState((e,t)=>d.updateVendorAction(A,e,t),b),{handleAddMessage:$}=l.useSnackbar();t.useEffect(()=>{P?.message&&($({message:P.message,severity:P.severity||"error"}),"success"===P.severity&&(I&&I(),z&&z()))},[P?.message]),t.useEffect(()=>{P?.strapiErrors&&$({message:P.strapiErrors.message||"Error updating vendor",severity:"error"})},[P?.strapiErrors]);const O=F||[];console.log("initialProducts",O);const[U,M]=t.useState([]),D=(e,t)=>{U.includes(t)?M(U.filter(e=>e!==t)):M([...U,t])},[G,W]=t.useState(B.reduce((e,t,s)=>(e.push({componentName:`contacts[${s}]`,componentReference:"logistics-elements.contact",data:t}),e),[])),[H,J]=t.useState([]);return e.jsx(n,{sx:[...Array.isArray(N)?N:[N]],children:e.jsx("form",{action:T,children:e.jsxs(m,{container:!0,spacing:2,children:[e.jsx(m,{size:12,children:e.jsxs(r,{direction:"row",justifyContent:"space-between",children:[e.jsx(o,{variant:"h5",children:"Edit Vendor"}),e.jsx(y.default,{content:"",related:[{id:_,__type:"api::logistics.vendor-profile"}],revalidateCallback:I})]})}),e.jsx(m,{size:12,children:e.jsx(f.ExplanatoryFoldOut,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})}),e.jsx(m,{size:{xs:12,md:6},children:e.jsx(u.BusinessCredentialsFields,{data:w,componentName:"business_credentials",componentReference:"common.business-credentials"})}),e.jsx(m,{size:{xs:12,md:6},children:e.jsxs(r,{spacing:2,children:[e.jsx(a,{id:"website_url",name:"website_url",label:"Website Url",defaultValue:E}),e.jsx(a,{id:"phone_number",name:"phone_number",label:"Phone Number",defaultValue:V}),e.jsx(a,{id:"email",name:"email",label:"Email",defaultValue:k})]})}),e.jsxs(m,{size:{xs:12,md:6},children:[e.jsx(o,{variant:"h6",children:"Address"}),e.jsx(x.AddressFields,{data:S,componentName:"address",componentReference:"common.address"})]}),e.jsxs(m,{sx:{mt:1},size:12,children:[e.jsx(o,{variant:"h6",children:"Products"}),e.jsx(p.default,{productNames:v,currentValue:O.map(e=>e.documentId)})]}),e.jsx(m,{sx:{mt:1},size:12,children:e.jsx(o,{variant:"h6",children:"Contacts"})}),G?.map((t,n)=>(console.log("contact",t),t.data?.first_name?U.includes(t.data?.first_name)?e.jsx(m,{sx:{justifyContent:"center",display:"flex",alignItems:"center"},size:{xs:12,sm:6,md:4,lg:3},children:e.jsx(s,{sx:{p:2,width:"100%",display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsx(j.ContactsFields,{data:t.data,componentName:`contacts[${n}]`,componentReference:"logistics-elements.contact",deleteCallback:()=>{W(G.filter((e,t)=>t!==n))}})})},t.data?.documentId||n):e.jsx(m,{sx:{justifyContent:"center",display:"flex",alignItems:"center"},size:{xs:12,sm:6,md:4,lg:3},children:e.jsx(s,{sx:{p:2,width:"100%",display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsx(j.default,{data:{...t.data,onClick:D}})})},t.data?.documentId||n):null)),H.map((t,n)=>e.jsx(m,{sx:{justifyContent:"center",display:"flex",alignItems:"center"},size:{xs:12,sm:6,md:4,lg:3},children:e.jsx(s,{sx:{p:2,width:"100%",display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsx(j.ContactsFields,{data:t.data,componentName:t.componentName,componentReference:"logistics-elements.contact",deleteCallback:()=>{J(H.filter((e,t)=>t!==n).map((e,t)=>({...e,componentName:`contacts[${t+G.length}]`})))}})})},t.data?.documentId||n)),e.jsx(m,{sx:{justifyContent:"center",display:"flex",alignItems:"center"},size:{xs:12,sm:6,md:4,lg:3},children:e.jsx(s,{sx:{p:2,width:"100%",display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsx(i,{variant:"contained",startIcon:e.jsx(h,{}),onClick:()=>{J([...H,{componentName:`contacts[${G.length+H.length}]`,componentReference:"logistics-elements.contact",data:{documentId:"",uuid:Math.random(),first_name:"",last_name:"",email:"",phone_number:"",type:g.ContactType.Other}}])},size:"large",children:"Add contact"})})}),e.jsxs(m,{size:12,children:[e.jsx(o,{variant:"h6",children:"Notes"}),Array.isArray(R)&&R.length>0?e.jsx(C.default,{notes:R}):e.jsx(o,{children:"No notes to display"})]})," ",e.jsx(m,{size:12,children:e.jsxs(r,{direction:"row",spacing:2,justifyContent:"space-between",alignItems:"center",sx:{mt:2},children:[z&&e.jsx(i,{onClick:z,variant:"outlined",children:"Cancel"}),e.jsx(c.SubmitButton,{text:"Update Vendor",loadingText:"Updating..."})]})})]})})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var r=require("zod"),e=require("../../../services/mutate-data.js"),t=require("../../../../lib/utils.js");const s=r.z.object({content:r.z.string().min(10,"Description must be at least 10 characters long").max(5e3,"Description cannot be more than 5000 characters long")});exports.createNoteAction=async function(r,a
|
|
7
|
+
"use strict";var r=require("zod"),e=require("../../../services/mutate-data.js"),t=require("../../../../lib/utils.js");const s=r.z.object({content:r.z.string().min(10,"Description must be at least 10 characters long").max(5e3,"Description cannot be more than 5000 characters long")});exports.createNoteAction=async function(r,o,a){if(null==r)return{...o,zodErrors:null,strapiErrors:null,message:"Failed to Create Note. Related entity is missing.",severity:"error"};const n=s.safeParse({content:a.get("content")});if(!n.success)return{...o,zodErrors:n.error.flatten().fieldErrors,strapiErrors:null,message:null,severity:null};const{data:i}=n,l={data:{...i,related:r}};console.log(l.data.related);const c=await e.mutateData("POST","/api/notes",l);if(console.log("responseData",c),!c)return{...o,zodErrors:null,strapiErrors:null,message:"Ops! Something went wrong. Please try again.",severity:"error"};if(c.error)return{...o,zodErrors:null,strapiErrors:c.error,message:"Failed to Create Note.",severity:"error"};const u=t.flattenAttributes(c);return{...o,zodErrors:null,message:"New Note Created",severity:"success",data:u,strapiErrors:null}};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var
|
|
7
|
+
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.createReportAction=async function(s,a,o,i){const n={data:{...t.parseFormData(i).data,related:s,type:a}};console.dir(n,3),console.log(n.data.related);const l=await r.mutateData("POST","/api/reports",n);if(console.log("responseData",l),!l)return{...o,zodErrors:null,strapiErrors:null,message:"Ops! Something went wrong. Please try again.",severity:"error"};if(l.error)return{...o,zodErrors:null,strapiErrors:l.error,message:"Failed to Create Report.",severity:"error"};const u=e.flattenAttributes(l);return{...o,zodErrors:null,message:"New Report Created",severity:"success",data:u,strapiErrors:null}};
|