(this["webpackJsonpcustomer-portal"]=this["webpackJsonpcustomer-portal"]||[]).push([[0],{298:function(e,t,n){},369:function(e,t,n){},370:function(e,t,n){},494:function(e,t,n){},496:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/medatech-logo.d9b936ff.png"},497:function(e,t,n){"use strict";n.r(t);var a=n(0),c=n.n(a),r=n(36),o=n.n(r),s=(n(369),n(370),n(4)),i=n(5),l=n(18),u=n(6),d=n(234),j=n(632),b=n(608),O=n(625),h=n(595),m=n(637),f=n(633),x=n(635),g=n(200),p=n(593),S=n(634),v=n(636),E=n(623),C=n(325),T=n.n(C),A=n(326),D=n.n(A),k=n(617),y=n(590),w=n(592),N=n(303),P=n.n(N),I=n(309),U=n.n(I),R=n(43),L=n(62),F=n(70),M=n(20),B=n.n(M),W=n(299),_=new(function(){function e(){Object(L.a)(this,e)}return Object(F.a)(e,[{key:"login",value:function(e){return B.a.post("/customer_portal/login",e)}},{key:"logout",value:function(){localStorage.removeItem("token"),window.location.reload()}},{key:"getCurrentUser",value:function(){var e=localStorage.getItem("token");if(e)var t=Object(W.a)(e);return t}},{key:"changePassword",value:function(e){return B.a.post("/customer_portal/changePassword",e)}},{key:"forgotPassword",value:function(e){return B.a.post("/customer_portal/forgotPassword",e)}}]),e}()),G=["title","titleId"];function z(){return z=Object.assign||function(e){for(var t=1;t=0||(c[n]=e[n]);return c}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n])}return c}function Y(e,t){var n=e.title,c=e.titleId,r=V(e,G);return a.createElement("svg",z({viewBox:"0 0 24 24",width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":c},r),n?a.createElement("title",{id:c},n):null,a.createElement("path",{d:"M15.7,16.6c-0.2,0.2 -0.6,0.3 -0.8,0.4c-0.5,0.2 -1,0.2 -1.7,0.1c-1.2,-0.1 -1.3,-0.4 -2,-0.3c-0.8,0.1 -1.5,0.5 -1.5,0.4c0,-0.1 0.3,-0.3 0.8,-0.8c0.4,-0.5 0.9,-1.1 0.8,-1.9c0,-0.4 -0.1,-0.9 -0.1,-1.1l2.3,0l0,-1.8l-3,0c-0.1,-0.1 -0.5,-0.9 -0.7,-1.7c-0.2,-1.1 0,-1.6 0.1,-1.9c0.3,-0.7 1,-1.3 1.9,-1.3c0.3,0 0.639,0.049 0.839,0.149c0.2,0.1 0.42,0.22 0.635,0.396c0.384,0.314 0.457,0.641 0.626,1.055c0.056,0.137 0.1,0.6 0.1,0.7l2.7,0c0.1,-0.8 -0.5,-2.3 -1.2,-3c-0.8,-0.8 -1.7,-1.2 -2.1,-1.4c-1.7,-0.6 -4.1,-0.4 -5.6,1.2c-0.2,0.2 -1.2,1.3 -1.2,2.9c0,0.5 0.2,1 0.5,1.9c0.1,0.3 0.2,0.6 0.3,0.9l-0.9,0l0,1.8l1.7,0c0.2,0.4 0.3,0.8 0.3,1.3c0,0.2 -0.1,1.6 -1,2.4c-0.3,0.3 -0.7,0.4 -0.9,0.6l1.6,2c0.6,-0.2 1.1,-1 2.2,-0.8c2.1,0.4 2.9,1.2 4.6,0.7c0.5,-0.1 1,-0.4 1.8,-0.7c0.4,-0.2 0.5,-0.3 0.6,-0.4l-1.7,-1.8Z",style:{fillRule:"nonzero",fill:"rgb(128, 128, 128)"}}))}var q=a.forwardRef(Y),X=(n.p,n(308)),Q=n.n(X),H=n(305),J=n.n(H),K=n(306),Z=n.n(K),$=n(304),ee=n.n($),te=n(1),ne=Object(te.jsx)("div",{children:_.getCurrentUser()?Object(te.jsxs)(te.Fragment,{children:[Object(te.jsxs)(k.a,{button:!0,component:R.b,to:"/dashboard",children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(P.a,{})}),Object(te.jsx)(w.a,{primary:"Dashboard"})]}),Object(te.jsxs)(k.a,{button:!0,component:R.b,to:"/dashboard/invoices",children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(q,{})}),Object(te.jsx)(w.a,{primary:"Invoices"})]}),Object(te.jsxs)(k.a,{button:!0,component:R.b,to:"/dashboard/statements",children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(ee.a,{})}),Object(te.jsx)(w.a,{primary:"Statements"})]}),Object(te.jsxs)(k.a,{button:!0,component:R.b,to:"/dashboard/kanban",children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(J.a,{})}),Object(te.jsx)(w.a,{primary:"Kanban Board"})]}),Object(te.jsxs)(k.a,{button:!0,component:R.b,to:"/dashboard/gantt",children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(Z.a,{})}),Object(te.jsx)(w.a,{primary:"Gantt Chart"})]}),Object(te.jsx)(p.a,{}),Object(te.jsxs)(k.a,{button:!0,component:R.b,to:"/dashboard/servicecalls",children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(Q.a,{})}),Object(te.jsx)(w.a,{primary:"Service Calls"})]})]}):Object(te.jsx)(te.Fragment,{children:Object(te.jsxs)(k.a,{button:!0,component:R.b,to:"/login",children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(U.a,{})}),Object(te.jsx)(w.a,{primary:"Login"})]})})}),ae=n(643),ce=n(647),re=n(642),oe=n(646),se=n(619),ie=n(641),le=n(334);function ue(){var e=localStorage.getItem("token");return e?{"x-access-token":e}:{}}var de=new(function(){function e(){Object(L.a)(this,e)}return Object(F.a)(e,[{key:"getItemsForSale",value:function(e,t){return B.a.get("/customer_portal/itemsForSale/".concat(e,"/").concat(t),{headers:ue()})}},{key:"getOrders",value:function(){return B.a.get("/customer_portal/orders",{headers:ue()})}},{key:"getCustomerOrders",value:function(e){return B.a.get("/customer_portal/customerOrders/".concat(e),{headers:ue()})}},{key:"getOrderItems",value:function(e){return B.a.get("/customer_portal/orderItems/".concat(e),{headers:ue()})}},{key:"getShipments",value:function(){return B.a.get("/customer_portal/shipments",{headers:ue()})}},{key:"getCustomerShipments",value:function(e){return B.a.get("/customer_portal/customerShipments/".concat(e),{headers:ue()})}},{key:"getShipmentItems",value:function(e,t){return B.a.get("/customer_portal/shipmentItems/".concat(e,"/").concat(t),{headers:ue()})}},{key:"getInvoices",value:function(){return B.a.get("/customer_portal/invoices",{headers:ue()})}},{key:"getCustomerInfo",value:function(e){return B.a.get("/customer_portal/getCustomerInfo",{headers:ue()})}},{key:"getCustomerInvoices",value:function(e){return B.a.get("/customer_portal/customerInvoices/".concat(e),{headers:ue()})}},{key:"getInvoiceItems",value:function(e,t,n){return B.a.get("/customer_portal/invoiceItems/".concat(e,"/").concat(t,"/").concat(n),{headers:ue()})}},{key:"getInvoiceStatus",value:function(e){return B.a.get("/customer_portal/invoiceStatus/".concat(e),{headers:ue()})}},{key:"getCustomerParts",value:function(){return B.a.get("/customer_portal/customerParts",{headers:ue()})}},{key:"createOrder",value:function(e){return B.a.post("/customer_portal/createOrder",e,{headers:ue()})}},{key:"getUserNotifications",value:function(){return B.a.get("/customer_portal/userNotifications",{headers:ue()})}},{key:"setNotificationRead",value:function(e){return B.a.post("/customer_portal/userNotifications",e,{headers:ue()})}},{key:"createTask",value:function(e){return B.a.post("/customer_portal/createTask",e,{headers:ue()})}},{key:"updateTask",value:function(e){return B.a.patch("/customer_portal/updateTask",e,{headers:ue()})}},{key:"getServiceCalls",value:function(e){return B.a.get("/customer_portal/servicecalls/".concat(e),{headers:ue()})}},{key:"getServiceCall",value:function(e){return B.a.get("/customer_portal/servicecall/".concat(e),{headers:ue()})}},{key:"getServiceCallExternalRemarks",value:function(e){return B.a.get("/customer_portal/servicecall/remarks/".concat(e),{headers:ue()})}},{key:"getTaskExplanation",value:function(e){return B.a.get("/customer_portal/taskExplanation/".concat(e),{headers:ue()})}},{key:"getTaskAttachments",value:function(e){return B.a.get("/customer_portal/taskAttachments/".concat(e),{headers:ue()})}},{key:"getCallStatuses",value:function(){return B.a.get("/customer_portal/callStatuses",{headers:ue()})}},{key:"getStatusLang2",value:function(e){return B.a.get("/customer_portal/statusLang2/".concat(e),{headers:ue()})}},{key:"getCallTypes",value:function(){return B.a.get("/customer_portal/callTypes",{headers:ue()})}},{key:"getCallSeverities",value:function(){return B.a.get("/customer_portal/callSeverities",{headers:ue()})}},{key:"getCustomerContacts",value:function(){return B.a.get("/customer_portal/customerContacts",{headers:ue()})}},{key:"getUserProjects",value:function(e){return B.a.get("/customer_portal/userProjects/".concat(e),{headers:ue()})}},{key:"getProjectTasks",value:function(e){return B.a.get("/customer_portal/projectTasks/".concat(e),{headers:ue()})}},{key:"getProjectWBS",value:function(e){return B.a.get("/customer_portal/projectWBS/".concat(e),{headers:ue()})}},{key:"getGanttWBS",value:function(e){return B.a.get("/customer_portal/ganttWBS/".concat(e),{headers:ue()})}},{key:"getSCAttachments",value:function(e){return B.a.get("/customer_portal/scAttachments/".concat(e),{headers:ue()})}},{key:"getTaskStatuses",value:function(){return B.a.get("/customer_portal/taskStatuses",{headers:ue()})}},{key:"getTaskTypes",value:function(){return B.a.get("/customer_portal/taskTypes",{headers:ue()})}},{key:"getTaskSizes",value:function(){return B.a.get("/customer_portal/taskSizes",{headers:ue()})}},{key:"getUsers",value:function(){return B.a.get("/customer_portal/users",{headers:ue()})}},{key:"getCustomerStatements",value:function(e){return B.a.get("/customer_portal/customerStatements/".concat(e),{headers:ue()})}},{key:"addServiceCallComment",value:function(e){return B.a.post("/customer_portal/addServiceCallComment",e,{headers:ue()})}},{key:"updateServiceCall",value:function(e){return B.a.patch("/customer_portal/updateServiceCall",e,{headers:ue()})}},{key:"updateCallStatus",value:function(e){return B.a.post("/customer_portal/updateCallStatus",e,{headers:ue()})}},{key:"changeTaskStatus",value:function(e){return B.a.patch("/customer_portal/changeTaskStatus",e,{headers:ue()})}},{key:"CreateServiceCall",value:function(e){return B.a.post("/customer_portal/createServiceCall",e,{headers:ue()})}},{key:"addServiceCallAttachment",value:function(e){return B.a.post("/customer_portal/addServiceCallAttachment",e,{headers:ue()})}},{key:"getCustomerSignup",value:function(e){return B.a.get("/customer_portal/CustomerSignup/".concat(e))}},{key:"checkContact",value:function(e){return B.a.get("/customer_portal/check_contact/".concat(e))}},{key:"checkUser",value:function(e){return B.a.get("/customer_portal/check_user/".concat(e))}},{key:"createContact",value:function(e){return B.a.post("/customer_portal/CreateContact/",e)}},{key:"createUser",value:function(e){return B.a.post("/customer_portal/CreateUser/",e)}},{key:"getTheseCustomers",value:function(e){return B.a.get("/customer_portal/customers/".concat(e),{headers:ue()})}},{key:"downloadOrderPdf",value:function(e){return B()({url:"/customer_portal/downloadOrderPdf",method:"POST",responseType:"blob",headers:ue(),data:{ORDNAME:e}})}},{key:"downloadInvoicePdf",value:function(e){return B()({url:"/customer_portal/downloadInvoicePdf",method:"POST",responseType:"blob",headers:ue(),data:{IVNUM:e}})}},{key:"downloadShipmentPdf",value:function(e){return B()({url:"/customer_portal/downloadShipmentPdf",method:"POST",responseType:"blob",headers:ue(),data:{DOCNO:e}})}},{key:"downloadServicePdf",value:function(e){return B()({url:"/customer_portal/downloadServicePdf",method:"POST",responseType:"blob",headers:ue(),data:{DOCNO:e}})}},{key:"downloadStatementPdf",value:function(e){return B()({url:"/customer_portal/downloadStatementPdf",method:"POST",responseType:"blob",headers:ue(),data:{STATEMENTNO:e}})}}]),e}()),je=n(21),be=n(639),Oe=n(626),he=function(){return Object(te.jsxs)(te.Fragment,{children:[Object(te.jsx)(be.a,{}),Object(te.jsx)(Oe.a,{variant:"rectangular",height:50,style:{marginBottom:10}}),Object(je.a)(Array(25)).map((function(e,t){return Object(te.jsx)(Oe.a,{variant:"rectangular",height:25,style:{marginBottom:5}},t)}))]})},me=n(81),fe=n.n(me),xe=n(30),ge=n(509);function pe(e,t,n){return t[n]e[n]?1:0}function Se(e,t){return"desc"===e?function(e,n){return pe(e,n,t)}:function(e,n){return-pe(e,n,t)}}function ve(e,t){var n=e.map((function(e,t){return[e,t]}));return n.sort((function(e,n){var a=t(e[0],n[0]);return 0!==a?a:e[1]-n[1]})),n.map((function(e){return e[0]}))}var Ee=n(640),Ce=n(627),Te=n(596);function Ae(e){var t=e.order,n=e.orderBy,a=e.onRequestSort;return Object(te.jsx)(Ee.a,{children:Object(te.jsx)(ie.a,{children:e.headCells.map((function(e){return Object(te.jsx)(re.a,{align:"center",padding:e.disablePadding?"none":"normal",sortDirection:n===e.id&&t,children:Object(te.jsxs)(Ce.a,{active:n===e.id,direction:n===e.id?t:"asc",onClick:(c=e.id,function(e){return a(e,c)}),children:[Object(te.jsx)("b",{children:e.label}),n===e.id?Object(te.jsx)(h.a,{component:"span",sx:Te.a,children:"desc"===t?"sorted descending":"sorted ascending"}):null]})},e.id);var c}))})})}var De=function(e){var t=e.title;return Object(te.jsx)(f.a,{sx:{pl:{sm:2},pr:{xs:1,sm:1}},children:Object(te.jsx)(g.a,{sx:{flex:"1 1 100%"},variant:"h6",id:"tableTitle",component:"div",children:t})})},ke=n(311),ye=n.n(ke),we=n(631),Ne=[{id:"IVDATE",numeric:!1,disablePadding:!0,label:"Date",align:"center"},{id:"IVNUM",numeric:!0,disablePadding:!1,label:"Invoice No.",align:"center"},{id:"TOTPRICE",numeric:!0,disablePadding:!1,label:"Total Price",align:"center"},{id:"REFERENCE",numeric:!0,disablePadding:!1,label:"Cust. P.O.",align:"center"},{id:"PAYDATE",numeric:!1,disablePadding:!0,label:"Due Date",align:"center"},{id:"ACTION",numeric:!0,disablePadding:!1,label:"PDF",align:"center"}];function Pe(e){var t=e.row,n=Object(a.useState)(!1),r=Object(i.a)(n,2),o=(r[0],r[1],Object(a.useState)([])),s=Object(i.a)(o,2),l=(s[0],s[1],Object(a.useState)(!0)),u=Object(i.a)(l,2),d=(u[0],u[1],Object(xe.b)()),j=d.enqueueSnackbar;d.closeSnackbar;return Object(te.jsx)(c.a.Fragment,{children:Object(te.jsxs)(ie.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(te.jsx)(re.a,{component:"th",scope:"row",align:"center",children:new Date(t.IVDATE).toLocaleDateString("en-GB")}),Object(te.jsx)(re.a,{align:"center",children:t.IVNUM}),Object(te.jsxs)(re.a,{align:"center",children:[t.CODE," ",Number(t.TOTPRICE).toFixed(2)]}),Object(te.jsx)(re.a,{align:"center",children:t.REFERENCE}),Object(te.jsx)(re.a,{component:"th",scope:"row",align:"center",children:new Date(t.PAYDATE).toLocaleDateString("en-GB")}),Object(te.jsx)(re.a,{align:"center",children:Object(te.jsx)(S.a,{onClick:function(){return e=t.IVNUM,void de.downloadInvoicePdf(e).then((function(t){var n=window.URL.createObjectURL(new Blob([t.data])),a=document.createElement("a");a.href=n,a.setAttribute("download","".concat(e,".pdf")),document.body.appendChild(a),a.click()})).catch((function(e){console.log(e.response),j("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(te.jsx)(fe.a,{})})})]})})}function Ie(e){var t=e.selectedCustomer,n=Object(a.useState)("asc"),c=Object(i.a)(n,2),r=c[0],o=c[1],s=Object(a.useState)("calories"),l=Object(i.a)(s,2),u=l[0],d=l[1],j=Object(a.useState)([]),b=Object(i.a)(j,2),O=b[0],m=b[1],f=Object(a.useState)(0),x=Object(i.a)(f,2),g=x[0],p=x[1],S=Object(a.useState)(5),v=Object(i.a)(S,2),E=v[0],C=v[1],T=Object(a.useState)([]),A=Object(i.a)(T,2),D=A[0],k=A[1],y=Object(a.useState)([]),w=Object(i.a)(y,2),N=w[0],P=w[1],I=Object(a.useState)(!1),U=Object(i.a)(I,2),R=U[0],L=U[1],F=Object(a.useState)(""),M=Object(i.a)(F,2),B=M[0],W=M[1];Object(a.useEffect)((function(){var e=t;if(!e){var n=localStorage.getItem("selectedCUSTNAME");if(n)try{e=JSON.parse(n)}catch(a){console.error("Error parsing stored customer:",a),e=null}}de.getCustomerInvoices(e).then((function(e){k(e.data.value),P(e.data.value),void 0!==e.data.value&&null!==e.data.value&&L(!0)})).catch((function(e){console.log(e)}))}),[t]);return R?Object(te.jsx)(h.a,{sx:{width:"100%"},children:Object(te.jsxs)(le.a,{sx:{width:"100%",mb:2},children:[Object(te.jsx)(ae.a,{children:Object(te.jsxs)(ie.a,{children:[Object(te.jsx)(re.a,{children:Object(te.jsx)(De,{title:"Invoices"})}),Object(te.jsx)(re.a,{children:Object(te.jsx)(ge.a,{id:"search-bar",className:"text",value:B,onChange:function(e){var t=e.target.value;if(W(t),""!==t){var n;n=D.filter((function(e){return e.IVNUM.toLowerCase().includes(t.toLowerCase())})),k(n)}else k(N)},label:"Invoice Search",variant:"outlined",placeholder:"Invoice Number...",InputProps:{startAdornment:Object(te.jsx)(we.a,{position:"start",children:Object(te.jsx)(ye.a,{})})},style:{height:"60px"}})})]})}),Object(te.jsx)(oe.a,{children:Object(te.jsxs)(ae.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(te.jsx)(Ae,{numSelected:O.length,order:r,orderBy:u,onSelectAllClick:function(e){if(e.target.checked){var t=D.map((function(e){return e.name}));m(t)}else m([])},onRequestSort:function(e,t){o(u===t&&"asc"===r?"desc":"asc"),d(t)},rowCount:D.length,headCells:Ne}),Object(te.jsx)(ce.a,{children:D.slice().sort(Se(r,u)).slice(g*E,g*E+E).map((function(e,t){return Object(te.jsx)(Pe,{row:e},t)}))})]})}),Object(te.jsx)(se.a,{rowsPerPageOptions:[5,10,25],component:"div",count:D.length,rowsPerPage:E,page:g,onPageChange:function(e,t){p(t)},onRowsPerPageChange:function(e){C(parseInt(e.target.value,10)),p(0)}})]})}):Object(te.jsx)(he,{})}var Ue=function(){return Object(te.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(te.jsx)(E.a,{item:!0,xs:12,children:Object(te.jsx)(Ie,{})})})},Re=n(123),Le=n.n(Re),Fe=n(122),Me=n.n(Fe),Be=n(649),We=n(650),_e=n(629),Ge=[{id:"CURDATE",numeric:!1,disablePadding:!0,label:"Date"},{id:"ORDNAME",numeric:!0,disablePadding:!1,label:"Order No."},{id:"REFERENCE",numeric:!0,disablePadding:!1,label:"Cust. P.O."},{id:"QPRICE",numeric:!0,disablePadding:!1,label:"Price ex. VAT"},{id:"TOTPRICE",numeric:!0,disablePadding:!1,label:"Total Price"},{id:"ORDSTATUSDES",numeric:!0,disablePadding:!1,label:"Order Status"},{id:"NAME",numeric:!1,disablePadding:!0,label:"Contact"},{id:"ACTION",numeric:!0,disablePadding:!1,label:"PDF"}];function ze(e){var t=e.row,n=Object(a.useState)(!1),r=Object(i.a)(n,2),o=r[0],s=r[1],l=Object(a.useState)([]),u=Object(i.a)(l,2),d=u[0],j=u[1],b=Object(a.useState)(!0),O=Object(i.a)(b,2),m=O[0],f=O[1],x=Object(xe.b)(),p=x.enqueueSnackbar,v=(x.closeSnackbar,function(){o?s(!o):(f(!1),de.getOrderItems(t.ORDNAME).then((function(e){j(e.data.value),f(!0),s(!o)})).catch((function(e){console.log(e)})))});return Object(te.jsxs)(c.a.Fragment,{children:[Object(te.jsxs)(ie.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(te.jsx)(re.a,{children:m?Object(te.jsx)(S.a,{"aria-label":"expand row",size:"small",onClick:v,children:o?Object(te.jsx)(Me.a,{}):Object(te.jsx)(Le.a,{})}):Object(te.jsx)(Be.a,{size:28})}),Object(te.jsx)(re.a,{component:"th",scope:"row",children:new Date(t.CURDATE).toLocaleDateString("en-GB")}),Object(te.jsx)(re.a,{align:"center",children:t.ORDNAME}),Object(te.jsx)(re.a,{align:"center",children:t.REFERENCE}),Object(te.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.QPRICE.toLocaleString()]}),Object(te.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.TOTPRICE.toLocaleString()]}),Object(te.jsx)(re.a,{align:"center",children:Object(te.jsx)(_e.a,{style:{color:function(e){switch(e){case"Draft":return"#00ff00";case"Confirmed":return"#fe9e00";case"In Progress":return"#5ab963";case"Completed":return"#80ffff";case"Assm Opened":case"Partial Assm":case"Assembled":return"#ff80ff";case"Paid":return"#ffff00";case"Canceled":return"#ff0000";default:return"black"}}(t.ORDSTATUSDES)},label:t.ORDSTATUSDES})}),Object(te.jsx)(re.a,{align:"center",children:t.NAME}),Object(te.jsx)(re.a,{align:"center",children:Object(te.jsx)(S.a,{onClick:function(){return e=t.ORDNAME,void de.downloadOrderPdf(e).then((function(t){var n=window.URL.createObjectURL(new Blob([t.data])),a=document.createElement("a");a.href=n,a.setAttribute("download","".concat(e,".pdf")),document.body.appendChild(a),a.click()})).catch((function(e){console.log(e.response),p("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(te.jsx)(fe.a,{})})})]}),Object(te.jsx)(ie.a,{children:Object(te.jsx)(re.a,{style:{paddingBottom:0,paddingTop:0,paddingLeft:100,backgroundColor:"#F8F8F8"},colSpan:8,children:Object(te.jsx)(We.a,{in:o,timeout:"auto",unmountOnExit:!0,onClick:v,children:Object(te.jsxs)(h.a,{sx:{margin:1},children:[Object(te.jsx)(g.a,{variant:"h6",gutterBottom:!0,component:"div",children:"Order Items"}),m?Object(te.jsxs)(ae.a,{size:"small","aria-label":"order-items",children:[Object(te.jsx)(Ee.a,{children:Object(te.jsxs)(ie.a,{children:[Object(te.jsx)(re.a,{children:Object(te.jsx)("b",{children:"Part No."})}),Object(te.jsx)(re.a,{children:Object(te.jsx)("b",{children:"Part Name"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Quantity"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Balance"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Price"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Total Price ex. VAT"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Total Price"})})]})}),Object(te.jsx)(ce.a,{children:d.map((function(e,t){return Object(te.jsxs)(ie.a,{children:[Object(te.jsx)(re.a,{component:"th",scope:"row",children:e.PARTNAME}),Object(te.jsx)(re.a,{children:e.PDES}),Object(te.jsx)(re.a,{align:"right",children:e.TQUANT}),Object(te.jsx)(re.a,{align:"right",children:e.TBALANCE}),Object(te.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.PRICE]}),Object(te.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.QPRICE]}),Object(te.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.VATPRICE]})]},t)}))})]}):Object(te.jsx)(Be.a,{})]})})})})]})}function Ve(e){var t=e.selectedCustomer,n=Object(a.useState)("asc"),c=Object(i.a)(n,2),r=c[0],o=c[1],s=Object(a.useState)("calories"),l=Object(i.a)(s,2),u=l[0],d=l[1],j=Object(a.useState)([]),b=Object(i.a)(j,2),O=b[0],m=(b[1],Object(a.useState)(0)),f=Object(i.a)(m,2),x=f[0],g=f[1],p=Object(a.useState)(5),S=Object(i.a)(p,2),v=S[0],E=S[1],C=Object(a.useState)([]),T=Object(i.a)(C,2),A=T[0],D=T[1],k=Object(a.useState)(!1),y=Object(i.a)(k,2),w=y[0],N=y[1];Object(a.useEffect)((function(){var e=t;if(!e){var n=localStorage.getItem("selectedCUSTNAME");if(n)try{e=JSON.parse(n)}catch(a){console.error("Error parsing stored customer:",a),e=null}}de.getCustomerOrders(e).then((function(e){D(e.data.value),void 0!==e.data.value&&null!==e.data.value&&N(!0)})).catch((function(e){console.log(e)}))}),[t]);return w?Object(te.jsx)(h.a,{sx:{width:"100%"},children:Object(te.jsxs)(le.a,{sx:{width:"100%",mb:2},children:[Object(te.jsx)(De,{title:"Orders"}),Object(te.jsx)(oe.a,{children:Object(te.jsxs)(ae.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(te.jsx)(Ae,{numSelected:O.length,order:r,orderBy:u,onRequestSort:function(e,t){o(u===t&&"asc"===r?"desc":"asc"),d(t)},rowCount:A.length,headCells:Ge}),Object(te.jsx)(ce.a,{children:A.slice().sort(Se(r,u)).slice(x*v,x*v+v).map((function(e,t){return Object(te.jsx)(ze,{row:e},t)}))})]})}),Object(te.jsx)(se.a,{rowsPerPageOptions:[5,10,25],component:"div",count:A.length,rowsPerPage:v,page:x,onPageChange:function(e,t){g(t)},onRowsPerPageChange:function(e){E(parseInt(e.target.value,10)),g(0)}})]})}):Object(te.jsx)("div",{children:"No Order for this Customer"})}var Ye=function(){return Object(te.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(te.jsx)(E.a,{item:!0,xs:12,children:Object(te.jsx)(Ve,{})})})},qe=[{id:"CURDATE",numeric:!1,disablePadding:!0,label:"Date"},{id:"DOCNO",numeric:!0,disablePadding:!1,label:"Shipment No."},{id:"REFERENCE",numeric:!0,disablePadding:!1,label:"Cust. P.O."},{id:"QPRICE",numeric:!0,disablePadding:!1,label:"Price ex. VAT"},{id:"TOTPRICE",numeric:!0,disablePadding:!1,label:"Total Price"},{id:"STATDES",numeric:!0,disablePadding:!1,label:"Shipment Status"},{id:"ACTION",numeric:!0,disablePadding:!1,label:"PDF"}];function Xe(e){var t=e.row,n=Object(a.useState)(!1),r=Object(i.a)(n,2),o=r[0],s=r[1],l=Object(a.useState)([]),u=Object(i.a)(l,2),d=u[0],j=u[1],b=Object(a.useState)(!0),O=Object(i.a)(b,2),m=O[0],f=O[1],x=Object(xe.b)(),p=x.enqueueSnackbar,v=(x.closeSnackbar,function(){o?s(!o):(f(!1),de.getShipmentItems(t.DOCNO,t.TYPE).then((function(e){j(e.data.value),f(!0),s(!o)})).catch((function(e){console.log(e)})))});return Object(te.jsxs)(c.a.Fragment,{children:[Object(te.jsxs)(ie.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(te.jsx)(re.a,{children:m?Object(te.jsx)(S.a,{"aria-label":"expand row",size:"small",onClick:v,children:o?Object(te.jsx)(Me.a,{}):Object(te.jsx)(Le.a,{})}):Object(te.jsx)(Be.a,{size:28})}),Object(te.jsx)(re.a,{component:"th",scope:"row",children:new Date(t.CURDATE).toLocaleDateString("en-GB")}),Object(te.jsx)(re.a,{align:"center",children:t.DOCNO}),Object(te.jsx)(re.a,{align:"center",children:t.REFERENCE}),Object(te.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.QPRICE.toLocaleString()]}),Object(te.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.TOTPRICE.toLocaleString()]}),Object(te.jsx)(re.a,{align:"center",children:Object(te.jsx)(_e.a,{style:{color:function(e){switch(e){case"Draft":return"#00ff00";case"Final":return"#ffd233";case"Canceled":return"#f56b62";default:return"black"}}(t.STATDES)},label:t.STATDES})}),Object(te.jsx)(re.a,{align:"center",children:Object(te.jsx)(S.a,{onClick:function(){return e=t.DOCNO,void de.downloadShipmentPdf(e).then((function(t){var n=window.URL.createObjectURL(new Blob([t.data])),a=document.createElement("a");a.href=n,a.setAttribute("download","".concat(e,".pdf")),document.body.appendChild(a),a.click()})).catch((function(e){console.log(e.response),p("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(te.jsx)(fe.a,{})})})]}),Object(te.jsx)(ie.a,{children:Object(te.jsx)(re.a,{style:{paddingBottom:0,paddingTop:0,paddingLeft:100,backgroundColor:"#F8F8F8"},colSpan:8,children:Object(te.jsx)(We.a,{in:o,timeout:"auto",unmountOnExit:!0,onClick:v,children:Object(te.jsxs)(h.a,{sx:{margin:1},children:[Object(te.jsx)(g.a,{variant:"h6",gutterBottom:!0,component:"div",children:"Shipped Items"}),m?Object(te.jsxs)(ae.a,{size:"small","aria-label":"purchases",children:[Object(te.jsx)(Ee.a,{children:Object(te.jsxs)(ie.a,{children:[Object(te.jsx)(re.a,{children:Object(te.jsx)("b",{children:"Part No."})}),Object(te.jsx)(re.a,{children:Object(te.jsx)("b",{children:"Part Name"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Quantity"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Price"})}),Object(te.jsx)(re.a,{align:"right",children:Object(te.jsx)("b",{children:"Total Price ex. VAT"})})]})}),Object(te.jsx)(ce.a,{children:d.map((function(e,t){return Object(te.jsxs)(ie.a,{children:[Object(te.jsx)(re.a,{component:"th",scope:"row",children:e.PARTNAME}),Object(te.jsx)(re.a,{children:e.PDES}),Object(te.jsx)(re.a,{align:"right",children:e.TQUANT}),Object(te.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.PRICE]}),Object(te.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.QPRICE]})]},t)}))})]}):Object(te.jsx)(Be.a,{})]})})})})]})}function Qe(e){var t=e.selectedCustomer,n=Object(a.useState)("asc"),c=Object(i.a)(n,2),r=c[0],o=c[1],s=Object(a.useState)("calories"),l=Object(i.a)(s,2),u=l[0],d=l[1],j=Object(a.useState)([]),b=Object(i.a)(j,2),O=b[0],m=b[1],f=Object(a.useState)(0),x=Object(i.a)(f,2),g=x[0],p=x[1],S=Object(a.useState)(5),v=Object(i.a)(S,2),E=v[0],C=v[1],T=Object(a.useState)([]),A=Object(i.a)(T,2),D=A[0],k=A[1],y=Object(a.useState)(!1),w=Object(i.a)(y,2),N=w[0],P=w[1];Object(a.useEffect)((function(){var e=t;if(!e){var n=localStorage.getItem("selectedCUSTNAME");if(n)try{e=JSON.parse(n)}catch(a){console.error("Error parsing stored customer:",a),e=null}}de.getCustomerShipments(e).then((function(e){k(e.data.value),void 0!==e.data.value&&null!==e.data.value&&P(!0)})).catch((function(e){console.log(e)}))}),[t]);return N?Object(te.jsx)(h.a,{sx:{width:"100%"},children:Object(te.jsxs)(le.a,{sx:{width:"100%",mb:2},children:[Object(te.jsx)(De,{title:"Shipments"}),Object(te.jsx)(oe.a,{children:Object(te.jsxs)(ae.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(te.jsx)(Ae,{numSelected:O.length,order:r,orderBy:u,onSelectAllClick:function(e){if(e.target.checked){var t=D.map((function(e){return e.name}));m(t)}else m([])},onRequestSort:function(e,t){o(u===t&&"asc"===r?"desc":"asc"),d(t)},rowCount:D.length,headCells:qe}),Object(te.jsx)(ce.a,{children:D.slice().sort(Se(r,u)).slice(g*E,g*E+E).map((function(e,t){return Object(te.jsx)(Xe,{row:e},t)}))})]})}),Object(te.jsx)(se.a,{rowsPerPageOptions:[5,10,25],component:"div",count:D.length,rowsPerPage:E,page:g,onPageChange:function(e,t){p(t)},onRowsPerPageChange:function(e){C(parseInt(e.target.value,10)),p(0)}})]})}):Object(te.jsx)(he,{})}var He=function(){return Object(te.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(te.jsx)(E.a,{item:!0,xs:12,children:Object(te.jsx)(Qe,{})})})},Je=n(40),Ke=n(620),Ze=n(335),$e=n(621),et=n(615),tt=n(125),nt=n.n(tt),at=n(499),ct=n(651),rt=n(124),ot=n.n(rt),st=n(312),it=n.n(st),lt=n(313),ut=n.n(lt);function dt(e){return Number.parseFloat(e).toFixed(2)}var jt=[{id:"PARTDES",numeric:!1,disablePadding:!0,label:"Item Description"},{id:"PARTNAME",numeric:!0,disablePadding:!1,label:"Item Number"},{id:"BASEPLPRICE",numeric:!0,disablePadding:!1,label:"Price"},{id:"VAT Price",numeric:!0,disablePadding:!1,label:"VAT Price"},{id:"QUANTITY",numeric:!0,disablePadding:!1,label:"Quantity"},{id:"total-price",numeric:!0,disablePadding:!1,label:"Total Price"}];function bt(e){var t=e.order,n=e.orderBy,a=e.onRequestSort;return Object(te.jsx)(Ee.a,{children:Object(te.jsxs)(ie.a,{children:[Object(te.jsx)(re.a,{padding:"checkbox"}),jt.map((function(e){return Object(te.jsx)(re.a,{align:e.numeric?"right":"left",padding:e.disablePadding?"none":"normal",sortDirection:n===e.id&&t,children:Object(te.jsxs)(Ce.a,{active:n===e.id,direction:n===e.id?t:"asc",onClick:(c=e.id,function(e){a(e,c)}),children:[Object(te.jsx)("b",{children:e.label}),n===e.id?Object(te.jsx)(h.a,{component:"span",sx:Te.a,children:"desc"===t?"sorted descending":"sorted ascending"}):null]})},e.id);var c}))]})})}var Ot=function(e){var t=e.numSelected;return Object(te.jsxs)(f.a,{sx:Object(l.a)({pl:{sm:2},pr:{xs:1,sm:1}},t>0&&{bgcolor:function(e){return Object(at.a)(e.palette.primary.main,e.palette.action.activatedOpacity)}}),children:[t>0?Object(te.jsxs)(g.a,{sx:{flex:"1 1 100%"},color:"inherit",variant:"subtitle1",component:"div",children:[t," selected"]}):Object(te.jsx)(g.a,{sx:{flex:"1 1 100%"},variant:"h6",id:"tableTitle",component:"div",children:"Items in Order"}),t>0?Object(te.jsx)(ct.a,{title:"Delete",children:Object(te.jsx)(S.a,{onClick:e.onDelete,children:Object(te.jsx)(ot.a,{})})}):Object(te.jsx)(ct.a,{title:"Filter list",children:Object(te.jsx)(S.a,{children:Object(te.jsx)(it.a,{})})})]})};function ht(e){var t=a.useState("asc"),n=Object(i.a)(t,2),c=n[0],r=n[1],o=a.useState("calories"),s=Object(i.a)(o,2),l=s[0],u=s[1],d=a.useState([]),j=Object(i.a)(d,2),b=j[0],O=j[1],m=e.items;return Object(te.jsx)(h.a,{sx:{width:"100%"},children:Object(te.jsxs)(le.a,{sx:{width:"100%",mb:2},children:[Object(te.jsx)(Ot,{}),Object(te.jsx)(oe.a,{children:Object(te.jsxs)(ae.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(te.jsx)(bt,{numSelected:b.length,order:c,orderBy:l,onSelectAllClick:function(e){if(e.target.checked){var t=m.map((function(e){return e.PARTNAME}));O(t)}else O([])},onRequestSort:function(e,t){r(l===t&&"asc"===c?"desc":"asc"),u(t)},rowCount:m.length}),Object(te.jsxs)(ce.a,{children:[ve(m,Se(c,l)).map((function(t,n){var a,c=(a=t.PARTNAME,-1!==b.indexOf(a)),r="enhanced-table-checkbox-".concat(n);return Object(te.jsxs)(ie.a,{hover:!0,role:"checkbox","aria-checked":c,tabIndex:-1,selected:c,children:[Object(te.jsx)(re.a,{padding:"checkbox"}),Object(te.jsx)(re.a,{component:"th",id:r,scope:"row",padding:"none",children:t.PARTDES}),Object(te.jsx)(re.a,{align:"right",children:t.PARTNAME}),Object(te.jsxs)(re.a,{align:"right",children:[t.BASEPLCODE," ",dt(t.BASEPLPRICE)]}),Object(te.jsxs)(re.a,{align:"right",children:[t.BASEPLCODE," ",dt(t.VATPRICE)]}),Object(te.jsxs)(re.a,{align:"right",children:[Object(te.jsx)(S.a,{onClick:function(n){return e.onDecrement(t,n)},children:Object(te.jsx)(ut.a,{})}),t.QUANTITY,Object(te.jsx)(S.a,{onClick:function(n){return e.onIncrement(t,n)},children:Object(te.jsx)(nt.a,{})})]}),Object(te.jsxs)(re.a,{align:"right",children:[t.BASEPLCODE," ",dt(t.VATPRICE*t.QUANTITY)]})]},n)})),Object(te.jsxs)(ie.a,{children:[Object(te.jsx)(re.a,{colSpan:6,align:"right",children:Object(te.jsx)("b",{children:"Total Price"})}),Object(te.jsx)(re.a,{align:"right",children:function(){for(var e=0,t=0;t0){var n=p.findIndex((function(e){return e.PARTNAME===u.PARTNAME}));console.log(u.PARTNAME),n>-1?(t[n].QUANTITY=parseInt(u.QUANTITY)+parseInt(O),S(t)):(u.QUANTITY=O,S((function(e){return[].concat(Object(je.a)(e),[u])})))}else console.log("Quantity must be greater than 0.")},children:"Add"})}),Object(te.jsx)(E.a,{item:!0,md:12,children:Object(te.jsx)(ht,{items:p,onDecrement:function(e){var t=Object(je.a)(p),n=p.findIndex((function(t){return t.PARTNAME===e.PARTNAME}));1===t[n].QUANTITY?t.splice(n,1):t[n].QUANTITY-=1,S(t)},onIncrement:function(e){var t=Object(je.a)(p),n=p.findIndex((function(t){return t.PARTNAME===e.PARTNAME}));t[n].QUANTITY=parseInt(t[n].QUANTITY)+1,S(t)}})}),Object(te.jsx)(E.a,{item:!0,md:12,children:Object(te.jsx)(Ze.a,{disabled:0===p.length,onClick:function(){console.log(p);for(var e=Object(je.a)(p),t=[],n=0;n0?r.map((function(e,t){return Object(te.jsxs)(xt.a,{onClick:function(){return 0===e.READ?function(e,t){de.setNotificationRead({ID:e}).then((function(e){var n=Object(je.a)(r);n[t].READ=1,o(n),console.log(r)})).catch((function(e){console.log(e)}))}(e.ID,t):null},selected:0===e.READ,children:[Object(te.jsx)(y.a,{children:Object(te.jsx)(Pt.a,{fontSize:"small"})}),Object(te.jsxs)(w.a,{children:[e.ORDNAME," has been changed to ",e.ORDSTATUSDES," ",f.format(new Date(e.DATE))]})]},t)})):Object(te.jsx)(g.a,{children:"No notifications."})})]}):Object(te.jsx)(Be.a,{})}var Lt=n(29),Ft=n.n(Lt),Mt=n(48),Bt=n(653),Wt=n(654),_t=n(126),Gt=n(99),zt=n.n(Gt),Vt=n(184),Yt=n.n(Vt),qt=n(42),Xt=(n(223),n(298),n(129)),Qt=n(512);function Ht(){var e=c.a.useState(!0),t=Object(i.a)(e,2),n=t[0];t[1];return Object(te.jsx)("div",{children:Object(te.jsx)(Qt.a,{sx:{color:"#fff",zIndex:function(e){return e.zIndex.drawer+1}},open:n,children:Object(te.jsx)(Be.a,{color:"inherit"})})})}var Jt=function(e){return{sx:{bgcolor:Zt(e),fontSize:16,width:30,height:30},children:Kt(e)}},Kt=function(e){var t=e.charAt(0),n=e.charAt(e.length-1);return t.toUpperCase()+n.toUpperCase()},Zt=function(e){var t,n=0;for(t=0;t>8*t&255).toString(16)).slice(-2)}return a},$t=function(e){return new Date(e).toLocaleDateString("en-GB",{month:"short",day:"numeric"})},en=function(e){return new Promise((function(t,n){return function(e,t){var n=new FileReader;n.readAsDataURL(e),n.onload=function(){return t(n.result)},n.onerror=function(e){}}(e,(function(e){return t({data:{link:e}})}))}))},tn=function(e,t,n){var a=document.createElement("a");a.href=e,a.download=t+"."+n,a.click()},nn=n(316),an=n.n(nn),cn=(n(490),n(491),n(492),n(493),n(14)),rn=n(328),on=n(75),sn=n(98),ln=n(315),un=(n(494),n(652)),dn=n(614),jn=Object(a.createContext)();function bn(){return Object(a.useContext)(jn)}function On(e){var t=e.children,n=Object(a.useState)([]),c=Object(i.a)(n,2),r=c[0],o=c[1],s=Object(a.useState)([]),l=Object(i.a)(s,2),u=l[0],d=l[1],j=Object(a.useState)(!0),b=Object(i.a)(j,2),O=b[0],h=b[1],m=Object(a.useState)(!1),f=Object(i.a)(m,2),x=f[0],g=f[1],p=Object(a.useState)({}),S=Object(i.a)(p,2),v=S[0],E=S[1],C=Object(a.useState)(""),T=Object(i.a)(C,2),A=T[0],D=T[1];return Object(te.jsx)(jn.Provider,{value:{serviceCallData:r,setServiceCallData:o,serviceCallStatus:u,setServiceCallStatus:d,hideAnsweredCalls:O,setHideAnsweredCalls:h,viewcallDataTable:x,setviewcallDataTable:g,filtersBlock:v,setFiltersBlock:E,globalFilterData:A,setGlobalFilterData:D},children:t})}var hn=function(e){var t,n=e.selectedCustomer,c=Object(a.useState)(""),r=Object(i.a)(c,2),o=r[0],s=r[1],u=Object(a.useState)(null),d=Object(i.a)(u,2),j=d[0],b=d[1],O=Object(a.useState)(null),h=Object(i.a)(O,2),m=h[0],f=h[1],x=Object(a.useState)(!0),g=Object(i.a)(x,2),p=g[0],v=g[1],E=function(){return{global:{value:null,matchMode:cn.a.CONTAINS},DOCNO:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.STARTS_WITH}]},ZEMG_SVC_DETAILS:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.STARTS_WITH}]},REFERENCE:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.STARTS_WITH}]},NAME:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.STARTS_WITH}]},STARTDATE:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.DATE_IS}]},CALLTYPECODE:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.EQUALS}]},CDES:{operator:cn.b.OR,constraints:[{value:null,matchMode:cn.a.EQUALS}]},CALLSTATUSCODE:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.EQUALS}]},STATUSDATE:{operator:cn.b.AND,constraints:[{value:null,matchMode:cn.a.DATE_IS}]}}},C=Object(a.useState)(E()),T=Object(i.a)(C,2),A=T[0],D=T[1],k=Object(a.useState)(!0),y=Object(i.a)(k,2),w=y[0],N=y[1],P=Object(xe.b)(),I=P.enqueueSnackbar,U=(P.closeSnackbar,bn()),L=U.serviceCallData,F=U.serviceCallStatus,M=U.setServiceCallData,B=U.setServiceCallStatus,W=U.hideAnsweredCalls,_=U.setHideAnsweredCalls,G=U.viewcallDataTable,z=U.setviewcallDataTable,V=U.filtersBlock,Y=U.setFiltersBlock,q=U.globalFilterData,X=U.setGlobalFilterData,Q=Object(a.useState)(!1),H=Object(i.a)(Q,2),J=H[0],K=H[1];Object(a.useEffect)((function(){f($(L)),b(F),N(!1),!0===G?(D(V),s(q)):Y(E())}),[]);var Z=function(){var e=Object(Mt.a)(Ft.a.mark((function e(){var t,a,c,r;return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Y(E()),D(E()),s(""),X(""),!(t=n)&&(a=localStorage.getItem("selectedCUSTNAME")))try{t=JSON.parse(a)}catch(o){console.error("Error parsing stored customer:",o),t=null}return K(!0),e.prev=7,e.next=10,de.getServiceCalls(t);case 10:return c=e.sent,f($(c.data.value)),M($(c.data.value)),e.next=15,de.getCallStatuses();case 15:r=e.sent,b(r.data.value),B(r.data.value),e.next=23;break;case 20:e.prev=20,e.t0=e.catch(7),console.error(e.t0);case 23:return e.prev=23,K(!1),N(!1),e.finish(23);case 27:case"end":return e.stop()}}),e,null,[[7,20,23,27]])})));return function(){return e.apply(this,arguments)}}();var $=function(e){return Object(je.a)(e||[]).map((function(e){return e.STARTDATE=new Date(e.STARTDATE),e.STATUSDATE=new Date(e.STATUSDATE),e}))},ee=function(e){return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"})},ne=function(e){var t=e.target.value,n=Object(l.a)({},A);n.global.value=t,D(n),Y(n),s(t),X(t)},ce=function(e){_(e.target.checked)},re=function(e){return Object(te.jsx)(ln.a,{value:e.value,onChange:function(t){return e.filterCallback(t.value,e.index)},dateFormat:"dd/mm/yy",placeholder:"dd/mm/yyyy",mask:"99/99/9999"})},oe=function(e){v(e.target.checked)},se=Object(te.jsxs)(te.Fragment,{children:[Object(te.jsx)(ae.a,{children:Object(te.jsx)("tr",{children:Object(te.jsxs)("td",{children:[Object(te.jsx)("h5",{className:"m-0",children:"Service Calls \xa0\xa0\xa0"}),J?Object(te.jsxs)("p",{style:{fontSize:15,color:"red"},children:["Please wait. The Data is loading....",Object(te.jsxs)("box",{children:[Object(te.jsx)(Be.a,{style:{width:20,height:23,color:"red"}})," "]})," "]}):Object(te.jsx)(te.Fragment,{})]})})}),Object(te.jsx)(un.a,{control:Object(te.jsx)(dn.a,{onChange:oe,checked:p,name:"gilad"}),label:"Show Only Active Tickets"})," ",Object(te.jsx)(un.a,{control:Object(te.jsx)(dn.a,{onChange:ce,checked:W,name:"gilad"}),label:"Hide Answered Calls"})," ",Object(te.jsxs)("span",{className:"p-input-icon-left",children:[Object(te.jsx)("i",{className:"pi pi-search"}),Object(te.jsx)(sn.a,{value:o,onChange:ne,placeholder:"Keyword Search"}),Object(te.jsx)(Ze.a,{onClick:Z,sx:{m:1},size:"small",variant:"contained",children:"Refresh Data"})]})]});return w?Object(te.jsx)(he,{}):Object(te.jsx)("div",{className:"datatable-doc-demo",children:Object(te.jsx)("div",{className:"card",children:Object(te.jsxs)(rn.a,{value:function(e,n){if(""!==(t=p&&W?e.filter((function(e){return"Y"===e.ACTIVEFLAG&&"Answered"!==e.CALLSTATUSCODE})):p?e.filter((function(e){return"Y"===e.ACTIVEFLAG})):W?e.filter((function(e){return"Answered"!==e.CALLSTATUSCODE})):e))return t.map((function(e){var t=n.find((function(t){return t.CODE===e.CALLSTATUSCODE}));return t&&t.ESTATDES?Object(l.a)(Object(l.a)({},e),{},{CALLSTATUSCODE:t.ESTATDES}):e}))}(m,j),paginator:!0,className:"p-datatable-customers",header:se,rows:10,breakpoint:"960px",paginatorTemplate:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown",rowsPerPageOptions:[10,25,50],dataKey:"id",rowHover:!0,filters:A,filterDisplay:"menu",loading:w,responsiveLayout:"stack",globalFilterFields:["DOCNO","ZEMG_SVC_DETAILS","REFERENCE","NAME","STARTDATE","ZEMG_SEVDES","CALLTYPECODE","CALLSTATUSCODE","STATUSDATE"],emptyMessage:"No service calls found.",currentPageReportTemplate:"Showing {first} to {last} of {totalRecords} entries",onFilter:function(e){D(e.filters),Y(e.filters)},children:[Object(te.jsx)(on.a,{field:"DOCNO",header:"Ticket ID",filterField:"DOCNO",sortable:!0,body:function(e){return Object(te.jsxs)(R.b,{style:{textDecoration:"none",color:"blue"},to:"/dashboard/servicecall/".concat(e.DOCNO),sx:{mt:3},onClick:function(){return e.DOCNO,void z(!1)},children:[" ",e.DOCNO]})},filter:!0,filterPlaceholder:"Search by Ticket ID"}),Object(te.jsx)(on.a,{field:"ZEMG_SVC_DETAILS",header:"Subject",sortable:!0,filter:!0,filterPlaceholder:"Search by Subject"}),Object(te.jsx)(on.a,{field:"REFERENCE",header:"Cust. Ref",sortable:!0,filter:!0,filterPlaceholder:"Search by Reference"}),Object(te.jsx)(on.a,{field:"NAME",header:"Contact",sortable:!0,filter:!0,filterPlaceholder:"Search by Contact"}),Object(te.jsx)(on.a,{field:"STARTDATE",header:"Open Date",sortable:!0,filterField:"STARTDATE",dataType:"date",body:function(e){return ee(e.STARTDATE)},filter:!0,filterPlaceholder:"Search by Open Date",filterElement:re}),Object(te.jsx)(on.a,{field:"CALLTYPECODE",header:"Classification",sortable:!0,filter:!0,filterPlaceholder:"Search by Classification"}),Object(te.jsx)(on.a,{field:"ZEMG_SEVDES",header:"Call Severity",sortable:!0,filter:!0,filterPlaceholder:"Search by Call Severity"}),Object(te.jsx)(on.a,{field:"CALLSTATUSCODE",header:"Status",sortable:!0,filter:!0,filterPlaceholder:"Search by Status"}),Object(te.jsx)(on.a,{field:"STATUSDATE",header:"Update Date",sortable:!0,filterField:"STATUSDATE",dataType:"date",body:function(e){return ee(e.STATUSDATE)},filter:!0,filterPlaceholder:"Search by Update Date",filterElement:re}),Object(te.jsx)(on.a,{header:"Action",body:function(e){return Object(te.jsx)(S.a,{onClick:function(){return function(e){de.downloadServicePdf(e.DOCNO).then((function(t){var n=window.URL.createObjectURL(new Blob([t.data])),a=document.createElement("a");a.href=n,a.setAttribute("download","".concat(e.DOCNO,".pdf")),document.body.appendChild(a),a.click()})).catch((function(e){I("File not found. Please contact system manager.",{variant:"error"})}))}(e)},style:{fontSize:"24px"},children:Object(te.jsx)(fe.a,{style:{fontSize:"24px"}})})}})]})})})},mn=function(e){return Object(te.jsx)(E.a,{item:!0,md:3,children:Object(te.jsx)(Bt.a,{children:Object(te.jsx)(Wt.a,{children:Object(te.jsxs)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:[Object(te.jsxs)("b",{children:[e.subject,":"]})," ",e.info]})})})})},fn=function(){var e,t=Object(xe.b)(),n=t.enqueueSnackbar,r=(t.closeSnackbar,Object(a.useState)(!1)),o=Object(i.a)(r,2),s=o[0],l=o[1],u=Object(Je.h)().docno,d=Object(a.useState)(null),j=Object(i.a)(d,2),b=j[0],O=j[1],h=Object(a.useState)(null),m=Object(i.a)(h,2),f=m[0],x=m[1],p=Object(a.useState)(!0),C=Object(i.a)(p,2),T=C[0],A=C[1],D=Object(a.useState)(0),k=Object(i.a)(D,2),y=(k[0],k[1],Object(a.useState)(_.getCurrentUser().name)),w=Object(i.a)(y,2),N=w[0],P=(w[1],Object(a.useState)([])),I=Object(i.a)(P,2),U=I[0],R=I[1],L=Object(Xt.a)({accept:"*",readAs:"DataURL"}),F=Object(i.a)(L,2),M=F[0],B=F[1],W=(B.plainFiles,B.filesContent),G=B.clear,z=Object(a.useState)([]),V=Object(i.a)(z,2),Y=V[0],q=V[1],X=Object(a.useState)(!0),Q=Object(i.a)(X,2),H=(Q[0],Q[1],Object(a.useState)(!1)),J=Object(i.a)(H,2),K=J[0],Z=J[1],$=bn(),ee=$.viewcallDataTable,ne=$.setviewcallDataTable,ae=function(e){console.info(W[0]),G(),R([])},ce=(qt.EditorState.createEmpty(),c.a.useState()),re=Object(i.a)(ce,2),oe=re[0],se=re[1],ie=function(){var e=Object(Mt.a)(Ft.a.mark((function e(){var t,n,a,c;return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,de.getServiceCall(u);case 2:if(1!==(t=e.sent.data).value.length){e.next=21;break}return e.next=6,de.getStatusLang2(t.value[0].CALLSTATUSCODE);case 6:return n=e.sent.data,e.next=9,de.getSCAttachments(u);case 9:return a=e.sent.data.value,t.ESTATDES=n.value[0].ESTATDES,t.CHANGEFLAG=n.value[0].CHANGEFLAG,O(t),e.next=15,de.getServiceCallExternalRemarks(u);case 15:c=e.sent.data,x(c),q(a),A(!1),e.next=22;break;case 21:Z(!0);case 22:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(a.useEffect)(Object(Mt.a)(Ft.a.mark((function e(){return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:!1===ee&&ie();case 1:case"end":return e.stop()}}),e)}))),[T,ee]),Object(a.useEffect)((function(){if(W){var e=W;R((function(t){return t.concat(e)}))}}),[W]);return Object(te.jsx)(te.Fragment,{children:ee?Object(te.jsx)(hn,{}):T&&!1===K?Object(te.jsx)(Ht,{}):K?Object(te.jsx)("div",{children:Object(te.jsx)("p",{children:Object(te.jsx)(et.a,{severity:"error",children:Object(te.jsx)("b",{children:"Sorry!..Invalid Service Call Number"})})})}):Object(te.jsxs)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:[Object(te.jsx)(Ze.a,{onClick:function(){ne(!0),O(null),A(!0),Z(!1)},size:"small",variant:"contained",children:"Back to search results"}),Object(te.jsxs)(E.a,{container:!0,spacing:1,direction:"row",alignItems:"center",children:[Object(te.jsx)(mn,{subject:"Ticket Number",info:b.value[0].DOCNO}),Object(te.jsx)(mn,{subject:"Subject",info:b.value[0].ZEMG_SVC_DETAILS}),Object(te.jsx)(mn,{subject:"Customer",info:b.value[0].CDES}),Object(te.jsx)(mn,{subject:"Contact",info:b.value[0].NAME}),Object(te.jsx)(mn,{subject:"Type of Call ",info:b.value[0].CALLTYPECODE}),Object(te.jsx)(mn,{subject:"Cust. Reference",info:b.value[0].REFERENCE}),Object(te.jsx)(mn,{subject:"Status",info:null!==(e=b.value[0].ESTATDES)&&void 0!==e?e:b.value[0].CALLSTATUSCODE})]}),"Y"===b.CHANGEFLAG?Object(te.jsxs)(te.Fragment,{children:[Object(te.jsx)(Bt.a,{sx:{mt:2,mb:2},children:Object(te.jsxs)(Wt.a,{children:[Object(te.jsxs)("div",{sx:{display:"flex",flexDirection:"row"},children:[Object(te.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(te.jsx)("b",{children:"Add a Comment"})}),Object(te.jsx)(S.a,{children:Object(te.jsx)(an.a,{})})]}),Object(te.jsx)(_t.Editor,{wrapperClassName:"wrapperClassName",editorState:oe,editorStyle:{overflow:"hidden",minHeight:"20vh"},onEditorStateChange:function(e){se(e)},toolbar:{options:["inline","blockType","fontSize","list","textAlign","colorPicker","link","history"]}})]})}),Object(te.jsx)(Ze.a,{onClick:function(){return M()},variant:"outlined",startIcon:Object(te.jsx)(Yt.a,{}),children:"Add File"}),Object(te.jsx)(Ze.a,{variant:"contained",sx:{marginLeft:"77.5%"},disabled:void 0===oe,onClick:function(){if(1===Object(qt.convertToRaw)(oe.getCurrentContent()).blocks.length&""===Object(qt.convertToRaw)(oe.getCurrentContent()).blocks[0].text)n("You can not submit an empty comment.",{variant:"error"});else{l(!0);var e=qt.EditorState.createEmpty();se(e);var t,a=(new Date).toLocaleString("en-GB"),c=[];for(var r in W){var o={EXTFILEDES:W[r].name.split(".")[0],EXTFILENAME:W[r].content};"msg"===W[r].name.split(".")[1]&&(o.SUFFIX=".msg"),"lic"===W[r].name.split(".")[1]&&(o.SUFFIX=".lic"),c.push(o)}t=0!==c.length?a+zt()(Object(qt.convertToRaw)(oe.getCurrentContent()))+"
"+c.length+" files attached.
"+"

".concat(N,"


"):a+zt()(Object(qt.convertToRaw)(oe.getCurrentContent()))+"

".concat(N,"


");b.CALLSTATUSCODE;var s={DOCNO:u,TEXT:t,APPEND:!0,SIGNATURE:!1,EXTFILES:c};de.updateServiceCall(s).then((function(e){"ZMED_TEMPSCTEXT"===e.data?n("There was a problem updating the call. The support team have been notified.",{variant:"error"}):n("Service call updated succesfully.",{variant:"success"}),l(!1),ae(),A(!0)})).catch((function(e){n("Error updating service call.",{variant:"error"}),l(!1),ae(),A(!0)}))}},children:"Update Ticket"})]}):null,0!=(null===U||void 0===U?void 0:U.length)?Object(te.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(te.jsx)(ot.a,{onClick:ae})}):Object(te.jsx)(te.Fragment,{}),null===U||void 0===U?void 0:U.map((function(e,t){return Object(te.jsx)(_e.a,{label:e.name})})),1==T||1==s?Object(te.jsx)(Ht,{}):null,Object(te.jsx)(Bt.a,{sx:{mt:2},children:Object(te.jsxs)(Wt.a,{children:[Object(te.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(te.jsx)("b",{children:"Description"})}),(null===f||void 0===f?void 0:f.TEXT)&&Object(te.jsx)("div",{style:{overflow:"auto"},dangerouslySetInnerHTML:{__html:f.TEXT.replaceAll("../../system/mail/","https://priority.medatecherp.co.uk/primail/")}})]})}),Object(te.jsx)(Bt.a,{sx:{mt:2},children:Object(te.jsxs)(Wt.a,{children:[Object(te.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(te.jsx)("b",{children:"Attachments"})}),null===Y||void 0===Y?void 0:Y.map((function(e,t){return Object(te.jsx)(_e.a,{label:e.EXTFILEDES+"."+e.SUFFIX,color:"primary",size:"small",sx:{mr:1,mb:1},onClick:function(){return tn(e.EXTFILENAME,e.EXTFILEDES,e.SUFFIX)}},t)}))]})})]})})},xn=n(616),gn=n(655),pn=n(603);function Sn(e){var t=e.items,n=e.onChange,c=e.labelname,r=e.title,o=e.description,s=e.required,u=e.disabled,d=a.useState(!1),j=Object(i.a)(d,2),b=j[0],O=j[1],h=b&&0===t.length;return Object(te.jsx)(Ke.a,{sx:{m:1},disabled:u,fullWidth:!0,open:b,onOpen:function(){O(!0)},onClose:function(){O(!1)},onChange:n,isOptionEqualToValue:function(e,t){return""===c?e===t:e[c]===t[c]},getOptionLabel:function(e){return""===c?e+(o?": "+e[o]:""):e[c]+(o?": "+e[o]:"")},options:t,loading:h,renderInput:function(e){return Object(te.jsx)(ge.a,Object(l.a)(Object(l.a)({required:s},e),{},{label:r,InputProps:Object(l.a)(Object(l.a)({},e.InputProps),{},{endAdornment:Object(te.jsxs)(a.Fragment,{children:[h?Object(te.jsx)(Be.a,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})})}))}})}var vn=function(e){var t=Object(a.useState)(!0),n=Object(i.a)(t,2),c=n[0],r=n[1],o=Object(a.useState)([{CODE:"From Portal"}]),s=Object(i.a)(o,2),l=(s[0],s[1]),u=Object(a.useState)(""),d=Object(i.a)(u,2),j=d[0],b=d[1],O=Object(a.useState)([]),h=Object(i.a)(O,2),m=h[0],f=h[1],x=Object(a.useState)(),p=Object(i.a)(x,2),C=(p[0],p[1]),T=Object(a.useState)([]),A=Object(i.a)(T,2),D=A[0],k=A[1],y=Object(a.useState)([]),w=Object(i.a)(y,2),N=w[0],P=w[1],I=Object(a.useState)(),U=Object(i.a)(I,2),R=U[0],L=U[1],F=Object(xe.b)(),M=F.enqueueSnackbar,B=(F.closeSnackbar,qt.EditorState.createEmpty()),W=Object(a.useState)(""),G=Object(i.a)(W,2),z=G[0],V=G[1],Y=Object(a.useState)(B),q=Object(i.a)(Y,2),X=q[0],Q=q[1],H=Object(a.useState)(_.getCurrentUser().name),J=Object(i.a)(H,2),K=J[0],Z=(J[1],Object(Xt.a)({accept:"*",readAs:"DataURL"})),$=Object(i.a)(Z,2),ee=$[0],ne=$[1],ae=ne.plainFiles,ce=ne.filesContent,re=ne.clear,oe=Object(a.useState)(!1),se=Object(i.a)(oe,2),ie=se[0],le=se[1],ue=Object(a.useState)(""),be=Object(i.a)(ue,2),Oe=be[0],he=be[1],me=bn(),fe=me.serviceCallData,pe=me.setServiceCallData,Se=Object(a.useState)(null),ve=Object(i.a)(Se,2),Ee=ve[0],Ce=ve[1];Object(a.useEffect)((function(){var e=function(){try{var e=localStorage.getItem("selectedCUSTNAME");if(e){var t=JSON.parse(e);return Ce(t),t}}catch(n){console.error("Error parsing stored customer:",n)}return null}();if(e){r(!0);var t=function(){var e=Object(Mt.a)(Ft.a.mark((function e(){var t;return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,de.getCallSeverities();case 2:t=e.sent,f(t.data.value);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n=function(){var t=Object(Mt.a)(Ft.a.mark((function t(){var n;return Ft.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,de.getCustomerContacts(e);case 2:n=t.sent,k(n.data.value);case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();Promise.all([n(),t()]).then((function(){r(!1)})).catch((function(e){console.error(e),r(!1)}))}var a=function(e){if("selectedCUSTNAME"===e.key){var t=e.newValue?JSON.parse(e.newValue):null;Ce(t),P([]),C(null),L(null),V(""),b(""),Q(qt.EditorState.createEmpty()),re(),t?(r(!0),Promise.all([de.getCustomerContacts(t),de.getCallSeverities()]).then((function(e){var t=Object(i.a)(e,3),n=t[0],a=(t[1],t[2]);k(n.data.value),f(a.data.value),r(!1)})).catch((function(e){console.error(e),r(!1)}))):(k([]),l([]),f([]))}};return window.addEventListener("storage",a),function(){window.removeEventListener("storage",a)}}),[]);return Object(te.jsxs)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:[""!=Oe?Object(te.jsx)(Je.a,{to:"/dashboard/servicecall/".concat(Oe)}):null,1==c||1==ie?Object(te.jsx)(Ht,{}):null,Ee?Object(te.jsxs)(E.a,{container:!0,spacing:2,children:[Object(te.jsx)(E.a,{item:!0,md:8,children:Object(te.jsx)(ge.a,{sx:{m:1},fullWidth:!0,required:!0,onChange:function(e){return V(e.target.value)},label:"Subject",inputProps:{maxLength:48}})}),Object(te.jsx)(E.a,{item:!0,md:4,children:Object(te.jsx)(ge.a,{sx:{m:1},fullWidth:!0,onChange:function(e){return b(e.target.value)},label:"Customer's Reference",inputProps:{maxLength:12}})}),Object(te.jsx)(E.a,{item:!0,md:4,children:Object(te.jsx)(Sn,{required:!0,title:"Call Severity",labelname:"SEVDES",items:m,onChange:function(e,t){return L(t)}})}),Object(te.jsx)(E.a,{item:!0,md:4,children:Object(te.jsx)(Sn,{required:!0,title:"Contact",labelname:"NAME",items:D,onChange:function(e,t){return P(t)}})}),Object(te.jsxs)(E.a,{item:!0,md:12,children:[Object(te.jsx)(Bt.a,{sx:{mt:2},children:Object(te.jsxs)(Wt.a,{children:[Object(te.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(te.jsx)("b",{children:"Details"})}),Object(te.jsx)(_t.Editor,{wrapperClassName:"wrapperClassName",editorStyle:{overflow:"hidden",minHeight:"40vh"},editorState:X,onEditorStateChange:function(e){Q(e)},toolbar:{options:["inline","blockType","fontSize","list","textAlign","colorPicker","link","history"]}})]})}),Object(te.jsx)("p",{}),Object(te.jsx)(Ze.a,{onClick:function(){return ee()},variant:"outlined",startIcon:Object(te.jsx)(Yt.a,{}),children:"Add File"}),Object(te.jsx)(Ze.a,{variant:"contained",sx:{marginLeft:"82.5%"},disabled:ie,onClick:function(){if(1===Object(qt.convertToRaw)(X.getCurrentContent()).blocks.length&""===Object(qt.convertToRaw)(X.getCurrentContent()).blocks[0].text)M("You can not submit an empty comment.",{variant:"error"});else if(/^ *$/.test(z))M("Please fill out the Subject field.",{variant:"error"});else if(void 0!=(null===R||void 0===R?void 0:R.SEV))if(void 0!=(null===N||void 0===N?void 0:N.NAME))if(Ee){le(!0);var e,t=(new Date).toLocaleString("en-GB"),n=[];for(var a in ce){var c={EXTFILEDES:ce[a].name.split(".")[0],EXTFILENAME:ce[a].content};"msg"===ce[a].name.split(".")[1]&&(c.SUFFIX=".msg"),"lic"===ce[a].name.split(".")[1]&&(c.SUFFIX=".lic"),n.push(c)}e=0!==n.length?t+zt()(Object(qt.convertToRaw)(X.getCurrentContent()))+"
"+n.length+" files attached.
"+"

".concat(K,"


"):t+zt()(Object(qt.convertToRaw)(X.getCurrentContent()))+"

".concat(K,"


");var o={DETAILS:z,CALLTYPECODE:"From Portal",ZEMG_SEVNAME:null===R||void 0===R?void 0:R.SEVNAME,TEXT:e,APPEND:!0,SIGNATURE:!1,REFERENCE:j,NAME:null===N||void 0===N?void 0:N.NAME,EXTFILES:n},s=function(e){de.getServiceCall(e).then((function(e){!function(e){var t={ACTIVEFLAG:e.ACTIVEFLAG,CALLSTATUSCODE:e.CALLSTATUSCODE,CALLTYPECODE:e.CALLTYPECODE,CDES:e.CDES,DOCNO:e.DOCNO,NAME:e.NAME,REFERENCE:e.REFERENCE,STARTDATE:e.STARTDATE,STATUSDATE:e.STATUSDATE,ZEMG_SEVDES:e.ZEMG_SEVDES,ZEMG_SVC_DETAILS:e.ZEMG_SVC_DETAILS};pe([t].concat(Object(je.a)(fe)))}(e.data)})).catch((function(e){console.log(e)}))};de.CreateServiceCall(o,Ee).then((function(e){void 0!=e.data.DOCNO?(M("Service Call ".concat(e.data.DOCNO," successfully created!"),{variant:"success"}),s(e.data.DOCNO),re(),r(!0),he(e.data.DOCNO)):(M("Error creating service call.",{variant:"error"}),le(!1))})).catch((function(e){e.response.data.message?M(e.response.data.message,{variant:"error"}):M("Error creating service call.",{variant:"error"}),le(!1)}))}else M("Please select a customer first.",{variant:"error"});else M("Please select a Contact.",{variant:"error"});else M("Please select a Call Severity.",{variant:"error"})},children:"Submit"}),0!=ae.length?Object(te.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(te.jsx)(ot.a,{onClick:function(e){re()}})}):Object(te.jsx)(te.Fragment,{}),ae.map((function(e,t){return Object(te.jsx)(_e.a,{label:e.name})}))]})]}):Object(te.jsx)(pn.a,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60vh",children:Object(te.jsx)(g.a,{variant:"h6",color:"text.secondary",children:"Please select a customer to create a service call"})})]})},En=function(e){e.selectedCustomer;var t=c.a.useState(0),n=Object(i.a)(t,2),r=n[0],o=n[1],s=bn().setviewcallDataTable;return Object(a.useEffect)((function(){s(!1)}),[]),Object(te.jsxs)(v.a,{maxWidth:!1,sx:{mt:4,mb:4},children:[Object(te.jsxs)(xn.a,{value:r,onChange:function(e,t){o(t)},"aria-label":"Service Call tabs",children:[Object(te.jsx)(gn.a,{label:"Service Call List"}),Object(te.jsx)(gn.a,{label:"Create Service Call"})]}),Object(te.jsxs)(h.a,{sx:{mt:2},children:[0===r&&Object(te.jsx)(E.a,{item:!0,xs:12,children:Object(te.jsx)(hn,{})}),1===r&&Object(te.jsx)(E.a,{item:!0,xs:12,children:Object(te.jsx)(vn,{})})]})]})},Cn=n(606),Tn=n(656),An=n(508),Dn=n(236),kn=n(514),yn=n(513),wn=n(187),Nn=n.n(wn),Pn=n(317),In=n.n(Pn),Un=n(192),Rn=n(604),Ln=n(185);function Fn(e){var t=e.open,n=e.description,c=e.loading,r=e.attachments,o=e.handleClose,s=(e.refreshTasks,e.handleTaskStatusChange),u=e.task,d=u.SUBJECT,j=u.STATDES,b=u.USERLOGIN,O=(u.CUSTNOTETYPEDES,u.CUSTNOTE),h=(u.EXTFILEFLAG,u.CURDATE),m=u.TILLDATE,f=u.STIME,x=u.ETIME,p=u.WBS,v=u.ACTDES,E=[b,u.USERLOGIN2,u.USERLOGIN3,u.USERLOGIN4,u.USERLOGIN5,u.USERLOGIN6,u.USERLOGIN7,u.USERLOGIN8],C=Object(Un.a)("div")({marginBottom:16}),T=Object(a.useState)(!1),A=Object(i.a)(T,2),D=A[0],k=A[1],y=Object(xe.b)(),w=(y.enqueueSnackbar,y.closeSnackbar,Object(Ln.b)());return Object(te.jsx)("div",{children:Object(te.jsxs)(An.a,{open:t,onClose:o,scroll:"paper","aria-labelledby":"scroll-dialog-title","aria-describedby":"scroll-dialog-description",children:[Object(te.jsx)("div",{children:Object(te.jsxs)(yn.a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",fontWeight:"bold"},id:"scroll-dialog-title",children:[null!==d&&void 0!==d?d:"Task Subject",Object(te.jsx)(ct.a,{placement:"right",title:"Cancel task.",children:Object(te.jsx)(S.a,{disabled:D,onClick:function(){w({description:"This will cancel the task."}).then((function(){k(!0),s(j,"Cancelled",O),o()})).catch((function(){console.log("Confirmation declined.")}))},color:"error","aria-label":"cancel-task",component:"label",children:Object(te.jsx)(Rn.a,{})})})]})}),c?Object(te.jsx)(be.a,{}):null,Object(te.jsxs)(Dn.a,{dividers:!c,sx:{minHeight:"50vh",minWidth:"30vw"},children:[Object(te.jsxs)(C,{children:[Object(te.jsx)(g.a,{variant:"subtitle2",children:"Members"}),Object(te.jsx)("div",{style:{display:"flex",flexDirection:"row"},children:null===E||void 0===E?void 0:E.filter((function(e){return e})).map((function(e,t){return Object(te.jsx)(ct.a,{style:{marginRight:8},title:e,children:Object(te.jsx)(gt.a,Object(l.a)({},Jt(e)))},t)}))})]}),p?Object(te.jsxs)(C,{children:[Object(te.jsx)(g.a,{variant:"subtitle2",children:"WBS"}),Object(te.jsx)(g.a,{children:p+": "+v})]}):null,Object(te.jsxs)(C,{children:[Object(te.jsx)(g.a,{variant:"subtitle2",children:"Dates"}),Object(te.jsx)(ct.a,{placement:"left",title:"Start and end date.",children:Object(te.jsx)(_e.a,{icon:Object(te.jsx)(In.a,{}),size:"small",label:$t(h)+" - "+$t(m)})}),Object(te.jsx)(ct.a,{sx:{ml:1},placement:"right",title:"Start and end time.",children:Object(te.jsx)(_e.a,{icon:Object(te.jsx)(Nn.a,{}),size:"small",label:f+" - "+x})})]}),Object(te.jsxs)(C,{children:[Object(te.jsx)(g.a,{variant:"subtitle2",children:"Description"}),Object(te.jsx)(kn.a,{id:"scroll-dialog-description",tabIndex:-1,children:c?Object(te.jsx)(Oe.a,{}):Object(te.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})})]})]}),r.length>0?Object(te.jsxs)(Dn.a,{dividers:!0,children:[Object(te.jsx)(g.a,{children:"Attachments"}),null===r||void 0===r?void 0:r.map((function(e,t){return Object(te.jsx)(_e.a,{label:e.EXTFILEDES+"."+e.SUFFIX,color:"primary",size:"small",sx:{mr:1,mb:1},onClick:function(){return tn(e.EXTFILENAME,e.EXTFILEDES,e.SUFFIX)}},t)}))]}):null]})})}var Mn=n(318),Bn=n.n(Mn),Wn=function(e){var t,n=e.task,c=n.SUBJECT,r=n.USERLOGIN,o=n.CUSTNOTETYPEDES,s=n.CUSTNOTE,u=n.EXTFILEFLAG,d=n.CURDATE,j=n.TILLDATE,b=n.ACTDES,O=(n.STIME,n.ETIME,n.WBS),h=n.USERLOGIN2,m=n.USERLOGIN3,f=n.USERLOGIN4,x=n.USERLOGIN5,p=n.USERLOGIN6,S=n.USERLOGIN7,v=n.USERLOGIN8,E=n.ZMED_TASKSIZENAME,C=e.refreshTasks,T=e.handleTaskStatusChange,A=[r,h,m,f,x,p,S,v],D=Object(a.useState)(!1),k=Object(i.a)(D,2),y=k[0],w=k[1],N=Object(a.useState)("There is no description."),P=Object(i.a)(N,2),I=P[0],U=P[1],R=Object(a.useState)([]),L=Object(i.a)(R,2),F=L[0],M=L[1],B=Object(a.useState)(!1),W=Object(i.a)(B,2),_=W[0],G=W[1],z=function(){G(!0),de.getTaskExplanation(s).then((function(e){e.data.hasOwnProperty("error")?(console.log(e.data),U("There is no description."),G(!1)):(U(e.data.TEXT),console.log(e.data),G(!1))})).catch((function(e){console.log(e),G(!1)}))},V=function(){de.getTaskAttachments(s).then((function(e){e.data.hasOwnProperty("error")?console.log(e.data):(console.log(e.data),M(e.data.value))})).catch((function(e){console.log(e)}))};return Object(te.jsxs)(Bt.a,{onClick:function(){y||(z(),"Y"===u&&V(),w(!0))},sx:{mb:2},children:[Object(te.jsx)(Fn,{open:y,description:I,handleClose:function(){w(!1)},task:e.task,loading:_,attachments:F,refreshTasks:C,handleTaskStatusChange:T}),Object(te.jsxs)(Wt.a,{sx:{display:"flex",flexDirection:"column"},children:[Object(te.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Object(te.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[o?Object(te.jsx)(ct.a,{enterDelay:500,placement:"top",title:"Task type.",children:Object(te.jsx)(_e.a,{label:o,color:"primary",size:"small",sx:{bgcolor:Zt(o),mr:1}})}):null,E?Object(te.jsx)(ct.a,{enterDelay:500,placement:"top",title:"Task size.",children:Object(te.jsx)(_e.a,{label:E,color:"primary",size:"small",sx:{bgcolor:(t=E,"S"===t?"#00FF00":"M"===t?"#FFA500":"L"===t?"#FF0000":"XL"===t?"#8b0000":void 0)}})}):null]}),u?Object(te.jsx)(ct.a,{enterDelay:500,placement:"top",title:"Includes attachments.",children:Object(te.jsx)(Bn.a,{color:"disabled"})}):null]}),Object(te.jsx)(g.a,{sx:{fontWeight:"bold",mt:1},component:"div",children:null!==c&&void 0!==c?c:"Task Subject"}),Object(te.jsx)(g.a,{sx:{mb:1},variant:"subtitle2",children:null!=O?O+": "+b:null}),Object(te.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Object(te.jsx)(ct.a,{enterDelay:500,title:"Start and end date.",children:Object(te.jsx)(_e.a,{icon:Object(te.jsx)(Nn.a,{}),size:"small",label:$t(d)+" - "+$t(j)})}),Object(te.jsx)(Tn.a,{sx:{"& .MuiAvatar-root":{width:30,height:30,fontSize:16}},max:2,children:null===A||void 0===A?void 0:A.filter((function(e){return e})).map((function(e,t){return Object(te.jsx)(ct.a,{title:e,children:Object(te.jsx)(gt.a,Object(l.a)({},Jt(e)))},t)}))})]})]})]})},_n=n(127),Gn=n(515),zn=n(609),Vn=n(329),Yn=n(227),qn=n(74),Xn=n.n(qn),Qn=n(605);function Hn(e){var t=e.disabled,n=e.taskTypes,c=e.taskSizes,r=e.users,o=e.projectWBS,s=e.project,u=e.handleUpdateTasks,d=e.STATDES,j=Object(a.useState)(!1),b=Object(i.a)(j,2),O=b[0],h=b[1],m=Object(a.useState)(!1),f=Object(i.a)(m,2),x=f[0],p=f[1],E=Object(a.useState)(),C=Object(i.a)(E,2),T=C[0],A=C[1],D=Object(a.useState)(),k=Object(i.a)(D,2),y=k[0],w=k[1],N=Object(a.useState)(),P=Object(i.a)(N,2),I=P[0],U=P[1],R=Object(a.useState)(),L=Object(i.a)(R,2),F=L[0],M=L[1],B=Object(a.useState)(),W=Object(i.a)(B,2),_=W[0],G=W[1],z=Object(a.useState)(Xn()()),V=Object(i.a)(z,2),Y=V[0],q=V[1],X=Object(a.useState)(Xn()()),Q=Object(i.a)(X,2),H=Q[0],J=Q[1],K=Object(xe.b)(),Z=K.enqueueSnackbar,$=(K.closeSnackbar,qt.EditorState.createEmpty()),ee=Object(a.useState)($),ne=Object(i.a)(ee,2),ae=ne[0],ce=ne[1],re=Object(Xt.a)({accept:"*",readAs:"DataURL"}),oe=Object(i.a)(re,2),se=oe[0],ie=oe[1],ue=ie.plainFiles,je=ie.filesContent,be=ie.clear,Oe=function(){h(!1)},he=function(){M(),A(),w(),U(),Oe(),p(!1)};return Object(te.jsxs)(te.Fragment,{children:[Object(te.jsx)(Ze.a,{disabled:t,size:"small",variant:"contained",startIcon:Object(te.jsx)(nt.a,{}),color:"inherit",onClick:function(){h(!0)},children:"Add a Task"}),Object(te.jsx)("div",{children:Object(te.jsxs)(An.a,{open:O,onClose:Oe,children:[Object(te.jsx)(yn.a,{children:"Add a Task"}),Object(te.jsxs)(Dn.a,{children:[Object(te.jsx)(ge.a,{autoFocus:!0,margin:"dense",id:"subject",label:"Subject",type:"subject",fullWidth:!0,variant:"standard",autoComplete:"off",value:T,onChange:function(e){return A(e.target.value)},sx:{mb:2}}),Object(te.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(te.jsx)(Sn,{required:!0,title:"Assigned To",labelname:"USERLOGIN",items:r,onChange:function(e,t){return M(t)}}),Object(te.jsx)(Sn,{title:"WBS",labelname:"WBS",items:o,onChange:function(e,t){return G(t)},description:"ACTDES"})]}),Object(te.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(te.jsx)(Sn,{title:"Task Type",labelname:"CUSTNOTETYPEDES",items:n,onChange:function(e,t){return w(t)}}),Object(te.jsx)(Sn,{title:"Task Size",labelname:"SIZENAME",items:c,onChange:function(e,t){return U(t)},description:"SIZEDES"})]}),Object(te.jsx)(Vn.a,{dateAdapter:Yn.a,children:Object(te.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(te.jsx)(zn.a,{disablePast:!0,ampm:!1,label:"Start Date & Time",value:Y,onChange:function(e){return q(e)},renderInput:function(e){return Object(te.jsx)(ge.a,Object(l.a)({fullWidth:!0,sx:{m:1}},e))}}),Object(te.jsx)(zn.a,{disablePast:!0,ampm:!1,label:"End Date & Time",value:H,onChange:function(e){return J(e)},renderInput:function(e){return Object(te.jsx)(ge.a,Object(l.a)({fullWidth:!0,sx:{m:1}},e))}})]})}),Object(te.jsxs)(v.a,{maxWidth:!1,sx:{mt:1},children:[Object(te.jsx)(g.a,{variant:"subtitle",children:"Explanation of Task"}),Object(te.jsx)(le.a,{children:Object(te.jsx)(_t.Editor,{editorStyle:{height:"150px"},editorState:ae,onEditorStateChange:function(e){ce(e)},toolbar:{image:{uploadCallback:en,previewImage:!0}}})})]}),Object(te.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex",flexWrap:"wrap",gap:"3px",mt:1},children:[0!=ue.length?Object(te.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(te.jsx)(Rn.a,{onClick:function(e){be()}})}):Object(te.jsx)(te.Fragment,{}),ue.map((function(e,t){return Object(te.jsx)(_e.a,{label:e.name})}))]})]}),Object(te.jsxs)(Gn.a,{children:[Object(te.jsx)(Ze.a,{onClick:function(){return se()},variant:"outlined",startIcon:Object(te.jsx)(Qn.a,{}),children:"Add File"}),Object(te.jsx)(Ze.a,{onClick:Oe,children:"Cancel"}),Object(te.jsx)(Ze.a,{disabled:x,onClick:function(){var e,t,n;if(1===Object(qt.convertToRaw)(ae.getCurrentContent()).blocks.length&""===Object(qt.convertToRaw)(ae.getCurrentContent()).blocks[0].text)Z("The task must have an explanation.",{variant:"error"});else if(T)if(void 0!==F){p(!0);var a=[];for(var c in je){var r={EXTFILEDES:je[c].name.split(".")[0],EXTFILENAME:je[c].content};a.push(r)}console.log(a);var o={SUBJECT:T,CUSTNOTETYPEDES:null!==(e=null===y||void 0===y?void 0:y.CUSTNOTETYPEDES)&&void 0!==e?e:"",ZMED_TASKSIZENAME:null!==(t=null===I||void 0===I?void 0:I.SIZENAME)&&void 0!==t?t:"",USERLOGIN:null===F||void 0===F?void 0:F.USERLOGIN,CURDATE:Y.format("YYYY-MM-DD"),TILLDATE:H.format("YYYY-MM-DD"),STIME:Y.format("HH:mm"),ETIME:H.format("HH:mm"),PROJDOCNO:s.DOCNO,WBS:null!==(n=null===_||void 0===_?void 0:_.WBS)&&void 0!==n?n:"",STATDES:d,TEXT:zt()(Object(qt.convertToRaw)(null===ae||void 0===ae?void 0:ae.getCurrentContent())),CUSTNOTEEXTFILES:a};console.log(o),de.createTask(o).then((function(e){Z("Task created succesfully.",{variant:"success"}),u(e.data),he(),console.log(e)})).catch((function(e){Z("Error creating task.",{variant:"error"}),he(),console.log(e)}))}else Z("Please select an Assigned To.",{variant:"error"});else Z("Please fill out the Subject field.",{variant:"error"})},children:"Add"})]})]})})]})}var Jn=Object(Cn.a)(le.a)({marginLeft:15,padding:8,display:"flex",flexDirection:"column",top:0,bottom:0,maxHeight:"75vh",width:250,minWidth:250,background:"#ebecf0",overflow:"auto",position:"relative"}),Kn=function(e){var t=e.title,n=e.tasks,a=e.project,c=e.taskTypes,r=e.taskSizes,o=e.users,s=e.projectWBS,i=e.handleUpdateTasks,u=e.refreshTasks,d=e.handleTaskStatusChange;return Object(te.jsx)(_n.c,{droppableId:t,type:"COLUMN",children:function(e,j){return Object(te.jsx)("div",Object(l.a)(Object(l.a)({},e.droppableProps),{},{ref:e.innerRef,children:Object(te.jsxs)(Jn,{children:[Object(te.jsx)(g.a,{component:"h2",variant:"h6",color:"inherit",gutterBottom:!0,children:t||"Title"}),Object(te.jsx)("div",{style:{overflowY:"auto"},children:null===n||void 0===n?void 0:n.map((function(e,t){return Object(te.jsx)(_n.b,{draggableId:e.CUSTNOTE.toString(),index:t,type:"TASK",children:function(t,n){return Object(te.jsx)("div",Object(l.a)(Object(l.a)(Object(l.a)({ref:t.innerRef},t.draggableProps),t.dragHandleProps),{},{children:Object(te.jsx)(Wn,{task:e,refreshTasks:u,handleTaskStatusChange:d},e.CUSTNOTE)}))}},e.CUSTNOTE.toString())}))}),e.placeholder,Object(te.jsx)(Hn,{disabled:""===a,taskTypes:c,taskSizes:r,users:o,project:a,projectWBS:s,handleUpdateTasks:i,STATDES:t})]})}))}})},Zn=function(){return Object(te.jsx)(te.Fragment,{children:Object(je.a)(Array(6)).map((function(e,t){return Object(te.jsx)(Oe.a,{sx:{marginLeft:2,padding:8,display:"flex",flexDirection:"column"},variant:"rectangular",width:250,height:"75vh",style:{marginBottom:5}},t)}))})},$n=function(e){var t=e.selectedCustomer,n=Object(a.useState)([]),c=Object(i.a)(n,2),r=c[0],o=c[1],s=Object(a.useState)(""),u=Object(i.a)(s,2),d=u[0],j=u[1],b=Object(a.useState)([]),O=Object(i.a)(b,2),h=O[0],m=O[1],f=Object(a.useState)(!0),x=Object(i.a)(f,2),g=x[0],p=x[1],S=Object(xe.b)(),E=S.enqueueSnackbar,C=(S.closeSnackbar,Object(a.useState)()),T=Object(i.a)(C,2),A=T[0],D=T[1],k=Object(a.useState)([]),y=Object(i.a)(k,2),w=y[0],N=y[1],P=Object(a.useState)([]),I=Object(i.a)(P,2),U=I[0],R=I[1],L=Object(a.useState)([]),F=Object(i.a)(L,2),M=F[0],B=F[1],W=Object(a.useState)([]),_=Object(i.a)(W,2),G=_[0],z=_[1],V=Object(a.useState)(Xn()()),Y=Object(i.a)(V,2),q=(Y[0],Y[1],Object(a.useState)(Xn()())),X=Object(i.a)(q,2),Q=(X[0],X[1],Object(a.useMemo)((function(){if(!A)return h;var e=h.map((function(e){var t,n=null===e||void 0===e||null===(t=e.TASKS)||void 0===t?void 0:t.filter((function(e){var t=!0;for(var n in A)if(A[n]&&(void 0===e[n]||e[n]!==A[n])){t=!1;break}return t}));return Object(l.a)(Object(l.a)({},e),{},{TASKS:n})}));return e}),[A,h]));function H(e,t){return t.forEach((function(t){var n=e.find((function(e){return e.STATDES===t.STATDES}));void 0!==n&&(n.TASKS||(n.TASKS=[]),n.TASKS.push(Object.assign({},t)))})),e}var J=function(e){if(!e)return[];var t=new Set;return e.forEach((function(e){e.TASKS&&e.TASKS.forEach((function(e){e.USERLOGIN&&t.add(e.USERLOGIN),e.USERLOGIN2&&t.add(e.USERLOGIN2),e.USERLOGIN3&&t.add(e.USERLOGIN3),e.USERLOGIN4&&t.add(e.USERLOGIN4),e.USERLOGIN5&&t.add(e.USERLOGIN5),e.USERLOGIN6&&t.add(e.USERLOGIN6),e.USERLOGIN7&&t.add(e.USERLOGIN7),e.USERLOGIN8&&t.add(e.USERLOGIN8)}))})),Object(je.a)(t)};function K(e,t){return e.filter((function(e){return void 0!==t.find((function(t){return t.STATDES===e.STATDES}))}))}Object(a.useEffect)(Object(Mt.a)(Ft.a.mark((function e(){var n,a,c,r,s,l,u,d;return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(n=t)&&(a=localStorage.getItem("selectedCUSTNAME")))try{n=JSON.parse(a)}catch(j){console.error("Error parsing stored customer:",j),n=null}return e.next=5,Promise.all([de.getTaskStatuses(),de.getUserProjects(n)]);case 5:c=e.sent,r=Object(i.a)(c,2),s=r[0],l=r[1],u=s.data.value,d=u.push({STATDES:"Cancelled"}),console.log(d),m(u),o(l.data.value),p(!1),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(0),console.log(e.t0);case 20:case"end":return e.stop()}}),e,null,[[0,17]])}))),[t]),Object(a.useEffect)(Object(Mt.a)(Ft.a.mark((function e(){var t,n,a,c,r;return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Promise.all([de.getTaskTypes(),de.getTaskSizes(),de.getUsers()]);case 3:t=e.sent,n=Object(i.a)(t,3),a=n[0],c=n[1],r=n[2],N(a.data.value),R(c.data.value),B(r.data.value),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(0),console.log(e.t0);case 16:case"end":return e.stop()}}),e,null,[[0,13]])}))),[]);var Z=function(e){d&&$(e,d)},$=function(){var e=Object(Mt.a)(Ft.a.mark((function e(t,n){return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==n&&(p(!0),j(n),void 0!=h&&m(((t=h).forEach((function(e){e.TASKS&&delete e.TASKS})),t)),de.getProjectTasks(n.DOCNO).then((function(e){var t=K(e.data.value,h),n=H(h,t);m(n),console.log(n),console.log(J(n)),p(!1)})).catch((function(e){console.log(e)})),de.getProjectWBS(n.DOCNO).then((function(e){z(e.data.value)})).catch((function(e){console.log(e)})));case 1:case"end":return e.stop()}var t}),e)})));return function(t,n){return e.apply(this,arguments)}}(),ee=function(){var e=Object(Mt.a)(Ft.a.mark((function e(t,n){return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:de.changeTaskStatus({CUSTNOTE:t,STATDES:n}).then((function(e){console.log(e)})).catch((function(e){E("Error updating task status in Priority.",{variant:"error"}),console.log(e)}));case 1:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),ne=function(e,t,n){var a=function(e,t,n,a){var c=e.find((function(e){return e.STATDES===t}));if(!c||!c.TASKS)return null;var r=c.TASKS.findIndex((function(e){return e.CUSTNOTE===a}));if(-1===r)return null;var o=c.TASKS.splice(r,1),s=Object(i.a)(o,1)[0],l=e.find((function(e){return e.STATDES===n}));if(!l)return null;l.TASKS||(l.TASKS=[]);return l.TASKS.push(s),e}(Object(je.a)(h),e,t,n);ee(n,t),m(a)},ae=function(){var e=Object(Mt.a)(Ft.a.mark((function e(t){var n,a,c;return Ft.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.destination){e.next=2;break}return e.abrupt("return");case 2:n=t.source.droppableId,a=t.destination.droppableId,c=parseInt(t.draggableId),ne(n,a,c);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var ce=function(e){var t=H(Object(je.a)(h),[e]);m(t)};return Object(te.jsxs)(te.Fragment,{children:[Object(te.jsx)(v.a,{maxWidth:!1,sx:{display:"flex"},children:Object(te.jsx)(Ze.a,{disabled:!d||g,onClick:Z,sx:{m:1},size:"small",variant:"contained",children:"Refresh Tasks"})}),Object(te.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},children:[Object(te.jsx)(Sn,{title:"Project",labelname:"DOCNO",items:r,onChange:$,description:"PROJDES"}),Object(te.jsx)(Sn,{disabled:""===d,title:"Assigned To",labelname:"",items:J(h),onChange:function(e,t){return D(Object(l.a)(Object(l.a)({},A),{},{USERLOGIN:t}))}}),Object(te.jsx)(Sn,{disabled:""===d,title:"WBS",labelname:"",items:function(e){if(!e)return[];var t=new Set;return e.forEach((function(e){e.TASKS&&e.TASKS.forEach((function(e){e.WBS&&t.add(e.WBS)}))})),Object(je.a)(t)}(h),onChange:function(e,t){return D(Object(l.a)(Object(l.a)({},A),{},{WBS:t}))}}),Object(te.jsx)(Sn,{disabled:""===d,title:"Task Type",labelname:"",items:function(e){if(!e)return[];var t=new Set;return e.forEach((function(e){e.TASKS&&e.TASKS.forEach((function(e){e.CUSTNOTETYPEDES&&t.add(e.CUSTNOTETYPEDES)}))})),Object(je.a)(t)}(h),onChange:function(e,t){return D(Object(l.a)(Object(l.a)({},A),{},{CUSTNOTETYPEDES:t}))}})]}),Object(te.jsx)(_n.a,{onDragEnd:ae,children:Object(te.jsx)(v.a,{maxWidth:!1,sx:{display:"flex",mt:2,mb:4},children:g?Object(te.jsx)(Zn,{}):null===Q||void 0===Q?void 0:Q.filter((function(e){return"Cancelled"!==e.STATDES})).map((function(e){return Object(te.jsx)(Kn,{title:e.STATDES,tasks:e.TASKS,project:d,taskTypes:w,taskSizes:U,users:M,projectWBS:G,handleUpdateTasks:ce,refreshTasks:Z,handleTaskStatusChange:ne},e.DOCSTATUSSORT)}))})})]})},ea=n(100);var ta=function(e){return Object(te.jsx)(g.a,{component:"h2",variant:"h6",color:"primary",gutterBottom:!0,children:e.children})},na=n(630),aa=n(657),ca=n(658),ra=n(607);function oa(e){var t=e.title,n=e.data,r=e.statusLabel,o=n.hasOwnProperty("value"),s=Object(a.useState)([]),l=Object(i.a)(s,2),u=l[0],d=l[1];return Object(a.useEffect)((function(){o&&r&&d(function(){var e,t={},a=Object(ea.a)(n.value);try{for(a.s();!(e=a.n()).done;){var c=e.value[r];t[c]?t[c]+=1:t[c]=1}}catch(o){a.e(o)}finally{a.f()}return t}())}),[n]),Object(te.jsxs)(c.a.Fragment,{children:[Object(te.jsxs)(le.a,{sx:{p:2,display:"flex",flexDirection:"column",minHeight:120},children:[Object(te.jsx)(ta,{children:t}),o?Object(te.jsxs)(g.a,{component:"p",variant:"h4",children:[n.value.length," ",t]}):Object(te.jsx)(be.a,{})]}),Object(te.jsxs)(na.a,{disabled:0===u.length,children:[Object(te.jsx)(aa.a,{expandIcon:Object(te.jsx)(ra.a,{}),"aria-controls":"panel1a-content",id:"panel1a-header",children:Object(te.jsx)(g.a,{children:"Status Breakdown"})}),Object(te.jsx)(ca.a,{children:Object(te.jsx)("div",{children:Object.entries(u).map((function(e){var t=Object(i.a)(e,2),n=t[0],a=t[1];return Object(te.jsxs)(g.a,{color:"text.secondary",sx:{flex:1},children:[n,": ",a]},n)}))})})]})]})}var sa=function(){var e=Object(a.useRef)(null),t=Object(a.useState)([]),n=Object(i.a)(t,2),c=n[0],r=n[1],o=Object(a.useState)(""),s=Object(i.a)(o,2),l=s[0],u=s[1],d=Object(a.useState)([]),j=Object(i.a)(d,2),b=j[0],O=j[1],m=function(e){var t=function(e){var t=function(e){return e&&"string"===typeof e?e.split(".").map((function(e){return parseInt(e,10)||0})):[0]};return Object(je.a)(e).sort((function(e,n){for(var a=t(e.WBS),c=t(n.WBS),r=0;r0;a--){var c=t.slice(0,a).join(".");if(n[c])return n[c]}return 0},c=t.map((function(e,t){var n=new Date(e.STARTDATE),c=new Date(e.ENDDATE);(isNaN(n.getTime())||n.getFullYear()<2e3)&&(console.warn("Invalid start date for ".concat(e.WBS,": ").concat(e.STARTDATE)),n=new Date),(isNaN(c.getTime())||c.getFullYear()<2e3)&&(console.warn("Invalid end date for ".concat(e.WBS,": ").concat(e.ENDDATE)),c=new Date),c=5&&(o="gtaskpink"),{pID:t+1,pName:"".concat(e.WBS,": ").concat(e.ACTDES),pStart:n,pEnd:c,pClass:o,pLink:"",pMile:0,pRes:e.HR||"",pComp:e.EXECPERCENT||0,pGroup:0,pParent:a(e.WBS),pOpen:1,pDepend:"",pCaption:"",pNotes:"WBS: ".concat(e.WBS),originalWBS:e.WBS,sortOrder:t}}));return c.forEach((function(e){c.some((function(t){return t.pParent===e.pID}))&&(e.pGroup=1)})),t.forEach((function(e,t){if(e.PROJACTPRED_SUBFORM&&e.PROJACTPRED_SUBFORM.length>0){var a=e.PROJACTPRED_SUBFORM.map((function(e){return n[e.WBS]})).filter((function(e){return e&&e!==t+1})).join(",");a&&(c[t].pDepend=a)}})),c};return Object(a.useEffect)((function(){de.getUserProjects().then((function(e){r(e.data.value)})).catch((function(e){console.log(e)}))}),[]),Object(a.useEffect)((function(){if(b.length>0&&e.current){var t=function(e){return'\n\n\n\n \n jsGantt Chart\n \n