(this["webpackJsonpcustomer-portal"]=this["webpackJsonpcustomer-portal"]||[]).push([[0],{329:function(e,t,n){},403:function(e,t,n){},404:function(e,t,n){},528:function(e,t,n){},530:function(e,t,n){"use strict";n.r(t),t.default=n.p+"static/media/medatech-logo.d9b936ff.png"},531:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),c=n(40),s=n.n(c),i=(n(403),n(404),n(5)),o=n(4),l=n(14),u=n(6),d=n(263),j=n(672),b=n(644),O=n(664),h=n(628),x=n(676),f=n(673),m=n(674),p=n(182),g=n(633),S=n(549),v=n(675),E=n(547),C=n(358),T=n.n(C),A=n(359),D=n.n(A),I=n(656),k=n(631),R=n(632),y=n(337),N=n.n(y),w=n(342),P=n.n(w),U=n(48),L=n(68),M=n(80),F=n(19),_=n.n(F),W=n(330),B=new(function(){function e(){Object(L.a)(this,e)}return Object(M.a)(e,[{key:"login",value:function(e){return _.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 _.a.post("/customer_portal/changePassword",e)}},{key:"forgotPassword",value:function(e){return _.a.post("/customer_portal/forgotPassword",e)}}]),e}()),Y=["title","titleId"];function G(){return G=Object.assign||function(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function X(e,t){var n=e.title,r=e.titleId,c=z(e,Y);return a.createElement("svg",G({viewBox:"0 0 24 24",width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":r},c),n?a.createElement("title",{id:r},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 V=a.forwardRef(X),H=(n.p,n(341)),q=n.n(H),K=n(339),J=n.n(K),Q=n(340),Z=n.n(Q),$=n(338),ee=n.n($),te=n(367),ne=n(688),ae=n(689),re=n(678),ce=n(687),se=n(680),ie=n(655),oe=n(681),le=n(665),ue=n(154),de=n(543),je=n(368),be=n(265),Oe=n(550),he=n(544),xe=n(686),fe=n(682),me=n(666),pe=n(691),ge=n(692),Se=n(679),ve=n(91),Ee=n.n(ve),Ce=n(210),Te=n.n(Ce),Ae=n(255),De=n.n(Ae),Ie=n(101),ke=n.n(Ie),Re=n(212),ye=n.n(Re),Ne=n(34);function we(){var e=localStorage.getItem("token");return e?{"x-access-token":e}:{}}var Pe=new(function(){function e(){Object(L.a)(this,e)}return Object(M.a)(e,[{key:"getItemsForSale",value:function(e,t){return _.a.get("/customer_portal/itemsForSale/".concat(e,"/").concat(t),{headers:we()})}},{key:"getOrders",value:function(){return _.a.get("/customer_portal/orders",{headers:we()})}},{key:"getCustomerOrders",value:function(e){return _.a.get("/customer_portal/customerOrders/".concat(e),{headers:we()})}},{key:"getOrderItems",value:function(e){return _.a.get("/customer_portal/orderItems/".concat(e),{headers:we()})}},{key:"getShipments",value:function(){return _.a.get("/customer_portal/shipments",{headers:we()})}},{key:"getCustomerShipments",value:function(e){return _.a.get("/customer_portal/customerShipments/".concat(e),{headers:we()})}},{key:"getShipmentItems",value:function(e,t){return _.a.get("/customer_portal/shipmentItems/".concat(e,"/").concat(t),{headers:we()})}},{key:"getInvoices",value:function(){return _.a.get("/customer_portal/invoices",{headers:we()})}},{key:"getCustomerInfo",value:function(e){return _.a.get("/customer_portal/getCustomerInfo",{headers:we()})}},{key:"getCustomerInvoices",value:function(e){return _.a.get("/customer_portal/customerInvoices/".concat(e),{headers:we()})}},{key:"getInvoiceItems",value:function(e,t,n){return _.a.get("/customer_portal/invoiceItems/".concat(e,"/").concat(t,"/").concat(n),{headers:we()})}},{key:"getInvoiceStatus",value:function(e){return _.a.get("/customer_portal/invoiceStatus/".concat(e),{headers:we()})}},{key:"getCustomerParts",value:function(){return _.a.get("/customer_portal/customerParts",{headers:we()})}},{key:"createOrder",value:function(e){return _.a.post("/customer_portal/createOrder",e,{headers:we()})}},{key:"getUserNotifications",value:function(){return _.a.get("/customer_portal/userNotifications",{headers:we()})}},{key:"setNotificationRead",value:function(e){return _.a.post("/customer_portal/userNotifications",e,{headers:we()})}},{key:"createTask",value:function(e){return _.a.post("/customer_portal/createTask",e,{headers:we()})}},{key:"updateTask",value:function(e){return _.a.patch("/customer_portal/updateTask",e,{headers:we()})}},{key:"getServiceCalls",value:function(e){return _.a.get("/customer_portal/servicecalls/".concat(e),{headers:we()})}},{key:"getServiceCall",value:function(e,t){return _.a.get("/customer_portal/servicecall/".concat(e,"/").concat(t),{headers:we()})}},{key:"getServiceCallExternalRemarks",value:function(e){return _.a.get("/customer_portal/servicecall/remarks/".concat(e),{headers:we()})}},{key:"getTaskExplanation",value:function(e){return _.a.get("/customer_portal/taskExplanation/".concat(e),{headers:we()})}},{key:"getTaskAttachments",value:function(e){return _.a.get("/customer_portal/taskAttachments/".concat(e),{headers:we()})}},{key:"getCallStatuses",value:function(){return _.a.get("/customer_portal/callStatuses",{headers:we()})}},{key:"getStatusLang2",value:function(e){return _.a.get("/customer_portal/statusLang2/".concat(e),{headers:we()})}},{key:"getCallTypes",value:function(){return _.a.get("/customer_portal/callTypes",{headers:we()})}},{key:"getCallSeverities",value:function(){return _.a.get("/customer_portal/callSeverities",{headers:we()})}},{key:"getCustomerContacts",value:function(e){return _.a.get("/customer_portal/customerContacts/".concat(e),{headers:we()})}},{key:"getUserProjects",value:function(e){return _.a.get("/customer_portal/userProjects/".concat(e),{headers:we()})}},{key:"getProjectTasks",value:function(e){return _.a.get("/customer_portal/projectTasks/".concat(e),{headers:we()})}},{key:"getProjectWBS",value:function(e){return _.a.get("/customer_portal/projectWBS/".concat(e),{headers:we()})}},{key:"getGanttWBS",value:function(e){return _.a.get("/customer_portal/ganttWBS/".concat(e),{headers:we()})}},{key:"getSCAttachments",value:function(e){return _.a.get("/customer_portal/scAttachments/".concat(e),{headers:we()})}},{key:"getTaskStatuses",value:function(){return _.a.get("/customer_portal/taskStatuses",{headers:we()})}},{key:"getTaskTypes",value:function(){return _.a.get("/customer_portal/taskTypes",{headers:we()})}},{key:"getTaskSizes",value:function(){return _.a.get("/customer_portal/taskSizes",{headers:we()})}},{key:"getUsers",value:function(){return _.a.get("/customer_portal/users",{headers:we()})}},{key:"getCustomerStatements",value:function(e){return _.a.get("/customer_portal/customerStatements/".concat(e),{headers:we()})}},{key:"addServiceCallComment",value:function(e){return _.a.post("/customer_portal/addServiceCallComment",e,{headers:we()})}},{key:"updateServiceCall",value:function(e){return _.a.patch("/customer_portal/updateServiceCall",e,{headers:we()})}},{key:"updateCallStatus",value:function(e){return _.a.post("/customer_portal/updateCallStatus",e,{headers:we()})}},{key:"changeTaskStatus",value:function(e){return _.a.patch("/customer_portal/changeTaskStatus",e,{headers:we()})}},{key:"CreateServiceCall",value:function(e,t){return _.a.post("/customer_portal/createServiceCall/".concat(t),e,{headers:we()})}},{key:"addServiceCallAttachment",value:function(e){return _.a.post("/customer_portal/addServiceCallAttachment",e,{headers:we()})}},{key:"getCustomerSignup",value:function(e){return _.a.get("/customer_portal/CustomerSignup/".concat(e))}},{key:"checkContact",value:function(e){return _.a.get("/customer_portal/check_contact/".concat(e))}},{key:"checkUser",value:function(e){return _.a.get("/customer_portal/check_user/".concat(e))}},{key:"createContact",value:function(e){return _.a.post("/customer_portal/CreateContact/",e)}},{key:"createUser",value:function(e){return _.a.post("/customer_portal/CreateUser/",e)}},{key:"getTheseCustomers",value:function(e){return _.a.get("/customer_portal/customers/".concat(e),{headers:we()})}},{key:"getOrderForStatus",value:function(){return _.a.get("/customer_portal/orderForStatus",{headers:we()})}},{key:"getLoginData",value:function(e,t){return _.a.get("/customer_portal/getLoginData/".concat(e,"/").concat(t),{headers:we()})}},{key:"getTaskslist",value:function(e,t,n,a,r,c){return _.a.get("/customer_portal/getTaskslist",{headers:we(),params:{projetNO:e,User:t,taskType:n,Order:a,WBSVAL:r,statdesArray:JSON.stringify(c)}})}},{key:"getInternalDialog",value:function(e){return _.a.get("/customer_portal/InternalDialog/".concat(e),{headers:we()})}},{key:"getProjectList",value:function(){return _.a.get("/customer_portal/getProjectList",{headers:we()})}},{key:"getClients",value:function(){return _.a.get("/customer_portal/getFinextraClient",{headers:we()})}},{key:"createClient",value:function(e){return _.a.post("/customer_portal/createFinextraClient",e,{headers:we()})}},{key:"updateClient",value:function(e){return _.a.patch("/customer_portal/updateFinextraClient",e,{headers:we()})}},{key:"deleteClient",value:function(e){return _.a.delete("/customer_portal/deleteFinextraClient/".concat(e),{headers:we()})}},{key:"createURL",value:function(e){return _.a.post("/customer_portal/createClientURL",e,{headers:we()})}},{key:"getUserMenuAccess",value:function(e){return _.a.get("/customer_portal/menuaccess/".concat(e),{headers:we()})}},{key:"getAllCustomersUnderUser",value:function(e){return _.a.get("/customer_portal/user/".concat(e,"/customers"),{headers:we()})}},{key:"downloadOrderPdf",value:function(e){return _()({url:"/customer_portal/downloadOrderPdf",method:"POST",responseType:"blob",headers:we(),data:{ORDNAME:e}})}},{key:"downloadInvoicePdf",value:function(e){return _()({url:"/customer_portal/downloadInvoicePdf",method:"POST",responseType:"blob",headers:we(),data:{IVNUM:e}})}},{key:"downloadShipmentPdf",value:function(e){return _()({url:"/customer_portal/downloadShipmentPdf",method:"POST",responseType:"blob",headers:we(),data:{DOCNO:e}})}},{key:"downloadServicePdf",value:function(e){return _()({url:"/customer_portal/downloadServicePdf",method:"POST",responseType:"blob",headers:we(),data:{DOCNO:e}})}},{key:"downloadStatementPdf",value:function(e){return _()({url:"/customer_portal/downloadStatementPdf",method:"POST",responseType:"blob",headers:we(),data:{STATEMENTNO:e}})}}]),e}());function Ue(e,t,n){return t[n]e[n]?1:0}function Le(e,t){return"desc"===e?function(e,n){return Ue(e,n,t)}:function(e,n){return-Ue(e,n,t)}}function Me(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 Fe=n(1),_e=function(e){var t=e.title;return Object(Fe.jsx)(f.a,{sx:{pl:{sm:2},pr:{xs:1,sm:1}},children:Object(Fe.jsx)(p.a,{sx:{flex:"1 1 100%"},variant:"h6",id:"tableTitle",component:"div",children:t})})},We=n(333),Be=n.n(We),Ye=[{id:"ID",label:"Customer ID",width:140},{id:"ACCNAME",label:"Name",width:170},{id:"EMAIL",label:"Email",width:240},{id:"FXR_CUSTOMERID",label:"Finexer Customer ID",width:190},{id:"FXR_BASE_URL",label:"Finexer Base URL",width:240},{id:"FXR_API_KEY",label:"Finexer API Key",width:180},{id:"FX_WEBHOOK_SECRET",label:"Webhook Secret",width:180},{id:"PRIORITY_BASE_URL",label:"Priority API URL",width:250},{id:"PRIORITY_COMPANY",label:"Priority Company",width:180},{id:"PRIORITY_USERNAME",label:"Priority Username",width:180},{id:"PRIORITY_PASSWORD",label:"Priority Password",width:180},{id:"RENEWAL_EMAIL",label:"Renewal Email",width:240},{id:"CONSENTURL",label:"Consent URL",width:260},{id:"ACTIVE",label:"Status",width:120},{id:"ACTION",label:"Action",width:200}],Ge={ID:"",ACCNAME:"",EMAIL:"",FXR_CUSTOMERID:"",FXR_BASE_URL:"",FXR_API_KEY:"",FX_WEBHOOK_SECRET:"",PRIORITY_BASE_URL:"",PRIORITY_COMPANY:"",PRIORITY_USERNAME:"",PRIORITY_PASSWORD:"",RENEWAL_EMAIL:"",CONSENTURL:"",ACTIVE:"Y"},ze={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"middle"};function Xe(e){var t=e.value,n=e.masked,a=void 0!==n&&n?function(e){if(!e)return"-";var t=String(e);return t.length<=4?"\u2022\u2022\u2022\u2022":"".concat(t.slice(0,4),"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022")}(t):t||"-";return Object(Fe.jsx)(re.a,{sx:ze,children:Object(Fe.jsx)(Se.a,{title:t?String(t):"",placement:"top",arrow:!0,children:Object(Fe.jsx)(p.a,{component:"span",variant:"body2",sx:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a})})})}function Ve(e){var t=e.order,n=e.orderBy,a=e.onRequestSort;return Object(Fe.jsx)(se.a,{children:Object(Fe.jsx)(oe.a,{children:Ye.map((function(e){var r,c="ACTION"!==e.id;return Object(Fe.jsx)(re.a,{sortDirection:n===e.id&&t,sx:{width:e.width,minWidth:e.width,maxWidth:e.width,fontWeight:700,whiteSpace:"nowrap",backgroundColor:"background.paper"},children:c?Object(Fe.jsx)(le.a,{active:n===e.id,direction:n===e.id?t:"asc",onClick:(r=e.id,function(e){a(e,r)}),children:e.label}):e.label},e.id)}))})})}function He(e){var t=e.row,n=e.onEdit,a=e.onDelete,r=e.deletingId,c=e.onGenerateConsentUrl,s=r===t.ID;return Object(Fe.jsxs)(oe.a,{hover:!0,children:[Object(Fe.jsx)(Xe,{value:t.ID}),Object(Fe.jsx)(Xe,{value:t.ACCNAME}),Object(Fe.jsx)(Xe,{value:t.EMAIL}),Object(Fe.jsx)(Xe,{value:t.FXR_CUSTOMERID}),Object(Fe.jsx)(Xe,{value:t.FXR_BASE_URL}),Object(Fe.jsx)(Xe,{value:t.FXR_API_KEY,masked:!0}),Object(Fe.jsx)(Xe,{value:t.FX_WEBHOOK_SECRET,masked:!0}),Object(Fe.jsx)(Xe,{value:t.PRIORITY_BASE_URL}),Object(Fe.jsx)(Xe,{value:t.PRIORITY_COMPANY}),Object(Fe.jsx)(Xe,{value:t.PRIORITY_USERNAME}),Object(Fe.jsx)(Xe,{value:t.PRIORITY_PASSWORD,masked:!0}),Object(Fe.jsx)(Xe,{value:t.RENEWAL_EMAIL}),Object(Fe.jsx)(Xe,{value:t.CONSENTURL}),Object(Fe.jsx)(re.a,{sx:ze,children:Object(Fe.jsx)(me.a,{label:"Y"===t.ACTIVE?"Active":"Inactive",color:"Y"===t.ACTIVE?"success":"default",size:"small"})}),Object(Fe.jsxs)(re.a,{sx:Object(l.a)(Object(l.a)({},ze),{},{whiteSpace:"nowrap"}),children:[Object(Fe.jsx)(Se.a,{title:"Edit",children:Object(Fe.jsx)(S.a,{color:"primary",onClick:function(){return n(t)},children:Object(Fe.jsx)(De.a,{})})}),Object(Fe.jsx)(Se.a,{title:"Delete",children:Object(Fe.jsx)("span",{children:Object(Fe.jsx)(S.a,{color:"error",disabled:s,onClick:function(){return a(t)},children:s?Object(Fe.jsx)(fe.a,{size:22}):Object(Fe.jsx)(ke.a,{})})})}),Object(Fe.jsx)(Se.a,{title:"Generate Consent URL",children:Object(Fe.jsx)(S.a,{color:"secondary",onClick:function(){return c(t)},children:Object(Fe.jsx)(Be.a,{sx:{fontSize:30}})})})]})]})}function qe(){var e=Object(Ne.b)().enqueueSnackbar,t=Object(a.useState)([]),n=Object(o.a)(t,2),r=n[0],c=n[1],s=Object(a.useState)(!1),u=Object(o.a)(s,2),d=u[0],j=u[1],b=Object(a.useState)(!1),O=Object(o.a)(b,2),x=(O[0],O[1]),f=Object(a.useState)("asc"),m=Object(o.a)(f,2),g=m[0],v=m[1],C=Object(a.useState)("ID"),T=Object(o.a)(C,2),A=T[0],D=T[1],I=Object(a.useState)(0),k=Object(o.a)(I,2),R=k[0],y=k[1],N=Object(a.useState)(5),w=Object(o.a)(N,2),P=w[0],U=w[1],L=Object(a.useState)(""),M=Object(o.a)(L,2),F=M[0],_=M[1],W=Object(a.useState)(!1),B=Object(o.a)(W,2),Y=B[0],G=B[1],z=Object(a.useState)(!1),X=Object(o.a)(z,2),V=X[0],H=X[1],q=Object(a.useState)(Ge),K=Object(o.a)(q,2),J=K[0],Q=K[1],Z=Object(a.useState)(!1),$=Object(o.a)(Z,2),ee=$[0],se=$[1],le=Object(a.useState)(""),me=Object(o.a)(le,2),Se=me[0],ve=(me[1],Object(a.useState)(!1)),Ce=Object(o.a)(ve,2),Ae=Ce[0],Ie=Ce[1],Re=Object(a.useState)(null),we=Object(o.a)(Re,2),Ue=we[0],Me=we[1],We=Object(a.useState)(!1),Be=Object(o.a)(We,2),ze=Be[0],Xe=Be[1],qe=Object(a.useState)(!1),Ke=Object(o.a)(qe,2),Je=Ke[0],Qe=Ke[1],Ze=Object(a.useState)(null),$e=Object(o.a)(Ze,2),et=$e[0],tt=$e[1],nt=Object(a.useState)(""),at=Object(o.a)(nt,2),rt=at[0],ct=at[1],st=Object(a.useState)(!1),it=Object(o.a)(st,2),ot=it[0],lt=it[1];Object(a.useEffect)((function(){ut()}),[]);var ut=function(){x(!0),Pe.getClients().then((function(e){console.log("client",e.data.value),c(e.data.value),j(!0)})).catch((function(t){console.error("Error loading customers:",t),c([]),j(!0),e("Error loading customers.",{variant:"error"})})).finally((function(){x(!1)}))},dt=Object(a.useMemo)((function(){var e=F.trim().toLowerCase();return e?r.filter((function(t){return[t.ID,t.ACCNAME,t.EMAIL,t.FXR_CUSTOMERID,t.FXR_BASE_URL,t.FXR_API_KEY,t.FX_WEBHOOK_SECRET,t.PRIORITY_BASE_URL,t.PRIORITY_COMPANY,t.PRIORITY_USERNAME,t.PRIORITY_PASSWORD,t.RENEWAL_EMAIL,t.CONSENTURL,t.ACTIVE].some((function(t){return String(null!==t&&void 0!==t?t:"").toLowerCase().includes(e)}))})):r}),[r,F]),jt=function(e){var t=e.target,n=t.name,a=t.value,r=t.checked,c=t.type;Q((function(e){return Object(l.a)(Object(l.a)({},e),{},Object(i.a)({},n,"checkbox"===c?r?"Y":"N":a))}))},bt=function(e){console.log("customer data",e),H(!0),Q({ID:e.ID||"",ACCNAME:e.ACCNAME||"",EMAIL:e.EMAIL||"",FXR_CUSTOMERID:e.FXR_CUSTOMERID||"",FXR_BASE_URL:e.FXR_BASE_URL||"",FXR_API_KEY:e.FXR_API_KEY||"",FX_WEBHOOK_SECRET:e.FX_WEBHOOK_SECRET||"",PRIORITY_BASE_URL:e.PRIORITY_BASE_URL||"",PRIORITY_COMPANY:e.PRIORITY_COMPANY||"",PRIORITY_USERNAME:e.PRIORITY_USERNAME||"",PRIORITY_PASSWORD:e.PRIORITY_PASSWORD||"",RENEWAL_EMAIL:e.RENEWAL_EMAIL||"",CONSENTURL:e.CONSENTURL||"",ACTIVE:"N"===e.ACTIVE?"N":"Y"}),G(!0)},Ot=function(){ee||(G(!1),H(!1),Q(Object(l.a)({},Ge)))},ht=["ID","ACCNAME","EMAIL","FXR_CUSTOMERID","FXR_BASE_URL","FXR_API_KEY","FX_WEBHOOK_SECRET","PRIORITY_BASE_URL","PRIORITY_COMPANY","PRIORITY_USERNAME","PRIORITY_PASSWORD","RENEWAL_EMAIL","CONSENTURL"].some((function(e){return!String(J[e]||"").trim()})),xt=function(e){Me(e),Ie(!0)},ft=function(){ze||(Ie(!1),Me(null))},mt=function(e){tt(e);var t=e.CONSENTURL||"",n=t.endsWith("=")?"".concat(t).concat(e.ID):"".concat(t,"=").concat(e.ID);ct(n),Qe(!0)},pt=function(){ot||(Qe(!1),tt(null),ct(""))};return Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(h.a,{sx:{width:"100%",display:"flex",justifyContent:"center",py:3},children:Object(Fe.jsx)(h.a,{sx:{width:"95%",maxWidth:"100%"},children:Object(Fe.jsxs)(te.a,{sx:{width:"100%",mb:2},children:[Object(Fe.jsxs)(h.a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,p:2,flexWrap:"wrap"},children:[Object(Fe.jsx)(ue.a,{variant:"contained",startIcon:Object(Fe.jsx)(Ee.a,{}),onClick:function(){H(!1),Q(Object(l.a)({},Ge)),G(!0)},children:"Onboard Customer"}),Object(Fe.jsx)(he.a,{id:"customer-search",value:F,onChange:function(e){_(e.target.value),y(0)},label:"Customer Search",variant:"outlined",placeholder:"Search customer details...",size:"small",sx:{width:{xs:"100%",sm:"320px"}},InputProps:{startAdornment:Object(Fe.jsx)(xe.a,{position:"start",children:Object(Fe.jsx)(Te.a,{})})}})]}),Object(Fe.jsx)(_e,{title:"Finexer Customers"}),Object(Fe.jsx)(ce.a,{sx:{width:"100%",overflowX:"auto"},children:Object(Fe.jsxs)(ne.a,{stickyHeader:!0,size:"medium","aria-labelledby":"tableTitle",sx:{tableLayout:"fixed",minWidth:2650},children:[Object(Fe.jsx)(Ve,{order:g,orderBy:A,onRequestSort:function(e,t){"ACTION"!==t&&(v(A===t&&"asc"===g?"desc":"asc"),D(t))}}),Object(Fe.jsx)(ae.a,{children:d?0===dt.length?Object(Fe.jsx)(oe.a,{children:Object(Fe.jsx)(re.a,{colSpan:Ye.length,align:"center",children:Object(Fe.jsx)(p.a,{color:"text.secondary",sx:{py:4},children:"No customer records found."})})}):dt.slice().sort(Le(g,A)).slice(R*P,R*P+P).map((function(e){return Object(Fe.jsx)(He,{row:e,onEdit:bt,onDelete:xt,deletingId:Se,onGenerateConsentUrl:mt},e.ID)})):Object(Fe.jsx)(oe.a,{children:Object(Fe.jsx)(re.a,{colSpan:Ye.length,align:"center",sx:{py:5},children:Object(Fe.jsx)(fe.a,{})})})})]})}),Object(Fe.jsx)(ie.a,{rowsPerPageOptions:[5,10,25],component:"div",count:dt.length,rowsPerPage:P,page:R,onPageChange:function(e,t){y(t)},onRowsPerPageChange:function(e){U(parseInt(e.target.value,10)),y(0)}})]})})}),Object(Fe.jsxs)(de.a,{open:Y,onClose:Ot,fullWidth:!0,maxWidth:"md",children:[Object(Fe.jsx)(Oe.a,{children:Object(Fe.jsxs)(h.a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Object(Fe.jsx)(p.a,{variant:"h6",children:V?"Edit Finexer Customer":"Finexer Customer Onboarding"}),Object(Fe.jsx)(S.a,{onClick:Ot,disabled:ee,children:Object(Fe.jsx)(ye.a,{})})]})}),Object(Fe.jsx)(be.a,{dividers:!0,children:Object(Fe.jsxs)(E.a,{container:!0,spacing:2,children:[Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,required:!0,size:"small",name:"ID",label:"Customer ID",value:J.ID,onChange:jt,disabled:V})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,required:!0,size:"small",name:"ACCNAME",label:"Name",value:J.ACCNAME,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,required:!0,size:"small",type:"email",name:"EMAIL",label:"Email",value:J.EMAIL,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"FXR_CUSTOMERID",label:"Finexer Customer ID",value:J.FXR_CUSTOMERID,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"FXR_BASE_URL",label:"Finexer Base URL",value:J.FXR_BASE_URL,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"FXR_API_KEY",label:"Finexer API Key",value:J.FXR_API_KEY,onChange:jt,autoComplete:"new-password"})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"FX_WEBHOOK_SECRET",label:"Finexer Webhook Secret",value:J.FX_WEBHOOK_SECRET,onChange:jt,autoComplete:"new-password"})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"PRIORITY_BASE_URL",label:"Priority Base URL",value:J.PRIORITY_BASE_URL,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"PRIORITY_COMPANY",label:"Priority Company",value:J.PRIORITY_COMPANY,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"PRIORITY_USERNAME",label:"Priority Username",value:J.PRIORITY_USERNAME,onChange:jt,autoComplete:"off"})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"PRIORITY_PASSWORD",label:"Priority Password",value:J.PRIORITY_PASSWORD,onChange:jt,autoComplete:"new-password"})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",type:"email",name:"RENEWAL_EMAIL",label:"Renewal Contact Email",value:J.RENEWAL_EMAIL,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,sm:6,children:Object(Fe.jsx)(he.a,{fullWidth:!0,size:"small",name:"CONSENTURL",label:"Consent URL",value:J.CONSENTURL,onChange:jt})}),Object(Fe.jsx)(E.a,{item:!0,xs:12,children:Object(Fe.jsx)(pe.a,{control:Object(Fe.jsx)(ge.a,{name:"ACTIVE",checked:"Y"===J.ACTIVE,onChange:jt}),label:"Y"===J.ACTIVE?"Active":"Inactive"})})]})}),Object(Fe.jsxs)(je.a,{children:[Object(Fe.jsx)(ue.a,{onClick:Ot,disabled:ee,children:"Cancel"}),Object(Fe.jsx)(ue.a,{variant:"outlined",disabled:ee,onClick:function(){Q(V?function(e){return Object(l.a)(Object(l.a)({},Ge),{},{ID:e.ID})}:Object(l.a)({},Ge))},children:"Clear"}),Object(Fe.jsx)(ue.a,{variant:"contained",onClick:function(){V?function(){se(!0);var t=Object(l.a)(Object(l.a)({},J),{},{UPDATEDATE:(new Date).toISOString()});console.log("Update Payload:",t),Pe.updateClient(t).then((function(t){console.log("Update Response:",t),e("Customer updated successfully.",{variant:"success"}),Ot(),ut()})).catch((function(t){console.error("Error updating customer:",t),e("Error updating customer.",{variant:"error"})})).finally((function(){se(!1)}))}():function(){se(!0);var t=Object(l.a)(Object(l.a)({},J),{},{CREATEDATE:(new Date).toISOString(),UPDATEDATE:(new Date).toISOString()});Pe.createClient(t).then((function(t){console.log("Create Response:",t),e("Customer onboarded successfully.",{variant:"success"}),Ot(),ut()})).catch((function(t){console.error("Error onboarding customer:",t),e("Error onboarding customer.",{variant:"error"})})).finally((function(){se(!1)}))}()},disabled:ee||ht,startIcon:ee?Object(Fe.jsx)(fe.a,{size:20,color:"inherit"}):V?Object(Fe.jsx)(De.a,{}):Object(Fe.jsx)(Ee.a,{}),children:ee?"Saving...":V?"Save Changes":"Onboard Customer"})]})]}),Object(Fe.jsxs)(de.a,{open:Ae,onClose:ft,maxWidth:"xs",fullWidth:!0,children:[Object(Fe.jsx)(Oe.a,{children:"Delete Customer"}),Object(Fe.jsx)(be.a,{children:"Do you really want to delete the customer details?"}),Object(Fe.jsxs)(je.a,{children:[Object(Fe.jsx)(ue.a,{onClick:ft,disabled:ze,children:"Cancel"}),Object(Fe.jsx)(ue.a,{variant:"contained",color:"error",onClick:function(){Ue&&(Xe(!0),console.log("customerToDelete.ID",Ue.ID),Pe.deleteClient(Ue.ID).then((function(){e("Customer deleted successfully.",{variant:"success"}),Ie(!1),Me(null),ut()})).catch((function(t){console.error("Error deleting customer:",t),e("Error deleting customer.",{variant:"error"})})).finally((function(){Xe(!1)})))},disabled:ze,startIcon:ze?Object(Fe.jsx)(fe.a,{size:18,color:"inherit"}):Object(Fe.jsx)(ke.a,{}),children:ze?"Deleting...":"Delete"})]})]}),Object(Fe.jsxs)(de.a,{open:Je,onClose:pt,fullWidth:!0,maxWidth:"md",children:[Object(Fe.jsx)(Oe.a,{children:"Generate Consent URL"}),Object(Fe.jsxs)(be.a,{dividers:!0,children:[Object(Fe.jsx)(p.a,{sx:{mb:2},children:"Consent URL for Customer, please save:"}),Object(Fe.jsx)(he.a,{fullWidth:!0,label:"Consent URL",value:rt,InputProps:{readOnly:!0}})]}),Object(Fe.jsxs)(je.a,{children:[Object(Fe.jsx)(ue.a,{onClick:pt,disabled:ot,children:"Cancel"}),Object(Fe.jsx)(ue.a,{variant:"contained",onClick:function(){if(et){lt(!0);var t={ID:et.ID,CONSENTURL:rt,CONSETURLGNRTD:et.CONSETURLGNRTD,PRIORITY_BASE_URL:et.PRIORITY_BASE_URL,PRIORITY_COMPANY:et.PRIORITY_COMPANY,PRIORITY_USERNAME:et.PRIORITY_USERNAME,PRIORITY_PASSWORD:et.PRIORITY_PASSWORD};Pe.createURL(t).then((function(){e("Consent URL saved successfully.",{variant:"success"}),Qe(!1),ut()})).catch((function(t){console.error(t),e("Error saving Consent URL.",{variant:"error"})})).finally((function(){lt(!1)}))}},disabled:ot,startIcon:ot?Object(Fe.jsx)(fe.a,{size:18,color:"inherit"}):null,children:ot?"Saving...":"Save"})]})]})]})}var Ke=function(e,t){if(!(null===e||void 0===e?void 0:e.ZMED_MENUACCESS_SUBFORM))return!0;var n=e.ZMED_MENUACCESS_SUBFORM.find((function(e){return e.MENUNAME===t}));return"Y"===(null===n||void 0===n?void 0:n.ACCESS)},Je=function(e){return Object(Fe.jsx)("div",{children:B.getCurrentUser()?Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsxs)(I.a,{button:!0,component:U.b,to:"/dashboard",children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)(N.a,{})}),Object(Fe.jsx)(R.a,{primary:"Dashboard"})]}),Ke(e,"INV")&&Object(Fe.jsxs)(I.a,{button:!0,component:U.b,to:"/dashboard/invoices",children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)(V,{})}),Object(Fe.jsx)(R.a,{primary:"Invoices"})]}),Ke(e,"STA")&&Object(Fe.jsxs)(I.a,{button:!0,component:U.b,to:"/dashboard/statements",children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)(ee.a,{})}),Object(Fe.jsx)(R.a,{primary:"Statements"})]}),Ke(e,"KAN")&&Object(Fe.jsxs)(I.a,{button:!0,component:U.b,to:"/dashboard/kanban",children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)(J.a,{})}),Object(Fe.jsx)(R.a,{primary:"Kanban Board"})]}),Ke(e,"GAN")&&Object(Fe.jsxs)(I.a,{button:!0,component:U.b,to:"/dashboard/gantt",children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)(Z.a,{})}),Object(Fe.jsx)(R.a,{primary:"Gantt Chart"})]}),Object(Fe.jsx)(g.a,{}),Ke(e,"SVC")&&Object(Fe.jsxs)(I.a,{button:!0,component:U.b,to:"/dashboard/servicecalls",children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)(q.a,{})}),Object(Fe.jsx)(R.a,{primary:"Service Calls"})]})]}):Object(Fe.jsx)(Fe.Fragment,{children:Object(Fe.jsxs)(I.a,{button:!0,component:U.b,to:"/login",children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)(P.a,{})}),Object(Fe.jsx)(R.a,{primary:"Login"})]})})})},Qe=n(22),Ze=n(693),$e=n(668),et=function(){return Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(Ze.a,{}),Object(Fe.jsx)($e.a,{variant:"rectangular",height:50,style:{marginBottom:10}}),Object(Qe.a)(Array(25)).map((function(e,t){return Object(Fe.jsx)($e.a,{variant:"rectangular",height:25,style:{marginBottom:5}},t)}))]})},tt=n(93),nt=n.n(tt),at=n(634);function rt(e){var t=e.order,n=e.orderBy,a=e.onRequestSort;return Object(Fe.jsx)(se.a,{children:Object(Fe.jsx)(oe.a,{children:e.headCells.map((function(e){return Object(Fe.jsx)(re.a,{align:"center",padding:e.disablePadding?"none":"normal",sortDirection:n===e.id&&t,children:Object(Fe.jsxs)(le.a,{active:n===e.id,direction:n===e.id?t:"asc",onClick:(r=e.id,function(e){return a(e,r)}),children:[Object(Fe.jsx)("b",{children:e.label}),n===e.id?Object(Fe.jsx)(h.a,{component:"span",sx:at.a,children:"desc"===t?"sorted descending":"sorted ascending"}):null]})},e.id);var r}))})})}var ct=n(671),st=[{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 it(e){var t=e.row,n=Object(a.useState)(!1),c=Object(o.a)(n,2),s=(c[0],c[1],Object(a.useState)([])),i=Object(o.a)(s,2),l=(i[0],i[1],Object(a.useState)(!0)),u=Object(o.a)(l,2),d=(u[0],u[1],Object(Ne.b)()),j=d.enqueueSnackbar;d.closeSnackbar;return Object(Fe.jsx)(r.a.Fragment,{children:Object(Fe.jsxs)(oe.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(Fe.jsx)(re.a,{component:"th",scope:"row",align:"center",children:new Date(t.IVDATE).toLocaleDateString("en-GB")}),Object(Fe.jsx)(re.a,{align:"center",children:t.IVNUM}),Object(Fe.jsxs)(re.a,{align:"center",children:[t.CODE," ",Number(t.TOTPRICE).toFixed(2)]}),Object(Fe.jsx)(re.a,{align:"center",children:t.REFERENCE}),Object(Fe.jsx)(re.a,{component:"th",scope:"row",align:"center",children:new Date(t.PAYDATE).toLocaleDateString("en-GB")}),Object(Fe.jsx)(re.a,{align:"center",children:Object(Fe.jsx)(S.a,{onClick:function(){return e=t.IVNUM,void Pe.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(Fe.jsx)(nt.a,{})})})]})})}function ot(e){var t=e.selectedCustomer,n=Object(a.useState)("asc"),r=Object(o.a)(n,2),c=r[0],s=r[1],i=Object(a.useState)("calories"),l=Object(o.a)(i,2),u=l[0],d=l[1],j=Object(a.useState)([]),b=Object(o.a)(j,2),O=b[0],x=b[1],f=Object(a.useState)(0),m=Object(o.a)(f,2),p=m[0],g=m[1],S=Object(a.useState)(5),v=Object(o.a)(S,2),E=v[0],C=v[1],T=Object(a.useState)([]),A=Object(o.a)(T,2),D=A[0],I=A[1],k=Object(a.useState)([]),R=Object(o.a)(k,2),y=R[0],N=R[1],w=Object(a.useState)(!1),P=Object(o.a)(w,2),U=P[0],L=P[1],M=Object(a.useState)(""),F=Object(o.a)(M,2),_=F[0],W=F[1];Object(a.useEffect)((function(){var e="";if(t&&(e=t.CUSTNAME),!e){var n=localStorage.getItem("selectedCUSTNAME");if(n)try{e=JSON.parse(n)}catch(a){console.error("Error parsing stored customer:",a),e=null}}Pe.getCustomerInvoices(e).then((function(e){I(e.data.value),N(e.data.value),void 0!==e.data.value&&null!==e.data.value&&L(!0)})).catch((function(e){console.log(e)}))}),[t]);return U?Object(Fe.jsx)(h.a,{sx:{width:"100%"},children:Object(Fe.jsxs)(te.a,{sx:{width:"100%",mb:2},children:[Object(Fe.jsx)(ne.a,{children:Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{children:Object(Fe.jsx)(_e,{title:"Invoices"})}),Object(Fe.jsx)(re.a,{children:Object(Fe.jsx)(he.a,{id:"search-bar",className:"text",value:_,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())})),I(n)}else I(y)},label:"Invoice Search",variant:"outlined",placeholder:"Invoice Number...",InputProps:{startAdornment:Object(Fe.jsx)(ct.a,{position:"start",children:Object(Fe.jsx)(Te.a,{})})},style:{height:"60px"}})})]})}),Object(Fe.jsx)(ce.a,{children:Object(Fe.jsxs)(ne.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(Fe.jsx)(rt,{numSelected:O.length,order:c,orderBy:u,onSelectAllClick:function(e){if(e.target.checked){var t=D.map((function(e){return e.name}));x(t)}else x([])},onRequestSort:function(e,t){s(u===t&&"asc"===c?"desc":"asc"),d(t)},rowCount:D.length,headCells:st}),Object(Fe.jsx)(ae.a,{children:D.slice().sort(Le(c,u)).slice(p*E,p*E+E).map((function(e,t){return Object(Fe.jsx)(it,{row:e},t)}))})]})}),Object(Fe.jsx)(ie.a,{rowsPerPageOptions:[5,10,25],component:"div",count:D.length,rowsPerPage:E,page:p,onPageChange:function(e,t){g(t)},onRowsPerPageChange:function(e){C(parseInt(e.target.value,10)),g(0)}})]})}):Object(Fe.jsx)(et,{})}var lt=function(){return Object(Fe.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(Fe.jsx)(E.a,{item:!0,xs:12,children:Object(Fe.jsx)(ot,{})})})},ut=n(142),dt=n.n(ut),jt=n(141),bt=n.n(jt),Ot=n(694),ht=[{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 xt(e){var t=e.row,n=Object(a.useState)(!1),c=Object(o.a)(n,2),s=c[0],i=c[1],l=Object(a.useState)([]),u=Object(o.a)(l,2),d=u[0],j=u[1],b=Object(a.useState)(!0),O=Object(o.a)(b,2),x=O[0],f=O[1],m=Object(Ne.b)(),g=m.enqueueSnackbar,v=(m.closeSnackbar,function(){s?i(!s):(f(!1),Pe.getOrderItems(t.ORDNAME).then((function(e){j(e.data.value),f(!0),i(!s)})).catch((function(e){console.log(e)})))});return Object(Fe.jsxs)(r.a.Fragment,{children:[Object(Fe.jsxs)(oe.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(Fe.jsx)(re.a,{children:x?Object(Fe.jsx)(S.a,{"aria-label":"expand row",size:"small",onClick:v,children:s?Object(Fe.jsx)(bt.a,{}):Object(Fe.jsx)(dt.a,{})}):Object(Fe.jsx)(fe.a,{size:28})}),Object(Fe.jsx)(re.a,{component:"th",scope:"row",children:new Date(t.CURDATE).toLocaleDateString("en-GB")}),Object(Fe.jsx)(re.a,{align:"center",children:t.ORDNAME}),Object(Fe.jsx)(re.a,{align:"center",children:t.REFERENCE}),Object(Fe.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.QPRICE.toLocaleString()]}),Object(Fe.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.TOTPRICE.toLocaleString()]}),Object(Fe.jsx)(re.a,{align:"center",children:Object(Fe.jsx)(me.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(Fe.jsx)(re.a,{align:"center",children:t.NAME}),Object(Fe.jsx)(re.a,{align:"center",children:Object(Fe.jsx)(S.a,{onClick:function(){return e=t.ORDNAME,void Pe.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),g("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(Fe.jsx)(nt.a,{})})})]}),Object(Fe.jsx)(oe.a,{children:Object(Fe.jsx)(re.a,{style:{paddingBottom:0,paddingTop:0,paddingLeft:100,backgroundColor:"#F8F8F8"},colSpan:8,children:Object(Fe.jsx)(Ot.a,{in:s,timeout:"auto",unmountOnExit:!0,onClick:v,children:Object(Fe.jsxs)(h.a,{sx:{margin:1},children:[Object(Fe.jsx)(p.a,{variant:"h6",gutterBottom:!0,component:"div",children:"Order Items"}),x?Object(Fe.jsxs)(ne.a,{size:"small","aria-label":"order-items",children:[Object(Fe.jsx)(se.a,{children:Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{children:Object(Fe.jsx)("b",{children:"Part No."})}),Object(Fe.jsx)(re.a,{children:Object(Fe.jsx)("b",{children:"Part Name"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Quantity"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Balance"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Price"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Total Price ex. VAT"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Total Price"})})]})}),Object(Fe.jsx)(ae.a,{children:d.map((function(e,t){return Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{component:"th",scope:"row",children:e.PARTNAME}),Object(Fe.jsx)(re.a,{children:e.PDES}),Object(Fe.jsx)(re.a,{align:"right",children:e.TQUANT}),Object(Fe.jsx)(re.a,{align:"right",children:e.TBALANCE}),Object(Fe.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.PRICE]}),Object(Fe.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.QPRICE]}),Object(Fe.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.VATPRICE]})]},t)}))})]}):Object(Fe.jsx)(fe.a,{})]})})})})]})}function ft(e){var t=e.selectedCustomer,n=Object(a.useState)("asc"),r=Object(o.a)(n,2),c=r[0],s=r[1],i=Object(a.useState)("calories"),l=Object(o.a)(i,2),u=l[0],d=l[1],j=Object(a.useState)([]),b=Object(o.a)(j,2),O=b[0],x=(b[1],Object(a.useState)(0)),f=Object(o.a)(x,2),m=f[0],p=f[1],g=Object(a.useState)(5),S=Object(o.a)(g,2),v=S[0],E=S[1],C=Object(a.useState)([]),T=Object(o.a)(C,2),A=T[0],D=T[1],I=Object(a.useState)(!1),k=Object(o.a)(I,2),R=k[0],y=k[1];Object(a.useEffect)((function(){var e="";if(t&&(e=t.CUSTNAME),!e){var n=localStorage.getItem("selectedCUSTNAME");if(n)try{e=JSON.parse(n)}catch(a){console.error("Error parsing stored customer:",a),e=null}}Pe.getCustomerOrders(e).then((function(e){D(e.data.value),void 0!==e.data.value&&null!==e.data.value&&y(!0)})).catch((function(e){console.log(e)}))}),[t]);return R?Object(Fe.jsx)(h.a,{sx:{width:"100%"},children:Object(Fe.jsxs)(te.a,{sx:{width:"100%",mb:2},children:[Object(Fe.jsx)(_e,{title:"Orders"}),Object(Fe.jsx)(ce.a,{children:Object(Fe.jsxs)(ne.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(Fe.jsx)(rt,{numSelected:O.length,order:c,orderBy:u,onRequestSort:function(e,t){s(u===t&&"asc"===c?"desc":"asc"),d(t)},rowCount:A.length,headCells:ht}),Object(Fe.jsx)(ae.a,{children:A.slice().sort(Le(c,u)).slice(m*v,m*v+v).map((function(e,t){return Object(Fe.jsx)(xt,{row:e},t)}))})]})}),Object(Fe.jsx)(ie.a,{rowsPerPageOptions:[5,10,25],component:"div",count:A.length,rowsPerPage:v,page:m,onPageChange:function(e,t){p(t)},onRowsPerPageChange:function(e){E(parseInt(e.target.value,10)),p(0)}})]})}):Object(Fe.jsx)("div",{children:"No Order for this Customer"})}var mt=function(){return Object(Fe.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(Fe.jsx)(E.a,{item:!0,xs:12,children:Object(Fe.jsx)(ft,{})})})},pt=[{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 gt(e){var t=e.row,n=Object(a.useState)(!1),c=Object(o.a)(n,2),s=c[0],i=c[1],l=Object(a.useState)([]),u=Object(o.a)(l,2),d=u[0],j=u[1],b=Object(a.useState)(!0),O=Object(o.a)(b,2),x=O[0],f=O[1],m=Object(Ne.b)(),g=m.enqueueSnackbar,v=(m.closeSnackbar,function(){s?i(!s):(f(!1),Pe.getShipmentItems(t.DOCNO,t.TYPE).then((function(e){j(e.data.value),f(!0),i(!s)})).catch((function(e){console.log(e)})))});return Object(Fe.jsxs)(r.a.Fragment,{children:[Object(Fe.jsxs)(oe.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(Fe.jsx)(re.a,{children:x?Object(Fe.jsx)(S.a,{"aria-label":"expand row",size:"small",onClick:v,children:s?Object(Fe.jsx)(bt.a,{}):Object(Fe.jsx)(dt.a,{})}):Object(Fe.jsx)(fe.a,{size:28})}),Object(Fe.jsx)(re.a,{component:"th",scope:"row",children:new Date(t.CURDATE).toLocaleDateString("en-GB")}),Object(Fe.jsx)(re.a,{align:"center",children:t.DOCNO}),Object(Fe.jsx)(re.a,{align:"center",children:t.REFERENCE}),Object(Fe.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.QPRICE.toLocaleString()]}),Object(Fe.jsxs)(re.a,{align:"center",children:[t.CODE," ",t.TOTPRICE.toLocaleString()]}),Object(Fe.jsx)(re.a,{align:"center",children:Object(Fe.jsx)(me.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(Fe.jsx)(re.a,{align:"center",children:Object(Fe.jsx)(S.a,{onClick:function(){return e=t.DOCNO,void Pe.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),g("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(Fe.jsx)(nt.a,{})})})]}),Object(Fe.jsx)(oe.a,{children:Object(Fe.jsx)(re.a,{style:{paddingBottom:0,paddingTop:0,paddingLeft:100,backgroundColor:"#F8F8F8"},colSpan:8,children:Object(Fe.jsx)(Ot.a,{in:s,timeout:"auto",unmountOnExit:!0,onClick:v,children:Object(Fe.jsxs)(h.a,{sx:{margin:1},children:[Object(Fe.jsx)(p.a,{variant:"h6",gutterBottom:!0,component:"div",children:"Shipped Items"}),x?Object(Fe.jsxs)(ne.a,{size:"small","aria-label":"purchases",children:[Object(Fe.jsx)(se.a,{children:Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{children:Object(Fe.jsx)("b",{children:"Part No."})}),Object(Fe.jsx)(re.a,{children:Object(Fe.jsx)("b",{children:"Part Name"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Quantity"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Price"})}),Object(Fe.jsx)(re.a,{align:"right",children:Object(Fe.jsx)("b",{children:"Total Price ex. VAT"})})]})}),Object(Fe.jsx)(ae.a,{children:d.map((function(e,t){return Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{component:"th",scope:"row",children:e.PARTNAME}),Object(Fe.jsx)(re.a,{children:e.PDES}),Object(Fe.jsx)(re.a,{align:"right",children:e.TQUANT}),Object(Fe.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.PRICE]}),Object(Fe.jsxs)(re.a,{align:"right",children:[e.CODE," ",e.QPRICE]})]},t)}))})]}):Object(Fe.jsx)(fe.a,{})]})})})})]})}function St(e){var t=e.selectedCustomer,n=Object(a.useState)("asc"),r=Object(o.a)(n,2),c=r[0],s=r[1],i=Object(a.useState)("calories"),l=Object(o.a)(i,2),u=l[0],d=l[1],j=Object(a.useState)([]),b=Object(o.a)(j,2),O=b[0],x=b[1],f=Object(a.useState)(0),m=Object(o.a)(f,2),p=m[0],g=m[1],S=Object(a.useState)(5),v=Object(o.a)(S,2),E=v[0],C=v[1],T=Object(a.useState)([]),A=Object(o.a)(T,2),D=A[0],I=A[1],k=Object(a.useState)(!1),R=Object(o.a)(k,2),y=R[0],N=R[1];Object(a.useEffect)((function(){var e="";if(t&&(e=t.CUSTNAME),!e){var n=localStorage.getItem("selectedCUSTNAME");if(n)try{e=JSON.parse(n)}catch(a){console.error("Error parsing stored customer:",a),e=null}}Pe.getCustomerShipments(e).then((function(e){I(e.data.value),void 0!==e.data.value&&null!==e.data.value&&N(!0)})).catch((function(e){console.log(e)}))}),[t]);return y?Object(Fe.jsx)(h.a,{sx:{width:"100%"},children:Object(Fe.jsxs)(te.a,{sx:{width:"100%",mb:2},children:[Object(Fe.jsx)(_e,{title:"Shipments"}),Object(Fe.jsx)(ce.a,{children:Object(Fe.jsxs)(ne.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(Fe.jsx)(rt,{numSelected:O.length,order:c,orderBy:u,onSelectAllClick:function(e){if(e.target.checked){var t=D.map((function(e){return e.name}));x(t)}else x([])},onRequestSort:function(e,t){s(u===t&&"asc"===c?"desc":"asc"),d(t)},rowCount:D.length,headCells:pt}),Object(Fe.jsx)(ae.a,{children:D.slice().sort(Le(c,u)).slice(p*E,p*E+E).map((function(e,t){return Object(Fe.jsx)(gt,{row:e},t)}))})]})}),Object(Fe.jsx)(ie.a,{rowsPerPageOptions:[5,10,25],component:"div",count:D.length,rowsPerPage:E,page:p,onPageChange:function(e,t){g(t)},onRowsPerPageChange:function(e){C(parseInt(e.target.value,10)),g(0)}})]})}):Object(Fe.jsx)(et,{})}var vt=function(){return Object(Fe.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(Fe.jsx)(E.a,{item:!0,xs:12,children:Object(Fe.jsx)(St,{})})})},Et=n(46),Ct=n(657),Tt=n(658),At=n(651),Dt=n(533),It=n(343),kt=n.n(It),Rt=n(344),yt=n.n(Rt);function Nt(e){return Number.parseFloat(e).toFixed(2)}var wt=[{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 Pt(e){var t=e.order,n=e.orderBy,a=e.onRequestSort;return Object(Fe.jsx)(se.a,{children:Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{padding:"checkbox"}),wt.map((function(e){return Object(Fe.jsx)(re.a,{align:e.numeric?"right":"left",padding:e.disablePadding?"none":"normal",sortDirection:n===e.id&&t,children:Object(Fe.jsxs)(le.a,{active:n===e.id,direction:n===e.id?t:"asc",onClick:(r=e.id,function(e){a(e,r)}),children:[Object(Fe.jsx)("b",{children:e.label}),n===e.id?Object(Fe.jsx)(h.a,{component:"span",sx:at.a,children:"desc"===t?"sorted descending":"sorted ascending"}):null]})},e.id);var r}))]})})}var Ut=function(e){var t=e.numSelected;return Object(Fe.jsxs)(f.a,{sx:Object(l.a)({pl:{sm:2},pr:{xs:1,sm:1}},t>0&&{bgcolor:function(e){return Object(Dt.a)(e.palette.primary.main,e.palette.action.activatedOpacity)}}),children:[t>0?Object(Fe.jsxs)(p.a,{sx:{flex:"1 1 100%"},color:"inherit",variant:"subtitle1",component:"div",children:[t," selected"]}):Object(Fe.jsx)(p.a,{sx:{flex:"1 1 100%"},variant:"h6",id:"tableTitle",component:"div",children:"Items in Order"}),t>0?Object(Fe.jsx)(Se.a,{title:"Delete",children:Object(Fe.jsx)(S.a,{onClick:e.onDelete,children:Object(Fe.jsx)(ke.a,{})})}):Object(Fe.jsx)(Se.a,{title:"Filter list",children:Object(Fe.jsx)(S.a,{children:Object(Fe.jsx)(kt.a,{})})})]})};function Lt(e){var t=a.useState("asc"),n=Object(o.a)(t,2),r=n[0],c=n[1],s=a.useState("calories"),i=Object(o.a)(s,2),l=i[0],u=i[1],d=a.useState([]),j=Object(o.a)(d,2),b=j[0],O=j[1],x=e.items;return Object(Fe.jsx)(h.a,{sx:{width:"100%"},children:Object(Fe.jsxs)(te.a,{sx:{width:"100%",mb:2},children:[Object(Fe.jsx)(Ut,{}),Object(Fe.jsx)(ce.a,{children:Object(Fe.jsxs)(ne.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(Fe.jsx)(Pt,{numSelected:b.length,order:r,orderBy:l,onSelectAllClick:function(e){if(e.target.checked){var t=x.map((function(e){return e.PARTNAME}));O(t)}else O([])},onRequestSort:function(e,t){c(l===t&&"asc"===r?"desc":"asc"),u(t)},rowCount:x.length}),Object(Fe.jsxs)(ae.a,{children:[Me(x,Le(r,l)).map((function(t,n){var a,r=(a=t.PARTNAME,-1!==b.indexOf(a)),c="enhanced-table-checkbox-".concat(n);return Object(Fe.jsxs)(oe.a,{hover:!0,role:"checkbox","aria-checked":r,tabIndex:-1,selected:r,children:[Object(Fe.jsx)(re.a,{padding:"checkbox"}),Object(Fe.jsx)(re.a,{component:"th",id:c,scope:"row",padding:"none",children:t.PARTDES}),Object(Fe.jsx)(re.a,{align:"right",children:t.PARTNAME}),Object(Fe.jsxs)(re.a,{align:"right",children:[t.BASEPLCODE," ",Nt(t.BASEPLPRICE)]}),Object(Fe.jsxs)(re.a,{align:"right",children:[t.BASEPLCODE," ",Nt(t.VATPRICE)]}),Object(Fe.jsxs)(re.a,{align:"right",children:[Object(Fe.jsx)(S.a,{onClick:function(n){return e.onDecrement(t,n)},children:Object(Fe.jsx)(yt.a,{})}),t.QUANTITY,Object(Fe.jsx)(S.a,{onClick:function(n){return e.onIncrement(t,n)},children:Object(Fe.jsx)(Ee.a,{})})]}),Object(Fe.jsxs)(re.a,{align:"right",children:[t.BASEPLCODE," ",Nt(t.VATPRICE*t.QUANTITY)]})]},n)})),Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{colSpan:6,align:"right",children:Object(Fe.jsx)("b",{children:"Total Price"})}),Object(Fe.jsx)(re.a,{align:"right",children:function(){for(var e=0,t=0;t0){var n=g.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(Qe.a)(e),[u])})))}else console.log("Quantity must be greater than 0.")},children:"Add"})}),Object(Fe.jsx)(E.a,{item:!0,md:12,children:Object(Fe.jsx)(Lt,{items:g,onDecrement:function(e){var t=Object(Qe.a)(g),n=g.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(Qe.a)(g),n=g.findIndex((function(t){return t.PARTNAME===e.PARTNAME}));t[n].QUANTITY=parseInt(t[n].QUANTITY)+1,S(t)}})}),Object(Fe.jsx)(E.a,{item:!0,md:12,children:Object(Fe.jsx)(ue.a,{disabled:0===g.length,onClick:function(){console.log(g);for(var e=Object(Qe.a)(g),t=[],n=0;n0?c.map((function(e,t){return Object(Fe.jsxs)(_t.a,{onClick:function(){return 0===e.READ?function(e,t){Pe.setNotificationRead({ID:e}).then((function(e){var n=Object(Qe.a)(c);n[t].READ=1,s(n),console.log(c)})).catch((function(e){console.log(e)}))}(e.ID,t):null},selected:0===e.READ,children:[Object(Fe.jsx)(k.a,{children:Object(Fe.jsx)($t.a,{fontSize:"small"})}),Object(Fe.jsxs)(R.a,{children:[e.ORDNAME," has been changed to ",e.ORDSTATUSDES," ",f.format(new Date(e.DATE))]})]},t)})):Object(Fe.jsx)(p.a,{children:"No notifications."})})]}):Object(Fe.jsx)(fe.a,{})}var an=n(32),rn=n.n(an),cn=n(49),sn=n(695),on=n(696),ln=n(102),un=n(83),dn=n.n(un),jn=n(215),bn=n.n(jn),On=n(26),hn=(n(199),n(329),n(113)),xn=n(548);function fn(){var e=r.a.useState(!0),t=Object(o.a)(e,2),n=t[0];t[1];return Object(Fe.jsx)("div",{children:Object(Fe.jsx)(xn.a,{sx:{color:"#fff",zIndex:function(e){return e.zIndex.drawer+1}},open:n,children:Object(Fe.jsx)(fe.a,{color:"inherit"})})})}var mn=function(e){return{sx:{bgcolor:gn(e),fontSize:16,width:30,height:30},children:pn(e)}},pn=function(e){var t=e.charAt(0),n=e.charAt(e.length-1);return t.toUpperCase()+n.toUpperCase()},gn=function(e){var t,n=0;for(t=0;t>8*t&255).toString(16)).slice(-2)}return a},Sn=function(e){return new Date(e).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}).toUpperCase()},vn=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}})}))}))},En=function(e,t,n){var a=document.createElement("a");a.href=e,a.download=t+"."+n,a.click()},Cn=n(347),Tn=n.n(Cn),An=(n(524),n(525),n(526),n(527),n(15)),Dn=n(361),In=n(84),kn=n(116),Rn=n(346),yn=(n(528),n(659)),Nn=Object(a.createContext)();function wn(){return Object(a.useContext)(Nn)}function Pn(e){var t=e.children,n=Object(a.useState)([]),r=Object(o.a)(n,2),c=r[0],s=r[1],i=Object(a.useState)([]),l=Object(o.a)(i,2),u=l[0],d=l[1],j=Object(a.useState)(!0),b=Object(o.a)(j,2),O=b[0],h=b[1],x=Object(a.useState)(!1),f=Object(o.a)(x,2),m=f[0],p=f[1],g=Object(a.useState)({}),S=Object(o.a)(g,2),v=S[0],E=S[1],C=Object(a.useState)(""),T=Object(o.a)(C,2),A=T[0],D=T[1],I=Object(a.useState)([]),k=Object(o.a)(I,2),R=k[0],y=k[1],N=Object(a.useState)([]),w=Object(o.a)(N,2),P=w[0],U=w[1],L=Object(a.useState)([]),M=Object(o.a)(L,2),F=M[0],_=M[1],W=Object(a.useState)([]),B=Object(o.a)(W,2),Y=B[0],G=B[1],z=Object(a.useState)([]),X=Object(o.a)(z,2),V=X[0],H=X[1],q=Object(a.useState)([]),K=Object(o.a)(q,2),J=K[0],Q=K[1],Z=Object(a.useState)([]),$=Object(o.a)(Z,2),ee=$[0],te=$[1];return Object(Fe.jsx)(Nn.Provider,{value:{serviceCallData:c,setServiceCallData:s,serviceCallStatus:u,setServiceCallStatus:d,hideAnsweredCalls:O,setHideAnsweredCalls:h,viewcallDataTable:m,setviewcallDataTable:p,filtersBlock:v,setFiltersBlock:E,globalFilterData:A,setGlobalFilterData:D,orders:R,setOrders:y,orderforStatus:P,setOrderForStatus:U,logincustData:F,setLogincustData:_,userBkup:Y,setUserBakup:G,filteredOrdersBkup:V,setFilteredOrdersBkup:H,taskTypesBkup:J,setTaskTypesBkup:Q,projectsBkup:ee,setProjectsBkup:te},children:t})}var Un=function(e){var t,n=e.selectedCustomer,r=Object(a.useState)(""),c=Object(o.a)(r,2),s=c[0],i=c[1],u=Object(a.useState)(null),d=Object(o.a)(u,2),j=d[0],b=d[1],O=Object(a.useState)(null),h=Object(o.a)(O,2),x=h[0],f=h[1],m=Object(a.useState)(!0),p=Object(o.a)(m,2),g=p[0],v=p[1],E=function(){return{global:{value:null,matchMode:An.a.CONTAINS},DOCNO:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.STARTS_WITH}]},ZEMG_SVC_DETAILS:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.STARTS_WITH}]},REFERENCE:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.STARTS_WITH}]},NAME:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.STARTS_WITH}]},STARTDATE:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.DATE_IS}]},CALLTYPECODE:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.EQUALS}]},CDES:{operator:An.b.OR,constraints:[{value:null,matchMode:An.a.EQUALS}]},CALLSTATUSCODE:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.EQUALS}]},STATUSDATE:{operator:An.b.AND,constraints:[{value:null,matchMode:An.a.DATE_IS}]}}},C=Object(a.useState)(E()),T=Object(o.a)(C,2),A=T[0],D=T[1],I=Object(a.useState)(!0),k=Object(o.a)(I,2),R=k[0],y=k[1],N=Object(Ne.b)(),w=N.enqueueSnackbar,P=(N.closeSnackbar,wn()),L=P.serviceCallData,M=P.serviceCallStatus,F=P.setServiceCallData,_=P.setServiceCallStatus,W=P.hideAnsweredCalls,B=P.setHideAnsweredCalls,Y=P.viewcallDataTable,G=P.setviewcallDataTable,z=P.filtersBlock,X=P.setFiltersBlock,V=P.globalFilterData,H=P.setGlobalFilterData,q=Object(a.useState)(!1),K=Object(o.a)(q,2),J=K[0],Q=K[1];Object(a.useEffect)((function(){f($(L)),b(M),y(!1),!0===Y?(D(z),i(V)):X(E())}),[]);var Z=function(){var e=Object(cn.a)(rn.a.mark((function e(){var t,a,r,c;return rn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(X(E()),D(E()),i(""),H(""),t="",n&&(t=n.CUSTNAME),!t&&(a=localStorage.getItem("selectedCUSTNAME")))try{t=JSON.parse(a)}catch(s){console.error("Error parsing stored customer:",s),t=null}return Q(!0),e.prev=8,e.next=11,Pe.getServiceCalls(t);case 11:return r=e.sent,f($(r.data.value)),F($(r.data.value)),e.next=16,Pe.getCallStatuses();case 16:c=e.sent,b(c.data.value),_(c.data.value),e.next=24;break;case 21:e.prev=21,e.t0=e.catch(8),console.error(e.t0);case 24:return e.prev=24,Q(!1),y(!1),e.finish(24);case 28:case"end":return e.stop()}}),e,null,[[8,21,24,28]])})));return function(){return e.apply(this,arguments)}}();var $=function(e){return Object(Qe.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"})},te=function(e){var t=e.target.value,n=Object(l.a)({},A);n.global.value=t,D(n),X(n),i(t),H(t)},ae=function(e){B(e.target.checked)},re=function(e){return Object(Fe.jsx)(Rn.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"})},ce=function(e){v(e.target.checked)},se=Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(ne.a,{children:Object(Fe.jsx)("tr",{children:Object(Fe.jsxs)("td",{children:[Object(Fe.jsx)("h5",{className:"m-0",children:"Service Calls \xa0\xa0\xa0"}),J?Object(Fe.jsxs)("p",{style:{fontSize:15,color:"red"},children:["Please wait. The Data is loading....",Object(Fe.jsxs)("box",{children:[Object(Fe.jsx)(fe.a,{style:{width:20,height:23,color:"red"}})," "]})," "]}):Object(Fe.jsx)(Fe.Fragment,{})]})})}),Object(Fe.jsx)(pe.a,{control:Object(Fe.jsx)(yn.a,{onChange:ce,checked:g,name:"gilad"}),label:"Show Only Active Tickets"})," ",Object(Fe.jsx)(pe.a,{control:Object(Fe.jsx)(yn.a,{onChange:ae,checked:W,name:"gilad"}),label:"Hide Answered Calls"})," ",Object(Fe.jsxs)("span",{className:"p-input-icon-left",children:[Object(Fe.jsx)("i",{className:"pi pi-search"}),Object(Fe.jsx)(kn.a,{value:s,onChange:te,placeholder:"Keyword Search"}),Object(Fe.jsx)(ue.a,{onClick:Z,sx:{m:1},size:"small",variant:"contained",children:"Refresh Data"})]})]});return R?Object(Fe.jsx)(et,{}):Object(Fe.jsx)("div",{className:"datatable-doc-demo",children:Object(Fe.jsx)("div",{className:"card",children:Object(Fe.jsxs)(Dn.a,{value:function(e,n){if(""!==(t=g&&W?e.filter((function(e){return"Y"===e.ACTIVEFLAG&&"Answered"!==e.CALLSTATUSCODE})):g?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}))}(x,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:R,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),X(e.filters)},children:[Object(Fe.jsx)(In.a,{field:"DOCNO",header:"Ticket ID",filterField:"DOCNO",sortable:!0,body:function(e){return Object(Fe.jsxs)(U.b,{style:{textDecoration:"none",color:"blue"},to:"/dashboard/servicecall/".concat(e.DOCNO),sx:{mt:3},onClick:function(){return e.DOCNO,void G(!1)},children:[" ",e.DOCNO]})},filter:!0,filterPlaceholder:"Search by Ticket ID"}),Object(Fe.jsx)(In.a,{field:"ZEMG_SVC_DETAILS",header:"Subject",sortable:!0,filter:!0,filterPlaceholder:"Search by Subject"}),Object(Fe.jsx)(In.a,{field:"REFERENCE",header:"Cust. Ref",sortable:!0,filter:!0,filterPlaceholder:"Search by Reference"}),Object(Fe.jsx)(In.a,{field:"NAME",header:"Contact",sortable:!0,filter:!0,filterPlaceholder:"Search by Contact"}),Object(Fe.jsx)(In.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(Fe.jsx)(In.a,{field:"CALLTYPECODE",header:"Classification",sortable:!0,filter:!0,filterPlaceholder:"Search by Classification"}),Object(Fe.jsx)(In.a,{field:"ZEMG_SEVDES",header:"Call Severity",sortable:!0,filter:!0,filterPlaceholder:"Search by Call Severity"}),Object(Fe.jsx)(In.a,{field:"CALLSTATUSCODE",header:"Status",sortable:!0,filter:!0,filterPlaceholder:"Search by Status"}),Object(Fe.jsx)(In.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(Fe.jsx)(In.a,{header:"Action",body:function(e){return Object(Fe.jsx)(S.a,{onClick:function(){return function(e){Pe.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){w("File not found. Please contact system manager.",{variant:"error"})}))}(e)},style:{fontSize:"24px"},children:Object(Fe.jsx)(nt.a,{style:{fontSize:"24px"}})})}})]})})})},Ln=function(e){return Object(Fe.jsx)(E.a,{item:!0,md:3,children:Object(Fe.jsx)(sn.a,{children:Object(Fe.jsx)(on.a,{children:Object(Fe.jsxs)(p.a,{sx:{fontSize:14},gutterBottom:!0,children:[Object(Fe.jsxs)("b",{children:[e.subject,":"]})," ",e.info]})})})})},Mn=function(){var e,t=Object(Ne.b)(),n=t.enqueueSnackbar,c=(t.closeSnackbar,Object(a.useState)(!1)),s=Object(o.a)(c,2),i=s[0],l=s[1],u=Object(Et.h)().docno,d=Object(a.useState)(null),j=Object(o.a)(d,2),b=j[0],O=j[1],h=Object(a.useState)(null),x=Object(o.a)(h,2),f=x[0],m=x[1],g=Object(a.useState)(!0),C=Object(o.a)(g,2),T=C[0],A=C[1],D=Object(a.useState)(0),I=Object(o.a)(D,2),k=(I[0],I[1],Object(a.useState)(B.getCurrentUser().name)),R=Object(o.a)(k,2),y=R[0],N=(R[1],Object(a.useState)([])),w=Object(o.a)(N,2),P=w[0],U=w[1],L=Object(hn.a)({accept:"*",readAs:"DataURL"}),M=Object(o.a)(L,2),F=M[0],_=M[1],W=(_.plainFiles,_.filesContent),Y=_.clear,G=Object(a.useState)([]),z=Object(o.a)(G,2),X=z[0],V=z[1],H=Object(a.useState)(!0),q=Object(o.a)(H,2),K=(q[0],q[1],Object(a.useState)(!1)),J=Object(o.a)(K,2),Q=J[0],Z=J[1],$=wn(),ee=$.viewcallDataTable,te=$.setviewcallDataTable,ne=function(e){console.info(W[0]),Y(),U([])},ae=(On.EditorState.createEmpty(),r.a.useState()),re=Object(o.a)(ae,2),ce=re[0],se=re[1],ie=JSON.parse(localStorage.getItem("selectedCUSTNAME")),oe=function(){var e=Object(cn.a)(rn.a.mark((function e(){var t,n,a,r;return rn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Pe.getServiceCall(ie,u);case 2:if(1!==(t=e.sent.data).value.length){e.next=21;break}return e.next=6,Pe.getStatusLang2(t.value[0].CALLSTATUSCODE);case 6:return n=e.sent.data,e.next=9,Pe.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,Pe.getServiceCallExternalRemarks(u);case 15:r=e.sent.data,m(r),V(a),A(!1),e.next=23;break;case 21:console.log("no matching"),Z(!0);case 23:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(a.useEffect)(Object(cn.a)(rn.a.mark((function e(){return rn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:!1===ee&&oe();case 1:case"end":return e.stop()}}),e)}))),[T,ee]),Object(a.useEffect)((function(){if(W){var e=W;U((function(t){return t.concat(e)}))}}),[W]);return Object(Fe.jsx)(Fe.Fragment,{children:ee?Object(Fe.jsx)(Un,{}):T&&!1===Q?Object(Fe.jsx)(fn,{}):Q?Object(Fe.jsx)("div",{children:Object(Fe.jsx)("p",{children:Object(Fe.jsx)(At.a,{severity:"error",children:Object(Fe.jsx)("b",{children:"Sorry!..Invalid Service Call Number"})})})}):Object(Fe.jsxs)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:[Object(Fe.jsx)(ue.a,{onClick:function(){te(!0),O(null),A(!0),Z(!1)},size:"small",variant:"contained",children:"Back to search results"}),Object(Fe.jsxs)(E.a,{container:!0,spacing:1,direction:"row",alignItems:"center",children:[Object(Fe.jsx)(Ln,{subject:"Ticket Number",info:b.value[0].DOCNO}),Object(Fe.jsx)(Ln,{subject:"Subject",info:b.value[0].ZEMG_SVC_DETAILS}),Object(Fe.jsx)(Ln,{subject:"Customer",info:b.value[0].CDES}),Object(Fe.jsx)(Ln,{subject:"Contact",info:b.value[0].NAME}),Object(Fe.jsx)(Ln,{subject:"Type of Call ",info:b.value[0].CALLTYPECODE}),Object(Fe.jsx)(Ln,{subject:"Cust. Reference",info:b.value[0].REFERENCE}),Object(Fe.jsx)(Ln,{subject:"Status",info:null!==(e=b.value[0].ESTATDES)&&void 0!==e?e:b.value[0].CALLSTATUSCODE})]}),"Y"===b.CHANGEFLAG?Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(sn.a,{sx:{mt:2,mb:2},children:Object(Fe.jsxs)(on.a,{children:[Object(Fe.jsxs)("div",{sx:{display:"flex",flexDirection:"row"},children:[Object(Fe.jsx)(p.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(Fe.jsx)("b",{children:"Add a Comment"})}),Object(Fe.jsx)(S.a,{children:Object(Fe.jsx)(Tn.a,{})})]}),Object(Fe.jsx)(ln.Editor,{wrapperClassName:"wrapperClassName",editorState:ce,editorStyle:{overflow:"hidden",minHeight:"20vh"},onEditorStateChange:function(e){se(e)},toolbar:{options:["inline","blockType","fontSize","list","textAlign","colorPicker","link","history"]}})]})}),Object(Fe.jsx)(ue.a,{onClick:function(){return F()},variant:"outlined",startIcon:Object(Fe.jsx)(bn.a,{}),children:"Add File"}),Object(Fe.jsx)(ue.a,{variant:"contained",sx:{marginLeft:"77.5%"},disabled:void 0===ce,onClick:function(){if(1===Object(On.convertToRaw)(ce.getCurrentContent()).blocks.length&""===Object(On.convertToRaw)(ce.getCurrentContent()).blocks[0].text)n("You can not submit an empty comment.",{variant:"error"});else{l(!0);var e=On.EditorState.createEmpty();se(e);var t,a=(new Date).toLocaleString("en-GB"),r=[];for(var c in W){var s={EXTFILEDES:W[c].name.split(".")[0],EXTFILENAME:W[c].content};"msg"===W[c].name.split(".")[1]&&(s.SUFFIX=".msg"),"lic"===W[c].name.split(".")[1]&&(s.SUFFIX=".lic"),r.push(s)}t=0!==r.length?a+dn()(Object(On.convertToRaw)(ce.getCurrentContent()))+"
"+r.length+" files attached.
"+"

".concat(y,"


"):a+dn()(Object(On.convertToRaw)(ce.getCurrentContent()))+"

".concat(y,"


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

".concat(Q,"


"):t+dn()(Object(On.convertToRaw)(H.getCurrentContent()))+"

".concat(Q,"


");var s={DETAILS:G,CALLTYPECODE:"From Portal",ZEMG_SEVNAME:null===U||void 0===U?void 0:U.SEVNAME,TEXT:e,APPEND:!0,SIGNATURE:!1,REFERENCE:j,NAME:null===y||void 0===y?void 0:y.NAME,EXTFILES:n},i=function(e,t){Pe.getServiceCall(t,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};fe([t].concat(Object(Qe.a)(xe)))}(e.data)})).catch((function(e){console.log(e)}))};Pe.CreateServiceCall(s,Se).then((function(e){void 0!=e.data.DOCNO?(F("Service Call ".concat(e.data.DOCNO," successfully created!"),{variant:"success"}),i(e.data.DOCNO,Se),re(),c(!0),be(e.data.DOCNO)):(F("Error creating service call.",{variant:"error"}),oe(!1))})).catch((function(e){e.response.data.message?F(e.response.data.message,{variant:"error"}):F("Error creating service call.",{variant:"error"}),oe(!1)}))}else F("Please select a customer first.",{variant:"error"});else F("Please select a Contact.",{variant:"error"});else F("Please select a Call Severity.",{variant:"error"})},children:"Submit"}),0!=ne.length?Object(Fe.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(Fe.jsx)(ke.a,{onClick:function(e){re()}})}):Object(Fe.jsx)(Fe.Fragment,{}),ne.map((function(e,t){return Object(Fe.jsx)(me.a,{label:e.name})}))]})]}):Object(Fe.jsx)(Wn.a,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60vh",children:Object(Fe.jsx)(p.a,{variant:"h6",color:"text.secondary",children:"Please select a customer to create a service call"})})]})},Gn=function(e){e.selectedCustomer;var t=r.a.useState(0),n=Object(o.a)(t,2),c=n[0],s=n[1],i=wn().setviewcallDataTable;return Object(a.useEffect)((function(){i(!1)}),[]),Object(Fe.jsxs)(v.a,{maxWidth:!1,sx:{mt:4,mb:4},children:[Object(Fe.jsxs)(Fn.a,{value:c,onChange:function(e,t){s(t)},"aria-label":"Service Call tabs",children:[Object(Fe.jsx)(_n.a,{label:"Service Call List"}),Object(Fe.jsx)(_n.a,{label:"Create Service Call"})]}),Object(Fe.jsxs)(h.a,{sx:{mt:2},children:[0===c&&Object(Fe.jsx)(E.a,{item:!0,xs:12,children:Object(Fe.jsx)(Un,{})}),1===c&&Object(Fe.jsx)(E.a,{item:!0,xs:12,children:Object(Fe.jsx)(Yn,{})})]})]})},zn=n(642),Xn=n(698),Vn=n(551),Hn=n(220),qn=n.n(Hn),Kn=n(354),Jn=n.n(Kn),Qn=n(225),Zn=n(639),$n=n(216),ea=n(641),ta=n(685),na=n(660),aa=n(654),ra=n(667),ca=n(649),sa=n(362),ia=n(147),oa=n(43),la=n.n(oa),ua=n(640),da=n(219),ja=n.n(da),ba=n(669),Oa=n(653),ha={display:"flex",flexDirection:"column",gap:"12px","& p:empty":{display:"none"},"& p:nth-of-type(odd)":{fontWeight:600,fontSize:"12px",color:"#000",backgroundColor:"#f2f2f2",padding:"10px 14px 4px",borderTopLeftRadius:"16px",borderTopRightRadius:"16px"},"& p:nth-of-type(even)":{fontSize:"14px",color:"#000",backgroundColor:"#f2f2f2",padding:"4px 14px 10px",borderBottomLeftRadius:"16px",borderBottomRightRadius:"16px",lineHeight:1.4}};function xa(e){var t=e.dlgOpen,n=e.handleUpdateClose,r=e.subjectInfo,c=e.WBSInfo,s=e.assignedToInfo,i=e.startDateInfo,u=e.endDateInfo,d=e.descriptionInfo,j=e.taskTypes,b=e.taskSizes,O=e.users,x=e.project,f=e.projectWBS,m=e.STATDES,g=e.CUSTNOTE,E=e.CUSTNOTETYPEDES,C=e.TaskSizeVal,T=(e.refreshTasks,e.selectedOrder),A=e.internalDialogResponse,D=e.handleClose,I=(e.handlegetFilterData,e.getInternalDialogue),k=Object(Ne.b)().enqueueSnackbar,R=Object(a.useState)(t),y=Object(o.a)(R,1)[0],N=Object(a.useState)(r),w=Object(o.a)(N,2),P=w[0],U=w[1],L=Object(a.useState)(s[0]),M=Object(o.a)(L,2),F=M[0],_=M[1],W=Object(a.useState)(c),B=Object(o.a)(W,2),Y=B[0],G=B[1],z=Object(a.useState)(E),X=Object(o.a)(z,2),V=X[0],H=X[1],q=Object(a.useState)(C),K=Object(o.a)(q,2),J=K[0],Q=K[1],Z=Object(a.useState)(la()(i)),$=Object(o.a)(Z,2),ee=$[0],ce=$[1],se=Object(a.useState)(la()(u)),ie=Object(o.a)(se,2),le=ie[0],xe=ie[1],ge=Object(a.useState)(),Se=Object(o.a)(ge,2),ve=Se[0],Ee=Se[1],Ce=Object(a.useState)("INTERNAL"),Te=Object(o.a)(Ce,2),Ae=Te[0],De=Te[1],Ie=Object(a.useState)(On.EditorState.createEmpty()),ke=Object(o.a)(Ie,2),Re=ke[0],ye=ke[1],we=Object(a.useState)(!1),Ue=Object(o.a)(we,2),Le=Ue[0],Me=Ue[1],_e=Object(hn.a)({readAs:"DataURL"}),We=Object(o.a)(_e,2),Be=We[0],Ye=We[1],Ge=Ye.plainFiles,ze=Ye.filesContent,Xe=Ye.clear;Object(a.useEffect)((function(){d&&Ee(function(e){var t=e.getCurrentContent(),n=Object(On.convertToRaw)(t),a=n.blocks.map((function(e){return Object(l.a)(Object(l.a)({},e),{},{text:e.text.replace(/\s+/g," ").trim()})})).filter((function(e){return e.text.length>0})),r=Object(l.a)(Object(l.a)({},n),{},{blocks:a});return On.EditorState.createWithContent(Object(On.convertFromRaw)(r))}(d))}),[]);var Ve=function(){n(!1),D()},He=function(){var e=Re.getCurrentContent(),t=Object(On.convertToRaw)(e).blocks;return 1===t.length&&""===t[0].text.trim()};return Object(Fe.jsxs)(de.a,{open:y,onClose:Ve,fullWidth:!0,maxWidth:"lg",children:[Object(Fe.jsx)(Oe.a,{children:"Update Task"}),Object(Fe.jsxs)(be.a,{children:[Object(Fe.jsx)(he.a,{fullWidth:!0,variant:"standard",label:"Subject",value:P,onChange:function(e){return U(e.target.value)},sx:{mb:2}}),Object(Fe.jsx)(sa.a,{dateAdapter:ia.a,children:Object(Fe.jsx)(ne.a,{size:"small",sx:{borderCollapse:"collapse"},children:Object(Fe.jsxs)(ae.a,{children:[Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{sx:{borderBottom:"none",p:0},children:Object(Fe.jsxs)(ta.a,{size:"small",fullWidth:!0,sx:{m:0},children:[Object(Fe.jsx)(na.a,{children:"Assigned To"}),Object(Fe.jsx)(aa.a,{value:F,onChange:function(e){return _(e.target.value)},input:Object(Fe.jsx)(ra.a,{label:"Assigned To",size:"small"}),children:O.map((function(e){return Object(Fe.jsx)(_t.a,{value:e.USERLOGIN,children:e.USERLOGIN},e.USERLOGIN)}))})]})}),Object(Fe.jsx)(re.a,{sx:{borderBottom:"none",p:1},children:Object(Fe.jsxs)(ta.a,{size:"small",fullWidth:!0,sx:{m:0},children:[Object(Fe.jsx)(na.a,{children:"WBS"}),Object(Fe.jsx)(aa.a,{value:Y||"",onChange:function(e){return G(e.target.value)},input:Object(Fe.jsx)(ra.a,{label:"WBS",size:"small"}),children:f.map((function(e){return Object(Fe.jsxs)(_t.a,{value:e.WBS,children:[e.WBS," : ",e.ACTDES]},e.WBS)}))})]})})]}),Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{sx:{borderBottom:"none",p:0},children:Object(Fe.jsxs)(ta.a,{size:"small",fullWidth:!0,sx:{m:0},children:[Object(Fe.jsx)(na.a,{children:"Task Type"}),Object(Fe.jsx)(aa.a,{value:V||"",onChange:function(e){return H(e.target.value)},input:Object(Fe.jsx)(ra.a,{label:"Task Type",size:"small"}),children:j.map((function(e){return Object(Fe.jsx)(_t.a,{value:e.CUSTNOTETYPEDES,children:e.CUSTNOTETYPEDES},e.CUSTNOTETYPEDES)}))})]})}),Object(Fe.jsx)(re.a,{sx:{borderBottom:"none",p:1},children:Object(Fe.jsxs)(ta.a,{size:"small",fullWidth:!0,sx:{m:0},children:[Object(Fe.jsx)(na.a,{children:"Task Size"}),Object(Fe.jsx)(aa.a,{value:J||"",onChange:function(e){return Q(e.target.value)},input:Object(Fe.jsx)(ra.a,{label:"Task Size",size:"small"}),children:b.map((function(e){return Object(Fe.jsxs)(_t.a,{value:e.SIZENAME,children:[e.SIZENAME," : ",e.SIZEDES]},e.SIZENAME)}))})]})})]}),Object(Fe.jsxs)(oe.a,{children:[Object(Fe.jsx)(re.a,{sx:{borderBottom:"none",p:0},children:Object(Fe.jsx)(ca.a,{label:"Start Date & Time",value:ee,onChange:ce,renderInput:function(e){return Object(Fe.jsx)(he.a,Object(l.a)(Object(l.a)({},e),{},{size:"small",fullWidth:!0,sx:{m:0}}))}})}),Object(Fe.jsx)(re.a,{sx:{borderBottom:"none",p:1},children:Object(Fe.jsx)(ca.a,{label:"End Date & Time",value:le,onChange:xe,renderInput:function(e){return Object(Fe.jsx)(he.a,Object(l.a)(Object(l.a)({},e),{},{size:"small",fullWidth:!0,sx:{m:0}}))}})})]})]})})}),Object(Fe.jsx)(ta.a,{component:"fieldset",sx:{mb:1},children:Object(Fe.jsxs)(ba.a,{row:!0,value:Ae,onChange:function(e){return De(e.target.value)},children:[Object(Fe.jsx)(pe.a,{value:"INTERNAL",control:Object(Fe.jsx)(Oa.a,{}),label:"Internal Dialog"}),Object(Fe.jsx)(pe.a,{value:"TASK",control:Object(Fe.jsx)(Oa.a,{}),label:"Explanation of Task"})]})}),"TASK"===Ae&&Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(p.a,{children:"Explanation of Task"}),Object(Fe.jsx)(te.a,{sx:{p:1},children:Object(Fe.jsx)(ln.Editor,{editorState:ve,onEditorStateChange:Ee,toolbar:{image:{uploadCallback:vn}},wrapperStyle:{width:"100%"},editorStyle:{minHeight:120,maxHeight:200}})})]}),"INTERNAL"===Ae&&Object(Fe.jsxs)(v.a,{sx:{display:"flex",gap:2},disableGutters:!0,children:[Object(Fe.jsxs)(v.a,{sx:{flex:1.2},disableGutters:!0,children:[Object(Fe.jsx)(p.a,{children:"Internal Dialog"}),Object(Fe.jsx)(te.a,{sx:{p:1,height:240,overflowY:"auto"},children:Object(Fe.jsx)(ln.Editor,{editorState:Re,onEditorStateChange:ye,wrapperStyle:{width:"100%"},editorStyle:{minHeight:180,maxHeight:180,overflowY:"auto"},toolbar:{options:["inline","blockType","list","link","emoji","history"]}})})]}),Object(Fe.jsxs)(v.a,{sx:{flex:1},disableGutters:!0,children:[Object(Fe.jsx)(p.a,{children:"Conversation History"}),Object(Fe.jsx)(te.a,{sx:{p:1,height:240,overflowY:"auto"},children:Object(Fe.jsxs)(h.a,{sx:{display:"flex",alignItems:"flex-start",gap:1},children:[Object(Fe.jsx)(Wt.a,{sx:{bgcolor:"#444",width:32,height:32},children:Object(Fe.jsx)(ja.a,{fontSize:"small"})}),Object(Fe.jsx)(h.a,{className:"conversation-history",sx:ha,dangerouslySetInnerHTML:{__html:A}})]})})]})]}),Object(Fe.jsxs)(v.a,{sx:{display:"flex",gap:1,mt:1},disableGutters:!0,children:[Ge.length>0&&Object(Fe.jsx)(S.a,{color:"error",onClick:Xe,children:Object(Fe.jsx)(Zn.a,{})}),Ge.map((function(e,t){return Object(Fe.jsx)(me.a,{label:e.name},t)}))]})]}),Object(Fe.jsx)(je.a,{children:Le?Object(Fe.jsxs)(h.a,{sx:{display:"flex",alignItems:"center",gap:1},children:[Object(Fe.jsx)(fe.a,{size:18,sx:{color:"#d21919"}}),Object(Fe.jsx)(p.a,{variant:"body2",children:"Task Updates is in progress. Please wait\u2026"})]}):Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(ue.a,{startIcon:Object(Fe.jsx)(ua.a,{}),onClick:Be,children:"Update File"}),Object(Fe.jsx)(ue.a,{onClick:Ve,children:"Cancel"}),Object(Fe.jsx)(ue.a,{disabled:!Re.getCurrentContent().hasText(),onClick:function(){if(1===Object(On.convertToRaw)(ve.getCurrentContent()).blocks.length&""===Object(On.convertToRaw)(ve.getCurrentContent()).blocks[0].text)k("The task must have an explanation.",{variant:"error"});else if(P)if(void 0!==F){var e;Me(!0);var t=(new Date).toLocaleString("en-GB"),n=Object(On.convertToRaw)(ve.getCurrentContent());if(He()||(e=Object(On.convertToRaw)(Re.getCurrentContent())),P&&F){var a=ze.map((function(e){return{EXTFILEDES:e.name.split(".")[0],EXTFILENAME:e.content}})),r={SUBJECT:P,USERLOGIN:F,CUSTNOTETYPEDES:V,ZMED_TASKSIZENAME:J,CURDATE:ee.format("YYYY-MM-DD"),TILLDATE:le.format("YYYY-MM-DD"),STIME:ee.format("HH:mm"),ETIME:le.format("HH:mm"),PROJDOCNO:Object.keys(x||{}).length>0?x.DOCNO:"",WBS:Y,STATDES:m,TEXT:dn()(n),INTERNALTEXT:He()?"":t+dn()(e),APPEND:!0,CUSTNOTEEXTFILES:a,TODOREFA:T||"",IVDES:T?"Sales Order":"",CUSTNOTE:g};Pe.updateTask(r).then((function(){k("Task Updated successfully.",{variant:"success"}),Me(!1),ye(On.EditorState.createEmpty()),I()})).catch((function(){k("Error updating task.",{variant:"error"}),Me(!1),ye(On.EditorState.createEmpty()),D()}))}else k("Subject and Assigned To are required.",{variant:"error"})}else k("Please select an Assigned To.",{variant:"error"});else k("Please fill out the Subject field.",{variant:"error"})},children:"Update"})," "]})})]})}var fa=n(353),ma=n.n(fa);function pa(e){var t,n=e.open,r=e.description,c=e.loading,s=e.attachments,i=e.handleClose,u=e.refreshTasks,d=e.handleTaskStatusChange,j=e.taskTypes,b=e.taskSizes,O=e.users,x=e.project,f=e.projectWBS,m=e.selectedOrder,g=e.internalDialogResponse,v=e.handlegetFilterData,E=e.getInternalDialogue,C=e.task,T=C.SUBJECT,A=C.STATDES,D=C.USERLOGIN,I=C.CUSTNOTETYPEDES,k=C.CUSTNOTE,R=(C.EXTFILEFLAG,C.CURDATE),y=C.TILLDATE,N=C.STIME,w=C.ETIME,P=C.WBS,U=C.ACTDES,L=C.USERLOGIN2,M=C.USERLOGIN3,F=C.USERLOGIN4,_=C.USERLOGIN5,W=C.USERLOGIN6,B=C.USERLOGIN7,Y=C.USERLOGIN8,G=C.ZMED_TASKSIZENAME,z=[D,L,M,F,_,W,B,Y],X=Object(Qn.a)("div")({marginBottom:16}),V=Object(a.useState)(!1),H=Object(o.a)(V,2),q=H[0],K=H[1],J=Object($n.b)(),Q=Object(a.useState)(!1),Z=Object(o.a)(Q,2),$=Z[0],ee=Z[1],te="",ne="",ae="";return Object(Fe.jsx)("div",{children:Object(Fe.jsxs)(de.a,{open:n,onClose:i,scroll:"paper","aria-labelledby":"scroll-dialog-title","aria-describedby":"scroll-dialog-description",children:[Object(Fe.jsx)("div",{children:Object(Fe.jsxs)(Oe.a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",fontWeight:"bold"},id:"scroll-dialog-title",children:[null!==T&&void 0!==T?T:"Task Subject",Object(Fe.jsxs)(h.a,{display:"flex",gap:1,children:[" ",Object(Fe.jsx)(Se.a,{title:"Edit task",children:Object(Fe.jsx)(S.a,{disabled:q||"On Hold"===A,onClick:function(){ee(!0)},color:"secondary","aria-label":"Edit-task",component:"label",children:Object(Fe.jsx)(ea.a,{})})}),Object(Fe.jsx)(Se.a,{placement:"right",title:"Cancel task.",children:Object(Fe.jsx)(S.a,{disabled:q,onClick:function(){J({description:"This will cancel the task."}).then((function(){K(!0),d(A,"Cancelled",k),i()})).catch((function(){console.log("Confirmation declined.")}))},color:"error","aria-label":"Cancel-task",component:"label",children:Object(Fe.jsx)(Zn.a,{})})})]})]})}),c?Object(Fe.jsx)(Ze.a,{}):null,Object(Fe.jsxs)(be.a,{dividers:!c,sx:{minHeight:"50vh",minWidth:"30vw"},children:[Object(Fe.jsxs)(X,{children:[Object(Fe.jsx)(p.a,{variant:"subtitle2",children:"Members"}),Object(Fe.jsx)("div",{style:{display:"flex",flexDirection:"row"},children:null===z||void 0===z?void 0:z.filter((function(e){return e})).map((function(e,t){return Object(Fe.jsx)(Se.a,{style:{marginRight:8},title:e,children:Object(Fe.jsx)(Wt.a,Object(l.a)({},mn(e)))},t)}))})]}),P?Object(Fe.jsxs)(X,{children:[Object(Fe.jsx)(p.a,{variant:"subtitle2",children:"WBS"}),Object(Fe.jsx)(p.a,{children:P+": "+U})]}):null,Object(Fe.jsxs)(X,{children:[Object(Fe.jsx)(p.a,{variant:"subtitle2",children:"Dates"}),Object(Fe.jsx)(Se.a,{placement:"left",title:"Start and end date.",children:Object(Fe.jsx)(me.a,{icon:Object(Fe.jsx)(Jn.a,{}),size:"small",label:Sn(R)+" - "+Sn(y)})}),Object(Fe.jsx)(Se.a,{sx:{ml:1},placement:"right",title:"Start and end time.",children:Object(Fe.jsx)(me.a,{icon:Object(Fe.jsx)(qn.a,{}),size:"small",label:N+" - "+w})})]}),Object(Fe.jsxs)(X,{children:[Object(Fe.jsx)(p.a,{variant:"subtitle2",children:"Description"}),Object(Fe.jsx)(Vn.a,{id:"scroll-dialog-description",tabIndex:-1,children:c?Object(Fe.jsx)($e.a,{}):Object(Fe.jsx)("div",{dangerouslySetInnerHTML:{__html:r}})})]})]}),s.length>0?Object(Fe.jsxs)(be.a,{dividers:!0,children:[Object(Fe.jsx)(p.a,{children:"Attachments"}),null===s||void 0===s?void 0:s.map((function(e,t){return Object(Fe.jsx)(me.a,{label:e.EXTFILEDES+"."+e.SUFFIX,color:"primary",size:"small",sx:{mr:1,mb:1},onClick:function(){return En(e.EXTFILENAME,e.EXTFILEDES,e.SUFFIX)}},t)}))]}):null,$?(function(){t=null===z||void 0===z?void 0:z.filter((function(e){return e})).map((function(e,t){return e})),b.find((function(e){return e.SIZENAME===G}));var e=R.split("T")[0],n=la()("".concat(e,"T").concat(N)),a=y.split("T")[0],c=la()("".concat(a,"T").concat(w));te=n.format("YYYY-MM-DDTHH:mm"),ne=c.format("YYYY-MM-DDTHH:mm"),ae=function(e){var t=e.replace(/\s+/g," ").replace(/\n\s*\n/g,"\n").trim(),n=ma()(t),a=n.contentBlocks,r=n.entityMap,c=On.ContentState.createFromBlockArray(a,r);return On.EditorState.createWithContent(c)}({__html:r}.__html)}(),Object(Fe.jsx)(xa,{dlgOpen:$,handleUpdateClose:function(){ee(!1)},subjectInfo:T,WBSInfo:P,assignedToInfo:t,startDateInfo:te,endDateInfo:ne,descriptionInfo:ae,taskTypes:j,taskSizes:b,users:O,project:x,projectWBS:f,STATDES:A,CUSTNOTE:k,CUSTNOTETYPEDES:I,TaskSizeVal:G,refreshTasks:u,selectedOrder:m,internalDialogResponse:g,handleClose:i,handlegetFilterData:v,getInternalDialogue:E})):Object(Fe.jsx)(Fe.Fragment,{})]})})}var ga=n(355),Sa=n.n(ga),va=function(e){var t,n=e.task,r=n.SUBJECT,c=n.USERLOGIN,s=n.CUSTNOTETYPEDES,i=n.CUSTNOTE,u=n.EXTFILEFLAG,d=n.CURDATE,j=n.TILLDATE,b=n.ACTDES,O=(n.STIME,n.ETIME,n.WBS),h=n.USERLOGIN2,x=n.USERLOGIN3,f=n.USERLOGIN4,m=n.USERLOGIN5,g=n.USERLOGIN6,S=n.USERLOGIN7,v=n.USERLOGIN8,E=n.ZMED_TASKSIZENAME,C=n.CUSTNAME,T=n.TODOREFA,A=e.refreshTasks,D=e.handleTaskStatusChange,I=e.taskTypes,k=e.taskSizes,R=e.users,y=e.project,N=e.projectWBS,w=e.STATDES,P=e.selectedOrder,U=e.handlegetFilterData,L=[c,h,x,f,m,g,S,v],M=Object(a.useState)(!1),F=Object(o.a)(M,2),_=F[0],W=F[1],B=Object(a.useState)("There is no description."),Y=Object(o.a)(B,2),G=Y[0],z=Y[1],X=Object(a.useState)([]),V=Object(o.a)(X,2),H=V[0],q=V[1],K=Object(a.useState)([]),J=Object(o.a)(K,2),Q=J[0],Z=J[1],$=Object(a.useState)(!1),ee=Object(o.a)($,2),te=ee[0],ne=ee[1],ae=function(){ne(!0),Pe.getTaskExplanation(i).then((function(e){e.data.hasOwnProperty("error")?z("There is no description."):z(e.data.TEXT)})).catch((function(e){console.log(e)})),Pe.getInternalDialog(i).then((function(e){e.data.hasOwnProperty("error")?q("There is no Internal Dialog."):q(e.data.TEXT)})).catch((function(e){console.log(e)})),ne(!1)},re=function(){Pe.getTaskAttachments(i).then((function(e){e.data.hasOwnProperty("error")||Z(e.data.value)})).catch((function(e){console.log(e)}))};return Object(Fe.jsxs)(sn.a,{onClick:function(){_||(ae(),"Y"===u&&re(),W(!0))},sx:{mb:2},children:[Object(Fe.jsx)(pa,{open:_,description:G,handleClose:function(){W(!1)},task:e.task,loading:te,attachments:Q,refreshTasks:A,handleTaskStatusChange:D,taskTypes:I,taskSizes:k,users:R,project:y,projectWBS:N,STATDES:w,selectedOrder:P,internalDialogResponse:H,handlegetFilterData:U,getInternalDialogue:ae}),Object(Fe.jsxs)(on.a,{sx:{display:"flex",flexDirection:"column"},children:[Object(Fe.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Object(Fe.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[s?Object(Fe.jsx)(Se.a,{enterDelay:500,placement:"top",title:"Task type.",children:Object(Fe.jsx)(me.a,{label:s,color:"primary",size:"small",sx:{bgcolor:gn(s),mr:1}})}):null,E?Object(Fe.jsx)(Se.a,{enterDelay:500,placement:"top",title:"Task size.",children:Object(Fe.jsx)(me.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(Fe.jsx)(Se.a,{enterDelay:500,placement:"top",title:"Includes attachments.",children:Object(Fe.jsx)(Sa.a,{color:"disabled"})}):null]}),Object(Fe.jsx)(p.a,{sx:{fontWeight:"bold",mt:1},component:"div",children:null!==r&&void 0!==r?r:"Task Subject"}),Object(Fe.jsx)(p.a,{sx:{mb:1},variant:"subtitle2",children:null!=O?O+": "+b:null}),Object(Fe.jsx)(p.a,{sx:{mb:1},variant:"subtitle2",children:C}),Object(Fe.jsx)(p.a,{sx:{mb:1},variant:"subtitle2",children:T}),Object(Fe.jsx)(Se.a,{enterDelay:500,title:"Start and end date.",children:Object(Fe.jsx)(me.a,{icon:Object(Fe.jsx)(qn.a,{}),size:"small",label:Sn(d)+" - "+Sn(j)})}),Object(Fe.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:Object(Fe.jsx)(Xn.a,{sx:{"& .MuiAvatar-root":{width:30,height:30,fontSize:16}},max:2,children:null===L||void 0===L?void 0:L.filter((function(e){return e})).map((function(e,t){return Object(Fe.jsx)(Se.a,{title:e,children:Object(Fe.jsx)(Wt.a,Object(l.a)({},mn(e)))},t)}))})})]})]})},Ea=n(144);function Ca(e){var t=e.disabled,n=e.taskTypes,r=e.taskSizes,c=e.users,s=e.projectWBS,i=e.project,u=e.handleUpdateTasks,d=e.STATDES,j=e.selectedOrder,b=(e.refreshTasks,e.selectedCustomer),O=e.handlegetFilterData,x=Object(a.useState)(!1),f=Object(o.a)(x,2),m=f[0],g=f[1],E=Object(a.useState)(!1),C=Object(o.a)(E,2),T=C[0],A=C[1],D=Object(a.useState)(),I=Object(o.a)(D,2),k=I[0],R=I[1],y=Object(a.useState)(),N=Object(o.a)(y,2),w=N[0],P=N[1],U=Object(a.useState)(),L=Object(o.a)(U,2),M=L[0],F=L[1],_=Object(a.useState)(),W=Object(o.a)(_,2),B=W[0],Y=W[1],G=Object(a.useState)(),z=Object(o.a)(G,2),X=z[0],V=z[1],H=Object(a.useState)(la()()),q=Object(o.a)(H,2),K=q[0],J=q[1],Q=Object(a.useState)(la()()),Z=Object(o.a)(Q,2),$=Z[0],ee=Z[1],ne=Object(Ne.b)(),ae=ne.enqueueSnackbar,re=(ne.closeSnackbar,On.EditorState.createEmpty()),ce=Object(a.useState)(re),se=Object(o.a)(ce,2),ie=se[0],oe=se[1],le=Object(hn.a)({accept:"*",readAs:"DataURL"}),xe=Object(o.a)(le,2),pe=xe[0],ge=xe[1],Se=ge.plainFiles,ve=ge.filesContent,Ce=ge.clear,Te=Object(a.useState)(!1),Ae=Object(o.a)(Te,2),De=Ae[0],Ie=Ae[1],ke=function(){g(!1)},Re=function(){Y(),R(),P(),F(),ke(),A(!1)};return Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(ue.a,{disabled:t,size:"small",variant:"contained",startIcon:Object(Fe.jsx)(Ee.a,{}),color:"inherit",onClick:function(){g(!0)},children:"Add a Task"}),Object(Fe.jsx)("div",{children:Object(Fe.jsxs)(de.a,{open:m,onClose:ke,children:[Object(Fe.jsx)(Oe.a,{children:"Add a Task"}),Object(Fe.jsxs)(be.a,{children:[Object(Fe.jsx)(he.a,{autoFocus:!0,margin:"dense",id:"subject",label:"Subject",type:"subject",fullWidth:!0,variant:"standard",autoComplete:"off",value:k,onChange:function(e){return R(e.target.value)},sx:{mb:2}}),Object(Fe.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(Fe.jsx)(Bn,{required:!0,title:"Assigned To",labelname:"USERLOGIN",items:c,onChange:function(e,t){return Y(t)}}),Object(Fe.jsx)(Bn,{title:"WBS",labelname:"WBS",items:s,onChange:function(e,t){return V(t)},description:"ACTDES"})]}),Object(Fe.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(Fe.jsx)(Bn,{title:"Task Type",labelname:"CUSTNOTETYPEDES",items:n,onChange:function(e,t){return P(t)}}),Object(Fe.jsx)(Bn,{title:"Task Size",labelname:"SIZENAME",items:r,onChange:function(e,t){return F(t)},description:"SIZEDES"})]}),Object(Fe.jsx)(sa.a,{dateAdapter:ia.a,children:Object(Fe.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(Fe.jsx)(ca.a,{disablePast:!0,ampm:!1,label:"Start Date & Time",value:K,onChange:function(e){return J(e)},renderInput:function(e){return Object(Fe.jsx)(he.a,Object(l.a)({fullWidth:!0,sx:{m:1}},e))}}),Object(Fe.jsx)(ca.a,{disablePast:!0,ampm:!1,label:"End Date & Time",value:$,onChange:function(e){return ee(e)},renderInput:function(e){return Object(Fe.jsx)(he.a,Object(l.a)({fullWidth:!0,sx:{m:1}},e))}})]})}),Object(Fe.jsxs)(v.a,{maxWidth:!1,sx:{mt:1},children:[Object(Fe.jsx)(p.a,{variant:"subtitle",children:"Explanation of Task"}),Object(Fe.jsx)(te.a,{children:Object(Fe.jsx)(ln.Editor,{editorStyle:{height:"150px"},editorState:ie,onEditorStateChange:function(e){oe(e)},toolbar:{image:{uploadCallback:vn,previewImage:!0}}})})]}),Object(Fe.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex",flexWrap:"wrap",gap:"3px",mt:1},children:[0!=Se.length?Object(Fe.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(Fe.jsx)(Zn.a,{onClick:function(e){Ce()}})}):Object(Fe.jsx)(Fe.Fragment,{}),Se.map((function(e,t){return Object(Fe.jsx)(me.a,{label:e.name})}))]})]}),Object(Fe.jsx)(je.a,{children:De?Object(Fe.jsxs)(h.a,{sx:{display:"flex",alignItems:"center",gap:1},children:[Object(Fe.jsx)(fe.a,{size:18,sx:{color:"#d21919"}}),Object(Fe.jsx)(p.a,{variant:"body2",children:"Task Creates is in progress. Please wait\u2026"})]}):Object(Fe.jsxs)(Fe.Fragment,{children:[Object(Fe.jsx)(ue.a,{onClick:function(){return pe()},variant:"outlined",startIcon:Object(Fe.jsx)(ua.a,{}),children:"Add File"}),Object(Fe.jsx)(ue.a,{onClick:ke,children:"Cancel"}),Object(Fe.jsx)(ue.a,{disabled:T,onClick:function(){var e,t,n;if(1===Object(On.convertToRaw)(ie.getCurrentContent()).blocks.length&""===Object(On.convertToRaw)(ie.getCurrentContent()).blocks[0].text)ae("The task must have an explanation.",{variant:"error"});else if(k)if(void 0!==B){Ie(!0),A(!0);var a=[];for(var r in ve){var c={EXTFILEDES:ve[r].name.split(".")[0],EXTFILENAME:ve[r].content};a.push(c)}var s={SUBJECT:k,CUSTNOTETYPEDES:null!==(e=null===w||void 0===w?void 0:w.CUSTNOTETYPEDES)&&void 0!==e?e:"",ZMED_TASKSIZENAME:null!==(t=null===M||void 0===M?void 0:M.SIZENAME)&&void 0!==t?t:"",USERLOGIN:null===B||void 0===B?void 0:B.USERLOGIN,CURDATE:K.format("YYYY-MM-DD"),TILLDATE:$.format("YYYY-MM-DD"),STIME:K.format("HH:mm"),ETIME:$.format("HH:mm"),PROJDOCNO:Object.keys(i||{}).length>0?i.DOCNO:"",WBS:null!==(n=null===X||void 0===X?void 0:X.WBS)&&void 0!==n?n:"",STATDES:d,TEXT:dn()(Object(On.convertToRaw)(null===ie||void 0===ie?void 0:ie.getCurrentContent())),CUSTNOTEEXTFILES:a,TODOREFA:j||"",IVDES:j?"Sales Order":"",CUSTNAME:b};Pe.createTask(s).then((function(e){ae("Task created succesfully.",{variant:"success"}),u(e.data),Re();try{O(),Ie(!1)}catch(t){console.error("Error in handlegetFilterData:",t)}})).catch((function(e){ae("Error creating task.",{variant:"error"}),Re(),console.log(e)}))}else ae("Please select an Assigned To.",{variant:"error"});else ae("Please fill out the Subject field.",{variant:"error"})},children:"Add"})]})})]})})]})}var Ta=Object(zn.a)(te.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"}),Aa=function(e){var t=e.title,n=e.tasks,a=e.project,r=e.taskTypes,c=e.taskSizes,s=e.users,i=e.projectWBS,o=e.handleUpdateTasks,u=e.refreshTasks,d=e.handleTaskStatusChange,j=e.selectedOrder,b=e.selectedUser,O=e.selectedType,h=e.selectedCustomer,x=e.handlegetFilterData;return Object(Fe.jsx)(Ea.c,{droppableId:t,type:"COLUMN",children:function(e,f){return Object(Fe.jsx)("div",Object(l.a)(Object(l.a)({},e.droppableProps),{},{ref:e.innerRef,children:Object(Fe.jsxs)(Ta,{children:[Object(Fe.jsx)(p.a,{component:"h2",variant:"h6",color:"inherit",gutterBottom:!0,children:t||"Title"}),Object(Fe.jsx)("div",{style:{overflowY:"auto"},children:null===n||void 0===n?void 0:n.map((function(e,n){return Object(Fe.jsx)(Ea.b,{draggableId:e.CUSTNOTE.toString(),index:n,type:"TASK",children:function(n,o){return Object(Fe.jsx)("div",Object(l.a)(Object(l.a)(Object(l.a)({ref:n.innerRef},n.draggableProps),n.dragHandleProps),{},{children:Object(Fe.jsx)(va,{task:e,refreshTasks:u,handleTaskStatusChange:d,taskTypes:r,taskSizes:c,users:s,project:a,projectWBS:i,STATDES:t,selectedOrder:j,handlegetFilterData:x},e.CUSTNOTE)}))}},e.CUSTNOTE.toString())}))}),e.placeholder,Object(Fe.jsx)(Ca,{disabled:""===a&&""===j&&""===b&&""===O,taskTypes:r,taskSizes:c,users:s,project:a,projectWBS:i,handleUpdateTasks:o,STATDES:t,selectedOrder:j,refreshTasks:u,selectedCustomer:h,handlegetFilterData:x})]})}))}})},Da=function(){return Object(Fe.jsx)(Fe.Fragment,{children:Object(Qe.a)(Array(6)).map((function(e,t){return Object(Fe.jsx)($e.a,{sx:{marginLeft:2,padding:8,display:"flex",flexDirection:"column"},variant:"rectangular",width:250,height:"75vh",style:{marginBottom:5}},t)}))})},Ia=n(662),ka=n(261),Ra=n.n(ka),ya=function(e){var t,n=e.selectedCustomer,r=Object(a.useState)([]),c=Object(o.a)(r,2),s=c[0],i=c[1],u=Object(a.useState)(""),d=Object(o.a)(u,2),j=d[0],b=d[1],O=Object(a.useState)([]),x=Object(o.a)(O,2),f=x[0],m=x[1],g=Object(a.useState)(!1),E=Object(o.a)(g,2),C=E[0],T=E[1],A=Object(Ne.b)(),D=A.enqueueSnackbar,I=(A.closeSnackbar,Object(a.useState)()),k=Object(o.a)(I,2),R=k[0],y=k[1],N=Object(a.useState)([]),w=Object(o.a)(N,2),P=w[0],U=w[1],L=Object(a.useState)([]),M=Object(o.a)(L,2),F=M[0],_=M[1],W=Object(a.useState)([]),B=Object(o.a)(W,2),Y=B[0],G=B[1],z=Object(a.useState)([]),X=Object(o.a)(z,2),V=X[0],H=X[1],q=Object(a.useState)([]),K=Object(o.a)(q,2),J=K[0],Q=K[1],Z=Object(a.useState)(""),$=Object(o.a)(Z,2),ee=$[0],te=$[1],ne=Object(a.useState)(""),ae=Object(o.a)(ne,2),re=ae[0],ce=ae[1],se=Object(a.useState)(""),ie=Object(o.a)(se,2),oe=ie[0],le=ie[1],ue=Object(a.useState)(""),de=Object(o.a)(ue,2),je=de[0],be=de[1],Oe=Object(a.useState)(""),xe=Object(o.a)(Oe,2),me=xe[0],pe=xe[1],ge=Object(a.useState)("ORDNAME"),ve=Object(o.a)(ge,2),Ee=ve[0],Ce=ve[1],Te=Object(a.useState)("DOCNO"),Ae=Object(o.a)(Te,2),De=Ae[0],Ie=Ae[1],ke=Object(a.useState)([]),Re=Object(o.a)(ke,2),we=Re[0],Ue=Re[1],Le=Object(a.useState)(la()()),Me=Object(o.a)(Le,2),_e=Me[0],We=Me[1],Be=Object(a.useState)(la()()),Ye=Object(o.a)(Be,2),Ge=Ye[0],ze=Ye[1],Xe=wn(),Ve=Xe.logincustData,He=(Xe.orders,Xe.orderforStatus),qe=Xe.userBkup,Ke=Xe.setUserBakup,Je=Xe.filteredOrdersBkup,Ze=Xe.setFilteredOrdersBkup,$e=Xe.taskTypesBkup,et=Xe.setTaskTypesBkup,tt=Xe.projectsBkup,nt=Xe.setProjectsBkup;Object(a.useEffect)((function(){var e=function(){var e=Object(cn.a)(rn.a.mark((function e(){var t,n,a,r,c;return rn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,T(!0),e.next=4,Promise.all([Pe.getTaskTypes(),Pe.getTaskSizes(),Pe.getUsers()]);case 4:t=e.sent,n=Object(o.a)(t,3),a=n[0],r=n[1],c=n[2],U(a.data.value),_(r.data.value),G(c.data.value),et(a.data.value),Ke(c.data.value),Q(He),Ze(He),e.next=21;break;case 18:e.prev=18,e.t0=e.catch(0),console.error(e.t0);case 21:return e.prev=21,T(!1),e.finish(21);case 24:case"end":return e.stop()}}),e,null,[[0,18,21,24]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),Object(a.useEffect)((function(){var e=!0,t=function(){var t=Object(cn.a)(rn.a.mark((function t(){var a,r,c,s,l,u,d,j;return rn.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,r="",null===n||void 0===n?void 0:n.CUSTNAME)r=n.CUSTNAME;else if(c=localStorage.getItem("selectedCUSTNAME"))try{r=JSON.parse(c)}catch(b){console.error("Error parsing stored customer:",b),r=null}return t.next=5,Promise.all([Pe.getTaskStatuses(),"Y"!==(null===(a=Ve[0])||void 0===a?void 0:a.MEDATECHCUSTOMER)?Pe.getUserProjects(r):Pe.getProjectList()]);case 5:if(s=t.sent,l=Object(o.a)(s,2),u=l[0],d=l[1],e){t.next=11;break}return t.abrupt("return");case 11:j=[].concat(Object(Qe.a)(u.data.value),[{STATDES:"Cancelled"}]),m(j),i(d.data.value),nt(d.data.value),T(!1),t.next=21;break;case 18:t.prev=18,t.t0=t.catch(0),e&&console.error(t.t0);case 21:case"end":return t.stop()}}),t,null,[[0,18]])})));return function(){return t.apply(this,arguments)}}();return t(),function(){e=!1}}),[n]),Object(a.useEffect)((function(){var e=function(){var e=Object(cn.a)(rn.a.mark((function e(){return rn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,me||re||oe||ee||je){e.next=13;break}return i(tt),G(qe),U($e),Q(Je),Ue([]),We(la()()),ze(la()()),Ce("ORDNAME"),Ie("DOCNO"),T(!1),e.abrupt("return");case 13:return e.next=15,at();case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(0),console.error("Error fetching tasks in useEffect:",e.t0);case 20:case"end":return e.stop()}}),e,null,[[0,17]])})));return function(){return e.apply(this,arguments)}}();e()}),[me,re,oe,ee,je]);var at=function(){var e=Object(cn.a)(rn.a.mark((function e(){var t,n,a,r,c,s,o,u,d,j,b;return rn.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=[],n=0;n=a&&n<=r:a?t>=a:!r||n<=r}));rt(e)}},sx:{border:"1px solid #515558",borderRadius:1,height:55,width:45},children:Object(Fe.jsx)(Ra.a,{})})}),Object(Fe.jsx)(Se.a,{title:"Clear filter",children:Object(Fe.jsxs)(S.a,{color:"primary",onClick:function(){rt(we)},sx:{border:"1px solid #515558",borderRadius:1,height:55,width:45,position:"relative"},children:[Object(Fe.jsx)(Ra.a,{}),Object(Fe.jsx)(h.a,{sx:{position:"absolute",top:6,right:6,background:"#fff",borderRadius:"50%",width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center"},children:Object(Fe.jsx)(ye.a,{sx:{fontSize:12}})})]})})]})]}),Object(Fe.jsx)(Ea.a,{onDragEnd:jt,children:Object(Fe.jsx)(v.a,{maxWidth:!1,sx:{display:"flex",mt:2,mb:4},children:C?Object(Fe.jsx)(Da,{}):null===ct||void 0===ct?void 0:ct.filter((function(e){return"Cancelled"!==e.STATDES})).map((function(e){return Object(Fe.jsx)(Aa,{title:e.STATDES,tasks:e.TASKS,project:j,taskTypes:$e,taskSizes:F,users:qe,projectWBS:V,handleUpdateTasks:bt,refreshTasks:ot,handleTaskStatusChange:dt,selectedOrder:re,selectedUser:ee,selectedType:oe,selectedCustomer:n.CUSTNAME,handlegetFilterData:at},e.DOCSTATUSSORT)}))})})]})},Na=n(119);var wa=function(e){return Object(Fe.jsx)(p.a,{component:"h2",variant:"h6",color:"primary",gutterBottom:!0,children:e.children})},Pa=n(670),Ua=n(699),La=n(700),Ma=n(643);function Fa(e){var t=e.title,n=e.data,c=e.statusLabel,s=n.hasOwnProperty("value"),i=Object(a.useState)([]),l=Object(o.a)(i,2),u=l[0],d=l[1];return Object(a.useEffect)((function(){s&&c&&d(function(){var e,t={},a=Object(Na.a)(n.value);try{for(a.s();!(e=a.n()).done;){var r=e.value[c];t[r]?t[r]+=1:t[r]=1}}catch(s){a.e(s)}finally{a.f()}return t}())}),[n]),Object(Fe.jsxs)(r.a.Fragment,{children:[Object(Fe.jsxs)(te.a,{sx:{p:2,display:"flex",flexDirection:"column",minHeight:120},children:[Object(Fe.jsx)(wa,{children:t}),s?Object(Fe.jsxs)(p.a,{component:"p",variant:"h4",children:[n.value.length," ",t]}):Object(Fe.jsx)(Ze.a,{})]}),Object(Fe.jsxs)(Pa.a,{disabled:0===u.length,children:[Object(Fe.jsx)(Ua.a,{expandIcon:Object(Fe.jsx)(Ma.a,{}),"aria-controls":"panel1a-content",id:"panel1a-header",children:Object(Fe.jsx)(p.a,{children:"Status Breakdown"})}),Object(Fe.jsx)(La.a,{children:Object(Fe.jsx)("div",{children:Object.entries(u).map((function(e){var t=Object(o.a)(e,2),n=t[0],a=t[1];return Object(Fe.jsxs)(p.a,{color:"text.secondary",sx:{flex:1},children:[n,": ",a]},n)}))})})]})]})}var _a=function(e){var t=e.selectedCustomer,n=Object(a.useRef)(null),r=Object(a.useState)([]),c=Object(o.a)(r,2),s=c[0],i=c[1],l=Object(a.useState)(""),u=Object(o.a)(l,2),d=u[0],j=u[1],b=Object(a.useState)([]),O=Object(o.a)(b,2),x=O[0],f=O[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(Qe.a)(e).sort((function(e,n){for(var a=t(e.WBS),r=t(n.WBS),c=0;c0;a--){var r=t.slice(0,a).join(".");if(n[r])return n[r]}return 0},r=t.map((function(e,t){var n=new Date(e.STARTDATE),r=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(r.getTime())||r.getFullYear()<2e3)&&(console.warn("Invalid end date for ".concat(e.WBS,": ").concat(e.ENDDATE)),r=new Date),r=5&&(s="gtaskpink"),{pID:t+1,pName:"".concat(e.WBS,": ").concat(e.ACTDES),pStart:n,pEnd:r,pClass:s,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 r.forEach((function(e){r.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&&(r[t].pDepend=a)}})),r};return Object(a.useEffect)((function(){var e=t.CUSTNAME;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}}Pe.getUserProjects(e).then((function(e){i(e.data.value)})).catch((function(e){console.log(e)}))}),[]),Object(a.useEffect)((function(){if(x.length>0&&n.current){var e=function(e){return'\n\n\n\n \n jsGantt Chart\n \n