umwd-components 0.1.723 → 0.1.724
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/common/media/UploadBase64MediaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/EditStockForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/common/media/UploadBase64MediaForm.js +2 -2
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/CreateOpoForm.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +8 -6
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +6 -4
- package/dist/esm/src/components/e-commerce/products/EditStockForm.js +1 -1
- package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +2 -2
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +2 -2
- package/dist/esm/src/data/actions/e-commerce/opo/updateOpoAction.js +2 -2
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/data/actions/e-commerce/opo/updateOpoAction.d.ts +1 -1
- package/dist/esm/types/data/actions/media/uploadBase64MediaAction.d.ts +1 -1
- package/dist/esm/types/types/common/media/types.d.ts +1 -1
- package/dist/esm/types/types/logistics/Note.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/Box"),a=require("react-dom"),s=require("../../../data/actions/media/uploadBase64MediaAction.js"),l=require("../../StrapiErrors.js"),o=require("../../ZodErrors.js"),d=require("@mui/material/Alert"),u=require("../../SubmitButton.js");const c={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadBase64MediaForm=function({reference:p,refID:m
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/Box"),a=require("react-dom"),s=require("../../../data/actions/media/uploadBase64MediaAction.js"),l=require("../../StrapiErrors.js"),o=require("../../ZodErrors.js"),d=require("@mui/material/Alert"),u=require("../../SubmitButton.js");const c={zodErrors:null,strapiErrors:null,data:null,message:null};exports.UploadBase64MediaForm=function({reference:p,refID:m,field:x,multiple:j=!0,accept:h="image/*",path:f="api/ipos",componentName:y="",componentReference:g,revalidateCallback:b}){const[q,E]=r.useState(null),[v,S]=r.useState(null),k=s.uploadBase64MediaAction.bind(null,f,m||"",y),[w,C]=a.useFormState(k,c),B=r.useRef(null);return r.useEffect(()=>{w.data&&b&&b()},[w.data]),e.jsx("form",{action:C,id:x,children:e.jsx(n,{sx:[q&&q.length>0&&{border:"2px solid red",p:1}],children:e.jsxs(t,{spacing:1,sx:{flex:1},children:[p&&e.jsx("input",{type:"text",name:"ref",value:p,style:{display:"none"},readOnly:!0}),m&&e.jsx("input",{type:"text",name:"refId",value:m,style:{display:"none"},readOnly:!0})," ",x&&e.jsx("input",{type:"text",name:"field",value:x,style:{display:"none"},readOnly:!0}),e.jsx("input",{id:"component_name",type:"hidden",name:`${y}.__component`,value:g}),null!==q?e.jsx(n,{onClick:()=>B.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"},children:void 0===h||"image/*"===h?e.jsx(t,{direction:"row",spacing:1,justifyContent:"flex-end",children:q.map((r,t)=>e.jsx("img",{src:r.url,alt:r.name,style:{width:"100px"}},t))}):e.jsx(t,{spacing:1,justifyContent:"flex-end",children:q.map((r,t)=>e.jsx(i,{children:r.name},t))})}):e.jsx(n,{onClick:()=>B.current?.click(),sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px",cursor:"pointer"},children:e.jsxs(i,{children:["No file",""+(j?"s":"")," selected for upload"]})}),e.jsxs(t,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between",children:[e.jsx(l.StrapiErrors,{error:w.strapiErrors}),e.jsx(o.ZodErrors,{error:w.zodErrors?.image}),w?.message&&e.jsx(d,{severity:"error",children:w?.message}),e.jsxs(n,{children:[e.jsx("label",{htmlFor:"pictureInput",children:e.jsx("input",{id:"pictureInput",accept:h,multiple:j,type:"file",name:"files",ref:B,onChange:e=>{const r=e.target.files;if(null===r)return;const t=Object.keys(r).map((e,t)=>({url:URL.createObjectURL(r[t]),name:r[t].name}));S(r),E(t)},style:{display:"none"}})}),null!==v&&e.jsx(u.SubmitButton,{text:"upload",loadingText:"loading"})]})]})]})})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../context/common/SnackbarContext.js"),s=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),a=require("../../StrapiErrors.js"),n=require("../../SubmitButton.js"),o=require("@mui/material/Typography"),u=require("@mui/material/Grid"),l=require("@mui/material/Box"),d=require("@mui/material/TextField"),c=require("@mui/material/Checkbox"),m=require("@mui/material/Button"),h=require("@mui/material/Alert"),x=require("@mui/material/Stack"),p=require("@mui/material"),g=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),b=require("@mui/material/DialogContentText"),f=require("@mui/material/DialogTitle"),v=require("../../common/NumberInput.js");const q={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},_=({items:t,itemsToReturn:i,setItemsToReturn:s,selectedItems:a,setSelectedItems:n})=>{const[u,l]=r.useState(!1),m=(e,r,t)=>{s(i.map((i,s)=>s===e?{...i,[r]:t}:i))};r.useEffect(()=>{t&&s(t.map(e=>({line_item_number:e.line_item_number,product:e.product,ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[h,g]=r.useState([]);return r.useEffect(()=>{i&&g(i.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:"object"==typeof e.product&&"id"in e.product?e.product.id:0,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))},[i]),e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h6",children:"Items"}),e.jsx(o,{variant:"body1",children:"from the items in the original order please select the items you'd like to return"}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(h)}),e.jsx(x,{spacing:1,children:t.map((r,t)=>e.jsxs(e.Fragment,{children:[e.jsxs(x,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(c,{checked:a.includes(t),onChange:e=>{e.target.checked?n([...a,t]):n(a.filter(e=>e!==t))}}),e.jsxs(o,{variant:"body1",children:["Line Item Number: ",r.line_item_number]}),e.jsxs(o,{variant:"body1",children:["Part Number: ",r.product?.product_number]}),e.jsxs(o,{variant:"body1",children:["Quantity Ordered: ",r.ordered_quantity]})]}),a.includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs(x,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(v.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(p.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(o,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(d,{value:i[t]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;l("other"===r),m(t,"reason",r)},children:[e.jsx("option",{value:"damaged",children:"Damaged on arrival"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]})]}),u&&e.jsx(d,{value:i[t].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;m(t,"other_reason",r)}})]}),e.jsx(p.Divider,{})]}))})]})})},S=({open:t,onClose:i,items:s,formState:u,submitCallback:l})=>{const[d,x]=r.useState(!0);return e.jsxs(g,{open:t,onClose:i,children:[e.jsx(f,{children:"Confirm RMA"}),e.jsxs(y,{children:[e.jsx(b,{children:"Summary of items to be returned:"}),e.jsx(p.List,{children:s.map((r,t)=>e.jsxs(p.ListItem,{children:["object"==typeof r.product?`${r?.product?.product_number} ${r?.product?.title}`:`Product with ID ${r.product}`," ","- Quantity: ",r.returned_quantity]},t))}),e.jsx(b,{children:"Are you sure you want to request a return merchandise authorization for these items?"}),e.jsx(c,{onChange:e=>x(!e.target.checked)}),e.jsx(o,{variant:"body1",children:"I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration."})]}),e.jsxs(j,{children:[l?e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d,onClick:l}):e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d}),e.jsx(m,{onClick:i,children:"No"}),null!==u?.strapiErrors&&e.jsx(a.StrapiErrors,{error:u?.strapiErrors}),u?.message&&e.jsx(h,{severity:"error",children:u?.message})]})]})};exports.default=function({opo:n,sx:d,revalidateCallback:c,handleClose:p}){const[g,j]=t.useFormState(s.requestRmaAction,q),{handleAddMessage:y}=i.useSnackbar(),[b,f]=r.useState(!1),[v,C]=r.useState([]),[k,I]=r.useState([]);return r.useEffect(()=>{g?.message&&(y({message:g.message,severity:g.severity||"error"}),"success"===g.severity&&(c&&c(),p&&p()))},[g?.message]),r.useEffect(()=>{g?.strapiErrors&&y({message:g.strapiErrors.message||"Error requesting RMA",severity:g.severity||"error"})},[g?.strapiErrors]),e.jsx(l,{sx:[...Array.isArray(d)?d:[d]],children:e.jsx("form",{action:j,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{item:!0,xs:12,children:e.jsx(o,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:JSON.stringify([n.
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../context/common/SnackbarContext.js"),s=require("../../../data/actions/e-commerce/iro/requestRmaAction.js"),a=require("../../StrapiErrors.js"),n=require("../../SubmitButton.js"),o=require("@mui/material/Typography"),u=require("@mui/material/Grid"),l=require("@mui/material/Box"),d=require("@mui/material/TextField"),c=require("@mui/material/Checkbox"),m=require("@mui/material/Button"),h=require("@mui/material/Alert"),x=require("@mui/material/Stack"),p=require("@mui/material"),g=require("@mui/material/Dialog"),j=require("@mui/material/DialogActions"),y=require("@mui/material/DialogContent"),b=require("@mui/material/DialogContentText"),f=require("@mui/material/DialogTitle"),v=require("../../common/NumberInput.js");const q={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},_=({items:t,itemsToReturn:i,setItemsToReturn:s,selectedItems:a,setSelectedItems:n})=>{const[u,l]=r.useState(!1),m=(e,r,t)=>{s(i.map((i,s)=>s===e?{...i,[r]:t}:i))};r.useEffect(()=>{t&&s(t.map(e=>({line_item_number:e.line_item_number,product:e.product,ordered_quantity:e.ordered_quantity,returned_quantity:0,reason:"damaged",other_reason:""})))},[t]);const[h,g]=r.useState([]);return r.useEffect(()=>{i&&g(i.map((e,r)=>({line_item_number:`${r+1}.0.0`,product:"object"==typeof e.product&&"id"in e.product?e.product.id:0,returned_quantity:e.returned_quantity,reason:e.reason,other_reason:e.other_reason||""})))},[i]),e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"h6",children:"Items"}),e.jsx(o,{variant:"body1",children:"from the items in the original order please select the items you'd like to return"}),e.jsx("input",{type:"hidden",name:"iro_items",value:JSON.stringify(h)}),e.jsx(x,{spacing:1,children:t.map((r,t)=>e.jsxs(e.Fragment,{children:[e.jsxs(x,{spacing:1,direction:"row",alignItems:"center",children:[e.jsx(c,{checked:a.includes(t),onChange:e=>{e.target.checked?n([...a,t]):n(a.filter(e=>e!==t))}}),e.jsxs(o,{variant:"body1",children:["Line Item Number: ",r.line_item_number]}),e.jsxs(o,{variant:"body1",children:["Part Number: ",r.product?.product_number]}),e.jsxs(o,{variant:"body1",children:["Quantity Ordered: ",r.ordered_quantity]})]}),a.includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs(x,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(v.default,{label:"Quantity to return",minNewValue:0,maxNewValue:r.ordered_quantity,setValueCallback:e=>{m(t,"returned_quantity",e)},sx:{width:"12rem"}}),e.jsx(p.Divider,{orientation:"vertical",flexItem:!0}),e.jsx(o,{variant:"body1",sx:{width:"12rem"},children:"Reason for return:"}),e.jsxs(d,{value:i[t]?.reason,select:!0,SelectProps:{native:!0},variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;l("other"===r),m(t,"reason",r)},children:[e.jsx("option",{value:"damaged",children:"Damaged on arrival"}),e.jsx("option",{value:"not_as_described",children:"Not as described"}),e.jsx("option",{value:"wrong_item",children:"Wrong item"}),e.jsx("option",{value:"other",children:"Other"})]})]}),u&&e.jsx(d,{value:i[t].other_reason,label:"Custom reason",variant:"outlined",fullWidth:!0,onChange:e=>{const r=e.target.value;m(t,"other_reason",r)}})]}),e.jsx(p.Divider,{})]}))})]})})},S=({open:t,onClose:i,items:s,formState:u,submitCallback:l})=>{const[d,x]=r.useState(!0);return e.jsxs(g,{open:t,onClose:i,children:[e.jsx(f,{children:"Confirm RMA"}),e.jsxs(y,{children:[e.jsx(b,{children:"Summary of items to be returned:"}),e.jsx(p.List,{children:s.map((r,t)=>e.jsxs(p.ListItem,{children:["object"==typeof r.product?`${r?.product?.product_number} ${r?.product?.title}`:`Product with ID ${r.product}`," ","- Quantity: ",r.returned_quantity]},t))}),e.jsx(b,{children:"Are you sure you want to request a return merchandise authorization for these items?"}),e.jsx(c,{onChange:e=>x(!e.target.checked)}),e.jsx(o,{variant:"body1",children:"I confirm that the information I have provided is accurate and truthful. I understand that providing false or misleading information about the reason for returning goods may result in additional costs being charged to me. By checking this box, I acknowledge my legal responsibility for the accuracy of my declaration."})]}),e.jsxs(j,{children:[l?e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d,onClick:l}):e.jsx(n.SubmitButton,{text:"Yes",loadingText:"Loading...",disabled:d}),e.jsx(m,{onClick:i,children:"No"}),null!==u?.strapiErrors&&e.jsx(a.StrapiErrors,{error:u?.strapiErrors}),u?.message&&e.jsx(h,{severity:"error",children:u?.message})]})]})};exports.default=function({opo:n,sx:d,revalidateCallback:c,handleClose:p}){const[g,j]=t.useFormState(s.requestRmaAction,q),{handleAddMessage:y}=i.useSnackbar(),[b,f]=r.useState(!1),[v,C]=r.useState([]),[k,I]=r.useState([]);return r.useEffect(()=>{g?.message&&(y({message:g.message,severity:g.severity||"error"}),"success"===g.severity&&(c&&c(),p&&p()))},[g?.message]),r.useEffect(()=>{g?.strapiErrors&&y({message:g.strapiErrors.message||"Error requesting RMA",severity:g.severity||"error"})},[g?.strapiErrors]),e.jsx(l,{sx:[...Array.isArray(d)?d:[d]],children:e.jsx("form",{action:j,children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{item:!0,xs:12,children:e.jsx(o,{variant:"h6",children:"RMA Form"})}),e.jsx("input",{type:"hidden",name:"opos",value:JSON.stringify([n.documentId])}),e.jsx(u,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(o,{variant:"body1",children:"Please fill out the form below to request a return merchandise authorization. Due to the sensitive nature of the products, only unopened packages can be returned."}),e.jsx(h,{severity:"warning",children:"We urge you to carefully photograph the items you are returning. These pictures can be requested at a later time by our team to verify the condition of the items."})]})}),e.jsx(u,{item:!0,xs:12,children:n.opo_items?e.jsx(x,{spacing:1,children:n.opo_items&&e.jsx(_,{items:n.opo_items,itemsToReturn:v,setItemsToReturn:C,selectedItems:k,setSelectedItems:I})}):e.jsx(o,{variant:"body1",children:"No items"})}),e.jsx(S,{formState:g,open:b,items:v.filter(e=>e.returned_quantity>0),onClose:()=>f(!b),submitCallback:()=>{console.log("submit callback");const e=document.querySelector("form");j(e?new FormData(e):new FormData),f(!b)}}),e.jsxs(u,{item:!0,xs:12,children:[e.jsx(m,{onClick:()=>{console.log(g),f(!b)},disabled:0===k.length||0===k.reduce((e,r)=>e+v[r].returned_quantity,0),children:"Request RMA"}),null!==g?.strapiErrors&&e.jsx(a.StrapiErrors,{error:g?.strapiErrors}),g?.message&&e.jsx(h,{severity:"error",children:g?.message})]})]})})})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),s=require("react-dom"),i=require("../../../data/actions/e-commerce/opo/createOpoAction.js"),t=require("../../SubmitButton.js"),
|
|
7
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),s=require("react-dom"),i=require("../../../data/actions/e-commerce/opo/createOpoAction.js"),t=require("../../SubmitButton.js"),n=require("../customer/CustomerSelector.js"),a=require("./OPOItemFields.js"),o=require("../../../context/common/SnackbarContext.js"),c=require("@mui/material/Typography"),l=require("@mui/material/Grid"),u=require("@mui/material/Box"),d=require("@mui/material/TextField"),m=require("@mui/material/Checkbox"),h=require("@mui/material/Stack"),x=require("@mui/material/Button");const j={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({sx:p,revalidateCallback:f,handleClose:g,customerLabels:v,productLabels:y}){const[C,q]=r.useState(!1),[b,w]=s.useFormState(i.createOpoAction,j),{handleAddMessage:S}=o.useSnackbar();return r.useEffect(()=>{b?.message&&(S({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(f&&f(),g&&g()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&S({message:b.strapiErrors.message||"Error creating order",severity:b.severity||"error"})},[b?.strapiErrors]),e.jsx(u,{sx:[...Array.isArray(p)?p:[p]],children:e.jsx("form",{action:w,children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{item:!0,xs:12,children:e.jsx(h,{spacing:2,children:e.jsx(c,{variant:"h3",component:"h1",children:"Create new order"})})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Choose a customer"}),e.jsx(n.CustomerSelector,{customerLabels:v})]})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Customer reference"}),e.jsx(c,{children:"If the customer utilizes a custom reference for inbound order management it should be left here"}),e.jsx(d,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}})]})}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(c,{variant:"h6",children:"Choose products for this order"}),e.jsx(a.OPOItemFields,{productsArr:y})]}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(c,{variant:"h6",children:"Confirm Order"}),e.jsx(c,{children:"Are you sure you want to confirm this order? Creating a order this way will not create a shipping label nor will it invoke a payment. It does however create an invoice which you can find under invoices"}),e.jsxs(h,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(m,{value:C,checked:C,onChange:()=>q(!C)}),C&&e.jsx(c,{color:"primary",children:"I am sure I want to confirm this order"})]}),e.jsx("input",{name:"internal_status",type:"hidden",value:C?"ordered":"placed"})]}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{direction:"row",justifyContent:"space-between",children:[g&&e.jsx(x,{onClick:g,variant:"outlined",children:"Cancel"}),e.jsx(t.SubmitButton,{text:"Confirm",loadingText:"Loading...",variant:"contained"})]})})]})})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),m=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),j=require("@mui/material/Typography"),y=require("@mui/material/Button"),v=require("@mui/material/Grid"),g=require("@mui/material/Box"),f=require("@mui/material/Paper"),b=require("@mui/material/Stack"),_=require("@mui/material/Divider"),q=require("../../../data/services/common/confirmation-service.js"),C=require("../../../context/common/SnackbarContext.js");const w={zodErrors:null,strapiErrors:null,message:null};function k({open:i,handleClose:r,orderID:n,currentStatus:t,revalidateCallback:a}){return e.jsxs(m,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{children:"Are you sure you want to confirm this order?"}),e.jsxs(j,{children:["Current status: ",t]})]})}),e.jsxs(p,{children:[e.jsx(y,{variant:"contained",onClick:e=>{q.confirmationService("opos",[n]),a&&a()},children:"Confirm"}),e.jsx(y,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:m,sx:p,revalidateCallback:x,handleClose:h,role:q}){const[D,O]=r.useFormState((e,i)=>n.updateOpoAction(m.documentId,e,i),w),{handleAddMessage:I}=C.useSnackbar(),[S,E]=i.useState(m.opo_items?m.opo_items:[]),[A,B]=i.useState(!1),N=(e,i,r)=>{const n=[...S],t=n.findIndex(e=>e.id===i);n[t][r]=e,E(n)};return i.useEffect(()=>{m.opo_items&&E(m.opo_items)},[m]),i.useEffect(()=>{D?.message&&(I({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(x&&x(),h&&h()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&I({message:D.strapiErrors.message||"Error updating OPO",severity:D.severity||"error"})},[D?.strapiErrors]),e.jsx(g,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(v,{container:!0,spacing:2,children:[e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h3",component:"h1",children:"Manage Outbound Purchase Order"}),e.jsx(j,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:m.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:6,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Details"}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(j,{variant:"body2",children:m.opo_number})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(j,{variant:"body2",children:m.customer_reference})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(j,{variant:"body2",children:m.order_date})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Customer"}),e.jsx(j,{variant:"body2",children:m.customer?.business_credentials?.company_name})]}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(j,{variant:"body2",width:"250px",children:m.internal_status})]}),("placed"===m.internal_status||"external_shipping_process"===m.internal_status)&&"enduser"===q&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"contained",color:"primary",onClick:()=>B(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(k,{open:A,handleClose:()=>B(!1),orderID:m.documentId,currentStatus:m.internal_status,revalidateCallback:x})]})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Documents"}),e.jsx(f,{sx:{p:2},children:e.jsx(b,{spacing:1,children:m.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h6",children:"Delivery Note"}),e.jsx(j,{children:m.delivery_note?.name}),e.jsx(y,{variant:"contained",onClick:()=>{a.default(`api/opos/${m.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h5",children:"Delivery Note"}),e.jsx(j,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(t.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:m.documentId,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:x})]})})})]})}),m?.notes?.length>0&&e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:m.notes}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:12,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Items"}),"placed"===m.internal_status&&e.jsx(u,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:O,children:[e.jsx("input",{name:"id",type:"hidden",value:m.documentId}),S&&S.map((i,r)=>(console.log("item",i),e.jsx(f,{sx:{p:2,mb:2},children:"placed"===m.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:N,image:i?.product?.image,revalidateCallback:x})},r))),e.jsx(f,{sx:{p:2},children:e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(y,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(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("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),l=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),k=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("opos",n,s),d({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.id),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items?u.opo_items:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items&&R(u.opo_items?u.opo_items:[])},[u]);const Y=(e,r,i)=>{const t=[...L],n=t.findIndex(e=>e.id===r);t[n][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),n=i[t]?.reports||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.documentId,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.documentId,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/ipos/${u.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),u?.notes?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:u.notes}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),l=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),k=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("opos",n,s),d({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.documentId),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items?u.opo_items:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items&&R(u.opo_items?u.opo_items:[])},[u]);const Y=(e,r,i)=>{const t=[...L],n=t.findIndex(e=>e.id===r);t[n][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),n=i[t]?.reports||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.documentId,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.documentId,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.documentId,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/opos/${u.documentId}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.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})]})})})]})}),u?.notes?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:u.notes}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
@@ -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"),
|
|
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("react-dom"),d=require("../../../data/actions/e-commerce/product/updateProductAction.js"),c=require("@mui/material/Grid"),l=require("../../logistics/report/ReportsDisplay.js"),o=require("../../logistics/report/ReportMakingComponent.js"),u=require("../../../context/common/SnackbarContext.js"),x=require("@mui/material/Table"),m=require("@mui/material/TableBody"),j=require("@mui/material/TableCell"),h=require("@mui/material/TableContainer"),p=require("@mui/material/TableFooter"),y=require("@mui/material/TableHead"),q=require("@mui/material/TableRow"),g=require("@mui/material/Tooltip"),_=require("@mui/material/Button"),k=require("../../common/AmountIndicator.js");const v={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.EditStockForm=function({data:b,revalidateCallback:f,handleClose:T,sx:A}){const{id:I,title:C,product_number:S,stock:E,ipos:Q,opos:V,reports:O}=b,{handleAddMessage:R}=u.useSnackbar(),[F,N]=a.useFormState(d.updateProductAction,v);return r.useEffect(()=>{F?.message&&(R({message:F.message,severity:F.severity||"error"}),"success"===F.severity&&(f&&f(),T&&T()))},[F?.message,R,f,T]),r.useEffect(()=>{F?.strapiErrors&&R({message:F.strapiErrors.message||"Error updating stock",severity:"error"})},[F?.strapiErrors,R]),e.jsxs(t,{sx:[...Array.isArray(A)?A:[A]],children:[e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{item:!0,xs:12,children:e.jsx(s,{variant:"h6",children:C})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(h,{component:i,children:[e.jsx(s,{variant:"h6",sx:{pl:2},children:"Incoming orders"}),e.jsxs(x,{size:"small",children:[e.jsx(y,{children:e.jsxs(q,{children:[e.jsx(j,{children:"Number"}),e.jsx(j,{children:"Order Date"}),e.jsx(j,{children:"Line Item Number"}),e.jsx(j,{children:"Ordered Quantity"}),e.jsx(j,{children:"Received Quantity"}),e.jsx(j,{children:"Registered Quantity"}),e.jsx(j,{children:"Released Quantity"})]})}),e.jsx(m,{children:Q.map(r=>e.jsx(e.Fragment,{children:r.items.map(i=>e.jsxs(q,{children:[e.jsx(j,{children:r.ipo_number}),e.jsx(j,{children:r.order_date}),e.jsx(j,{children:i.line_item_number}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.ordered_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.received_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.registered_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.released_quantity,maxValue:i.ordered_quantity,color:"primary"})})]},r.id))}))}),e.jsx(p,{children:e.jsxs(q,{children:[e.jsx(j,{colSpan:6,align:"right",children:"Total added to stock:"}),e.jsx(j,{children:Q.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0)})]})})]}),e.jsx(s,{variant:"h6",sx:{pl:2},children:"Outgoing orders"}),e.jsxs(x,{size:"small",children:[e.jsx(y,{children:e.jsxs(q,{children:[e.jsx(j,{children:"Number"}),e.jsx(j,{children:"Order Date"}),e.jsx(j,{children:"Line Item Number"}),e.jsx(j,{children:"Ordered Quantity"}),e.jsx(j,{children:"Picked Quantity"}),e.jsx(j,{children:"Packed Quantity"}),e.jsx(j,{children:"Shipped Quantity"})]})}),e.jsx(m,{children:V.map(r=>e.jsx(e.Fragment,{children:r.opo_items.map(i=>e.jsxs(q,{children:[e.jsx(j,{children:r.opo_number}),e.jsx(j,{children:r.order_date}),e.jsx(j,{children:i.line_item_number}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.ordered_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.picked_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.packed_quantity,maxValue:i.ordered_quantity,color:"primary"})}),e.jsx(j,{children:e.jsx(k.AmountIndicator,{value:i.shipped_quantity,maxValue:i.ordered_quantity,color:"primary"})})]},r.documentId))}))}),e.jsx(p,{children:e.jsxs(q,{children:[e.jsx(j,{colSpan:3,align:"right",children:"Total reduced from stock:"}),e.jsx(j,{children:V.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0)})]})})]}),e.jsxs(x,{size:"small",children:[e.jsxs(q,{children:[e.jsx(j,{align:"right",children:"Total added to stock:"}),e.jsx(j,{children:Q.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0)})]}),e.jsxs(q,{children:[e.jsx(j,{align:"right",children:"Total reduced from stock:"}),e.jsx(j,{children:V.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0)})]}),e.jsxs(q,{children:[e.jsx(j,{align:"right",children:"Corrections:"}),e.jsx(j,{children:e.jsx(g,{title:"Total stock corrections",children:e.jsx(s,{children:O?O.reduce((e,r)=>e+r.quantity,0):0})})}),e.jsx(j,{children:e.jsx(g,{title:"Total stock corrections after updating",children:e.jsx("b",{children:O?O.reduce((e,r)=>e+r.quantity,0):0})})})]}),e.jsxs(q,{children:[e.jsx(j,{align:"right",children:"Stock:"}),e.jsx(j,{children:e.jsx(g,{title:"Total stock",children:e.jsx(s,{children:Q.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0)-V.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0)+(O?O.reduce((e,r)=>e+r.quantity,0):0)})})}),e.jsx(j,{children:e.jsx(g,{title:"Total stock after updating",children:e.jsx("b",{children:Q.reduce((e,r)=>e+r.items.reduce((e,r)=>e+r.released_quantity,0),0)-V.reduce((e,r)=>e+r.opo_items.reduce((e,r)=>e+r.ordered_quantity,0),0)+(O?O.reduce((e,r)=>e+r.quantity,0):0)})})})]})]})]})})]}),e.jsxs("form",{action:N,children:[I&&e.jsx("input",{id:"id",type:"hidden",name:"id",value:I}),e.jsx("input",{id:"stock_reports",type:"hidden",name:"stock_reports",value:JSON.stringify(O)}),e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{item:!0,xs: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(l.default,{reports:O}),e.jsx(n,{direction:"row",justifyContent:"flex-end",children:e.jsx(o.default,{content:"content",quantity:0,type:"stock",related:[{id:I,__type:"api::e-commerce.product"}],revalidateCallback:f,biggerButton:!0})})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsx(n,{direction:"row",justifyContent:"flex-end",alignItems:"center",sx:{py:1},children:T&&e.jsx(_,{onClick:T,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"),i=require("react"),r=require("react-dom"),n=require("../../../context/common/SnackbarContext.js"),a=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),s=require("../../../data/loaders/common/media/downloadBase64File.js"),o=require("./IPOItemUpdater.js"),d=require("./ItemDisplay.js"),c=require("../note/NotesDisplay.js"),l=require("../note/NoteTakingComponent.js"),m=require("../../SubmitButton.js"),p=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),x=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),j=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),f=require("@mui/material/Typography"),g=require("@mui/material/Button"),y=require("@mui/material/Grid"),b=require("@mui/material/Box"),_=require("@mui/material/Paper"),q=require("@mui/material/Stack"),C=require("@mui/material/Divider");const w={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(x,{open:i,children:[e.jsx(v,{children:"Confirm Order"}),e.jsx(j,{children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{children:"Are you sure you want to confirm this order?"}),e.jsxs(f,{children:["Current status: ",a]})]})}),e.jsxs(h,{children:[e.jsx(g,{variant:"contained",onClick:e=>{p.confirmationService("ipos",[n]),t&&t(),r()},children:"Confirm"}),e.jsx(g,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:p,sx:x,revalidateCallback:h,handleClose:j,role:v}){const[D,I]=r.useFormState((e,i)=>a.updateIpoAction(p.id,e,i),w),{handleAddMessage:S}=n.useSnackbar(),[O,U]=i.useState(p.items?p.items:[]),[N,A]=i.useState(!1);i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(h&&h(),j&&j()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error performing action",severity:"error"})},[D?.strapiErrors]);const B=(e,i,r)=>{const n=[...O],a=n.findIndex(e=>e.id===i);n[a][r]=e,U(n)};return e.jsx(b,{sx:[...Array.isArray(x)?x:[x]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsxs(q,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(f,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(l.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:6,children:e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h5",children:"Details"}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(f,{variant:"body2",children:p.ipo_number})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(f,{variant:"body2",children:p.customer_reference})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(f,{variant:"body2",children:p.order_date})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(f,{variant:"body2",children:p.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(f,{variant:"body2",width:"250px",children:p.internal_status})]}),("placed"===p.internal_status||"released_on_stock"===p.internal_status)&&"enduser"===v&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"contained",color:"primary",onClick:()=>A(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher."}),e.jsx(k,{open:N,handleClose:()=>A(!1),orderID:p.documentId,currentStatus:p.internal_status,revalidateCallback:h})]})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Documents"}),e.jsx(_,{sx:{p:2},children:e.jsxs(q,{spacing:1,children:["enduser"===v&&e.jsx(e.Fragment,{children:p.order_confirmation?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{children:p.order_confirmation?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../context/common/SnackbarContext.js"),a=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),t=require("../../common/media/UploadBase64MediaForm.js"),s=require("../../../data/loaders/common/media/downloadBase64File.js"),o=require("./IPOItemUpdater.js"),d=require("./ItemDisplay.js"),c=require("../note/NotesDisplay.js"),l=require("../note/NoteTakingComponent.js"),m=require("../../SubmitButton.js"),p=require("../../../data/services/common/confirmation-service.js"),u=require("@mui/material/Alert"),x=require("@mui/material/Dialog"),h=require("@mui/material/DialogActions"),j=require("@mui/material/DialogContent"),v=require("@mui/material/DialogTitle"),f=require("@mui/material/Typography"),g=require("@mui/material/Button"),y=require("@mui/material/Grid"),b=require("@mui/material/Box"),_=require("@mui/material/Paper"),q=require("@mui/material/Stack"),C=require("@mui/material/Divider");const w={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(x,{open:i,children:[e.jsx(v,{children:"Confirm Order"}),e.jsx(j,{children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{children:"Are you sure you want to confirm this order?"}),e.jsxs(f,{children:["Current status: ",a]})]})}),e.jsxs(h,{children:[e.jsx(g,{variant:"contained",onClick:e=>{p.confirmationService("ipos",[n]),t&&t(),r()},children:"Confirm"}),e.jsx(g,{variant:"outlined",onClick:r,children:"Cancel"})]})]})}exports.default=function({data:p,sx:x,revalidateCallback:h,handleClose:j,role:v}){const[D,I]=r.useFormState((e,i)=>a.updateIpoAction(p.id,e,i),w),{handleAddMessage:S}=n.useSnackbar(),[O,U]=i.useState(p.items?p.items:[]),[N,A]=i.useState(!1);i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(h&&h(),j&&j()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error performing action",severity:"error"})},[D?.strapiErrors]);const B=(e,i,r)=>{const n=[...O],a=n.findIndex(e=>e.id===i);n[a][r]=e,U(n)};return e.jsx(b,{sx:[...Array.isArray(x)?x:[x]],children:e.jsxs(y,{container:!0,spacing:2,children:[e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsxs(q,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h3",component:"h1",children:"Manage Inbound Purchase Order"}),e.jsx(f,{variant:"body1",children:"Update the incoming purchase order details"})]}),e.jsx(l.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:h})]}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:6,children:e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h5",children:"Details"}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(f,{variant:"body2",children:p.ipo_number})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Custom reference"}),e.jsx(f,{variant:"body2",children:p.customer_reference})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(f,{variant:"body2",children:p.order_date})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Supplier"}),e.jsx(f,{variant:"body2",children:p.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(q,{direction:"row",spacing:2,children:[e.jsx(f,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(f,{variant:"body2",width:"250px",children:p.internal_status})]}),("placed"===p.internal_status||"released_on_stock"===p.internal_status)&&"enduser"===v&&e.jsxs(e.Fragment,{children:[e.jsx(g,{variant:"contained",color:"primary",onClick:()=>A(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible. Only upon confirmation will this order be available to the dispatcher."}),e.jsx(k,{open:N,handleClose:()=>A(!1),orderID:p.documentId,currentStatus:p.internal_status,revalidateCallback:h})]})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Documents"}),e.jsx(_,{sx:{p:2},children:e.jsxs(q,{spacing:1,children:["enduser"===v&&e.jsx(e.Fragment,{children:p.order_confirmation?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{children:p.order_confirmation?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.documentId,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})}),p.delivery_note?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{children:p.delivery_note?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{variant:"body1",children:"Upload the delivery note for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.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:h})]})]})})]})}),p?.notes?.length>0&&e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:p.notes}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Items"}),"placed"===p.internal_status&&e.jsx(u,{severity:"warning",children:"Items cannot be updated before order confirmation"}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(O))}),e.jsxs(q,{spacing:2,children:[p?.items&&p.items.map((i,r)=>e.jsx(_,{sx:{p:2},children:"placed"===p.internal_status?e.jsx(d.default,{item:i,index:r,image:i?.product?.image}):e.jsx(o.default,{item:i,index:r,handleUpdateQuantity:B,image:i?.product?.image,revalidateCallback:h})},r)),"placed"!==p.internal_status&&e.jsx(_,{sx:{p:2},children:e.jsxs(q,{direction:"row",justifyContent:"flex-end",spacing:2,children:[j&&e.jsx(g,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Update Items",loadingText:"Updating...",variant:"contained"})]})})]})]})]})})]})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../context/common/SnackbarContext.js"),a=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),l=require("../../common/media/UploadBase64MediaForm.js"),c=require("../note/NoteTakingComponent.js"),d=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),_=require("@mui/material/Divider"),w=require("@mui/material/TextField"),I=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=t.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:a,orderID:n,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=t.useSnackbar();return e.jsxs(g,{open:i,onClose:a,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(I,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(w,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:a,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),a()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,w]=i.useFormState((e,r)=>a.updateIpoAction(n.id,e,r),N),{handleAddMessage:I}=t.useSnackbar(),[k,R]=r.useState(n.items?n.items:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(I({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const t=[...k],a=t.findIndex(e=>e.id===r);t[a][i]=e,R(t)},Q=(e,r)=>{const i=[...k],t=i.findIndex(e=>e.id===r),a=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=a,R(i)},K=(e,r)=>{const i=[...k],t=i.findIndex(r=>r.id===e),a=i[t]?.reports||[],n=a.filter(e=>"id"in e),s=a.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[t].reports=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(I({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&I({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items&&R(n.items?n.items:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.internal_status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.internal_status||"released_on_stock"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.documentId,currentStatus:n.internal_status,revalidateCallback:g})]}),("placed"===n.internal_status||"ordered"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.documentId,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})]})})]})}),n?.notes?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:n.notes}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:w,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.internal_status||"cancelled"===n.internal_status||"done"===n.internal_status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../context/common/SnackbarContext.js"),a=require("../../../data/actions/logistics/ipo/updateIpoAction.js"),n=require("../../../data/services/common/confirmation-service.js"),s=require("../../../data/services/common/cancellation-service.js"),o=require("../../../data/loaders/common/media/downloadBase64File.js"),l=require("../../common/media/UploadBase64MediaForm.js"),c=require("../note/NoteTakingComponent.js"),d=require("../note/NotesDisplay.js"),u=require("./ItemDisplay.js"),m=require("./TextualIPOItemUpdater.js"),p=require("./IpoStatusIndicator.js"),h=require("@mui/material/Box"),x=require("@mui/material/Stack"),j=require("@mui/material/Paper"),g=require("@mui/material/Dialog"),v=require("@mui/material/DialogActions"),f=require("@mui/material/DialogContent"),y=require("@mui/material/DialogTitle"),b=require("@mui/material/Typography"),C=require("@mui/material/Button"),q=require("@mui/material/Grid"),_=require("@mui/material/Divider"),I=require("@mui/material/TextField"),w=require("@mui/material/List"),k=require("@mui/material/ListItem"),S=require("@mui/material/Alert"),D=require("@mui/material/Checkbox"),F=require("@mui/material/FormControlLabel"),O=require("@mui/icons-material/Numbers"),E=require("@mui/icons-material/Description"),A=require("@mui/icons-material/CalendarToday"),P=require("@mui/icons-material/Business"),B=require("@mui/icons-material/Update"),U=require("../../SubmitButton.js");const N={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M({open:r,handleClose:i,orderID:a,currentStatus:s,revalidateCallback:o}){const{handleAddMessage:l}=t.useSnackbar();return e.jsxs(g,{open:r,onClose:i,children:[e.jsx(y,{children:"Confirm Order"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to confirm this order?"}),e.jsxs(b,{children:["Current status: ",s]}),e.jsx(S,{severity:"info",children:"Once confirmed, the order will be available for processing."})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"contained",color:"primary",onClick:async()=>{try{await n.confirmationService("ipos",[a]),l({message:"IPO confirmed successfully",severity:"success"}),o&&o(),i()}catch(e){l({message:"Failed to confirm IPO",severity:"error"})}},children:"Confirm Order"})]})]})}function T({open:i,handleClose:a,orderID:n,revalidateCallback:o}){const[l,c]=r.useState(""),[d,u]=r.useState(""),{handleAddMessage:m}=t.useSnackbar();return e.jsxs(g,{open:i,onClose:a,children:[e.jsx(y,{children:"Cancel Return"}),e.jsx(f,{children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{children:"Are you sure you want to cancel this return?"}),e.jsxs(w,{children:[e.jsx(k,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(k,{children:"Please provide a reason for the cancellation"}),e.jsx(k,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(I,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:l,onChange:e=>c(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!d,helperText:d})]})}),e.jsxs(v,{children:[e.jsx(C,{variant:"outlined",onClick:a,children:"Close"}),e.jsx(C,{variant:"contained",color:"error",onClick:async()=>{if(l.length<5)u("Please provide a reason for the cancellation (min 5 characters)");else try{await s.cancellationService("ipos",n,l),m({message:"Order cancelled successfully",severity:"success"}),o&&o(),a()}catch(e){m({message:"Failed to cancel order",severity:"error"})}},children:"Confirm Cancellation"})]})]})}exports.default=function({data:n,sx:s,revalidateCallback:g,handleClose:v,role:f}){const[y,I]=i.useFormState((e,r)=>a.updateIpoAction(n.id,e,r),N),{handleAddMessage:w}=t.useSnackbar(),[k,R]=r.useState(n.items?n.items:[]),[W,L]=r.useState(!1),[z,H]=r.useState(!1),[$,G]=r.useState(["received","registered","released","reports"]);r.useEffect(()=>{y?.message&&(w({message:y.message,severity:y.severity||"error"}),"success"===y.severity&&(g&&g(),v&&v()))},[y?.message]),r.useEffect(()=>{y?.strapiErrors&&w({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]);const J=(e,r,i)=>{const t=[...k],a=t.findIndex(e=>e.id===r);t[a][i]=e,R(t)},Q=(e,r)=>{const i=[...k],t=i.findIndex(e=>e.id===r),a=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=a,R(i)},K=(e,r)=>{const i=[...k],t=i.findIndex(r=>r.id===e),a=i[t]?.reports||[],n=a.filter(e=>"id"in e),s=a.filter(e=>!("id"in e));s.splice(r,1);const o=[...n,...s];i[t].reports=o,R(i)};return r.useEffect(()=>{"Ipo Updated"===y?.message&&(w({message:"Ipo Updated",severity:"success"}),v&&v(),g&&g())},[y]),r.useEffect(()=>{y?.strapiErrors&&w({message:y.strapiErrors.message||"Error updating IPO",severity:"error"})},[y?.strapiErrors]),r.useEffect(()=>{console.log("data",n),n.items&&R(n.items?n.items:[])},[n]),e.jsx(h,{sx:[...Array.isArray(s)?s:[s]],children:e.jsxs(q,{container:!0,spacing:2,children:[e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(b,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:n.id,__type:"api::logistics.ipo"}],revalidateCallback:g})]}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsx(b,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(O,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.ipo_number})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(E,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom Reference"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.customer_reference})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(A,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.order_date})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(P,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Supplier"}),e.jsx(b,{variant:"body1",fontWeight:"medium",children:n.vendor_profile?.business_credentials?.company_name})]}),e.jsxs(x,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(B,{color:"primary"}),e.jsx(b,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(p.IpoStatusIndicator,{status:n.internal_status})]})]})})}),"enduser"===f&&e.jsx(q,{item:!0,xs:6,children:e.jsx(j,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(x,{spacing:2,children:[("placed"===n.internal_status||"released_on_stock"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),e.jsx(S,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(M,{open:W,handleClose:()=>L(!1),orderID:n.documentId,currentStatus:n.internal_status,revalidateCallback:g})]}),("placed"===n.internal_status||"ordered"===n.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(T,{open:z,handleClose:()=>H(!1),orderID:n.documentId,revalidateCallback:g})]})]})})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Documents"}),e.jsx(j,{sx:{p:2},children:e.jsxs(x,{spacing:1,children:["enduser"===f&&e.jsx(e.Fragment,{children:n.order_confirmation?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Order Confirmation"}),e.jsx(b,{children:n.order_confirmation?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Order Confirmation"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the order confirmation for this order"}),e.jsx(b,{variant:"body1",children:"FileUpload"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.documentId,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:g})]})}),n.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h6",children:"Delivery Note"}),e.jsx(b,{children:n.delivery_note?.name}),e.jsx(C,{variant:"contained",onClick:()=>{o.default(`api/ipos/${n.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"h5",children:"Delivery Note"}),e.jsx(b,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(l.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:n.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:g})]})]})})]})}),n?.notes?.length>0&&e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:2,children:[e.jsx(b,{variant:"h5",children:"Notes"}),e.jsx(d.default,{notes:n.notes}),e.jsx(_,{})]})}),e.jsx(q,{item:!0,xs:12,children:e.jsxs(x,{spacing:1,children:[e.jsx(b,{variant:"h5",children:"Items"}),e.jsxs(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:j,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(b,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(F,{control:e.jsx(D,{size:"small",checked:$.includes(r),onChange:e=>{e.target.checked?G([...$,r]):G($.filter(e=>e!==r))}}),label:e.jsx(b,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"placed"===n.internal_status&&e.jsx(S,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:n.id}),k&&k.map((r,i)=>e.jsx(j,{sx:{p:2,mb:2},children:"placed"===n.internal_status||"cancelled"===n.internal_status||"done"===n.internal_status?e.jsx(u.default,{item:r,index:i,image:r?.product?.image}):e.jsx(m.default,{item:r,index:i,handleUpdateQuantity:J,handleAddReport:Q,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:g,showing:$})},i)),e.jsxs(x,{direction:"row",spacing:2,justifyContent:"space-between",children:[v&&e.jsx(C,{onClick:v,variant:"outlined",children:"Cancel"}),e.jsx(U.SubmitButton,{variant:"contained",text:"Update items",loadingText:"Loading..."})]}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(k))})]})]})})]})})};
|