umwd-components 0.1.799 → 0.1.800
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/AddIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/opo/createOpoAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/ipo/createIPOAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/ipo/updateIpoAction.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +2 -2
- package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +2 -2
- package/dist/esm/src/components/logistics/ipo/AddIPOForm.js +0 -1
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +8 -5
- package/dist/esm/src/data/actions/e-commerce/opo/createOpoAction.js +0 -1
- package/dist/esm/src/data/actions/logistics/ipo/createIPOAction.js +0 -1
- package/dist/esm/src/data/actions/logistics/ipo/updateIpoAction.js +0 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),b=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),_=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js"),F=require("../../common/media/minio/UploadMinioMediaForm.js");const M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},z=["picked","packed","shipped","reports"];function B({open:r,handleClose:i,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",t]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{b.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function N({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:n,children:[e.jsx(p,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this order?"}),e.jsxs(_.List,{children:[e.jsx(_.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(_.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(_.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(_.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"outlined",onClick:n,children:"Close"}),e.jsx(x,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await C.cancellationService("opos",t,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),n()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:b}){const C=i.updateOpoAction.bind(null,d.documentId),[E,T]=r.useActionState(C,M),[U,P]=r.useState(d.opo_items?d.opo_items:[]),[L,R]=r.useState(!1),[W,G]=r.useState(!1),[H,J]=r.useState(["picked","packed","shipped","reports"]),Q=(e,r,i)=>{const n=[...U],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,P(n)},Y=(e,r)=>{const i=[...U],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,P(i)},$=(e,r)=>{const i=[...U],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"documentId"in e),s=t.filter(e=>!("documentId"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,P(i)},{handleAddMessage:K}=O.useSnackbar();return r.useEffect(()=>{E?.message&&(K({message:E.message,severity:E.severity||"error"}),"success"===E.severity&&(m&&m(),p&&p()))},[E?.message]),r.useEffect(()=>{E?.strapiErrors&&K({message:E.strapiErrors.message||"Error updating OPO",severity:E.severity||"error"})},[E?.strapiErrors]),r.useEffect(()=>{d.opo_items&&P(d.opo_items?d.opo_items:[])},[d]),e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Outbound Sales Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:d.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_number})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===b&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(B,{open:L,handleClose:()=>R(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(N,{open:W,handleClose:()=>G(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{t.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Minio Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(F.UploadMinioMediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"minio",multiple:!1,revalidateCallback:m})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(y,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),z.map(r=>e.jsx(_.FormControlLabel,{control:e.jsx(_.Checkbox,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:T,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(U))}),U&&U.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:Y,image:r?.product?.image,handleRemoveReportAtIndex:$,revalidateCallback:m,showing:H})},i)),e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),a=require("./TextualOpoItemUpdater.js"),s=require("./OpoItemDisplay.js"),o=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),p=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),x=require("@mui/material/Button"),j=require("@mui/material/Grid"),g=require("@mui/material/Box"),v=require("@mui/material/Paper"),y=require("@mui/material/Stack"),f=require("@mui/material/Divider"),b=require("../../../data/services/common/confirmation-service.js"),C=require("../../../data/services/common/cancellation-service.js"),_=require("@mui/material"),q=require("@mui/icons-material/Numbers"),I=require("@mui/icons-material/CalendarToday"),k=require("@mui/icons-material/Business"),w=require("@mui/icons-material/Description"),S=require("@mui/icons-material/Update"),D=require("./OpoStatusIndicator.js"),O=require("../../../context/common/SnackbarContext.js"),A=require("../../SubmitButton.js"),F=require("../../common/media/minio/UploadMinioMediaForm.js");const M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},z=["picked","packed","shipped","reports"];function B({open:r,handleClose:i,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(d,{open:r,onClose:i,children:[e.jsx(p,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this order?"}),e.jsxs(h,{children:["Current status: ",t]})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"contained",onClick:e=>{b.confirmationService("opos",[n]),a&&a(),i()},children:"Yes"}),e.jsx(x,{variant:"contained",onClick:i,children:"No"})]})]})}function N({open:i,handleClose:n,orderID:t,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:j}=O.useSnackbar();return e.jsxs(d,{open:i,onClose:n,children:[e.jsx(p,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this order?"}),e.jsxs(_.List,{children:[e.jsx(_.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(_.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(_.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(_.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(u,{children:[e.jsx(x,{variant:"outlined",onClick:n,children:"Close"}),e.jsx(x,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await C.cancellationService("opos",t,s),j({message:"Order cancelled successfully",severity:"success"}),a&&a(),n()}catch(e){j({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:d,sx:u,revalidateCallback:m,handleClose:p,role:b}){const C=i.updateOpoAction.bind(null,d.documentId),[E,T]=r.useActionState(C,M),[U,P]=r.useState(d.opo_items?d.opo_items:[]),[L,R]=r.useState(!1),[W,G]=r.useState(!1),[H,J]=r.useState(["picked","packed","shipped","reports"]),Q=(e,r,i)=>{const n=[...U],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,P(n)},Y=(e,r)=>{const i=[...U],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,P(i)},$=(e,r)=>{const i=[...U],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,P(i)},{handleAddMessage:K}=O.useSnackbar();return r.useEffect(()=>{E?.message&&(K({message:E.message,severity:E.severity||"error"}),"success"===E.severity&&(m&&m(),p&&p()))},[E?.message]),r.useEffect(()=>{E?.strapiErrors&&K({message:E.strapiErrors.message||"Error updating OPO",severity:E.severity||"error"})},[E?.strapiErrors]),r.useEffect(()=>{d.opo_items&&P(d.opo_items?d.opo_items:[])},[d]),e.jsx(g,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Outbound Sales Order"}),e.jsx(h,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(l.default,{content:"",related:[{id:d.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.opo_number})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.order_date})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(y,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(D.OpoStatusIndicator,{status:d.internal_status})]})]})})}),"enduser"===b&&e.jsx(j,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(y,{spacing:2,children:[("placed"===d.internal_status||"external_shipping_process"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(B,{open:L,handleClose:()=>R(!1),orderID:d.documentId,currentStatus:d.internal_status,revalidateCallback:m})]}),("placed"===d.internal_status||"ordered"===d.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"contained",color:"error",onClick:()=>G(!0),children:"Cancel order"}),e.jsx(N,{open:W,handleClose:()=>G(!1),orderID:d.documentId,revalidateCallback:m})]})]})})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(y,{spacing:1,children:d.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h6",children:"Delivery Note"}),e.jsx(h,{children:d.delivery_note?.name}),e.jsx(x,{variant:"contained",onClick:()=>{t.default(`api/opos/${d.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"h5",children:"Delivery Note"}),e.jsx(h,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(f,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Minio Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(F.UploadMinioMediaForm,{reference:"api::e-commerce.opo",refID:d.documentId,field:"minio",multiple:!1,revalidateCallback:m})})]})}),d?.notes?.length>0&&e.jsx(j,{size:12,children:e.jsxs(y,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(o.default,{notes:d.notes}),e.jsx(f,{})]})}),e.jsx(j,{size:12,children:e.jsxs(y,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(y,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),z.map(r=>e.jsx(_.FormControlLabel,{control:e.jsx(_.Checkbox,{size:"small",checked:H.includes(r),onChange:e=>{e.target.checked?J([...H,r]):J(H.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(f,{}),e.jsxs("form",{action:T,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(U))}),U&&U.map((r,i)=>e.jsx(v,{sx:{p:2,mb:2},children:"placed"===d.internal_status||"external_shipping_process"===d.internal_status||"done"===d.internal_status||"cancelled"===d.internal_status?e.jsx(s.default,{item:r,index:i,image:r?.product?.image}):e.jsx(a.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:Y,image:r?.product?.image,handleRemoveReportAtIndex:$,revalidateCallback:m,showing:H})},i)),e.jsxs(y,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[p&&e.jsx(x,{onClick:p,variant:"outlined",children:"Close"}),"placed"!==d.internal_status&&"external_shipping_process"!==d.internal_status&&"done"!==d.internal_status&&"cancelled"!==d.internal_status&&e.jsx(A.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportsDisplay.js"),u=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),p=require("@mui/material/Box");exports.default=function({item:x,index:h,handleAddReport:j,handleUpdateQuantity:y,image:g,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:f,product:w,ordered_quantity:v,picked_quantity:I,packed_quantity:k,shipped_quantity:A,reports:_}=x,[C,R]=r.useState(!1)
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportsDisplay.js"),u=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),p=require("@mui/material/Box");exports.default=function({item:x,index:h,handleAddReport:j,handleUpdateQuantity:y,image:g,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:f,product:w,ordered_quantity:v,picked_quantity:I,packed_quantity:k,shipped_quantity:A,reports:_}=x,[C,R]=r.useState(!1),D=Array.isArray(_)&&_.length>0?_.filter(e=>"picked"===e.type).reduce((e,r)=>e+r.quantity,0):0,P=Array.isArray(_)&&_.length>0?_.filter(e=>"packed"===e.type).reduce((e,r)=>e+r.quantity,0):0;Array.isArray(_)&&_.length>0&&_.filter(e=>"shipped"===e.type).reduce((e,r)=>e+r.quantity,0);const V=x.reports?.filter(e=>"id"in e)||[],T=x.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:x&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",f]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",w?.product_number]}),g&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:g,label:w?.title})})]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("picked")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(l.TextualAmountUpdater,{label:"Picked",currentValue:I,totalValue:v,minnewvalue:0,maxnewvalue:v+D,color:"info",handleChange:e=>{y(e,x.documentId,"picked_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("packed")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(l.TextualAmountUpdater,{label:"Packed",currentValue:k,totalValue:v+P,minnewvalue:0+A,maxnewvalue:I+P,color:"info",handleChange:e=>{y(e,x.documentId,"packed_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(p,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>R(!C),children:e.jsx(d,{})})]})}),e.jsx(s,{in:C,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:V}),e.jsx(u.default,{itemID:x.documentId,reports:T,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:x.documentId,content:"",type:"packed",minValue:-(I-k+P),handleAddReport:j})]})})]}),q&&q.includes("shipped")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(l.TextualAmountUpdater,{label:"Shipped",currentValue:A,totalValue:v+P,minnewvalue:0,maxnewvalue:k,color:"info",handleChange:e=>{y(e,x.documentId,"shipped_quantity")}})]})]})},h)};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/Box"),t=require("@mui/material/Stack"),
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material/Box"),t=require("@mui/material/Stack"),a=require("@mui/material/TextField"),s=require("@mui/material/Typography"),n=require("@mui/material/Divider"),o=require("@mui/material/Button"),d=require("@mui/material/Checkbox"),c=require("../../SubmitButton.js"),l=require("../../../data/actions/logistics/ipo/createIPOAction.js"),u=require("@mui/material/Grid"),m=require("../vendor/VendorSelector.js"),x=require("../../../data/loaders/logistics/getSingleVendor.js"),h=require("./IPOItemFields.js"),j=require("@mui/x-date-pickers/AdapterDayjs"),f=require("@mui/x-date-pickers/LocalizationProvider"),p=require("@mui/x-date-pickers/DatePicker"),v=require("../../../context/common/SnackbarContext.js");const g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.AddIPOForm=function({vendorNamesArr:y,sx:b,revalidateCallback:q,handleClose:k}){const[A,C]=r.useActionState(l.createIPOAction,g),[I,P]=r.useState([]),[S,z]=r.useState(null),{handleAddMessage:O}=v.useSnackbar();return r.useEffect(()=>{A?.message&&(O({message:A.message,severity:A.severity||"error"}),"success"===A.severity&&(q&&q(),k&&k()))},[A?.message]),r.useEffect(()=>{A?.strapiErrors&&O({message:A.strapiErrors.message||"Error performing action",severity:"error"})},[A?.strapiErrors]),e.jsx(i,{sx:[...Array.isArray(b)?b:[b]],children:e.jsx("form",{action:C,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{size:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(s,{variant:"h3",component:"h1",children:"Add IPO"}),e.jsx(s,{variant:"body1",children:"Create a new incoming purchase order"})]})}),e.jsx(u,{sx:{mt:1},size:{xs:12,md:6},children:y?e.jsx(m.default,{vendorNames:y,currentValue:null,onSelectVendor:async e=>{if(z(e),!e)return void P([]);const r=await x.getSingleVendor(e),i=r?.products.filter(e=>!e.product_number.startsWith("r"))||[];P(i)}}):e.jsx(s,{children:"No vendors on file, you need to create a vendor first before you are able to create incoming purchase orders"})}),e.jsx(u,{size:12,children:e.jsxs(t,{spacing:2,children:[e.jsx(s,{variant:"h5",children:"Order Details"}),e.jsx(s,{variant:"body1",children:"The orderdate should be the official date of the order, don't worry, you can also set days in the past or future"}),e.jsx(f.LocalizationProvider,{dateAdapter:j.AdapterDayjs,children:e.jsx(p.DatePicker,{name:"order_date",label:"Order Date"})}),e.jsx(s,{variant:"body1",children:"Please enter a custom reference for this order"}),e.jsx(a,{id:"customer_reference",name:"customer_reference",type:"text",label:"Custom Reference"}),e.jsx(n,{})]})}),e.jsx(u,{size:12,children:e.jsx(h.IPOItemFields,{productsArr:I,vendorID:S})}),e.jsxs(u,{size:12,children:[e.jsx(d,{name:"confirmation",defaultChecked:!0}),e.jsx(s,{variant:"body2",children:"I confirm that the information provided is accurate to the best of my knowledge and like to confirm immediately."})]}),e.jsx(u,{size:12,children:e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:2},children:[k&&e.jsx(o,{onClick:k,variant:"outlined",children:"Cancel"}),e.jsx(c.SubmitButton,{text:"Create IPO",loadingText:"Creating...",variant:"contained",disabled:null===S})]})})]})})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),c=require("./ItemDisplay.js"),d=require("./TextualIPOItemUpdater.js"),u=require("./IpoStatusIndicator.js"),m=require("@mui/material/Box"),h=require("@mui/material/Stack"),x=require("@mui/material/Paper"),p=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),g=require("@mui/material/DialogTitle"),v=require("@mui/material/Typography"),f=require("@mui/material/Button"),b=require("@mui/material/Grid"),_=require("@mui/material/Divider"),C=require("@mui/material/TextField"),I=require("@mui/material/List"),q=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),w=require("@mui/material/Checkbox"),S=require("@mui/material/FormControlLabel"),D=require("@mui/icons-material/Numbers"),N=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),M=require("@mui/icons-material/Business"),z=require("@mui/icons-material/Update"),A=require("../../SubmitButton.js"),E=require("../../common/media/minio/MinioDisplay.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function T({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(p,{open:r,onClose:n,children:[e.jsx(g,{children:"Confirm Order"}),e.jsx(y,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{children:"Are you sure you want to confirm this order?"}),e.jsxs(v,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(f,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function U({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(p,{open:n,onClose:t,children:[e.jsx(g,{children:"Cancel Return"}),e.jsx(y,{children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(q,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(q,{children:"Please provide a reason for the cancellation"}),e.jsx(q,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(f,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:t,sx:a,revalidateCallback:p,handleClose:j,role:y}){console.log("TextualManageIPOForm data",t);const[g,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:I}=i.useSnackbar(),[q,F]=r.useState(t.items?t.items:[]),[B,R]=r.useState(!1),[W,L]=r.useState(!1),[G,J]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{g?.message&&(I({message:g.message,severity:g.severity||"error"}),"success"===g.severity&&(p&&p(),j&&j()))},[g?.message]),r.useEffect(()=>{g?.strapiErrors&&I({message:g.strapiErrors.message||"Error updating IPO",severity:"error"})},[g?.strapiErrors]);const Q=(e,r,i)=>{const n=[...q],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...q],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,F(i)},K=(e,r)=>{const i=[...q],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,F(i)};return r.useEffect(()=>{"Ipo Updated"===g?.message&&(I({message:"Ipo Updated",severity:"success"}),j&&j(),p&&p())},[g]),r.useEffect(()=>{g?.strapiErrors&&I({message:g.strapiErrors.message||"Error updating IPO",severity:"error"})},[g?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&F(t.items?t.items:[])},[t]),e.jsx(m,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(b,{container:!0,spacing:2,children:[e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(v,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(o.default,{content:"",related:[{id:t.documentId,__type:"api::logistics.ipo"}],revalidateCallback:p})]}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsx(v,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(b,{size:6,children:e.jsx(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(N,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(M,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(v,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(z,{color:"primary"}),e.jsx(v,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===y&&e.jsx(b,{size:6,children:e.jsx(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(k,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(T,{open:B,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:p})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(U,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:p})]})]})})}),e.jsx(b,{size:12,children:e.jsx(v,{variant:"h5",children:"Documents"})}),"enduser"===y&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(E.MinioDisplay,{fileSize:t.minio_order_confirmation?.fileSize,mimeType:t.minio_order_confirmation?.mimeType,fileName:t.minio_order_confirmation?.fileName,bucketName:t.minio_order_confirmation?.bucketName,revalidateCallback:p})]})}):e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Order Confirmation"}),e.jsx(v,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,revalidateCallback:p})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(E.MinioDisplay,{fileSize:t.minio_delivery_note?.fileSize,mimeType:t.minio_delivery_note?.mimeType,fileName:t.minio_delivery_note?.fileName,bucketName:t.minio_delivery_note?.bucketName,revalidateCallback:p})]})}):e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h6",children:"Delivery Note"}),e.jsx(v,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,revalidateCallback:p})]})})}),t?.notes?.length>0&&e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(v,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(v,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:x,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(v,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(S,{control:e.jsx(w,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(v,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(k,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:C,children:[q&&q.map((r,i)=>e.jsx(x,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(c.default,{item:r,index:i,image:r?.product?.image}):e.jsx(d.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:p,showing:G})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[j&&e.jsx(f,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(A.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(q))})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("../../../context/common/SnackbarContext.js"),n=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../../data/services/common/confirmation-service.js"),a=require("../../../data/services/common/cancellation-service.js"),s=require("../../common/media/minio/UploadMinioMediaForm.js"),o=require("../note/NoteTakingComponent.js"),l=require("../note/NotesDisplay.js"),c=require("./ItemDisplay.js"),d=require("./TextualIPOItemUpdater.js"),u=require("./IpoStatusIndicator.js"),m=require("@mui/material/Box"),h=require("@mui/material/Stack"),x=require("@mui/material/Paper"),p=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),v=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),g=require("@mui/material/Typography"),f=require("@mui/material/Button"),b=require("@mui/material/Grid"),_=require("@mui/material/Divider"),C=require("@mui/material/TextField"),I=require("@mui/material/List"),q=require("@mui/material/ListItem"),k=require("@mui/material/Alert"),w=require("@mui/material/Checkbox"),S=require("@mui/material/FormControlLabel"),D=require("@mui/icons-material/Numbers"),N=require("@mui/icons-material/Description"),O=require("@mui/icons-material/CalendarToday"),M=require("@mui/icons-material/Business"),z=require("@mui/icons-material/Update"),A=require("../../SubmitButton.js"),E=require("../../common/media/minio/MinioDisplay.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function T({open:r,handleClose:n,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=i.useSnackbar();return e.jsxs(p,{open:r,onClose:n,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to confirm this order?"}),e.jsxs(g,{children:["Current status: ",s]}),e.jsx(k,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:n,children:"Cancel"}),e.jsx(f,{variant:"contained",color:"primary",onClick:async()=>{try{await t.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),n()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function U({open:n,handleClose:t,orderID:s,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=i.useSnackbar();return e.jsxs(p,{open:n,onClose:t,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(v,{children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(q,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(q,{children:"Please provide a reason for the cancellation"}),e.jsx(q,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(j,{children:[e.jsx(f,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(f,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await a.cancellationService("ipos",s,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),t()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:t,sx:a,revalidateCallback:p,handleClose:j,role:v}){console.log("TextualManageIPOForm data",t);const[y,C]=r.useActionState((e,r)=>n.updateIpoAction(t.documentId,e,r),P),{handleAddMessage:I}=i.useSnackbar(),[q,F]=r.useState(t.items?t.items:[]),[B,R]=r.useState(!1),[W,L]=r.useState(!1),[G,J]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(p&&p(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const Q=(e,r,i)=>{const n=[...q],t=n.findIndex(e=>e.documentId===r);n[t][i]=e,F(n)},H=(e,r)=>{const i=[...q],n=i.findIndex(e=>e.documentId===r),t=[...i[n]?.reports||[],e];null==i[n]?.reports&&(i[n]={...i[n],reports:[]}),i[n].reports=t,F(i)},K=(e,r)=>{const i=[...q],n=i.findIndex(r=>r.documentId===e),t=i[n]?.reports||[],a=t.filter(e=>"id"in e),s=t.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[n].reports=o,F(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),"success"===y.severity&&(p&&p(),j&&j()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",t),t.items&&F(t.items?t.items:[])},[t]),e.jsx(m,{sx:[...Array.isArray(a)?a:[a]],children:e.jsxs(b,{container:!0,spacing:2,children:[e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(g,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(o.default,{content:"",related:[{id:t.documentId,__type:"api::logistics.ipo"}],revalidateCallback:p})]}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(b,{size:6,children:e.jsx(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.ipo_number})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(N,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.customer_reference})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.order_date})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(M,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(g,{variant:"body1",fontWeight:"medium",children:t.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(h,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(z,{color:"primary"}),e.jsx(g,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(u.IpoStatusIndicator,{status:t.internal_status})]})]})})}),"enduser"===v&&e.jsx(b,{size:6,children:e.jsx(x,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(h,{spacing:2,children:[("placed"===t.internal_status||"released_on_stock"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Confirm order"}),e.jsx(k,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(T,{open:B,handleClose:()=>R(!1),orderID:t.documentId,currentStatus:t.internal_status,revalidateCallback:p})]}),("placed"===t.internal_status||"ordered"===t.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(f,{variant:"contained",color:"error",onClick:()=>L(!0),children:"Cancel order"}),e.jsx(U,{open:W,handleClose:()=>L(!1),orderID:t.documentId,revalidateCallback:p})]})]})})}),e.jsx(b,{size:12,children:e.jsx(g,{variant:"h5",children:"Documents"})}),"enduser"===v&&e.jsx(b,{size:6,children:t.minio_order_confirmation?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(E.MinioDisplay,{fileSize:t.minio_order_confirmation?.fileSize,mimeType:t.minio_order_confirmation?.mimeType,fileName:t.minio_order_confirmation?.fileName,bucketName:t.minio_order_confirmation?.bucketName,revalidateCallback:p})]})}):e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Order Confirmation"}),e.jsx(g,{variant:"body2",children:"Upload the order confirmation document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_order_confirmation",bucketName:"umwd",multiple:!1,revalidateCallback:p})]})})}),e.jsx(b,{size:6,children:t.minio_delivery_note?e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(E.MinioDisplay,{fileSize:t.minio_delivery_note?.fileSize,mimeType:t.minio_delivery_note?.mimeType,fileName:t.minio_delivery_note?.fileName,bucketName:t.minio_delivery_note?.bucketName,revalidateCallback:p})]})}):e.jsx(x,{sx:{p:2},children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h6",children:"Delivery Note"}),e.jsx(g,{variant:"body2",children:"Upload the delivery note document for this purchase order"}),e.jsx(s.UploadMinioMediaForm,{reference:"api::logistics.ipo",refID:t.documentId,field:"minio_delivery_note",bucketName:"umwd",multiple:!1,revalidateCallback:p})]})})}),t?.notes?.length>0&&e.jsx(b,{size:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(g,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:t.notes}),e.jsx(_,{})]})}),e.jsx(b,{size:12,children:e.jsxs(h,{spacing:1,children:[e.jsx(g,{variant:"h5",children:"Items"}),e.jsxs(h,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:x,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(g,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(S,{control:e.jsx(w,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(g,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===t.internal_status&&e.jsx(k,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:C,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(q))}),q&&q.map((r,i)=>e.jsx(x,{sx:{p:2,mb:2},children:"placed"===t.internal_status||"cancelled"===t.internal_status||"done"===t.internal_status?e.jsx(c.default,{item:r,index:i,image:r?.product?.image}):e.jsx(d.default,{item:r,index:i,handleUpdateQuantity:Q,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:p,showing:G})},i)),e.jsxs(h,{direction:"row",spacing:2,justifyContent:"space-between",children:[j&&e.jsx(f,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(A.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]})]})]})})]})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.createOpoAction=async function(s,a){Object.fromEntries(a);const
|
|
7
|
+
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.createOpoAction=async function(s,a){Object.fromEntries(a);const i=t.parseFormData(a),o=await r.mutateData("POST","/api/opos/createAdmin",i);if(!o)return{...s,severity:"error",strapiErrors:null,message:"Ops! Something went wrong. Please try again."};if(o.error)return{...s,severity:"error",strapiErrors:o.error,message:"Failed to Create Opo."};const n=e.flattenAttributes(o);return{...s,severity:"success",message:"Opo Created Successfully",data:n,strapiErrors:null}};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("../../../services/mutate-data.js"),r=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js"),a=require("../../../../../node_modules/dayjs/dayjs.min.js");exports.createIPOAction=async function(s,
|
|
7
|
+
"use strict";var e=require("../../../services/mutate-data.js"),r=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js"),a=require("../../../../../node_modules/dayjs/dayjs.min.js");exports.createIPOAction=async function(s,i){const o=t.parseFormData(i);if(!o.data.order_date)return{...s,severity:"error",strapiErrors:null,message:"Please select an Order Date."};const d={data:{vendor_profile:o.data.vendors,customer_reference:o.data.customer_reference,order_date:a.default(o.data.order_date).format("YYYY-MM-DD"),items:o.data.ipo_items,internal_status:o.data.confirmation?"ordered":"placed"}};if(0===JSON.parse(o.data.ipo_items).length)return{...s,severity:"error",strapiErrors:null,message:"Please add items to the IPO."};const n=await e.mutateData("POST","/api/ipos",d);if(!n)return{...s,severity:"error",strapiErrors:null,message:"Failed to create IPO. Please try again."};if(n.error)return{...s,severity:"error",strapiErrors:n.error,message:"Failed to create IPO."};const u=r.flattenAttributes(n);return{...s,severity:"success",message:"IPO Created Successfully",data:u,strapiErrors:null}};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.updateIpoAction=async function(s,a,i){const
|
|
7
|
+
"use strict";var r=require("../../../services/mutate-data.js"),e=require("../../../../lib/utils.js"),t=require("../../../../lib/parseFormData.js");exports.updateIpoAction=async function(s,a,i){const u=t.parseFormData(i),o=await r.mutateData("PUT",`/api/ipos/${s}`,u);if(!o)return{...a,severity:"error",strapiErrors:null,message:"Failed to update IPO. Please try again."};if(o.error)return{...a,severity:"error",strapiErrors:o.error,message:"Failed to update IPO."};const l=e.flattenAttributes(o);return{...a,severity:"success",message:"IPO Updated Successfully",data:l,strapiErrors:null}};
|