umwd-components 0.1.823 → 0.1.824

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.
@@ -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 r=require("../../_virtual/_commonjsHelpers.js"),e=require("../../_virtual/index5.js"),t=require("../color-name/index.js"),a=require("../simple-swizzle/index.js"),s=t.colorName,n=a.simpleSwizzleExports,o=Object.hasOwnProperty,l=Object.create(null);for(var u in s)o.call(s,u)&&(l[s[u]]=u);var d=e.__module.exports={to:{},get:{}};function i(r,e,t){return Math.min(Math.max(e,r),t)}function h(r){var e=Math.round(r).toString(16).toUpperCase();return e.length<2?"0"+e:e}d.get=function(r){var e,t;switch(r.substring(0,3).toLowerCase()){case"hsl":e=d.get.hsl(r),t="hsl";break;case"hwb":e=d.get.hwb(r),t="hwb";break;default:e=d.get.rgb(r),t="rgb"}return e?{model:t,value:e}:null},d.get.rgb=function(r){if(!r)return null;var e,t,a,n=[0,0,0,1];if(e=r.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(a=e[2],e=e[1],t=0;t<3;t++){var l=2*t;n[t]=parseInt(e.slice(l,l+2),16)}a&&(n[3]=parseInt(a,16)/255)}else if(e=r.match(/^#([a-f0-9]{3,4})$/i)){for(a=(e=e[1])[3],t=0;t<3;t++)n[t]=parseInt(e[t]+e[t],16);a&&(n[3]=parseInt(a+a,16)/255)}else if(e=r.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(t=0;t<3;t++)n[t]=parseInt(e[t+1],0);e[4]&&(e[5]?n[3]=.01*parseFloat(e[4]):n[3]=parseFloat(e[4]))}else{if(!(e=r.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=r.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:o.call(s,e[1])?((n=s[e[1]])[3]=1,n):null:null;for(t=0;t<3;t++)n[t]=Math.round(2.55*parseFloat(e[t+1]));e[4]&&(e[5]?n[3]=.01*parseFloat(e[4]):n[3]=parseFloat(e[4]))}for(t=0;t<3;t++)n[t]=i(n[t],0,255);return n[3]=i(n[3],0,1),n},d.get.hsl=function(r){if(!r)return null;var e=r.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var t=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,i(parseFloat(e[2]),0,100),i(parseFloat(e[3]),0,100),i(isNaN(t)?1:t,0,1)]}return null},d.get.hwb=function(r){if(!r)return null;var e=r.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var t=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,i(parseFloat(e[2]),0,100),i(parseFloat(e[3]),0,100),i(isNaN(t)?1:t,0,1)]}return null},d.to.hex=function(){var r=n(arguments);return"#"+h(r[0])+h(r[1])+h(r[2])+(r[3]<1?h(Math.round(255*r[3])):"")},d.to.rgb=function(){var r=n(arguments);return r.length<4||1===r[3]?"rgb("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+")":"rgba("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+", "+r[3]+")"},d.to.rgb.percent=function(){var r=n(arguments),e=Math.round(r[0]/255*100),t=Math.round(r[1]/255*100),a=Math.round(r[2]/255*100);return r.length<4||1===r[3]?"rgb("+e+"%, "+t+"%, "+a+"%)":"rgba("+e+"%, "+t+"%, "+a+"%, "+r[3]+")"},d.to.hsl=function(){var r=n(arguments);return r.length<4||1===r[3]?"hsl("+r[0]+", "+r[1]+"%, "+r[2]+"%)":"hsla("+r[0]+", "+r[1]+"%, "+r[2]+"%, "+r[3]+")"},d.to.hwb=function(){var r=n(arguments),e="";return r.length>=4&&1!==r[3]&&(e=", "+r[3]),"hwb("+r[0]+", "+r[1]+"%, "+r[2]+"%"+e+")"},d.to.keyword=function(r){return l[r.slice(0,3)]};var c=e.__module.exports,f=r.getDefaultExportFromCjs(c);exports.default=f;
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("../../_virtual/_commonjsHelpers.js"),e=require("../../_virtual/index6.js"),t=require("../color-name/index.js"),a=require("../simple-swizzle/index.js"),s=t.colorName,n=a.simpleSwizzleExports,o=Object.hasOwnProperty,l=Object.create(null);for(var u in s)o.call(s,u)&&(l[s[u]]=u);var d=e.__module.exports={to:{},get:{}};function i(r,e,t){return Math.min(Math.max(e,r),t)}function h(r){var e=Math.round(r).toString(16).toUpperCase();return e.length<2?"0"+e:e}d.get=function(r){var e,t;switch(r.substring(0,3).toLowerCase()){case"hsl":e=d.get.hsl(r),t="hsl";break;case"hwb":e=d.get.hwb(r),t="hwb";break;default:e=d.get.rgb(r),t="rgb"}return e?{model:t,value:e}:null},d.get.rgb=function(r){if(!r)return null;var e,t,a,n=[0,0,0,1];if(e=r.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(a=e[2],e=e[1],t=0;t<3;t++){var l=2*t;n[t]=parseInt(e.slice(l,l+2),16)}a&&(n[3]=parseInt(a,16)/255)}else if(e=r.match(/^#([a-f0-9]{3,4})$/i)){for(a=(e=e[1])[3],t=0;t<3;t++)n[t]=parseInt(e[t]+e[t],16);a&&(n[3]=parseInt(a+a,16)/255)}else if(e=r.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(t=0;t<3;t++)n[t]=parseInt(e[t+1],0);e[4]&&(e[5]?n[3]=.01*parseFloat(e[4]):n[3]=parseFloat(e[4]))}else{if(!(e=r.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=r.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:o.call(s,e[1])?((n=s[e[1]])[3]=1,n):null:null;for(t=0;t<3;t++)n[t]=Math.round(2.55*parseFloat(e[t+1]));e[4]&&(e[5]?n[3]=.01*parseFloat(e[4]):n[3]=parseFloat(e[4]))}for(t=0;t<3;t++)n[t]=i(n[t],0,255);return n[3]=i(n[3],0,1),n},d.get.hsl=function(r){if(!r)return null;var e=r.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var t=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,i(parseFloat(e[2]),0,100),i(parseFloat(e[3]),0,100),i(isNaN(t)?1:t,0,1)]}return null},d.get.hwb=function(r){if(!r)return null;var e=r.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var t=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,i(parseFloat(e[2]),0,100),i(parseFloat(e[3]),0,100),i(isNaN(t)?1:t,0,1)]}return null},d.to.hex=function(){var r=n(arguments);return"#"+h(r[0])+h(r[1])+h(r[2])+(r[3]<1?h(Math.round(255*r[3])):"")},d.to.rgb=function(){var r=n(arguments);return r.length<4||1===r[3]?"rgb("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+")":"rgba("+Math.round(r[0])+", "+Math.round(r[1])+", "+Math.round(r[2])+", "+r[3]+")"},d.to.rgb.percent=function(){var r=n(arguments),e=Math.round(r[0]/255*100),t=Math.round(r[1]/255*100),a=Math.round(r[2]/255*100);return r.length<4||1===r[3]?"rgb("+e+"%, "+t+"%, "+a+"%)":"rgba("+e+"%, "+t+"%, "+a+"%, "+r[3]+")"},d.to.hsl=function(){var r=n(arguments);return r.length<4||1===r[3]?"hsl("+r[0]+", "+r[1]+"%, "+r[2]+"%)":"hsla("+r[0]+", "+r[1]+"%, "+r[2]+"%, "+r[3]+")"},d.to.hwb=function(){var r=n(arguments),e="";return r.length>=4&&1!==r[3]&&(e=", "+r[3]),"hwb("+r[0]+", "+r[1]+"%, "+r[2]+"%"+e+")"},d.to.keyword=function(r){return l[r.slice(0,3)]};var c=e.__module.exports,f=r.getDefaultExportFromCjs(c);exports.default=f;
@@ -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,r=require("../../_virtual/_commonjsHelpers.js"),i=require("../../_virtual/index6.js"),u=require("./core.js"),_=require("./x64-core.js"),q=require("./lib-typedarrays.js"),s=require("./enc-utf16.js"),j=require("./enc-base64.js"),a=require("./enc-base64url.js"),o=require("./md5.js"),d=require("./sha1.js"),t=require("./sha256.js"),p=require("./sha224.js"),c=require("./sha512.js"),m=require("./sha384.js"),l=require("./sha3.js"),n=require("./ripemd160.js"),b=require("./hmac.js"),f=require("./pbkdf2.js"),h=require("./evpkdf.js"),x=require("./cipher-core.js"),v=require("./mode-cfb.js"),g=require("./mode-ctr.js"),y=require("./mode-ctr-gladman.js"),k=require("./mode-ofb.js"),E=require("./mode-ecb.js"),w=require("./pad-ansix923.js"),z=require("./pad-iso10126.js"),C=require("./pad-iso97971.js"),D=require("./pad-zeropadding.js"),F=require("./pad-nopadding.js"),G=require("./format-hex.js"),H=require("./aes.js"),M=require("./tripledes.js"),O=require("./rc4.js"),P=require("./rabbit.js"),A=require("./rabbit-legacy.js"),B=require("./blowfish.js");e=i.__module,r.commonjsGlobal,e.exports=function(e){return e}(u.__require(),_.__require(),q.__require(),s.__require(),j.__require(),a.__require(),o.md5Exports,d.__require(),t.__require(),p.__require(),c.__require(),m.__require(),l.__require(),n.__require(),b.__require(),f.__require(),h.__require(),x.__require(),v.__require(),g.__require(),y.__require(),k.__require(),E.__require(),w.__require(),z.__require(),C.__require(),D.__require(),F.__require(),G.__require(),H.__require(),M.__require(),O.__require(),P.__require(),A.__require(),B.__require());var I=i.__module.exports,J=r.getDefaultExportFromCjs(I);exports.default=J;
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../_virtual/_commonjsHelpers.js"),i=require("../../_virtual/index5.js"),u=require("./core.js"),_=require("./x64-core.js"),q=require("./lib-typedarrays.js"),s=require("./enc-utf16.js"),j=require("./enc-base64.js"),a=require("./enc-base64url.js"),o=require("./md5.js"),d=require("./sha1.js"),t=require("./sha256.js"),p=require("./sha224.js"),c=require("./sha512.js"),m=require("./sha384.js"),l=require("./sha3.js"),n=require("./ripemd160.js"),b=require("./hmac.js"),f=require("./pbkdf2.js"),h=require("./evpkdf.js"),x=require("./cipher-core.js"),v=require("./mode-cfb.js"),g=require("./mode-ctr.js"),y=require("./mode-ctr-gladman.js"),k=require("./mode-ofb.js"),E=require("./mode-ecb.js"),w=require("./pad-ansix923.js"),z=require("./pad-iso10126.js"),C=require("./pad-iso97971.js"),D=require("./pad-zeropadding.js"),F=require("./pad-nopadding.js"),G=require("./format-hex.js"),H=require("./aes.js"),M=require("./tripledes.js"),O=require("./rc4.js"),P=require("./rabbit.js"),A=require("./rabbit-legacy.js"),B=require("./blowfish.js");e=i.__module,r.commonjsGlobal,e.exports=function(e){return e}(u.__require(),_.__require(),q.__require(),s.__require(),j.__require(),a.__require(),o.md5Exports,d.__require(),t.__require(),p.__require(),c.__require(),m.__require(),l.__require(),n.__require(),b.__require(),f.__require(),h.__require(),x.__require(),v.__require(),g.__require(),y.__require(),k.__require(),E.__require(),w.__require(),z.__require(),C.__require(),D.__require(),F.__require(),G.__require(),H.__require(),M.__require(),O.__require(),P.__require(),A.__require(),B.__require());var I=i.__module.exports,J=r.getDefaultExportFromCjs(I);exports.default=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("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),_=require("@mui/material/Divider"),y=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),F=require("../../../../node_modules/qs/lib/index.js"),D=require("../../../context/common/SnackbarContext.js"),R=require("../../common/media/minio/MinioItemList.js");const P={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function W({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a,revalidateCallback:l}){const[o,p]=r.useState(!1),{handleAddMessage:j}=D.useSnackbar();return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{p(!0);const e=F.default.stringify({filters:{product_number:{$in:a.iro_items.map(e=>e.product?.product_number?.replace(/^r-/,"")||"")}},populate:{price:!0}},{encodeValuesOnly:!0}),r=(await A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),p(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),o?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{try{await y.confirmationService("iros",[a.documentId],n),l&&l(),i()}catch(e){j({message:"Failed to confirm return order",severity:"error"})}},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function z({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=D.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await y.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function M({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=D.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:y}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),P),[F,E]=r.useState(c.iro_items?c.iro_items:[]),[O,L]=r.useState(!1),[N,B]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...F],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,E(i)},H=(e,r)=>{const t=[...F],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,E(t)},K=(e,r)=>{const t=[...F],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"documentId"in e),a=n.filter(e=>!("documentId"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,E(t)},{handleAddMessage:X}=D.useSnackbar();return r.useEffect(()=>{f?.message&&(X({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&X({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{c.iro_items&&E(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.id,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===y&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>B(!0),children:"Cancel order"}),e.jsx(z,{open:O,handleClose:()=>L(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>V(!0)}),e.jsx(W,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:c}),e.jsx(M,{open:N,handleClose:()=>B(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Customer Attachements"}),e.jsx(v,{sx:{p:1},children:e.jsx(R.MinioItemList,{items:c.customer_attachment,emptyMessage:"No customer attachments found.",direction:"row",revalidateCallback:u})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(_,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(_,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(F))}),F&&F.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:u,showing:G})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../../data/actions/e-commerce/iro/updateIroAction.js"),i=require("./TextualIROItemUpdater.js"),n=require("./IroItemDisplay.js"),s=require("../../logistics/note/NotesDisplay.js"),a=require("../../logistics/note/NoteTakingComponent.js"),l=require("../../SubmitButton.js"),o=require("@mui/material/Alert"),c=require("@mui/material/Dialog"),d=require("@mui/material/DialogActions"),u=require("@mui/material/DialogContent"),m=require("@mui/material/DialogTitle"),x=require("@mui/material/Typography"),h=require("@mui/material/Button"),p=require("@mui/material/Grid"),j=require("@mui/material/Box"),v=require("@mui/material/Paper"),g=require("@mui/material/Stack"),y=require("@mui/material/Divider"),_=require("../../../data/services/common/confirmation-service.js"),f=require("../../../data/services/common/cancellation-service.js"),b=require("@mui/material"),C=require("@mui/icons-material/Numbers"),q=require("@mui/icons-material/AssignmentReturn"),I=require("@mui/icons-material/CalendarToday"),w=require("@mui/icons-material/Business"),S=require("@mui/icons-material/Description"),k=require("@mui/icons-material/Update"),T=require("./IroStatusIndicator.js"),A=require("../../../data/loaders/e-commerce/queryAllProducts.js"),D=require("../../../../node_modules/qs/lib/index.js"),F=require("../../../context/common/SnackbarContext.js"),R=require("../../common/media/minio/MinioItemList.js");const M={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function P({open:t,handleClose:i,overwrites:n,setOverwrites:s,iro:a,revalidateCallback:l,closeMainDialog:o}){const[p,j]=r.useState(!1),{handleAddMessage:v}=F.useSnackbar();return r.useEffect(()=>{t&&a?.iro_items?.length>0&&(async()=>{j(!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 A.queryAllProducts(e)).data.map(e=>({id:e.documentId,product_number:e.product_number,price:e.price}));console.log("correspondingProducts",r),j(!1);let t=0,i=0;const n=a.iro_items.map((e,n)=>{const s=e.product,a=r.find(e=>e.product_number===s?.product_number?.replace(/^r-/,"")||"");let l=0,o=0,c=0;if(a&&a.price){l=a.price.price||0,o=a.price.price_incl_vat||0,c=a.price.vat_rate||0;const r=l*e.returned_quantity,n=o*e.returned_quantity;t+=r,i+=n}return{vat_rate:c,price_excl_vat:l,price_incl_vat:o,quantity:e.returned_quantity}});s({customer_internal_reference:a.customer_reference||"",total_excl_vat:parseFloat(t.toFixed(2)),total_incl_vat:parseFloat(i.toFixed(2)),lines:n})})()},[t,a]),e.jsxs(c,{open:t,onClose:i,fullWidth:!0,maxWidth:"lg",children:[e.jsx(m,{children:"Check or overwrite value for the return payment"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,alignItems:"left",sx:{px:0},children:[e.jsx(b.DialogContentText,{children:"This is very important because these values will be used for automated invoice generation"}),e.jsx(b.DialogContentText,{variant:"h5",children:"Overwrites"}),p?e.jsx(b.CircularProgress,{}):e.jsxs(g,{spacing:2,children:[e.jsx(b.TextField,{label:"Customer internal reference",name:"customer_internal_reference",fullWidth:!0,variant:"outlined",value:n.customer_internal_reference,onChange:e=>s({...n,customer_internal_reference:e.target.value})}),e.jsx(b.TextField,{label:"Total excl. VAT",name:"total_excl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_excl_vat,onChange:e=>s({...n,total_excl_vat:parseFloat(e.target.value)})}),e.jsx(b.TextField,{label:"Total incl. VAT",name:"total_incl_vat",type:"number",fullWidth:!0,variant:"outlined",value:n.total_incl_vat,onChange:e=>s({...n,total_incl_vat:parseFloat(e.target.value)})})]}),a?.iro_items?.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(b.DialogContentText,{variant:"h5",children:"Items"}),a.iro_items.map((r,t)=>e.jsxs(g,{spacing:2,direction:"row",alignItems:"center",sx:{px:2},children:[e.jsx(x,{sx:{minWidth:100},children:r.line_item_number}),e.jsx(x,{sx:{minWidth:150},children:r.product?.product_number}),e.jsx(x,{sx:{minWidth:200},children:r.product?.title}),e.jsx(b.TextField,{size:"small",label:"VAT %",name:"vat_rate",type:"number",sx:{width:100},value:n?.lines?.[t]?.vat_rate??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],vat_rate:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price excl.",name:"price_excl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_excl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_excl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Price incl.",name:"price_incl_vat",type:"number",sx:{width:120},value:n?.lines?.[t]?.price_incl_vat??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],price_incl_vat:parseFloat(e.target.value)},s({...n,lines:r})}}),e.jsx(b.TextField,{size:"small",label:"Qty",name:"quantity",type:"number",sx:{width:80},value:n?.lines?.[t]?.quantity??"",onChange:e=>{const r=[...n.lines||[]];r[t]={...r[t],quantity:parseFloat(e.target.value)},s({...n,lines:r})}})]},r.documentId))]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{try{await _.confirmationService("iros",[a.documentId],n),v({message:"Return order confirmed successfully",severity:"success"}),l&&l(),i(),o&&o()}catch(e){v({message:"Failed to confirm return order",severity:"error"})}},children:"Confirm"}),e.jsx(h,{variant:"contained",onClick:i,children:"Cancel"})]})]})}function W({open:r,handleClose:t,orderID:i,currentStatus:n,revalidateCallback:s,openOverwritesDialog:a}){const{handleAddMessage:l}=F.useSnackbar();return e.jsxs(c,{open:r,onClose:t,children:[e.jsx(m,{children:"Confirm Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to confirm this return?"}),e.jsxs(b.List,{children:["requested"===n&&e.jsx(b.ListItem,{children:"When confirming this return order a rma number will be generated"}),e.jsx(b.ListItem,{children:"requested"===n?"By confirming the return you will update it's status from requested to returning":"By confirming the return you will update it's status from finalising_process to done"}),"finalising_process"===n&&e.jsx(b.ListItem,{children:"Confirming this order will automatically create an invoice"})]}),e.jsxs(x,{children:["Current status: ",n]})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"contained",onClick:async()=>{if("requested"===n||"finalising_process"===n){if("finalising_process"===n)return a?(a(),void t()):void l({message:"Please provide overwrites for the invoice",severity:"error"});try{await _.confirmationService("iros",[i]),l({message:"Return order confirmed successfully",severity:"success"}),s&&s(),t()}catch(e){l({message:"Failed to confirm return order",severity:"error"})}}else l({message:"Cannot confirm return order in current status",severity:"error"})},children:"Yes"}),e.jsx(h,{variant:"contained",onClick:t,children:"No"})]})]})}function z({open:t,handleClose:i,orderID:n,revalidateCallback:s}){const[a,l]=r.useState(""),[o,p]=r.useState(""),{handleAddMessage:j}=F.useSnackbar();return e.jsx("form",{children:e.jsxs(c,{open:t,onClose:i,children:[e.jsx(m,{children:"Cancel Return"}),e.jsx(u,{children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{children:"Are you sure you want to cancel this return?"}),e.jsxs(b.List,{children:[e.jsx(b.ListItem,{children:"By cancelling this return order you will update it's status from requested to cancelled"}),e.jsx(b.ListItem,{children:"Please provide a reason for the cancellation"}),e.jsx(b.ListItem,{children:"The customer will be notified about the cancellation and of the reason for the cancellation"})]}),e.jsx(b.TextField,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:a,onChange:e=>l(e.target.value),placeholder:"Please provide a reason for the cancellation",error:!!o,helperText:o})]})}),e.jsxs(d,{children:[e.jsx(h,{variant:"outlined",onClick:i,children:"Close"}),e.jsx(h,{variant:"contained",color:"error",onClick:async()=>{if(a.length<5)p("Please provide a reason for the cancellation (min 5 characters)");else{p("");try{await f.cancellationService("iros",n,a),j({message:"Return order cancelled successfully",severity:"success"}),s&&s(),i()}catch(e){j({message:"Failed to cancel return order",severity:"error"})}}},children:"Confirm Cancellation"})]})]})})}exports.default=function({data:c,sx:d,revalidateCallback:u,handleClose:m,role:_}){const[f,A]=r.useActionState((e,r)=>t.updateIroAction(c.documentId,e,r),M),[D,E]=r.useState(c.iro_items?c.iro_items:[]),[O,L]=r.useState(!1),[N,B]=r.useState(!1),[U,V]=r.useState(!1),[Q,Y]=r.useState({customer_internal_reference:"",total_excl_vat:0,total_incl_vat:0,lines:[]}),[G,J]=r.useState(["received","registered","released","reports"]),$=(e,r,t)=>{const i=[...D],n=i.findIndex(e=>e.documentId===r);i[n][t]=e,E(i)},H=(e,r)=>{const t=[...D],i=t.findIndex(e=>e.documentId===r),n=[...t[i]?.reports||[],e];null==t[i]?.reports&&(t[i]={...t[i],reports:[]}),t[i].reports=n,E(t)},K=(e,r)=>{const t=[...D],i=t.findIndex(r=>r.documentId===e),n=t[i]?.reports||[],s=n.filter(e=>"documentId"in e),a=n.filter(e=>!("documentId"in e));a.splice(r,1);const l=[...s,...a];t[i].reports=l,E(t)},{handleAddMessage:X}=F.useSnackbar();return r.useEffect(()=>{f?.message&&(X({message:f.message,severity:f.severity||"error"}),"success"===f.severity&&(u&&u(),m&&m()))},[f?.message]),r.useEffect(()=>{f?.strapiErrors&&X({message:f.strapiErrors.message||"Error updating IRO",severity:f.severity||"error"})},[f?.strapiErrors]),r.useEffect(()=>{c.iro_items&&E(c.iro_items?c.iro_items:[])},[c]),e.jsx(j,{sx:[...Array.isArray(d)?d:[d]],children:e.jsxs(p,{container:!0,spacing:2,children:[e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,justifyContent:"space-between",children:[e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h3",component:"h1",children:"Management Inbound Return"}),e.jsx(x,{variant:"body1",children:"Manage arrival, registration and release of returns"})]}),e.jsx(a.default,{content:"",related:[{id:c.id,__type:"api::e-commerce.iro"}],revalidateCallback:u})]}),e.jsx(y,{})]})}),e.jsx(p,{size:12,children:e.jsx(x,{variant:"h5",sx:{py:1},children:"Details"})}),e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(C,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(q,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"RMA Number"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.rma_number})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(S,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer Reference"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer_reference})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(I,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Date"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.return_date})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(w,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Customer"}),e.jsx(x,{variant:"body1",fontWeight:"medium",children:c.customer?.business_credentials?.company_name})]}),e.jsxs(g,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(k,{color:"primary"}),e.jsx(x,{variant:"subtitle1",color:"text.secondary",width:"200px",children:"Return Status"}),e.jsx(T.IroStatusIndicator,{status:c.internal_status})]})]})})}),("requested"===c.internal_status||"finalising_process"===c.internal_status)&&"enduser"===_&&e.jsx(p,{size:6,children:e.jsx(v,{elevation:2,sx:{p:2,height:"100%"},children:e.jsxs(g,{spacing:2,children:[e.jsx(h,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Confirm order"}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please confirm the order as soon as possible, only upon confirmation this order will be assigned an RMA number and will become available to the dispatcher. Status: requested - returning"}),"finalising_process"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Please finalise this return order. Make sure the customer receives a return payment if eligible and then confirm this step. Status: finalising_process - done"}),"finalising_process"===c.internal_status&&e.jsx(h,{variant:"contained",sx:{color:"yellow"},children:"// TODO RE-PAYMENT PROCESS"}),e.jsx(h,{variant:"contained",color:"error",onClick:()=>B(!0),children:"Cancel order"}),e.jsx(W,{open:O,handleClose:()=>L(!1),orderID:c.documentId,currentStatus:c.internal_status,revalidateCallback:u,openOverwritesDialog:()=>V(!0)}),e.jsx(P,{open:U,handleClose:()=>V(!1),overwrites:Q,setOverwrites:Y,iro:c,revalidateCallback:u,closeMainDialog:m}),e.jsx(z,{open:N,handleClose:()=>B(!1),orderID:c.documentId,revalidateCallback:u})]})})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Documents"}),e.jsx(v,{sx:{p:2},children:e.jsx(g,{spacing:1})})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Customer Attachements"}),e.jsx(v,{sx:{p:1},children:e.jsx(R.MinioItemList,{items:c.customer_attachment,emptyMessage:"No customer attachments found.",direction:"row",revalidateCallback:u})})]})}),c?.notes?.length>0&&e.jsx(p,{size:12,children:e.jsxs(g,{spacing:2,children:[e.jsx(x,{variant:"h5",children:"Notes"}),e.jsx(s.default,{notes:c.notes}),e.jsx(y,{})]})}),e.jsx(p,{size:12,children:e.jsxs(g,{spacing:1,children:[e.jsx(x,{variant:"h5",children:"Items"}),e.jsxs(g,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:v,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"},children:[e.jsx(x,{variant:"body2",color:"text.secondary",children:"Show:"}),["received","registered","released","reports"].map(r=>e.jsx(b.FormControlLabel,{control:e.jsx(b.Checkbox,{size:"small",checked:G.includes(r),onChange:e=>{e.target.checked?J([...G,r]):J(G.filter(e=>e!==r))}}),label:e.jsx(x,{variant:"body2",color:"text.secondary",children:r.charAt(0).toUpperCase()+r.slice(1)}),sx:{mr:0}},r))]}),"requested"===c.internal_status&&e.jsx(o,{severity:"warning",children:"Before confirmation you cannot update the items"}),e.jsx(y,{}),e.jsxs("form",{action:A,children:[e.jsx("input",{type:"hidden",name:"items",value:JSON.stringify((e=>e.map(e=>({documentId:e.documentId,returned_quantity:e.returned_quantity,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_quantity,reports:e.reports?.map(e=>({id:"id"in e?e.id:void 0,documentId:"documentId"in e?e.documentId:void 0,quantity:e.quantity,content:e.content,type:e.type}))||[]})))(D))}),D&&D.map((r,t)=>e.jsx(v,{sx:{p:2,mb:2},children:"requested"===c.internal_status||"cancelled"===c.internal_status||"done"===c.internal_status?e.jsx(n.default,{item:r,index:t,image:r?.product?.image}):e.jsx(i.default,{item:r,index:t,handleUpdateQuantity:$,handleAddReport:H,image:r?.product?.image,handleRemoveReportAtIndex:K,revalidateCallback:u,showing:G})},t)),e.jsxs(g,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2},children:[m&&e.jsx(h,{onClick:m,variant:"outlined",children:"Cancel"}),e.jsx(l.SubmitButton,{text:"Save changes",loadingText:"Saving...",variant:"contained"})]})]})]})})]})})};