umwd-components 0.1.721 → 0.1.722
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/components/e-commerce/iro/IroItemDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoItemDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoSummary.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/data/loaders/e-commerce/getAllOpos.js +1 -1
- package/dist/cjs/src/data/loaders/e-commerce-loaders.js +1 -1
- package/dist/cjs/src/lib/isEORIValid.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/e-commerce/iro/IroItemDisplay.js +1 -1
- package/dist/esm/src/components/e-commerce/iro/IroItemUpdater.js +5 -5
- package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +3 -3
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +8 -8
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +14 -14
- package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +4 -4
- package/dist/esm/src/components/e-commerce/opo/OpoItemDisplay.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/OpoItemUpdater.js +8 -7
- package/dist/esm/src/components/e-commerce/opo/OpoSummary.js +2 -2
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +10 -10
- package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +8 -8
- package/dist/esm/src/components/logistics/ipo/IPOItemUpdater.js +5 -5
- package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +3 -3
- package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +8 -8
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +10 -10
- package/dist/esm/src/data/loaders/e-commerce/getAllOpos.js +1 -1
- package/dist/esm/src/data/loaders/e-commerce-loaders.js +0 -1
- package/dist/esm/src/lib/isEORIValid.js +0 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/data/services/archive-service.d.ts +2 -2
- package/dist/esm/types/types/e-commerce/iro/types.d.ts +3 -9
- package/dist/esm/types/types/e-commerce/opo/types.d.ts +3 -9
- package/dist/esm/types/types/logistics/Ipo.d.ts +3 -9
- package/package.json +1 -1
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("../../common/ImagePreviewTooltip.js"),t=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:s,index:a,image:c}){const{line_item_number:d,product:o,returned_quantity:l,received_quantity:h,registered_quantity:j,released_quantity:p,reports:x,reason:u,other_reason:g}=s;return e.jsxs(r,{spacing:1,children:[s&&e.jsxs(r,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsxs(r,{spacing:1,sx:{width:"100%"},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",d]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",o?.product_number]})]}),e.jsxs(r,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Reason: ",u]}),void 0!==g&&e.jsx(i,{variant:"body1",children:g})]}),c&&e.jsx(e.Fragment,{children:e.jsx(n.default,{image:c,label:s.product?.title})})]}),e.jsxs(r,{direction:"row",spacing:1,justifyContent:"space-between",alignItems:"center",children:[e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Ordered"}),e.jsx(i,{variant:"h6",children:l})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Received"}),e.jsx(i,{variant:"h6",children:h})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Registered"}),e.jsx(i,{variant:"h6",children:j})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Released"}),e.jsx(i,{variant:"h6",children:p})]})]}),x?.
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("../../common/ImagePreviewTooltip.js"),t=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:s,index:a,image:c}){const{line_item_number:d,product:o,returned_quantity:l,received_quantity:h,registered_quantity:j,released_quantity:p,reports:x,reason:u,other_reason:g}=s;return e.jsxs(r,{spacing:1,children:[s&&e.jsxs(r,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsxs(r,{spacing:1,sx:{width:"100%"},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",d]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",o?.product_number]})]}),e.jsxs(r,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Reason: ",u]}),void 0!==g&&e.jsx(i,{variant:"body1",children:g})]}),c&&e.jsx(e.Fragment,{children:e.jsx(n.default,{image:c,label:s.product?.title})})]}),e.jsxs(r,{direction:"row",spacing:1,justifyContent:"space-between",alignItems:"center",children:[e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Ordered"}),e.jsx(i,{variant:"h6",children:l})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Received"}),e.jsx(i,{variant:"h6",children:h})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Registered"}),e.jsx(i,{variant:"h6",children:j})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"caption",children:"Released"}),e.jsx(i,{variant:"h6",children:p})]})]}),x?.length>0&&e.jsxs(r,{spacing:1,children:[e.jsx(i,{variant:"body1",children:"Reports:"}),e.jsx(t.default,{reports:x.filter(e=>"id"in e&&!("pre_report"in e))})]})]},a)};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),l=require("../../common/AmountUpdater.js"),s=require("@mui/icons-material/ArrowDropDown"),d=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportMakingComponent.js"),c=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:q,registered_quantity:v,released_quantity:b,returned_quantity:f,reports:_,reason:V,other_reason:w}=m,C=void 0!==_&&_.length>0?_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,N=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[k,R]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g&&g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(d.default,{image:j,label:g&&g.title})})]}),e.jsx(i,{variant:"body1",children:"Reason"}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.AmountUpdater,{currentValue:q,totalValue:f+C,minNewValue:0+v+-N,maxNewValue:f+C,color:"info",handleChange:e=>{x(e,m.id,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.AmountUpdater,{currentValue:v,totalValue:f+C,minNewValue:0+b,maxNewValue:q+N,color:"info",handleChange:e=>{x(e,m.id,"registered_quantity")},offsetEnd:N}),e.jsx(n,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>R(!k),children:e.jsx(s,{})})]})}),e.jsx(o,{in:k,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:_}),e.jsx(u.default,{content:"content",quantity:0,type:"registered",minValue:-(q+N),maxValue:q,related:[{id:m.id,__type:"api::e-commerce.iro-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.AmountUpdater,{currentValue:b||0,totalValue:f+C+N,minNewValue:0,maxNewValue:v,color:"info",handleChange:e=>{x(e,m.id,"released_quantity")}})]})},p)};
|
|
@@ -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/iro/updateIroAction.js"),
|
|
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/iro/updateIroAction.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),n=require("../../StrapiErrors.js"),d=require("../../SubmitButton.js"),l=require("@mui/material/Alert");require("@mui/material/Dialog"),require("@mui/material/DialogActions"),require("@mui/material/DialogContent"),require("@mui/material/DialogTitle");var o=require("@mui/material/Typography");require("@mui/material/Button");var c=require("@mui/material/Grid"),u=require("@mui/material/Box"),x=require("@mui/material/Paper"),m=require("@mui/material/Stack"),h=require("@mui/material/Divider");require("next/headers");const j={zodErrors:null,strapiErrors:null,data:null,message:null};exports.default=function({data:p,sx:g,revalidateCallback:v,handleClose:y,role:q}){const[b,_]=i.useFormState(t.updateIroAction,j),[w,f]=r.useState(p.iro_items?p.iro_items:[]),[S,D]=r.useState(!1);return e.jsx(u,{sx:[...Array.isArray(g)?g:[g]],children:e.jsxs(c,{container:!0,spacing:2,children:[e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsxs(m,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(m,{spacing:2,children:[e.jsx(o,{variant:"h3",component:"h1",children:"Management Inbound Purchase Order"}),e.jsx(o,{variant:"body1",children:"Manage arrival, registration and recieval of purchase order"})]}),e.jsx(a.default,{content:"",related:[{id:p.id,__type:"api::logistics.ipo"}],revalidateCallback:v})]}),e.jsx(h,{})]})}),e.jsx(c,{item:!0,xs:6,children:e.jsxs(m,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Details"}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(o,{variant:"body2",children:p.return_number})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Custom reference"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Date"}),e.jsx(o,{variant:"body2",children:p.return_date})]}),e.jsx(m,{direction:"row",spacing:2,children:e.jsx(o,{variant:"body1",width:"250px",children:"Supplier"})}),e.jsxs(m,{direction:"row",spacing:2,children:[e.jsx(o,{variant:"body1",width:"250px",children:"Order Status"}),e.jsx(o,{variant:"body2",width:"250px",children:p.internal_status})]})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Documents"}),e.jsx(x,{sx:{p:2},children:e.jsx(m,{spacing:1,children:"enduser"===q&&e.jsx(e.Fragment,{})})})]})}),p?.notes?.length>0&&e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:2,children:[e.jsx(o,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:p.notes}),e.jsx(h,{})]})}),e.jsx(c,{item:!0,xs:12,children:e.jsxs(m,{spacing:1,children:[e.jsx(o,{variant:"h5",children:"Items"}),e.jsx(h,{}),e.jsxs("form",{action:_,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),p?.iro_items&&p.iro_items.map((r,i)=>(console.log("item",r),e.jsx(x,{sx:{p:2,mb:2}},i))),e.jsx(x,{sx:{p:2},children:e.jsxs(m,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(d.SubmitButton,{text:"Update items",loadingText:"Loading..."}),e.jsx(n.StrapiErrors,{error:b?.strapiErrors}),b?.message&&e.jsx(l,{severity:"error",children:b?.message})]})}),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})))(w))})]})]})})]})})};
|
|
@@ -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.id])}),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
|
|
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.id])}),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})]})]})})})};
|
|
@@ -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"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),o=require("@mui/icons-material/ArrowDropDown"),d=require("../../common/ImagePreviewTooltip.js"),u=require("../../logistics/report/ReportsDisplay.js"),c=require("../../logistics/report/PreReportsDisplay.js"),m=require("../../logistics/report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:v,product:f,returned_quantity:w,received_quantity:R,registered_quantity:I,released_quantity:V,reports:_,reason:C,other_reason:A}=p,[D,N]=r.useState(!1);void 0!==_&&_.length>0&&_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const T=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;void 0!==_&&_.length>0&&_.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const F=p.reports?.filter(e=>"id"in e)||[],U=p.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",v]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(d.default,{image:y,label:p.product?.title})})]}),e.jsxs(i,{variant:"body1",children:["Reason: ",C,"other"===C&&void 0!==A&&`, ${A}`]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.TextualAmountUpdater,{label:"Received",currentValue:R,totalValue:w,minNewValue:0+I,maxNewValue:w,color:"info",handleChange:e=>{g(e,p.id,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.TextualAmountUpdater,{label:"Registered",currentValue:I,totalValue:w+T,minNewValue:0+V,maxNewValue:R+T,color:"info",handleChange:e=>{g(e,p.id,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>N(!D),children:e.jsx(o,{})})]})}),e.jsx(s,{in:D,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:F}),e.jsx(c.default,{itemID:p.id,reports:U,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.id,content:"",type:"registered",minValue:-(R-I+T),handleAddReport:h})]})})]}),q&&q.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.TextualAmountUpdater,{label:"Released",currentValue:V,totalValue:w+T,minNewValue:0,maxNewValue:I,color:"info",handleChange:e=>{g(e,p.id,"released_quantity")}})]})]})},j)};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),n=require("./TextualIROItemUpdater.js"),a=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),o=require("../../SubmitButton.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),x=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),p=require("@mui/material/Button"),j=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),_=require("@mui/material/Stack"),y=require("@mui/material/Divider"),f=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),C=require("@mui/material"),q=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),S=require("@mui/icons-material/Business"),k=require("@mui/icons-material/Description"),T=require("@mui/icons-material/Update"),A=require("./IroStatusIndicator.js"),F=require("../../../data/loaders/e-commerce/queryAllProducts.js"),D=require("../../../../node_modules/qs/lib/index.js"),R=require("../../../context/common/SnackbarContext.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:a,iro:s}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&s?.iro_items?.data?.length>0&&(async()=>{o(!0);const e=D.default.stringify({filters:{product_number:{$in:s.iro_items.data.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.id,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=s.iro_items.data.map((e,n)=>{const a=e.product,s=r.find(e=>e.product_number===a?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(s&&s.price){l=s.price.price||0,o=s.price.price_incl_vat||0,c=s.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});a({customer_internal_reference:s.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,s]),e.jsxs(d,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(x,{children:"Check or overwrite value for the return payment"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(C.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(C.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(C.CircularProgress,{}):e.jsxs(_,{spacing:2,children:[e.jsx(C.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>a({...n,customer_internal_reference:e.target.value})}),e.jsx(C.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>a({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(C.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>a({...n,total_incl_vat:parseFloat(e.target.value)})})]}),s?.iro_items?.data?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C.DialogContentText,{variant:"h5",children:"Items"}),s.iro_items.data.map((r,t)=>e.jsxs(_,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(h,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(h,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(h,{sx:{minWidth:200},children:r.product?.title}),e.jsx(C.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},a({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},a({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},a({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},a({...n,lines:r})}})]},r.id))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{f.confirmationService("iros",[s.id],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:a,openOverwritesDialog:s}){const{handleAddMessage:l}=R.useSnackbar();return e.jsxs(d,{open:r,onClose:t,children:[e.jsx(x,{children:"Confirm Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this return?"}),e.jsxs(C.List,{children:["requested"===n&&e.jsx(C.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(C.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(C.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(h,{children:["Current status: ",n]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return s?(s(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await f.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),a&&a(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(p,{variant:"contained",onClick:t,children:"No"})]})]})}function O({open:t,handleClose:i,orderID:n,revalidateCallback:a}){const[s,l]=r.useState(""),[o,c]=r.useState(""),{handleAddMessage:j}=R.useSnackbar();return e.jsx("form",{children:e.jsxs(d,{open:t,onClose:i,children:[e.jsx(x,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this return?"}),e.jsxs(C.List,{children:[e.jsx(C.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(C.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(C.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(p,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("iros",n,s),j({message:"Return order cancelled successfully",severity:"success"}),a&&a(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:d,sx:u,revalidateCallback:m,handleClose:x,role:f}){const[b,F]=t.useFormState(i.updateIroAction,P),[D,M]=r.useState(d.iro_items.data?d.iro_items.data:[]),[B,L]=r.useState(!1),[N,z]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...D],n=i.findIndex(e=>e.id===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.id===r),n=[...t[i]?.reports?.data||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:{data:[]}}),t[i].reports.data=n,M(t)},K=(e,r)=>{const t=[...D],i=t.findIndex(r=>r.id===e),n=t[i]?.reports?.data||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const l=[...a,...s];t[i].reports.data=l,M(t)},{handleAddMessage:X}=R.useSnackbar();return r.useEffect(()=>{b?.message&&(X({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(m&&m(),x&&x()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&X({message:b.strapiErrors.message||"Error updating IRO",severity:b.severity||"error"})},[b?.strapiErrors]),r.useEffect(()=>{console.log("data",d),d.iro_items?.data&&M(d.iro_items.data?d.iro_items.data:[])},[d]),e.jsx(v,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.rma_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_date})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(T,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(A.IroStatusIndicator,{status:d.internal_status})]})]})})}),("requested"===d.internal_status||"finalising_process"===d.internal_status)&&"enduser"===f&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===d.internal_status&&e.jsx(p,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(p,{variant:"contained",color:"error",onClick:()=>z(!0),children:"Cancel order"}),e.jsx(E,{open:B,handleClose:()=>L(!1),orderID:d.id,currentStatus:d.internal_status,revalidateCallback:m,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:d}),e.jsx(O,{open:N,handleClose:()=>z(!1),orderID:d.id,revalidateCallback:m})]})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(_,{spacing:1})})]})}),d?.notes?.data?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:d.notes.data}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:g,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(C.FormControlLabel,{control:e.jsx(C.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(y,{}),e.jsxs("form",{action:F,children:[e.jsx("input",{name:"id",type:"hidden",value:d.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.internal_status||"cancelled"===d.internal_status||"done"===d.internal_status?e.jsx(a.default,{item:r,index:t,image:r?.product?.image}):e.jsx(n.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:G})},t)),e.jsxs(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[x&&e.jsx(p,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(o.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("react-dom"),i=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),n=require("./TextualIROItemUpdater.js"),s=require("./IroItemDisplay.js"),a=require("../../logistics/note/NotesDisplay.js"),l=require("../../logistics/note/NoteTakingComponent.js"),o=require("../../SubmitButton.js"),c=require("@mui/material/Alert"),d=require("@mui/material/Dialog"),u=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),x=require("@mui/material/DialogTitle"),h=require("@mui/material/Typography"),p=require("@mui/material/Button"),j=require("@mui/material/Grid"),v=require("@mui/material/Box"),g=require("@mui/material/Paper"),_=require("@mui/material/Stack"),y=require("@mui/material/Divider"),f=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),C=require("@mui/material"),q=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),S=require("@mui/icons-material/Business"),k=require("@mui/icons-material/Description"),T=require("@mui/icons-material/Update"),A=require("./IroStatusIndicator.js"),F=require("../../../data/loaders/e-commerce/queryAllProducts.js"),D=require("../../../../node_modules/qs/lib/index.js"),R=require("../../../context/common/SnackbarContext.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a}){const[l,o]=r.useState(!1);return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{o(!0);const e=D.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await F.queryAllProducts(e)).data.map(e=>({id:e.id,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),o(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(d,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(x,{children:"Check or overwrite value for the return payment"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(C.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(C.DialogContentText,{variant:"h5",children:"Overwrites"}),l?e.jsx(C.CircularProgress,{}):e.jsxs(_,{spacing:2,children:[e.jsx(C.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(C.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(C.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(C.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(_,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(h,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(h,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(h,{sx:{minWidth:200},children:r.product?.title}),e.jsx(C.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(C.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.id))]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:e=>{f.confirmationService("iros",[a.id],n),i()},children:"Confirm"}),e.jsx(p,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function E({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=R.useSnackbar();return e.jsxs(d,{open:r,onClose:t,children:[e.jsx(x,{children:"Confirm Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to confirm this return?"}),e.jsxs(C.List,{children:["requested"===n&&e.jsx(C.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(C.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(C.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(h,{children:["Current status: ",n]})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await f.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(p,{variant:"contained",onClick:t,children:"No"})]})]})}function O({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,c]=r.useState(""),{handleAddMessage:j}=R.useSnackbar();return e.jsx("form",{children:e.jsxs(d,{open:t,onClose:i,children:[e.jsx(x,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{children:"Are you sure you want to cancel this return?"}),e.jsxs(C.List,{children:[e.jsx(C.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(C.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(C.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(C.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(u,{children:[e.jsx(p,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(p,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:d,sx:u,revalidateCallback:m,handleClose:x,role:f}){const[b,F]=t.useFormState(i.updateIroAction,P),[D,M]=r.useState(d.iro_items?d.iro_items:[]),[B,L]=r.useState(!1),[N,z]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...D],n=i.findIndex(e=>e.id===r);i[n][t]=e,M(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.id===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,M(t)},K=(e,r)=>{const t=[...D],i=t.findIndex(r=>r.id===e),n=t[i]?.reports||[],s=n.filter(e=>"id"in e),a=n.filter(e=>!("id"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,M(t)},{handleAddMessage:X}=R.useSnackbar();return r.useEffect(()=>{b?.message&&(X({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(m&&m(),x&&x()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&X({message:b.strapiErrors.message||"Error updating IRO",severity:b.severity||"error"})},[b?.strapiErrors]),r.useEffect(()=>{console.log("data",d),d.iro_items&&M(d.iro_items?d.iro_items:[])},[d]),e.jsx(v,{sx:[...Array.isArray(u)?u:[u]],children:e.jsxs(j,{container:!0,spacing:2,children:[e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(h,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(l.default,{content:"",related:[{id:d.id,__type:"api::e-commerce.iro"}],revalidateCallback:m})]}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsx(h,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.rma_number})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer_reference})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.return_date})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(h,{variant:"body1",fontWeight:"medium",children:d.customer?.business_credentials?.company_name})]}),e.jsxs(_,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(T,{color:"primary"}),e.jsx(h,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(A.IroStatusIndicator,{status:d.internal_status})]})]})})}),("requested"===d.internal_status||"finalising_process"===d.internal_status)&&"enduser"===f&&e.jsx(j,{item:!0,xs:6,children:e.jsx(g,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(_,{spacing:2,children:[e.jsx(p,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===d.internal_status&&e.jsx(p,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(p,{variant:"contained",color:"error",onClick:()=>z(!0),children:"Cancel order"}),e.jsx(E,{open:B,handleClose:()=>L(!1),orderID:d.id,currentStatus:d.internal_status,revalidateCallback:m,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:d}),e.jsx(O,{open:N,handleClose:()=>z(!1),orderID:d.id,revalidateCallback:m})]})})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Documents"}),e.jsx(g,{sx:{p:2},children:e.jsx(_,{spacing:1})})]})}),d?.notes?.length>0&&e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:2,children:[e.jsx(h,{variant:"h5",children:"Notes"}),e.jsx(a.default,{notes:d.notes}),e.jsx(y,{})]})}),e.jsx(j,{item:!0,xs:12,children:e.jsxs(_,{spacing:1,children:[e.jsx(h,{variant:"h5",children:"Items"}),e.jsxs(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:g,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(h,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(C.FormControlLabel,{control:e.jsx(C.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(h,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===d.internal_status&&e.jsx(c,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(y,{}),e.jsxs("form",{action:F,children:[e.jsx("input",{name:"id",type:"hidden",value:d.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(g,{sx:{p:2,mb:2},children:"requested"===d.internal_status||"cancelled"===d.internal_status||"done"===d.internal_status?e.jsx(s.default,{item:r,index:t,image:r?.product?.image}):e.jsx(n.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:G})},t)),e.jsxs(_,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[x&&e.jsx(p,{onClick:x,variant:"outlined",children:"Cancel"}),e.jsx(o.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
@@ -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"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("react"),r=require("react-dom"),n=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),a=require("../../common/media/UploadBase64MediaForm.js"),t=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./OpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),d=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),u=require("@mui/material/Alert"),p=require("@mui/material/Dialog"),m=require("@mui/material/DialogActions"),x=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),j=require("@mui/material/Typography"),y=require("@mui/material/Button"),v=require("@mui/material/Grid"),g=require("@mui/material/Box"),f=require("@mui/material/Paper"),b=require("@mui/material/Stack"),_=require("@mui/material/Divider"),q=require("../../../data/services/common/confirmation-service.js"),C=require("../../../context/common/SnackbarContext.js");const w={zodErrors:null,strapiErrors:null,message:null};function k({open:i,handleClose:r,orderID:n,currentStatus:a,revalidateCallback:t}){return e.jsxs(p,{open:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(x,{children:e.jsxs(b,{spacing:2,children:[e.jsx(j,{children:"Are you sure you want to confirm this order?"}),e.jsxs(j,{children:["Current status: ",a]})]})}),e.jsxs(m,{children:[e.jsx(y,{variant:"contained",onClick:e=>{q.confirmationService("opos",[n]),t&&t()},children:"Confirm"}),e.jsx(y,{variant:"contained",onClick:r,children:"Cancel"})]})]})}exports.default=function({opo:p,sx:m,revalidateCallback:x,handleClose:h,role:q}){const[D,O]=r.useFormState((e,i)=>n.updateOpoAction(p.id,e,i),w),{handleAddMessage:S}=C.useSnackbar(),[E,A]=i.useState(p.opo_items?p.opo_items:[]),[B,N]=i.useState(!1),F=(e,i,r)=>{const n=[...E],a=n.findIndex(e=>e.id===i);n[a][r]=e,A(n)};return i.useEffect(()=>{p.opo_items&&A(p.opo_items)},[p]),i.useEffect(()=>{D?.message&&(S({message:D.message,severity:D.severity||"error"}),"success"===D.severity&&(x&&x(),h&&h()))},[D?.message]),i.useEffect(()=>{D?.strapiErrors&&S({message:D.strapiErrors.message||"Error updating OPO",severity:D.severity||"error"})},[D?.strapiErrors]),e.jsx(g,{sx:[...Array.isArray(m)?m:[m]],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:p.id,__type:"api::e-commerce.opo"}],revalidateCallback:x})]}),e.jsx(_,{})]})}),e.jsx(v,{item:!0,xs:6,children:e.jsxs(b,{spacing:1,children:[e.jsx(j,{variant:"h5",children:"Details"}),e.jsxs(b,{direction:"row",spacing:2,children:[e.jsx(j,{variant:"body1",width:"250px",children:"Purchase Order Number"}),e.jsx(j,{variant:"body2",children:p.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:p.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:p.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:p.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:p.internal_status})]}),("placed"===p.internal_status||"external_shipping_process"===p.internal_status)&&"enduser"===q&&e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"contained",color:"primary",onClick:()=>N(!0),children:"Confirm order"}),e.jsx(u,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(k,{open:B,handleClose:()=>N(!1),orderID:p.id,currentStatus:p.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:p.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h6",children:"Delivery Note"}),e.jsx(j,{children:p.delivery_note?.name}),e.jsx(y,{variant:"contained",onClick:()=>{t.default(`api/opos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"h5",children:"Delivery Note"}),e.jsx(j,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(a.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:p.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/opos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:x})]})})})]})}),p?.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:p.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"===p.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:p.id}),E&&E.map((i,r)=>(console.log("item",i),e.jsx(f,{sx:{p:2,mb:2},children:"placed"===p.internal_status?e.jsx(o.default,{item:i,index:r,image:i?.product?.image}):e.jsx(s.default,{item:i,index:r,handleUpdateQuantity:F,image:i?.product?.image,revalidateCallback:x})},r))),e.jsx(f,{sx:{p:2},children:e.jsxs(b,{direction:"row",spacing:2,justifyContent:"space-between",children:[h&&e.jsx(y,{onClick:h,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Update items",loadingText:"Loading..."})]})}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity})))(E))})]})]})})]})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/material/Stack"),r=require("@mui/material/Typography"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("@mui/material/Stack"),r=require("@mui/material/Typography"),n=require("../../common/ImagePreviewTooltip.js"),t=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:s,index:a,image:c}){const{line_item_number:d,product:l,ordered_quantity:o,picked_quantity:p,packed_quantity:u,shipped_quantity:j,reports:h}=s;return e.jsxs(i,{spacing:1,children:[s&&e.jsxs(i,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsxs(i,{spacing:1,children:[e.jsxs(r,{variant:"body1",children:["Line Item Number: ",d]}),e.jsxs(r,{variant:"body1",children:["Part Number: ",l?.product_number]})]}),c&&e.jsx(e.Fragment,{children:e.jsx(n.default,{image:c,label:s.product?.title})})]}),e.jsxs(i,{direction:"row",spacing:1,justifyContent:"space-between",alignItems:"center",children:[e.jsxs(i,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(r,{variant:"caption",children:"Ordered"}),e.jsx(r,{variant:"h6",children:o})]}),e.jsxs(i,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(r,{variant:"caption",children:"Received"}),e.jsx(r,{variant:"h6",children:p})]}),e.jsxs(i,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(r,{variant:"caption",children:"Registered"}),e.jsx(r,{variant:"h6",children:u})]}),e.jsxs(i,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(r,{variant:"caption",children:"Released"}),e.jsx(r,{variant:"h6",children:j})]})]}),h?.length>0&&e.jsxs(i,{spacing:1,children:[e.jsx(r,{variant:"body1",children:"Reports:"}),e.jsx(t.default,{reports:h.filter(e=>"documentId"in e&&!("pre_report"in e))})]})]},a)};
|
|
@@ -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"),t=require("react"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),o=require("@mui/material/Collapse"),d=require("../../common/AmountUpdater.js"),l=require("@mui/icons-material/ArrowDropDown"),u=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportMakingComponent.js"),s=require("../../logistics/report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:h,image:x,revalidateCallback:j}){const{line_item_number:y,product:g,ordered_quantity:q,picked_quantity:f,packed_quantity:b,shipped_quantity:v,reports:k}=m,[V,_]=t.useState(!1);t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"picked"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);const w=t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"packed"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]);return t.useMemo(()=>void 0!==k&&k.length>0?k.filter(e=>"shipped"===e.type).reduce((e,t)=>e+t.quantity,0):0,[k]),e.jsx(r,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",children:[e.jsxs(r,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g?.product_number]})]}),x&&e.jsx(e.Fragment,{children:e.jsx(u.default,{image:x,label:g?.title})})]}),e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(d.AmountUpdater,{currentValue:f,totalValue:q+-w,minNewValue:0+b+-w,maxNewValue:q+-w,color:"info",handleChange:e=>{h(e,m.id,"picked_quantity")}}),e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(d.AmountUpdater,{currentValue:b,totalValue:q,minNewValue:0+v,maxNewValue:f+w,color:"info",handleChange:e=>{h(e,m.id,"packed_quantity")},offsetEnd:w}),e.jsx(n,{sx:{p:0},children:e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>_(!V),children:e.jsx(l,{})})]})}),e.jsx(o,{in:V,children:e.jsxs(r,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(s.default,{reports:k.filter(e=>"documentId"in e&&"string"==typeof e.documentId)}),e.jsx(c.default,{content:"content",quantity:0,type:"packed",minValue:-(f+w),maxValue:0,related:[{id:m.id,__type:"api::e-commerce.opo-item"}],revalidateCallback:j})]})}),e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(d.AmountUpdater,{currentValue:v,totalValue:q,minNewValue:0,maxNewValue:b,color:"info",handleChange:e=>{h(e,m.id,"shipped_quantity")}})]})},p)};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Table"),l=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),n=require("@mui/material/TableHead"),
|
|
6
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("@mui/material/Box"),i=require("@mui/material/Table"),l=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),n=require("@mui/material/TableHead"),c=require("@mui/material/TableFooter"),s=require("@mui/material/TableRow"),t=require("@mui/material/Typography"),o=require("./OpoSummaryRow.js");exports.OpoSummary=function({opo:u}){const{opo_items:m}=u;return m?(console.log("opo_items",m),e.jsx(r,{sx:{p:{xs:1,md:2}},children:null!=m?e.jsxs(i,{children:[e.jsx(n,{children:e.jsxs(s,{children:[e.jsx(a,{children:"Amount"}),e.jsx(a,{children:"Product Title"}),e.jsx(a,{children:"Price Excl. VAT"}),e.jsx(a,{children:"Price Incl. VAT"})]})}),e.jsx(l,{children:m&&m.map(r=>e.jsx(o.OpoSummaryRow,{data:r},r.id))}),e.jsxs(c,{children:[e.jsxs(s,{children:[e.jsx(a,{colSpan:3,align:"right",children:"Total excl VAT"}),e.jsxs(a,{colSpan:1,align:"left",children:["€ ",u.total_excl_vat]})]}),e.jsxs(s,{children:[e.jsx(a,{colSpan:3,align:"right",children:"Total incl VAT"}),e.jsxs(a,{colSpan:1,align:"left",children:["€ ",u.total_incl_vat]})]})]})]}):e.jsx(t,{children:"No products in cart"})})):e.jsx(t,{children:"Loading..."})};
|
|
@@ -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"),a=require("../../common/media/UploadBase64MediaForm.js"),n=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:a,revalidateCallback:n}){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: ",a]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),n&&n(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:a,revalidateCallback:n}){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",a,s),d({message:"Order cancelled successfully",severity:"success"}),n&&n(),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.data?u.opo_items.data:[]),[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?.data&&R(u.opo_items.data?u.opo_items.data:[])},[u]);const Y=(e,r,i)=>{const t=[...L],a=t.findIndex(e=>e.id===r);t[a][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),a=[...i[t]?.reports?.data||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:{data:[]}}),i[t].reports.data=a,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),a=i[t]?.reports?.data||[],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.data=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.id,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.id,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{n.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(a.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?.data?.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.data}),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?.data?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-dom"),t=require("../../../data/actions/e-commerce/opo/updateOpoAction.js"),n=require("../../common/media/UploadBase64MediaForm.js"),a=require("../../../data/loaders/common/media/downloadBase64File.js"),s=require("./TextualOpoItemUpdater.js"),o=require("./OpoItemDisplay.js"),l=require("../../logistics/note/NotesDisplay.js"),c=require("../../logistics/note/NoteTakingComponent.js"),d=require("@mui/material/Alert"),u=require("@mui/material/Dialog"),p=require("@mui/material/DialogActions"),m=require("@mui/material/DialogContent"),h=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),j=require("@mui/material/Button"),g=require("@mui/material/Grid"),v=require("@mui/material/Box"),y=require("@mui/material/Paper"),f=require("@mui/material/Stack"),_=require("@mui/material/Divider"),C=require("../../../data/services/common/confirmation-service.js"),b=require("../../../data/services/common/cancellation-service.js"),q=require("@mui/material"),k=require("@mui/icons-material/Numbers"),w=require("@mui/icons-material/CalendarToday"),I=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),D=require("@mui/icons-material/Update"),O=require("./OpoStatusIndicator.js"),A=require("../../../context/common/SnackbarContext.js"),F=require("../../SubmitButton.js");const B={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},N=["picked","packed","shipped","reports"];function E({open:r,handleClose:i,orderID:t,currentStatus:n,revalidateCallback:a}){return e.jsxs(u,{open:r,onClose:i,children:[e.jsx(h,{children:"Confirm Order"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this order?"}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"contained",onClick:e=>{C.confirmationService("opos",[t]),a&&a(),i()},children:"Yes"}),e.jsx(j,{variant:"contained",onClick:i,children:"No"})]})]})}function P({open:i,handleClose:t,orderID:n,revalidateCallback:a}){const[s,o]=r.useState(""),[l,c]=r.useState(""),{handleAddMessage:d}=A.useSnackbar();return e.jsxs(u,{open:i,onClose:t,children:[e.jsx(h,{children:"Cancel Return"}),e.jsx(m,{children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this order?"}),e.jsxs(q.List,{children:[e.jsx(q.ListItem,{children:"By cancelling this order you will update it's status from ordered to cancelled"}),e.jsx(q.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(q.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(q.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:s,onChange:e=>o(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!l,helperText:l})]})}),e.jsxs(p,{children:[e.jsx(j,{variant:"outlined",onClick:t,children:"Close"}),e.jsx(j,{variant:"contained",color:"error",onClick:async()=>{if(s.length<5)c("Please provide a reason for the cancellation (min 5 characters)");else{c("");try{await b.cancellationService("opos",n,s),d({message:"Order cancelled successfully",severity:"success"}),a&&a(),t()}catch(e){d({message:"Failed to cancel order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})}exports.default=function({opo:u,sx:p,revalidateCallback:m,handleClose:h,role:C}){const b=t.updateOpoAction.bind(null,u.id),[T,M]=i.useFormState(b,B),{handleAddMessage:U}=A.useSnackbar(),[L,R]=r.useState(u.opo_items?u.opo_items:[]),[W,z]=r.useState(!1),[G,H]=r.useState(!1),[J,Q]=r.useState(["picked","packed","shipped","reports"]);r.useEffect(()=>{T?.message&&(U({message:T.message,severity:T.severity||"info"}),"success"===T.severity&&(m?.(),h?.()))},[T?.message]),r.useEffect(()=>{T?.strapiErrors&&U({message:T.strapiErrors.message||"Error updating OPO",severity:"error"})},[T?.strapiErrors]),r.useEffect(()=>{u.opo_items&&R(u.opo_items?u.opo_items:[])},[u]);const Y=(e,r,i)=>{const t=[...L],n=t.findIndex(e=>e.id===r);t[n][i]=e,R(t)},$=(e,r)=>{const i=[...L],t=i.findIndex(e=>e.id===r),n=[...i[t]?.reports||[],e];null==i[t]?.reports&&(i[t]={...i[t],reports:[]}),i[t].reports=n,R(i)},K=(e,r)=>{const i=[...L],t=i.findIndex(r=>r.id===e),n=i[t]?.reports||[],a=n.filter(e=>"id"in e),s=n.filter(e=>!("id"in e));s.splice(r,1);const o=[...a,...s];i[t].reports=o,R(i)};return e.jsx(v,{sx:[...Array.isArray(p)?p:[p]],children:e.jsxs(g,{container:!0,spacing:2,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Outbound Purchase Order"}),e.jsx(x,{variant:"body1",children:"Manage picking, packing and shipping of purchase order"})]}),e.jsx(c.default,{content:"",related:[{id:u.id,__type:"api::e-commerce.opo"}],revalidateCallback:m})]}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Purchase Order Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.opo_number})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Custom reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer_reference})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.order_date})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:u.customer?.business_credentials?.company_name})]}),e.jsxs(f,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(D,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Order Status"}),e.jsx(O.OpoStatusIndicator,{status:u.internal_status})]})]})})}),"enduser"===C&&e.jsx(g,{item:!0,xs:6,children:e.jsx(y,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(f,{spacing:2,children:[("placed"===u.internal_status||"external_shipping_process"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"primary",onClick:()=>z(!0),children:"Confirm order"}),e.jsx(d,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"}),e.jsx(E,{open:W,handleClose:()=>z(!1),orderID:u.id,currentStatus:u.internal_status,revalidateCallback:m})]}),("placed"===u.internal_status||"ordered"===u.internal_status)&&e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"contained",color:"error",onClick:()=>H(!0),children:"Cancel order"}),e.jsx(P,{open:G,handleClose:()=>H(!1),orderID:u.id,revalidateCallback:m})]})]})})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(y,{sx:{p:2},children:e.jsx(f,{spacing:1,children:u.delivery_note?e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h6",children:"Delivery Note"}),e.jsx(x,{children:u.delivery_note?.name}),e.jsx(j,{variant:"contained",onClick:()=>{a.default(`api/ipos/${u.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"h5",children:"Delivery Note"}),e.jsx(x,{variant:"body1",children:"Here you can upload the the delivery note for this order"}),e.jsx(_,{}),e.jsx(n.UploadBase64MediaForm,{reference:"api::e-commerce.opo",refID:u.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:m})]})})})]})}),u?.notes?.length>0&&e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(l.default,{notes:u.notes}),e.jsx(_,{})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(f,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:y,p:1,children:[e.jsx(x,{variant:"body1",children:"Show:"}),N.map(r=>e.jsx(q.FormControlLabel,{control:e.jsx(q.Checkbox,{checked:J.includes(r),onChange:e=>{e.target.checked?Q([...J,r]):Q(J.filter(e=>e!==r))}}),label:r.charAt(0).toUpperCase()+r.slice(1)},r))]}),"placed"===u.internal_status&&e.jsx(d,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:M,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(L))}),L&&L.map((r,i)=>e.jsx(y,{sx:{p:2,mb:2},children:"placed"===u.internal_status||"external_shipping_process"===u.internal_status||"done"===u.internal_status||"cancelled"===u.internal_status?e.jsx(o.default,{item:r,index:i,image:r?.product?.image}):e.jsx(s.default,{item:r,index:i,handleUpdateQuantity:Y,handleAddReport:$,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:m,showing:J})},i))," ",e.jsxs(f,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[h&&e.jsx(j,{onClick:h,variant:"outlined",children:"Close"}),"placed"!==u.internal_status&&"external_shipping_process"!==u.internal_status&&"done"!==u.internal_status&&"cancelled"!==u.internal_status&&e.jsx(F.SubmitButton,{text:"Update items",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
|
|
@@ -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"),t=require("react"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),c=require("../../logistics/report/ReportsDisplay.js"),u=require("../../logistics/report/PreReportsDisplay.js"),p=require("../../logistics/report/SimpleReportFields.js"),m=require("@mui/material/Box");exports.default=function({item:x,index:h,handleAddReport:j,handleUpdateQuantity:y,image:g,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:f,product:w,ordered_quantity:k,picked_quantity:v,packed_quantity:I,shipped_quantity:V,reports:_}=x,[C,A]=t.useState(!1);void 0!==_&&_.length>0&&_.filter(e=>"picked"===e.type).reduce((e,t)=>e+t.quantity,0);const R=void 0!==_&&_.length>0?_.filter(e=>"packed"===e.type).reduce((e,t)=>e+t.quantity,0):0;void 0!==_&&_.length>0&&_.filter(e=>"shipped"===e.type).reduce((e,t)=>e+t.quantity,0);const D=x.reports?.filter(e=>"id"in e)||[],N=x.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(r,{spacing:1,children:x&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",f]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",w?.product_number]}),g&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:g,label:w?.title})})]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("picked")&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Picked"}),e.jsx(l.TextualAmountUpdater,{label:"Picked",currentValue:v,totalValue:k,minNewValue:0+I,maxNewValue:k,color:"info",handleChange:e=>{y(e,x.id,"picked_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("packed")&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Packed"}),e.jsx(l.TextualAmountUpdater,{label:"Packed",currentValue:I,totalValue:k+R,minNewValue:0+V,maxNewValue:v+R,color:"info",handleChange:e=>{y(e,x.id,"packed_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(m,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>A(!C),children:e.jsx(d,{})})]})}),e.jsx(s,{in:C,children:e.jsxs(r,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:D}),e.jsx(u.default,{itemID:x.id,reports:N,handleRemoveReportAtIndex:b}),e.jsx(p.default,{itemID:x.id,content:"",type:"packed",minValue:-(v-I+R),handleAddReport:j})]})})]}),q&&q.includes("shipped")&&e.jsxs(r,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Shipped"}),e.jsx(l.TextualAmountUpdater,{label:"Shipped",currentValue:V,totalValue:k+R,minNewValue:0,maxNewValue:I,color:"info",handleChange:e=>{y(e,x.id,"shipped_quantity")}})]})]})},h)};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),a=require("@mui/material/IconButton"),n=require("@mui/material/Divider"),l=require("@mui/material/Collapse"),o=require("../../common/AmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),u=require("../../common/ImagePreviewTooltip.js"),s=require("../report/ReportMakingComponent.js"),c=require("../report/ReportsDisplay.js");exports.default=function({item:m,index:p,handleUpdateQuantity:x,image:j,revalidateCallback:h}){const{line_item_number:y,product:g,received_quantity:q,registered_quantity:v,released_quantity:b,ordered_quantity:f,reports:V}=m,_=void 0!==V&&V.length>0?V.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0):0,w=void 0!==V&&V.length>0?V.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0,[C,N]=r.useState(!1);return e.jsx(t,{spacing:1,children:m&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",children:[e.jsxs(t,{spacing:1,children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",y]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",g.product_number]})]}),j&&e.jsx(e.Fragment,{children:e.jsx(u.default,{image:j,label:m.product.title})})]}),e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(o.AmountUpdater,{currentValue:q,totalValue:f+_,minNewValue:0+v+-w,maxNewValue:f+_,color:"info",handleChange:e=>{x(e,m.id,"received_quantity")}}),e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(o.AmountUpdater,{currentValue:v,totalValue:f+_,minNewValue:0+b,maxNewValue:q+w,color:"info",handleChange:e=>{x(e,m.id,"registered_quantity")},offsetEnd:w}),e.jsx(n,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(a,{onClick:()=>N(!C),children:e.jsx(d,{})})]})}),e.jsx(l,{in:C,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(c.default,{reports:V}),e.jsx(s.default,{content:"content",quantity:0,type:"registered",minValue:-(q+w),maxValue:q,related:[{id:m.id,__type:"api::logistics.ipo-item"}],revalidateCallback:h})]})}),e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(o.AmountUpdater,{currentValue:b||0,totalValue:f+_+w,minNewValue:0,maxNewValue:v,color:"info",handleChange:e=>{x(e,m.id,"released_quantity")}})]})},p)};
|
|
@@ -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"),
|
|
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.id,currentStatus:p.internal_status,revalidateCallback:h})]})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Documents"}),e.jsx(_,{sx:{p:2},children:e.jsxs(q,{spacing:1,children:["enduser"===v&&e.jsx(e.Fragment,{children:p.order_confirmation?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{children:p.order_confirmation?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"order_confirmation")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Order Confirmation"}),e.jsx(f,{variant:"body1",children:"Upload the order confirmation for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})}),p.delivery_note?e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{children:p.delivery_note?.name}),e.jsx(g,{variant:"contained",onClick:()=>{s.default(`api/ipos/${p.id}`,"delivery_note")},children:"Download"})]}):e.jsxs(q,{spacing:1,children:[e.jsx(f,{variant:"h6",children:"Delivery Note"}),e.jsx(f,{variant:"body1",children:"Upload the delivery note for this order"}),e.jsx(t.UploadBase64MediaForm,{reference:"api::logistics.ipo",refID:p.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:h})]})]})})]})}),p?.notes?.length>0&&e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Notes"}),e.jsx(c.default,{notes:p.notes}),e.jsx(C,{})]})}),e.jsx(y,{item:!0,xs:12,children:e.jsxs(q,{spacing:2,children:[e.jsx(f,{variant:"h5",children:"Items"}),"placed"===p.internal_status&&e.jsx(u,{severity:"warning",children:"Items cannot be updated before order confirmation"}),e.jsxs("form",{action:I,children:[e.jsx("input",{name:"id",type:"hidden",value:p.id}),e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({id:e.id,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity})))(O))}),e.jsxs(q,{spacing:2,children:[p?.items&&p.items.map((i,r)=>e.jsx(_,{sx:{p:2},children:"placed"===p.internal_status?e.jsx(d.default,{item:i,index:r,image:i?.product?.image}):e.jsx(o.default,{item:i,index:r,handleUpdateQuantity:B,image:i?.product?.image,revalidateCallback:h})},r)),"placed"!==p.internal_status&&e.jsx(_,{sx:{p:2},children:e.jsxs(q,{direction:"row",justifyContent:"flex-end",spacing:2,children:[j&&e.jsx(g,{onClick:j,variant:"outlined",children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Update Items",loadingText:"Updating...",variant:"contained"})]})})]})]})]})})]})})};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Stack"),i=require("@mui/material/Typography"),n=require("@mui/material/IconButton"),a=require("@mui/material/Divider"),s=require("@mui/material/Collapse"),l=require("../../common/TextualAmountUpdater.js"),d=require("@mui/icons-material/ArrowDropDown"),o=require("../../common/ImagePreviewTooltip.js"),u=require("../report/ReportsDisplay.js"),c=require("../report/PreReportsDisplay.js"),m=require("../report/SimpleReportFields.js"),x=require("@mui/material/Box");exports.default=function({item:p,index:j,handleAddReport:h,handleUpdateQuantity:g,image:y,handleRemoveReportAtIndex:b,showing:q}){const{line_item_number:v,product:f,ordered_quantity:w,received_quantity:R,registered_quantity:I,released_quantity:V,reports:_}=p,[C,A]=r.useState(!1);void 0!==_&&_.length>0&&_.filter(e=>"received"===e.type).reduce((e,r)=>e+r.quantity,0);const D=void 0!==_&&_.length>0?_.filter(e=>"registered"===e.type).reduce((e,r)=>e+r.quantity,0):0;void 0!==_&&_.length>0&&_.filter(e=>"released"===e.type).reduce((e,r)=>e+r.quantity,0);const N=p.reports?.filter(e=>"id"in e)||[],T=p.reports?.filter(e=>!1===Boolean("id"in e))||[];return e.jsx(t,{spacing:1,children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsxs(i,{variant:"body1",children:["Line Item Number: ",v]}),e.jsxs(i,{variant:"body1",children:["Part Number: ",f?.product_number]}),y&&e.jsx(e.Fragment,{children:e.jsx(o.default,{image:y,label:p.product?.title})})]}),e.jsx(a,{sx:{mb:1}}),q&&q.includes("received")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Received"}),e.jsx(l.TextualAmountUpdater,{label:"Received",currentValue:R,totalValue:w,minNewValue:0+I,maxNewValue:w,color:"info",handleChange:e=>{g(e,p.id,"received_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("registered")&&e.jsxs(e.Fragment,{children:[e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Registered"}),e.jsx(l.TextualAmountUpdater,{label:"Registered",currentValue:I,totalValue:w+D,minNewValue:0+V,maxNewValue:R+D,color:"info",handleChange:e=>{g(e,p.id,"registered_quantity")}})]}),e.jsx(a,{sx:{mb:2}})]}),q&&q.includes("reports")&&e.jsxs(x,{sx:{mb:2},children:[e.jsx(a,{sx:{p:0},children:e.jsxs(t,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(i,{variant:"body2",children:"Irregularities / Corrections"}),e.jsx(n,{onClick:()=>A(!C),children:e.jsx(d,{})})]})}),e.jsx(s,{in:C,children:e.jsxs(t,{spacing:2,children:[e.jsx(i,{variant:"body2",children:"Here you can report and correct for damages wrong items etc. Do not forget to click the button!"}),e.jsx(u.default,{reports:N}),e.jsx(c.default,{itemID:p.id,reports:T,handleRemoveReportAtIndex:b}),e.jsx(m.default,{itemID:p.id,content:"",type:"registered",minValue:-(R-I+D),handleAddReport:h})]})})]}),q&&q.includes("released")&&e.jsxs(t,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[e.jsx(i,{variant:"body2",children:"Released"}),e.jsx(l.TextualAmountUpdater,{label:"Released",currentValue:V,totalValue:w+D,minNewValue:0,maxNewValue:I,color:"info",handleChange:e=>{g(e,p.id,"released_quantity")}})]})]})},j)};
|