(this["webpackJsonpcustomer-portal"]=this["webpackJsonpcustomer-portal"]||[]).push([[0],{348:function(e,t,a){},349:function(e,t,a){},469:function(e,t,a){},474:function(e,t,a){},476:function(e,t,a){"use strict";a.r(t),t.default=a.p+"static/media/medatech-logo.d9b936ff.png"},477:function(e,t,a){"use strict";a.r(t);var n=a(0),c=a.n(n),r=a(32),s=a.n(r),i=(a(348),a(349),a(5)),o=a(4),l=a(18),u=a(6),j=a(309),d=a(606),b=a(585),O=a(600),h=a(607),x=a(612),m=a(608),f=a(610),g=a(185),p=a(572),S=a(609),v=a(611),E=a(598),T=a(307),C=a.n(T),A=a(308),y=a.n(A),k=a(592),D=a(569),P=a(571),I=a(289),w=a.n(I),N=a(294),R=a.n(N),U=a(51),L=a(60),F=a(69),M=a(21),W=a.n(M),B=a(285),_=new(function(){function e(){Object(L.a)(this,e)}return Object(F.a)(e,[{key:"login",value:function(e){return W.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(B.a)(e);return t}},{key:"changePassword",value:function(e){return W.a.post("/customer_portal/changePassword",e)}},{key:"forgotPassword",value:function(e){return W.a.post("/customer_portal/forgotPassword",e)}}]),e}());a.p;var G=a(292),z=a.n(G),Y=a(293),V=a.n(Y),q=a(290),Q=a.n(q),X=a(1),K=Object(X.jsx)("div",{children:_.getCurrentUser()?Object(X.jsxs)(X.Fragment,{children:[Object(X.jsxs)(k.a,{button:!0,component:U.b,to:"/dashboard",children:[Object(X.jsx)(D.a,{children:Object(X.jsx)(w.a,{})}),Object(X.jsx)(P.a,{primary:"Dashboard"})]}),Object(X.jsxs)(k.a,{button:!0,component:U.b,to:"/dashboard/kanban",children:[Object(X.jsx)(D.a,{children:Object(X.jsx)(Q.a,{})}),Object(X.jsx)(P.a,{primary:"Kanban Board"})]}),Object(X.jsx)(p.a,{}),Object(X.jsxs)(k.a,{button:!0,component:U.b,to:"/dashboard/servicecalls",children:[Object(X.jsx)(D.a,{children:Object(X.jsx)(z.a,{})}),Object(X.jsx)(P.a,{primary:"Service Calls"})]}),Object(X.jsxs)(k.a,{button:!0,component:U.b,to:"/dashboard/createservicecall",children:[Object(X.jsx)(D.a,{children:Object(X.jsx)(V.a,{})}),Object(X.jsx)(P.a,{primary:"Create Service Call"})]})]}):Object(X.jsx)(X.Fragment,{children:Object(X.jsxs)(k.a,{button:!0,component:U.b,to:"/login",children:[Object(X.jsx)(D.a,{children:Object(X.jsx)(R.a,{})}),Object(X.jsx)(P.a,{primary:"Login"})]})})}),H=a(622),Z=a(623),J=a(619),$=a(624),ee=a(617),te=a(593),ae=a(618),ne=a(315);function ce(){var e=localStorage.getItem("token");return e?{"x-access-token":e}:{}}var re=new(function(){function e(){Object(L.a)(this,e)}return Object(F.a)(e,[{key:"getItemsForSale",value:function(){return W.a.get("/customer_portal/itemsForSale",{headers:ce()})}},{key:"getOrders",value:function(){return W.a.get("/customer_portal/orders",{headers:ce()})}},{key:"getCustomerOrders",value:function(){return W.a.get("/customer_portal/customerOrders",{headers:ce()})}},{key:"getOrderItems",value:function(e){return W.a.get("/customer_portal/orderItems/".concat(e),{headers:ce()})}},{key:"getShipments",value:function(){return W.a.get("/customer_portal/shipments",{headers:ce()})}},{key:"getCustomerShipments",value:function(){return W.a.get("/customer_portal/customerShipments",{headers:ce()})}},{key:"getShipmentItems",value:function(e,t){return W.a.get("/customer_portal/shipmentItems/".concat(e,"/").concat(t),{headers:ce()})}},{key:"getInvoices",value:function(){return W.a.get("/customer_portal/invoices",{headers:ce()})}},{key:"getCustomerInfo",value:function(e){return W.a.get("/customer_portal/getCustomerInfo",{headers:ce()})}},{key:"getCustomerInvoices",value:function(){return W.a.get("/customer_portal/customerInvoices",{headers:ce()})}},{key:"getInvoiceItems",value:function(e,t,a){return W.a.get("/customer_portal/invoiceItems/".concat(e,"/").concat(t,"/").concat(a),{headers:ce()})}},{key:"getCustomerParts",value:function(){return W.a.get("/customer_portal/customerParts",{headers:ce()})}},{key:"createOrder",value:function(e){return W.a.post("/customer_portal/createOrder",e,{headers:ce()})}},{key:"getUserNotifications",value:function(){return W.a.get("/customer_portal/userNotifications",{headers:ce()})}},{key:"setNotificationRead",value:function(e){return W.a.post("/customer_portal/userNotifications",e,{headers:ce()})}},{key:"createTask",value:function(e){return W.a.post("/customer_portal/createTask",e,{headers:ce()})}},{key:"updateTask",value:function(e){return W.a.patch("/customer_portal/updateTask",e,{headers:ce()})}},{key:"getServiceCalls",value:function(){return W.a.get("/customer_portal/servicecalls",{headers:ce()})}},{key:"getServiceCall",value:function(e){return W.a.get("/customer_portal/servicecall/".concat(e),{headers:ce()})}},{key:"getServiceCallExternalRemarks",value:function(e){return W.a.get("/customer_portal/servicecall/remarks/".concat(e),{headers:ce()})}},{key:"getTaskExplanation",value:function(e){return W.a.get("/customer_portal/taskExplanation/".concat(e),{headers:ce()})}},{key:"getTaskAttachments",value:function(e){return W.a.get("/customer_portal/taskAttachments/".concat(e),{headers:ce()})}},{key:"getCallStatuses",value:function(){return W.a.get("/customer_portal/callStatuses",{headers:ce()})}},{key:"getStatusLang2",value:function(e){return W.a.get("/customer_portal/statusLang2/".concat(e),{headers:ce()})}},{key:"getCallTypes",value:function(){return W.a.get("/customer_portal/callTypes",{headers:ce()})}},{key:"getCallSeverities",value:function(){return W.a.get("/customer_portal/callSeverities",{headers:ce()})}},{key:"getCustomerContacts",value:function(){return W.a.get("/customer_portal/customerContacts",{headers:ce()})}},{key:"getUserProjects",value:function(){return W.a.get("/customer_portal/userProjects",{headers:ce()})}},{key:"getProjectTasks",value:function(e){return W.a.get("/customer_portal/projectTasks/".concat(e),{headers:ce()})}},{key:"getProjectWBS",value:function(e){return W.a.get("/customer_portal/projectWBS/".concat(e),{headers:ce()})}},{key:"getGanttWBS",value:function(e){return W.a.get("/customer_portal/ganttWBS/".concat(e),{headers:ce()})}},{key:"getSCAttachments",value:function(e){return W.a.get("/customer_portal/scAttachments/".concat(e),{headers:ce()})}},{key:"getTaskStatuses",value:function(){return W.a.get("/customer_portal/taskStatuses",{headers:ce()})}},{key:"getTaskTypes",value:function(){return W.a.get("/customer_portal/taskTypes",{headers:ce()})}},{key:"getTaskSizes",value:function(){return W.a.get("/customer_portal/taskSizes",{headers:ce()})}},{key:"getUsers",value:function(){return W.a.get("/customer_portal/users",{headers:ce()})}},{key:"addServiceCallComment",value:function(e){return W.a.post("/customer_portal/addServiceCallComment",e,{headers:ce()})}},{key:"updateServiceCall",value:function(e){return W.a.patch("/customer_portal/updateServiceCall",e,{headers:ce()})}},{key:"updateCallStatus",value:function(e){return W.a.post("/customer_portal/updateCallStatus",e,{headers:ce()})}},{key:"changeTaskStatus",value:function(e){return W.a.patch("/customer_portal/changeTaskStatus",e,{headers:ce()})}},{key:"CreateServiceCall",value:function(e){return W.a.post("/customer_portal/createServiceCall",e,{headers:ce()})}},{key:"addServiceCallAttachment",value:function(e){return W.a.post("/customer_portal/addServiceCallAttachment",e,{headers:ce()})}},{key:"getCustomerSignup",value:function(e){return W.a.get("/customer_portal/CustomerSignup/".concat(e))}},{key:"checkContact",value:function(e){return W.a.get("/customer_portal/check_contact/".concat(e))}},{key:"checkUser",value:function(e){return W.a.get("/customer_portal/check_user/".concat(e))}},{key:"createContact",value:function(e){return W.a.post("/customer_portal/CreateContact/",e)}},{key:"createUser",value:function(e){return W.a.post("/customer_portal/CreateUser/",e)}},{key:"downloadOrderPdf",value:function(e){return W()({url:"/customer_portal/downloadOrderPdf",method:"POST",responseType:"blob",headers:ce(),data:{ORDNAME:e}})}},{key:"downloadInvoicePdf",value:function(e){return W()({url:"/customer_portal/downloadInvoicePdf",method:"POST",responseType:"blob",headers:ce(),data:{IVNUM:e}})}},{key:"downloadShipmentPdf",value:function(e){return W()({url:"/customer_portal/downloadShipmentPdf",method:"POST",responseType:"blob",headers:ce(),data:{DOCNO:e}})}}]),e}()),se=a(115),ie=a.n(se),oe=a(114),le=a.n(oe),ue=a(620),je=a(621),de=a(20),be=a(616),Oe=a(601),he=function(){return Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)(be.a,{}),Object(X.jsx)(Oe.a,{variant:"rectangular",height:50,style:{marginBottom:10}}),Object(de.a)(Array(25)).map((function(e,t){return Object(X.jsx)(Oe.a,{variant:"rectangular",height:25,style:{marginBottom:5}},t)}))]})},xe=a(116),me=a.n(xe),fe=a(34),ge=a(603);function pe(e,t,a){return t[a]e[a]?1:0}function Se(e,t){return"desc"===e?function(e,a){return pe(e,a,t)}:function(e,a){return-pe(e,a,t)}}function ve(e,t){var a=e.map((function(e,t){return[e,t]}));return a.sort((function(e,a){var n=t(e[0],a[0]);return 0!==n?n:e[1]-a[1]})),a.map((function(e){return e[0]}))}var Ee=a(602),Te=a(573);function Ce(e){var t=e.order,a=e.orderBy,n=e.onRequestSort;return Object(X.jsx)(ee.a,{children:Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{}),e.headCells.map((function(e){return Object(X.jsx)(J.a,{align:"center",padding:e.disablePadding?"none":"normal",sortDirection:a===e.id&&t,children:Object(X.jsxs)(Ee.a,{active:a===e.id,direction:a===e.id?t:"asc",onClick:(c=e.id,function(e){return n(e,c)}),children:[Object(X.jsx)("b",{children:e.label}),a===e.id?Object(X.jsx)(h.a,{component:"span",sx:Te.a,children:"desc"===t?"sorted descending":"sorted ascending"}):null]})},e.id);var c}))]})})}var Ae=function(e){var t=e.title;return Object(X.jsxs)(m.a,{sx:{pl:{sm:2},pr:{xs:1,sm:1}},children:[Object(X.jsx)(g.a,{sx:{flex:"1 1 100%"},variant:"h6",id:"tableTitle",component:"div",children:t}),")"]})},ye=[{id:"IVDATE",numeric:!1,disablePadding:!0,label:"Date"},{id:"IVNUM",numeric:!0,disablePadding:!1,label:"Invoice 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:"Invoice Status"},{id:"ACTION",numeric:!0,disablePadding:!1,label:"Action"}];function ke(e){var t=e.row,a=Object(n.useState)(!1),r=Object(i.a)(a,2),s=r[0],o=r[1],l=Object(n.useState)([]),u=Object(i.a)(l,2),j=u[0],d=u[1],b=Object(n.useState)(!0),O=Object(i.a)(b,2),x=O[0],m=O[1],f=Object(fe.b)(),p=f.enqueueSnackbar,v=(f.closeSnackbar,function(){s?o(!s):(m(!1),re.getInvoiceItems(t.IVNUM,t.DEBIT,t.IVTYPE).then((function(e){d(e.data.value),m(!0),o(!s)})).catch((function(e){console.log(e)})))});return Object(X.jsxs)(c.a.Fragment,{children:[Object(X.jsxs)(ae.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(X.jsx)(J.a,{children:x?Object(X.jsx)(S.a,{"aria-label":"expand row",size:"small",onClick:v,children:s?Object(X.jsx)(le.a,{}):Object(X.jsx)(ie.a,{})}):Object(X.jsx)(ue.a,{size:28})}),Object(X.jsx)(J.a,{component:"th",scope:"row",children:new Date(t.IVDATE).toLocaleDateString("en-GB")}),Object(X.jsx)(J.a,{align:"center",children:t.IVNUM}),Object(X.jsx)(J.a,{align:"center",children:t.REFERENCE}),Object(X.jsxs)(J.a,{align:"center",children:[t.CODE," ",t.QPRICE.toLocaleString()]}),Object(X.jsxs)(J.a,{align:"center",children:[t.CODE," ",t.TOTPRICE.toLocaleString()]}),Object(X.jsx)(J.a,{align:"center",children:Object(X.jsx)(ge.a,{style:{color:function(e){switch(e){case"Draft":return"#00ff00";case"Checking":return"#2cc3f8";case"Approved":return"#beeeb0";case"Final":return"#ffd233";case"Canceled":return"#f56b62";default:return"black"}}(t.STATDES)},label:t.STATDES})}),Object(X.jsx)(J.a,{align:"center",children:Object(X.jsx)(S.a,{onClick:function(){return e=t.IVNUM,void re.downloadInvoicePdf(e).then((function(t){var a=window.URL.createObjectURL(new Blob([t.data])),n=document.createElement("a");n.href=a,n.setAttribute("download","".concat(e,".pdf")),document.body.appendChild(n),n.click()})).catch((function(e){console.log(e.response),p("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(X.jsx)(me.a,{})})})]}),Object(X.jsx)(ae.a,{children:Object(X.jsx)(J.a,{style:{paddingBottom:0,paddingTop:0,paddingLeft:100,backgroundColor:"#F8F8F8"},colSpan:8,children:Object(X.jsx)(je.a,{in:s,timeout:"auto",unmountOnExit:!0,onClick:v,children:Object(X.jsxs)(h.a,{sx:{margin:1},children:[Object(X.jsx)(g.a,{variant:"h6",gutterBottom:!0,component:"div",children:"Invoice Items"}),x?Object(X.jsxs)(H.a,{size:"small","aria-label":"order-items",children:[Object(X.jsx)(ee.a,{children:Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{children:Object(X.jsx)("b",{children:"Part No."})}),Object(X.jsx)(J.a,{children:Object(X.jsx)("b",{children:"Part Name"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Quantity"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Price"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Total Price ex. VAT"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Total Price"})})]})}),Object(X.jsx)(Z.a,{children:j.map((function(e,t){return Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{component:"th",scope:"row",children:e.PARTNAME}),Object(X.jsx)(J.a,{children:e.PDES}),Object(X.jsx)(J.a,{align:"right",children:e.TQUANT}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.PRICE]}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.QPRICE]}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.TOTPRICE]})]},t)}))})]}):Object(X.jsx)(ue.a,{})]})})})})]})}function De(){var e=Object(n.useState)("asc"),t=Object(i.a)(e,2),a=t[0],c=t[1],r=Object(n.useState)("calories"),s=Object(i.a)(r,2),o=s[0],l=s[1],u=Object(n.useState)([]),j=Object(i.a)(u,2),d=j[0],b=j[1],O=Object(n.useState)(0),x=Object(i.a)(O,2),m=x[0],f=x[1],g=Object(n.useState)(5),p=Object(i.a)(g,2),S=p[0],v=p[1],E=Object(n.useState)([]),T=Object(i.a)(E,2),C=T[0],A=T[1],y=Object(n.useState)(!1),k=Object(i.a)(y,2),D=k[0],P=k[1];Object(n.useEffect)((function(){re.getCustomerInvoices().then((function(e){A(e.data.value),P(!0)})).catch((function(e){console.log(e)}))}),[]);return D?Object(X.jsx)(h.a,{sx:{width:"100%"},children:Object(X.jsxs)(ne.a,{sx:{width:"100%",mb:2},children:[Object(X.jsx)(Ae,{title:"Invoices"}),Object(X.jsx)($.a,{children:Object(X.jsxs)(H.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(X.jsx)(Ce,{numSelected:d.length,order:a,orderBy:o,onSelectAllClick:function(e){if(e.target.checked){var t=C.map((function(e){return e.name}));b(t)}else b([])},onRequestSort:function(e,t){c(o===t&&"asc"===a?"desc":"asc"),l(t)},rowCount:C.length,headCells:ye}),Object(X.jsx)(Z.a,{children:C.slice().sort(Se(a,o)).slice(m*S,m*S+S).map((function(e,t){return Object(X.jsx)(ke,{row:e},t)}))})]})}),Object(X.jsx)(te.a,{rowsPerPageOptions:[5,10,25],component:"div",count:C.length,rowsPerPage:S,page:m,onPageChange:function(e,t){f(t)},onRowsPerPageChange:function(e){v(parseInt(e.target.value,10)),f(0)}})]})}):Object(X.jsx)(he,{})}var Pe=function(){return Object(X.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(X.jsx)(E.a,{item:!0,xs:12,children:Object(X.jsx)(De,{})})})},Ie=[{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:"Action"}];function we(e){var t=e.row,a=Object(n.useState)(!1),r=Object(i.a)(a,2),s=r[0],o=r[1],l=Object(n.useState)([]),u=Object(i.a)(l,2),j=u[0],d=u[1],b=Object(n.useState)(!0),O=Object(i.a)(b,2),x=O[0],m=O[1],f=Object(fe.b)(),p=f.enqueueSnackbar,v=(f.closeSnackbar,function(){s?o(!s):(m(!1),re.getOrderItems(t.ORDNAME).then((function(e){d(e.data.value),m(!0),o(!s)})).catch((function(e){console.log(e)})))});return Object(X.jsxs)(c.a.Fragment,{children:[Object(X.jsxs)(ae.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(X.jsx)(J.a,{children:x?Object(X.jsx)(S.a,{"aria-label":"expand row",size:"small",onClick:v,children:s?Object(X.jsx)(le.a,{}):Object(X.jsx)(ie.a,{})}):Object(X.jsx)(ue.a,{size:28})}),Object(X.jsx)(J.a,{component:"th",scope:"row",children:new Date(t.CURDATE).toLocaleDateString("en-GB")}),Object(X.jsx)(J.a,{align:"center",children:t.ORDNAME}),Object(X.jsx)(J.a,{align:"center",children:t.REFERENCE}),Object(X.jsxs)(J.a,{align:"center",children:[t.CODE," ",t.QPRICE.toLocaleString()]}),Object(X.jsxs)(J.a,{align:"center",children:[t.CODE," ",t.TOTPRICE.toLocaleString()]}),Object(X.jsx)(J.a,{align:"center",children:Object(X.jsx)(ge.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(X.jsx)(J.a,{align:"center",children:t.NAME}),Object(X.jsx)(J.a,{align:"center",children:Object(X.jsx)(S.a,{onClick:function(){return e=t.ORDNAME,void re.downloadOrderPdf(e).then((function(t){var a=window.URL.createObjectURL(new Blob([t.data])),n=document.createElement("a");n.href=a,n.setAttribute("download","".concat(e,".pdf")),document.body.appendChild(n),n.click()})).catch((function(e){console.log(e.response),p("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(X.jsx)(me.a,{})})})]}),Object(X.jsx)(ae.a,{children:Object(X.jsx)(J.a,{style:{paddingBottom:0,paddingTop:0,paddingLeft:100,backgroundColor:"#F8F8F8"},colSpan:8,children:Object(X.jsx)(je.a,{in:s,timeout:"auto",unmountOnExit:!0,onClick:v,children:Object(X.jsxs)(h.a,{sx:{margin:1},children:[Object(X.jsx)(g.a,{variant:"h6",gutterBottom:!0,component:"div",children:"Order Items"}),x?Object(X.jsxs)(H.a,{size:"small","aria-label":"order-items",children:[Object(X.jsx)(ee.a,{children:Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{children:Object(X.jsx)("b",{children:"Part No."})}),Object(X.jsx)(J.a,{children:Object(X.jsx)("b",{children:"Part Name"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Quantity"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Balance"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Price"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Total Price ex. VAT"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Total Price"})})]})}),Object(X.jsx)(Z.a,{children:j.map((function(e,t){return Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{component:"th",scope:"row",children:e.PARTNAME}),Object(X.jsx)(J.a,{children:e.PDES}),Object(X.jsx)(J.a,{align:"right",children:e.TQUANT}),Object(X.jsx)(J.a,{align:"right",children:e.TBALANCE}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.PRICE]}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.QPRICE]}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.VATPRICE]})]},t)}))})]}):Object(X.jsx)(ue.a,{})]})})})})]})}function Ne(){var e=Object(n.useState)("asc"),t=Object(i.a)(e,2),a=t[0],c=t[1],r=Object(n.useState)("calories"),s=Object(i.a)(r,2),o=s[0],l=s[1],u=Object(n.useState)([]),j=Object(i.a)(u,2),d=j[0],b=(j[1],Object(n.useState)(0)),O=Object(i.a)(b,2),x=O[0],m=O[1],f=Object(n.useState)(5),g=Object(i.a)(f,2),p=g[0],S=g[1],v=Object(n.useState)([]),E=Object(i.a)(v,2),T=E[0],C=E[1],A=Object(n.useState)(!1),y=Object(i.a)(A,2),k=y[0],D=y[1];Object(n.useEffect)((function(){re.getCustomerOrders().then((function(e){C(e.data.value),D(!0)})).catch((function(e){console.log(e)}))}),[]);return k?Object(X.jsx)(h.a,{sx:{width:"100%"},children:Object(X.jsxs)(ne.a,{sx:{width:"100%",mb:2},children:[Object(X.jsx)(Ae,{title:"Orders"}),Object(X.jsx)($.a,{children:Object(X.jsxs)(H.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(X.jsx)(Ce,{numSelected:d.length,order:a,orderBy:o,onRequestSort:function(e,t){c(o===t&&"asc"===a?"desc":"asc"),l(t)},rowCount:T.length,headCells:Ie}),Object(X.jsx)(Z.a,{children:T.slice().sort(Se(a,o)).slice(x*p,x*p+p).map((function(e,t){return Object(X.jsx)(we,{row:e},t)}))})]})}),Object(X.jsx)(te.a,{rowsPerPageOptions:[5,10,25],component:"div",count:T.length,rowsPerPage:p,page:x,onPageChange:function(e,t){m(t)},onRowsPerPageChange:function(e){S(parseInt(e.target.value,10)),m(0)}})]})}):Object(X.jsx)(he,{})}var Re=function(){return Object(X.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(X.jsx)(E.a,{item:!0,xs:12,children:Object(X.jsx)(Ne,{})})})},Ue=[{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:"Action"}];function Le(e){var t=e.row,a=Object(n.useState)(!1),r=Object(i.a)(a,2),s=r[0],o=r[1],l=Object(n.useState)([]),u=Object(i.a)(l,2),j=u[0],d=u[1],b=Object(n.useState)(!0),O=Object(i.a)(b,2),x=O[0],m=O[1],f=Object(fe.b)(),p=f.enqueueSnackbar,v=(f.closeSnackbar,function(){s?o(!s):(m(!1),re.getShipmentItems(t.DOCNO,t.TYPE).then((function(e){d(e.data.value),m(!0),o(!s)})).catch((function(e){console.log(e)})))});return Object(X.jsxs)(c.a.Fragment,{children:[Object(X.jsxs)(ae.a,{sx:{"& > *":{borderBottom:"unset"}},children:[Object(X.jsx)(J.a,{children:x?Object(X.jsx)(S.a,{"aria-label":"expand row",size:"small",onClick:v,children:s?Object(X.jsx)(le.a,{}):Object(X.jsx)(ie.a,{})}):Object(X.jsx)(ue.a,{size:28})}),Object(X.jsx)(J.a,{component:"th",scope:"row",children:new Date(t.CURDATE).toLocaleDateString("en-GB")}),Object(X.jsx)(J.a,{align:"center",children:t.DOCNO}),Object(X.jsx)(J.a,{align:"center",children:t.REFERENCE}),Object(X.jsxs)(J.a,{align:"center",children:[t.CODE," ",t.QPRICE.toLocaleString()]}),Object(X.jsxs)(J.a,{align:"center",children:[t.CODE," ",t.TOTPRICE.toLocaleString()]}),Object(X.jsx)(J.a,{align:"center",children:Object(X.jsx)(ge.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(X.jsx)(J.a,{align:"center",children:Object(X.jsx)(S.a,{onClick:function(){return e=t.DOCNO,void re.downloadShipmentPdf(e).then((function(t){var a=window.URL.createObjectURL(new Blob([t.data])),n=document.createElement("a");n.href=a,n.setAttribute("download","".concat(e,".pdf")),document.body.appendChild(n),n.click()})).catch((function(e){console.log(e.response),p("File not found. Please contact system manager.",{variant:"error"})}));var e},children:Object(X.jsx)(me.a,{})})})]}),Object(X.jsx)(ae.a,{children:Object(X.jsx)(J.a,{style:{paddingBottom:0,paddingTop:0,paddingLeft:100,backgroundColor:"#F8F8F8"},colSpan:8,children:Object(X.jsx)(je.a,{in:s,timeout:"auto",unmountOnExit:!0,onClick:v,children:Object(X.jsxs)(h.a,{sx:{margin:1},children:[Object(X.jsx)(g.a,{variant:"h6",gutterBottom:!0,component:"div",children:"Shipped Items"}),x?Object(X.jsxs)(H.a,{size:"small","aria-label":"purchases",children:[Object(X.jsx)(ee.a,{children:Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{children:Object(X.jsx)("b",{children:"Part No."})}),Object(X.jsx)(J.a,{children:Object(X.jsx)("b",{children:"Part Name"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Quantity"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Price"})}),Object(X.jsx)(J.a,{align:"right",children:Object(X.jsx)("b",{children:"Total Price ex. VAT"})})]})}),Object(X.jsx)(Z.a,{children:j.map((function(e,t){return Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{component:"th",scope:"row",children:e.PARTNAME}),Object(X.jsx)(J.a,{children:e.PDES}),Object(X.jsx)(J.a,{align:"right",children:e.TQUANT}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.PRICE]}),Object(X.jsxs)(J.a,{align:"right",children:[e.CODE," ",e.QPRICE]})]},t)}))})]}):Object(X.jsx)(ue.a,{})]})})})})]})}function Fe(){var e=Object(n.useState)("asc"),t=Object(i.a)(e,2),a=t[0],c=t[1],r=Object(n.useState)("calories"),s=Object(i.a)(r,2),o=s[0],l=s[1],u=Object(n.useState)([]),j=Object(i.a)(u,2),d=j[0],b=j[1],O=Object(n.useState)(0),x=Object(i.a)(O,2),m=x[0],f=x[1],g=Object(n.useState)(5),p=Object(i.a)(g,2),S=p[0],v=p[1],E=Object(n.useState)([]),T=Object(i.a)(E,2),C=T[0],A=T[1],y=Object(n.useState)(!1),k=Object(i.a)(y,2),D=k[0],P=k[1];Object(n.useEffect)((function(){re.getCustomerShipments().then((function(e){A(e.data.value),P(!0)})).catch((function(e){console.log(e)}))}),[]);return D?Object(X.jsx)(h.a,{sx:{width:"100%"},children:Object(X.jsxs)(ne.a,{sx:{width:"100%",mb:2},children:[Object(X.jsx)(Ae,{title:"Shipments"}),Object(X.jsx)($.a,{children:Object(X.jsxs)(H.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(X.jsx)(Ce,{numSelected:d.length,order:a,orderBy:o,onSelectAllClick:function(e){if(e.target.checked){var t=C.map((function(e){return e.name}));b(t)}else b([])},onRequestSort:function(e,t){c(o===t&&"asc"===a?"desc":"asc"),l(t)},rowCount:C.length,headCells:Ue}),Object(X.jsx)(Z.a,{children:C.slice().sort(Se(a,o)).slice(m*S,m*S+S).map((function(e,t){return Object(X.jsx)(Le,{row:e},t)}))})]})}),Object(X.jsx)(te.a,{rowsPerPageOptions:[5,10,25],component:"div",count:C.length,rowsPerPage:S,page:m,onPageChange:function(e,t){f(t)},onRowsPerPageChange:function(e){v(parseInt(e.target.value,10)),f(0)}})]})}):Object(X.jsx)(he,{})}var Me=function(){return Object(X.jsx)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:Object(X.jsx)(E.a,{item:!0,xs:12,children:Object(X.jsx)(Fe,{})})})},We=a(39),Be=a(595),_e=a(488),Ge=a(316),ze=a(596),Ye=a(591),Ve=a(118),qe=a.n(Ve),Qe=a(478),Xe=a(627),Ke=a(117),He=a.n(Ke),Ze=a(296),Je=a.n(Ze),$e=a(297),et=a.n($e);function tt(e){return Number.parseFloat(e).toFixed(2)}var at=[{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 nt(e){var t=e.order,a=e.orderBy,n=e.onRequestSort;return Object(X.jsx)(ee.a,{children:Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{padding:"checkbox"}),at.map((function(e){return Object(X.jsx)(J.a,{align:e.numeric?"right":"left",padding:e.disablePadding?"none":"normal",sortDirection:a===e.id&&t,children:Object(X.jsxs)(Ee.a,{active:a===e.id,direction:a===e.id?t:"asc",onClick:(c=e.id,function(e){n(e,c)}),children:[Object(X.jsx)("b",{children:e.label}),a===e.id?Object(X.jsx)(h.a,{component:"span",sx:Te.a,children:"desc"===t?"sorted descending":"sorted ascending"}):null]})},e.id);var c}))]})})}var ct=function(e){var t=e.numSelected;return Object(X.jsxs)(m.a,{sx:Object(l.a)({pl:{sm:2},pr:{xs:1,sm:1}},t>0&&{bgcolor:function(e){return Object(Qe.a)(e.palette.primary.main,e.palette.action.activatedOpacity)}}),children:[t>0?Object(X.jsxs)(g.a,{sx:{flex:"1 1 100%"},color:"inherit",variant:"subtitle1",component:"div",children:[t," selected"]}):Object(X.jsx)(g.a,{sx:{flex:"1 1 100%"},variant:"h6",id:"tableTitle",component:"div",children:"Items in Order"}),t>0?Object(X.jsx)(Xe.a,{title:"Delete",children:Object(X.jsx)(S.a,{onClick:e.onDelete,children:Object(X.jsx)(He.a,{})})}):Object(X.jsx)(Xe.a,{title:"Filter list",children:Object(X.jsx)(S.a,{children:Object(X.jsx)(Je.a,{})})})]})};function rt(e){var t=n.useState("asc"),a=Object(i.a)(t,2),c=a[0],r=a[1],s=n.useState("calories"),o=Object(i.a)(s,2),l=o[0],u=o[1],j=n.useState([]),d=Object(i.a)(j,2),b=d[0],O=d[1],x=e.items;return Object(X.jsx)(h.a,{sx:{width:"100%"},children:Object(X.jsxs)(ne.a,{sx:{width:"100%",mb:2},children:[Object(X.jsx)(ct,{}),Object(X.jsx)($.a,{children:Object(X.jsxs)(H.a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:"medium",children:[Object(X.jsx)(nt,{numSelected:b.length,order:c,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){r(l===t&&"asc"===c?"desc":"asc"),u(t)},rowCount:x.length}),Object(X.jsxs)(Z.a,{children:[ve(x,Se(c,l)).map((function(t,a){var n,c=(n=t.PARTNAME,-1!==b.indexOf(n)),r="enhanced-table-checkbox-".concat(a);return Object(X.jsxs)(ae.a,{hover:!0,role:"checkbox","aria-checked":c,tabIndex:-1,selected:c,children:[Object(X.jsx)(J.a,{padding:"checkbox"}),Object(X.jsx)(J.a,{component:"th",id:r,scope:"row",padding:"none",children:t.PARTDES}),Object(X.jsx)(J.a,{align:"right",children:t.PARTNAME}),Object(X.jsxs)(J.a,{align:"right",children:[t.BASEPLCODE," ",tt(t.BASEPLPRICE)]}),Object(X.jsxs)(J.a,{align:"right",children:[t.BASEPLCODE," ",tt(t.VATPRICE)]}),Object(X.jsxs)(J.a,{align:"right",children:[Object(X.jsx)(S.a,{onClick:function(a){return e.onDecrement(t,a)},children:Object(X.jsx)(et.a,{})}),t.QUANTITY,Object(X.jsx)(S.a,{onClick:function(a){return e.onIncrement(t,a)},children:Object(X.jsx)(qe.a,{})})]}),Object(X.jsxs)(J.a,{align:"right",children:[t.BASEPLCODE," ",tt(t.VATPRICE*t.QUANTITY)]})]},a)})),Object(X.jsxs)(ae.a,{children:[Object(X.jsx)(J.a,{colSpan:6,align:"right",children:Object(X.jsx)("b",{children:"Total Price"})}),Object(X.jsx)(J.a,{align:"right",children:function(){for(var e=0,t=0;t0){var a=p.findIndex((function(e){return e.PARTNAME===u.PARTNAME}));console.log(u.PARTNAME),a>-1?(t[a].QUANTITY=parseInt(u.QUANTITY)+parseInt(O),S(t)):(u.QUANTITY=O,S((function(e){return[].concat(Object(de.a)(e),[u])})))}else console.log("Quantity must be greater than 0.")},children:"Add"})}),Object(X.jsx)(E.a,{item:!0,md:12,children:Object(X.jsx)(rt,{items:p,onDecrement:function(e){var t=Object(de.a)(p),a=p.findIndex((function(t){return t.PARTNAME===e.PARTNAME}));1===t[a].QUANTITY?t.splice(a,1):t[a].QUANTITY-=1,S(t)},onIncrement:function(e){var t=Object(de.a)(p),a=p.findIndex((function(t){return t.PARTNAME===e.PARTNAME}));t[a].QUANTITY=parseInt(t[a].QUANTITY)+1,S(t)}})}),Object(X.jsx)(E.a,{item:!0,md:12,children:Object(X.jsx)(Ge.a,{disabled:0===p.length,onClick:function(){console.log(p);for(var e=Object(de.a)(p),t=[],a=0;a0?r.map((function(e,t){return Object(X.jsxs)(ot.a,{onClick:function(){return 0===e.READ?function(e,t){re.setNotificationRead({ID:e}).then((function(e){var a=Object(de.a)(r);a[t].READ=1,s(a),console.log(r)})).catch((function(e){console.log(e)}))}(e.ID,t):null},selected:0===e.READ,children:[Object(X.jsx)(D.a,{children:Object(X.jsx)(pt.a,{fontSize:"small"})}),Object(X.jsxs)(P.a,{children:[e.ORDNAME," has been changed to ",e.ORDSTATUSDES," ",m.format(new Date(e.DATE))]})]},t)})):Object(X.jsx)(g.a,{children:"No notifications."})})]}):Object(X.jsx)(ue.a,{})}var Tt=a(25),Ct=a.n(Tt),At=a(42),yt=a(628),kt=a(629),Dt=a(580),Pt=a(119),It=a(95),wt=a.n(It),Nt=a(169),Rt=a.n(Nt),Ut=a(43),Lt=(a(211),a(615)),Ft=(a(469),a(121)),Mt=a(491);function Wt(){var e=c.a.useState(!0),t=Object(i.a)(e,2),a=t[0];t[1];return Object(X.jsx)("div",{children:Object(X.jsx)(Mt.a,{sx:{color:"#fff",zIndex:function(e){return e.zIndex.drawer+1}},open:a,children:Object(X.jsx)(ue.a,{color:"inherit"})})})}var Bt=function(e){return{sx:{bgcolor:Gt(e),fontSize:16,width:30,height:30},children:_t(e)}},_t=function(e){var t=e.charAt(0),a=e.charAt(e.length-1);return t.toUpperCase()+a.toUpperCase()},Gt=function(e){var t,a=0;for(t=0;t>8*t&255).toString(16)).slice(-2)}return n},zt=function(e){return new Date(e).toLocaleDateString("en-GB",{month:"short",day:"numeric"})},Yt=function(e){return new Promise((function(t,a){return function(e,t){var a=new FileReader;a.readAsDataURL(e),a.onload=function(){return t(a.result)},a.onerror=function(e){}}(e,(function(e){return t({data:{link:e}})}))}))},Vt=function(e,t,a){var n=document.createElement("a");n.href=e,n.download=t+"."+a,n.click()},qt=a(299),Qt=a.n(qt),Xt=function(e){return Object(X.jsx)(E.a,{item:!0,md:3,children:Object(X.jsx)(yt.a,{children:Object(X.jsx)(kt.a,{children:Object(X.jsxs)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:[Object(X.jsxs)("b",{children:[e.subject,":"]})," ",e.info]})})})})},Kt=function(){var e,t=Object(fe.b)(),a=t.enqueueSnackbar,r=(t.closeSnackbar,Object(n.useState)(!1)),s=Object(i.a)(r,2),o=s[0],l=s[1],u=Object(We.g)().docno,j=Object(n.useState)(null),d=Object(i.a)(j,2),b=d[0],O=d[1],h=Object(n.useState)(null),x=Object(i.a)(h,2),m=x[0],f=x[1],p=Object(n.useState)(!0),T=Object(i.a)(p,2),C=T[0],A=T[1],y=Object(n.useState)(0),k=Object(i.a)(y,2),D=(k[0],k[1],Object(n.useState)(_.getCurrentUser().username)),P=Object(i.a)(D,2),I=(P[0],P[1],Object(n.useState)([])),w=Object(i.a)(I,2),N=w[0],R=w[1],U=Object(Ft.a)({accept:"*",readAs:"DataURL"}),L=Object(i.a)(U,2),F=L[0],M=L[1],W=(M.plainFiles,M.filesContent),B=M.clear,G=Object(n.useState)([]),z=Object(i.a)(G,2),Y=z[0],V=z[1],q=Object(n.useState)(!0),Q=Object(i.a)(q,2),K=(Q[0],Q[1],function(e){console.info(W[0]),B(),R([])}),H=(Ut.EditorState.createEmpty(),c.a.useState()),Z=Object(i.a)(H,2),J=Z[0],$=Z[1],ee=function(){var e=Object(At.a)(Ct.a.mark((function e(){var t,a,n,c;return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,re.getServiceCall(u);case 2:return t=e.sent.data,e.next=5,re.getStatusLang2(t.CALLSTATUSCODE);case 5:return a=e.sent.data,e.next=8,re.getSCAttachments(u);case 8:return n=e.sent.data.value,t.ESTATDES=a.value[0].ESTATDES,t.CHANGEFLAG=a.value[0].CHANGEFLAG,O(t),e.next=14,re.getServiceCallExternalRemarks(u);case 14:c=e.sent.data,f(c),V(n),A(!1);case 18:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Object(n.useEffect)(Object(At.a)(Ct.a.mark((function e(){return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:ee();case 1:case"end":return e.stop()}}),e)}))),[C]),Object(n.useEffect)((function(){if(W){var e=W;R((function(t){return t.concat(e)}))}}),[W]);return Object(X.jsx)(X.Fragment,{children:C?Object(X.jsx)(Wt,{}):Object(X.jsxs)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:[Object(X.jsxs)(E.a,{container:!0,spacing:1,direction:"row",alignItems:"center",children:[Object(X.jsx)(Xt,{subject:"Ticket Number",info:u}),Object(X.jsx)(Xt,{subject:"Subject",info:b.ZEMG_SVC_DETAILS}),Object(X.jsx)(Xt,{subject:"Customer",info:b.CDES}),Object(X.jsx)(Xt,{subject:"Contact",info:b.NAME}),Object(X.jsx)(Xt,{subject:"Type of Call ",info:b.CALLTYPECODE}),Object(X.jsx)(Xt,{subject:"Cust. Reference",info:b.REFERENCE}),Object(X.jsx)(Xt,{subject:"Status",info:null!==(e=b.ESTATDES)&&void 0!==e?e:b.CALLSTATUSCODE})]}),"Y"===b.CHANGEFLAG?Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)(yt.a,{sx:{mt:2,mb:2},children:Object(X.jsxs)(kt.a,{children:[Object(X.jsxs)("div",{sx:{display:"flex",flexDirection:"row"},children:[Object(X.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(X.jsx)("b",{children:"Add a Comment"})}),Object(X.jsx)(S.a,{children:Object(X.jsx)(Qt.a,{})})]}),Object(X.jsx)(Pt.Editor,{wrapperClassName:"wrapperClassName",editorState:J,editorStyle:{overflow:"hidden",minHeight:"20vh"},onEditorStateChange:function(e){$(e)},toolbar:{image:{uploadCallback:Yt,previewImage:!0}}})]})}),Object(X.jsx)(Lt.a,{children:Object(X.jsxs)(Dt.a,{direction:"row",spacing:2,children:[Object(X.jsx)(Ge.a,{onClick:function(){return F()},variant:"outlined",startIcon:Object(X.jsx)(Rt.a,{}),children:"Add File"}),Object(X.jsx)(Ge.a,{variant:"contained",onClick:function(){if(1===Object(Ut.convertToRaw)(J.getCurrentContent()).blocks.length&""===Object(Ut.convertToRaw)(J.getCurrentContent()).blocks[0].text)a("You can not submit an empty comment.",{variant:"error"});else{l(!0);var e=Ut.EditorState.createEmpty();$(e);var t,n=(new Date).toLocaleString("en-GB"),c=[];for(var r in N)c.push({EXTFILEDES:N[r].name.split(".")[0],EXTFILENAME:N[r].content});t=0!==c.length?n+wt()(Object(Ut.convertToRaw)(J.getCurrentContent()))+"
"+c.length+" files attached.
":n+wt()(Object(Ut.convertToRaw)(J.getCurrentContent()))+"
";b.CALLSTATUSCODE;var s={DOCNO:u,TEXT:t,APPEND:!0,SIGNATURE:!1,EXTFILES:c};re.updateServiceCall(s).then((function(e){a("Service call updated succesfully.",{variant:"success"}),l(!1),K(),A(!0)})).catch((function(e){a("Error updating service call.",{variant:"error"}),l(!1),K(),A(!0)}))}},children:"Update Ticket"})]})})]}):null,0!=(null===N||void 0===N?void 0:N.length)?Object(X.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(X.jsx)(He.a,{onClick:K})}):Object(X.jsx)(X.Fragment,{}),null===N||void 0===N?void 0:N.map((function(e,t){return Object(X.jsx)(ge.a,{label:e.name})})),1==C||1==o?Object(X.jsx)(Wt,{}):null,Object(X.jsx)(yt.a,{sx:{mt:2},children:Object(X.jsxs)(kt.a,{children:[Object(X.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(X.jsx)("b",{children:"Description"})}),Object(X.jsx)("div",{style:{overflow:"auto"},dangerouslySetInnerHTML:{__html:m.TEXT}})]})}),Object(X.jsx)(yt.a,{sx:{mt:2},children:Object(X.jsxs)(kt.a,{children:[Object(X.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(X.jsx)("b",{children:"Attachments"})}),null===Y||void 0===Y?void 0:Y.map((function(e,t){return Object(X.jsx)(ge.a,{label:e.EXTFILEDES+"."+e.SUFFIX,color:"primary",size:"small",sx:{mr:1,mb:1},onClick:function(){return Vt(e.EXTFILENAME,e.EXTFILEDES,e.SUFFIX)}},t)}))]})})]})})},Ht=(a(470),a(471),a(472),a(473),a(14)),Zt=a(311),Jt=a(81),$t=a(93),ea=a(300),ta=(a(474),a(630)),aa=a(590),na=function(){var e=Object(n.useState)(null),t=Object(i.a)(e,2),a=t[0],c=t[1],r=Object(n.useState)(null),s=Object(i.a)(r,2),o=s[0],u=s[1],j=Object(n.useState)(!0),d=Object(i.a)(j,2),b=d[0],O=d[1],h=Object(n.useState)({global:{value:null,matchMode:Ht.a.CONTAINS},DOCNO:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.STARTS_WITH}]},ZEMG_SVC_DETAILS:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.STARTS_WITH}]},REFERENCE:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.STARTS_WITH}]},NAME:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.STARTS_WITH}]},STARTDATE:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.DATE_IS}]},CALLTYPECODE:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.EQUALS}]},CDES:{operator:Ht.b.OR,constraints:[{value:null,matchMode:Ht.a.EQUALS}]},CALLSTATUSCODE:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.EQUALS}]},STATUSDATE:{operator:Ht.b.AND,constraints:[{value:null,matchMode:Ht.a.DATE_IS}]}}),x=Object(i.a)(h,2),m=x[0],f=x[1],g=Object(n.useState)(""),p=Object(i.a)(g,2),S=p[0],v=p[1],E=Object(n.useState)(!0),T=Object(i.a)(E,2),C=T[0],A=T[1];Object(n.useEffect)((function(){console.log("Use effect"),re.getServiceCalls().then((function(e){u(y(e.data.value)),re.getCallStatuses().then((function(e){c(e.data.value),A(!1)})).catch((function(e){console.log(e)}))})).catch((function(e){console.log(e)}))}),[]);var y=function(e){return Object(de.a)(e||[]).map((function(e){return e.STARTDATE=new Date(e.STARTDATE),e.STATUSDATE=new Date(e.STATUSDATE),e}))},k=function(e){return e.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"})},D=function(e){var t=e.target.value,a=Object(l.a)({},m);a.global.value=t,f(a),v(t)},P=function(e){return Object(X.jsx)(ea.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"})},I=function(e){O(e.target.checked)},w=Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)("h5",{className:"m-0",children:"Service Calls"}),Object(X.jsx)(ta.a,{control:Object(X.jsx)(aa.a,{onChange:I,checked:b,name:"gilad"}),label:"Show Only Active Tickets"})," ",Object(X.jsxs)("span",{className:"p-input-icon-left",children:[Object(X.jsx)("i",{className:"pi pi-search"}),Object(X.jsx)($t.a,{value:S,onChange:D,placeholder:"Keyword Search"})]})]});return C?Object(X.jsx)(he,{}):Object(X.jsx)("div",{className:"datatable-doc-demo",children:Object(X.jsx)("div",{className:"card",children:Object(X.jsxs)(Zt.a,{value:function(e,t){return(b?e.filter((function(e){return"Y"===e.ACTIVEFLAG})):e).map((function(e){var a=t.find((function(t){return t.CODE===e.CALLSTATUSCODE}));return a&&a.ESTATDES?Object(l.a)(Object(l.a)({},e),{},{CALLSTATUSCODE:a.ESTATDES}):e}))}(o,a),paginator:!0,className:"p-datatable-customers",header:w,rows:10,breakpoint:"960px",paginatorTemplate:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown",rowsPerPageOptions:[10,25,50],dataKey:"id",rowHover:!0,filters:m,filterDisplay:"menu",loading:C,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",children:[Object(X.jsx)(Jt.a,{field:"DOCNO",header:"Ticket ID",filterField:"DOCNO",sortable:!0,body:function(e){return Object(X.jsx)(U.b,{style:{textDecoration:"none",color:"blue"},to:"/dashboard/servicecall/".concat(e.DOCNO),sx:{mt:3},children:e.DOCNO})},filter:!0,filterPlaceholder:"Search by Ticket ID"}),Object(X.jsx)(Jt.a,{field:"ZEMG_SVC_DETAILS",header:"Subject",sortable:!0,filter:!0,filterPlaceholder:"Search by Subject"}),Object(X.jsx)(Jt.a,{field:"REFERENCE",header:"Cust. Ref",sortable:!0,filter:!0,filterPlaceholder:"Search by Reference"}),Object(X.jsx)(Jt.a,{field:"NAME",header:"Contact",sortable:!0,filter:!0,filterPlaceholder:"Search by Contact"}),Object(X.jsx)(Jt.a,{field:"STARTDATE",header:"Open Date",sortable:!0,filterField:"STARTDATE",dataType:"date",body:function(e){return k(e.STARTDATE)},filter:!0,filterPlaceholder:"Search by Open Date",filterElement:P}),Object(X.jsx)(Jt.a,{field:"CALLTYPECODE",header:"Classification",sortable:!0,filter:!0,filterPlaceholder:"Search by Classification"}),Object(X.jsx)(Jt.a,{field:"ZEMG_SEVDES",header:"Call Severity",sortable:!0,filter:!0,filterPlaceholder:"Search by Call Severity"}),Object(X.jsx)(Jt.a,{field:"CALLSTATUSCODE",header:"Status",sortable:!0,filter:!0,filterPlaceholder:"Search by Status"}),Object(X.jsx)(Jt.a,{field:"STATUSDATE",header:"Update Date",sortable:!0,filterField:"STATUSDATE",dataType:"date",body:function(e){return k(e.STATUSDATE)},filter:!0,filterPlaceholder:"Search by Update Date",filterElement:P})]})})})},ca=function(){return Object(X.jsx)(v.a,{maxWidth:!1,sx:{mt:4,mb:4},children:Object(X.jsx)(na,{})})};function ra(e){var t=e.items,a=e.onChange,c=e.labelname,r=e.title,s=e.description,o=e.required,u=e.disabled,j=n.useState(!1),d=Object(i.a)(j,2),b=d[0],O=d[1],h=b&&0===t.length;return Object(X.jsx)(Be.a,{sx:{m:1},disabled:u,fullWidth:!0,open:b,onOpen:function(){O(!0)},onClose:function(){O(!1)},onChange:a,isOptionEqualToValue:function(e,t){return""===c?e===t:e[c]===t[c]},getOptionLabel:function(e){return""===c?e+(s?": "+e[s]:""):e[c]+(s?": "+e[s]:"")},options:t,loading:h,renderInput:function(e){return Object(X.jsx)(_e.a,Object(l.a)(Object(l.a)({required:o},e),{},{label:r,InputProps:Object(l.a)(Object(l.a)({},e.InputProps),{},{endAdornment:Object(X.jsxs)(n.Fragment,{children:[h?Object(X.jsx)(ue.a,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})})}))}})}var sa=function(e){var t=Object(n.useState)(!0),a=Object(i.a)(t,2),c=a[0],r=a[1],s=Object(n.useState)([]),o=Object(i.a)(s,2),l=o[0],u=o[1],j=Object(n.useState)(""),d=Object(i.a)(j,2),b=d[0],O=d[1],h=Object(n.useState)([]),x=Object(i.a)(h,2),m=x[0],f=x[1],p=Object(n.useState)(),T=Object(i.a)(p,2),C=T[0],A=T[1],y=Object(n.useState)([]),k=Object(i.a)(y,2),D=k[0],P=k[1],I=Object(n.useState)([]),w=Object(i.a)(I,2),N=w[0],R=w[1],U=Object(n.useState)(),L=Object(i.a)(U,2),F=L[0],M=L[1],W=Object(fe.b)(),B=W.enqueueSnackbar,G=(W.closeSnackbar,Ut.EditorState.createEmpty()),z=Object(n.useState)(""),Y=Object(i.a)(z,2),V=Y[0],q=Y[1],Q=Object(n.useState)(G),K=Object(i.a)(Q,2),H=K[0],Z=K[1],J=Object(n.useState)(_.getCurrentUser().username),$=Object(i.a)(J,2),ee=($[0],$[1],Object(Ft.a)({accept:"*",readAs:"DataURL"})),te=Object(i.a)(ee,2),ae=te[0],ne=te[1],ce=ne.plainFiles,se=ne.filesContent,ie=ne.clear,oe=Object(n.useState)(!1),le=Object(i.a)(oe,2),ue=le[0],je=le[1],de=Object(n.useState)(""),be=Object(i.a)(de,2),Oe=be[0],he=be[1];Object(n.useEffect)((function(){var e=function(){var e=Object(At.a)(Ct.a.mark((function e(){var t;return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,re.getCallTypes();case 2:t=e.sent,u(t.data.value);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),t=function(){var e=Object(At.a)(Ct.a.mark((function e(){var t;return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,re.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)}}(),a=function(){var e=Object(At.a)(Ct.a.mark((function e(){var t;return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,re.getCustomerContacts();case 2:t=e.sent,P(t.data.value);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();a().catch(console.error),e().catch(console.error),t().catch(console.error),r(!1)}),[c]);return Object(X.jsxs)(v.a,{maxWidth:"lg",sx:{mt:4,mb:4},children:[""!=Oe?Object(X.jsx)(We.a,{to:"/dashboard/servicecall/".concat(Oe)}):null,1==c||1==ue?Object(X.jsx)(Wt,{}):null,Object(X.jsxs)(E.a,{container:!0,spacing:2,children:[Object(X.jsx)(E.a,{item:!0,md:8,children:Object(X.jsx)(_e.a,{sx:{m:1},fullWidth:!0,required:!0,onChange:function(e){return q(e.target.value)},label:"Subject",inputProps:{maxLength:48}})}),Object(X.jsx)(E.a,{item:!0,md:4,children:Object(X.jsx)(_e.a,{sx:{m:1},fullWidth:!0,onChange:function(e){return O(e.target.value)},label:"Customer's Reference",inputProps:{maxLength:12}})}),Object(X.jsx)(E.a,{item:!0,md:4,children:Object(X.jsx)(ra,{required:!0,title:"Call Type",labelname:"CODE",items:l,onChange:function(e,t){return A(t)}})}),Object(X.jsx)(E.a,{item:!0,md:4,children:Object(X.jsx)(ra,{required:!0,title:"Call Severity",labelname:"SEVDES",items:m,onChange:function(e,t){return M(t)}})}),Object(X.jsx)(E.a,{item:!0,md:4,children:Object(X.jsx)(ra,{required:!0,title:"Contact",labelname:"NAME",items:D,onChange:function(e,t){return R(t)}})}),Object(X.jsxs)(E.a,{item:!0,md:12,children:[Object(X.jsx)(yt.a,{sx:{mt:2},children:Object(X.jsxs)(kt.a,{children:[Object(X.jsx)(g.a,{sx:{fontSize:14},gutterBottom:!0,children:Object(X.jsx)("b",{children:"Details"})}),Object(X.jsx)(Pt.Editor,{wrapperClassName:"wrapperClassName",editorStyle:{overflow:"hidden",minHeight:"40vh"},editorState:H,onEditorStateChange:function(e){Z(e)},toolbar:{image:{uploadCallback:Yt,previewImage:!0}}})]})}),Object(X.jsx)(Lt.a,{children:Object(X.jsxs)(Dt.a,{direction:"row",spacing:2,sx:{mt:2,mb:2},children:[Object(X.jsx)(Ge.a,{onClick:function(){return ae()},variant:"outlined",startIcon:Object(X.jsx)(Rt.a,{}),children:"Add File"}),Object(X.jsx)(Ge.a,{variant:"contained",onClick:function(){if(1===Object(Ut.convertToRaw)(H.getCurrentContent()).blocks.length&""===Object(Ut.convertToRaw)(H.getCurrentContent()).blocks[0].text)B("You can not submit an empty comment.",{variant:"error"});else if(/^ *$/.test(V))B("Please fill out the Subject field.",{variant:"error"});else if(void 0!=(null===C||void 0===C?void 0:C.CODE))if(void 0!=(null===F||void 0===F?void 0:F.SEV))if(void 0!=(null===N||void 0===N?void 0:N.NAME)){je(!0);var e,t=(new Date).toLocaleString("en-GB"),a=[];for(var n in se)a.push({EXTFILEDES:se[n].name.split(".")[0],EXTFILENAME:se[n].content});e=0!==a.length?t+wt()(Object(Ut.convertToRaw)(H.getCurrentContent()))+"
"+a.length+" files attached.
":t+wt()(Object(Ut.convertToRaw)(H.getCurrentContent()))+"
";var c={DETAILS:V,CALLTYPECODE:null===C||void 0===C?void 0:C.CODE,ZEMG_SEVNAME:null===F||void 0===F?void 0:F.SEVNAME,TEXT:e,APPEND:!0,SIGNATURE:!1,REFERENCE:b,NAME:null===N||void 0===N?void 0:N.NAME,EXTFILES:a};re.CreateServiceCall(c).then((function(e){void 0!=e.data.DOCNO?(B("Service Call ".concat(e.data.DOCNO," successfully created!"),{variant:"success"}),ie(),r(!0),he(e.data.DOCNO)):(B("Error creating service call.",{variant:"error"}),je(!1))})).catch((function(e){e.response.data.message?B(e.response.data.message,{variant:"error"}):B("Error creating service call.",{variant:"error"}),je(!1)}))}else B("Please select a Contact.",{variant:"error"});else B("Please select a Call Severity.",{variant:"error"});else B("Please select a Call Type.",{variant:"error"})},children:"Submit"})]})}),0!=ce.length?Object(X.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(X.jsx)(He.a,{onClick:function(e){ie()}})}):Object(X.jsx)(X.Fragment,{}),ce.map((function(e,t){return Object(X.jsx)(ge.a,{label:e.name})}))]})]})]})},ia=a(583),oa=a(631),la=a(487),ua=a(222),ja=a(493),da=a(492),ba=a(173),Oa=a.n(ba),ha=a(301),xa=a.n(ha),ma=a(177),fa=a(581),ga=a(171);function pa(e){var t=e.open,a=e.description,c=e.loading,r=e.attachments,s=e.handleClose,o=(e.refreshTasks,e.handleTaskStatusChange),u=e.task,j=u.SUBJECT,d=u.STATDES,b=u.USERLOGIN,O=(u.CUSTNOTETYPEDES,u.CUSTNOTE),h=(u.EXTFILEFLAG,u.CURDATE),x=u.TILLDATE,m=u.STIME,f=u.ETIME,p=u.WBS,v=u.ACTDES,E=[b,u.USERLOGIN2,u.USERLOGIN3,u.USERLOGIN4,u.USERLOGIN5,u.USERLOGIN6,u.USERLOGIN7,u.USERLOGIN8],T=Object(ma.a)("div")({marginBottom:16}),C=Object(n.useState)(!1),A=Object(i.a)(C,2),y=A[0],k=A[1],D=Object(fe.b)(),P=(D.enqueueSnackbar,D.closeSnackbar,Object(ga.b)());return Object(X.jsx)("div",{children:Object(X.jsxs)(la.a,{open:t,onClose:s,scroll:"paper","aria-labelledby":"scroll-dialog-title","aria-describedby":"scroll-dialog-description",children:[Object(X.jsx)("div",{children:Object(X.jsxs)(da.a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",fontWeight:"bold"},id:"scroll-dialog-title",children:[null!==j&&void 0!==j?j:"Task Subject",Object(X.jsx)(Xe.a,{placement:"right",title:"Cancel task.",children:Object(X.jsx)(S.a,{disabled:y,onClick:function(){P({description:"This will cancel the task."}).then((function(){k(!0),o(d,"Cancelled",O),s()})).catch((function(){console.log("Confirmation declined.")}))},color:"error","aria-label":"cancel-task",component:"label",children:Object(X.jsx)(fa.a,{})})})]})}),c?Object(X.jsx)(be.a,{}):null,Object(X.jsxs)(ua.a,{dividers:!c,sx:{minHeight:"50vh",minWidth:"30vw"},children:[Object(X.jsxs)(T,{children:[Object(X.jsx)(g.a,{variant:"subtitle2",children:"Members"}),Object(X.jsx)("div",{style:{display:"flex",flexDirection:"row"},children:null===E||void 0===E?void 0:E.filter((function(e){return e})).map((function(e,t){return Object(X.jsx)(Xe.a,{style:{marginRight:8},title:e,children:Object(X.jsx)(lt.a,Object(l.a)({},Bt(e)))},t)}))})]}),p?Object(X.jsxs)(T,{children:[Object(X.jsx)(g.a,{variant:"subtitle2",children:"WBS"}),Object(X.jsx)(g.a,{children:p+": "+v})]}):null,Object(X.jsxs)(T,{children:[Object(X.jsx)(g.a,{variant:"subtitle2",children:"Dates"}),Object(X.jsx)(Xe.a,{placement:"left",title:"Start and end date.",children:Object(X.jsx)(ge.a,{icon:Object(X.jsx)(xa.a,{}),size:"small",label:zt(h)+" - "+zt(x)})}),Object(X.jsx)(Xe.a,{sx:{ml:1},placement:"right",title:"Start and end time.",children:Object(X.jsx)(ge.a,{icon:Object(X.jsx)(Oa.a,{}),size:"small",label:m+" - "+f})})]}),Object(X.jsxs)(T,{children:[Object(X.jsx)(g.a,{variant:"subtitle2",children:"Description"}),Object(X.jsx)(ja.a,{id:"scroll-dialog-description",tabIndex:-1,children:c?Object(X.jsx)(Oe.a,{}):Object(X.jsx)("div",{dangerouslySetInnerHTML:{__html:a}})})]})]}),r.length>0?Object(X.jsxs)(ua.a,{dividers:!0,children:[Object(X.jsx)(g.a,{children:"Attachments"}),null===r||void 0===r?void 0:r.map((function(e,t){return Object(X.jsx)(ge.a,{label:e.EXTFILEDES+"."+e.SUFFIX,color:"primary",size:"small",sx:{mr:1,mb:1},onClick:function(){return Vt(e.EXTFILENAME,e.EXTFILEDES,e.SUFFIX)}},t)}))]}):null]})})}var Sa=a(302),va=a.n(Sa),Ea=function(e){var t,a=e.task,c=a.SUBJECT,r=a.USERLOGIN,s=a.CUSTNOTETYPEDES,o=a.CUSTNOTE,u=a.EXTFILEFLAG,j=a.CURDATE,d=a.TILLDATE,b=a.ACTDES,O=(a.STIME,a.ETIME,a.WBS),h=a.USERLOGIN2,x=a.USERLOGIN3,m=a.USERLOGIN4,f=a.USERLOGIN5,p=a.USERLOGIN6,S=a.USERLOGIN7,v=a.USERLOGIN8,E=a.ZMED_TASKSIZENAME,T=e.refreshTasks,C=e.handleTaskStatusChange,A=[r,h,x,m,f,p,S,v],y=Object(n.useState)(!1),k=Object(i.a)(y,2),D=k[0],P=k[1],I=Object(n.useState)("There is no description."),w=Object(i.a)(I,2),N=w[0],R=w[1],U=Object(n.useState)([]),L=Object(i.a)(U,2),F=L[0],M=L[1],W=Object(n.useState)(!1),B=Object(i.a)(W,2),_=B[0],G=B[1],z=function(){G(!0),re.getTaskExplanation(o).then((function(e){e.data.hasOwnProperty("error")?(console.log(e.data),R("There is no description."),G(!1)):(R(e.data.TEXT),console.log(e.data),G(!1))})).catch((function(e){console.log(e),G(!1)}))},Y=function(){re.getTaskAttachments(o).then((function(e){e.data.hasOwnProperty("error")?console.log(e.data):(console.log(e.data),M(e.data.value))})).catch((function(e){console.log(e)}))};return Object(X.jsxs)(yt.a,{onClick:function(){D||(z(),"Y"===u&&Y(),P(!0))},sx:{mb:2},children:[Object(X.jsx)(pa,{open:D,description:N,handleClose:function(){P(!1)},task:e.task,loading:_,attachments:F,refreshTasks:T,handleTaskStatusChange:C}),Object(X.jsxs)(kt.a,{sx:{display:"flex",flexDirection:"column"},children:[Object(X.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Object(X.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[s?Object(X.jsx)(Xe.a,{enterDelay:500,placement:"top",title:"Task type.",children:Object(X.jsx)(ge.a,{label:s,color:"primary",size:"small",sx:{bgcolor:Gt(s),mr:1}})}):null,E?Object(X.jsx)(Xe.a,{enterDelay:500,placement:"top",title:"Task size.",children:Object(X.jsx)(ge.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(X.jsx)(Xe.a,{enterDelay:500,placement:"top",title:"Includes attachments.",children:Object(X.jsx)(va.a,{color:"disabled"})}):null]}),Object(X.jsx)(g.a,{sx:{fontWeight:"bold",mt:1},component:"div",children:null!==c&&void 0!==c?c:"Task Subject"}),Object(X.jsx)(g.a,{sx:{mb:1},variant:"subtitle2",children:null!=O?O+": "+b:null}),Object(X.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Object(X.jsx)(Xe.a,{enterDelay:500,title:"Start and end date.",children:Object(X.jsx)(ge.a,{icon:Object(X.jsx)(Oa.a,{}),size:"small",label:zt(j)+" - "+zt(d)})}),Object(X.jsx)(oa.a,{sx:{"& .MuiAvatar-root":{width:30,height:30,fontSize:16}},max:2,children:null===A||void 0===A?void 0:A.filter((function(e){return e})).map((function(e,t){return Object(X.jsx)(Xe.a,{title:e,children:Object(X.jsx)(lt.a,Object(l.a)({},Bt(e)))},t)}))})]})]})]})},Ta=a(120),Ca=a(494),Aa=a(586),ya=a(312),ka=a(215),Da=a(72),Pa=a.n(Da),Ia=a(582);function wa(e){var t=e.disabled,a=e.taskTypes,c=e.taskSizes,r=e.users,s=e.projectWBS,o=e.project,u=e.handleUpdateTasks,j=e.STATDES,d=Object(n.useState)(!1),b=Object(i.a)(d,2),O=b[0],h=b[1],x=Object(n.useState)(!1),m=Object(i.a)(x,2),f=m[0],p=m[1],E=Object(n.useState)(),T=Object(i.a)(E,2),C=T[0],A=T[1],y=Object(n.useState)(),k=Object(i.a)(y,2),D=k[0],P=k[1],I=Object(n.useState)(),w=Object(i.a)(I,2),N=w[0],R=w[1],U=Object(n.useState)(),L=Object(i.a)(U,2),F=L[0],M=L[1],W=Object(n.useState)(),B=Object(i.a)(W,2),_=B[0],G=B[1],z=Object(n.useState)(Pa()()),Y=Object(i.a)(z,2),V=Y[0],q=Y[1],Q=Object(n.useState)(Pa()()),K=Object(i.a)(Q,2),H=K[0],Z=K[1],J=Object(fe.b)(),$=J.enqueueSnackbar,ee=(J.closeSnackbar,Ut.EditorState.createEmpty()),te=Object(n.useState)(ee),ae=Object(i.a)(te,2),ce=ae[0],se=ae[1],ie=Object(Ft.a)({accept:"*",readAs:"DataURL"}),oe=Object(i.a)(ie,2),le=oe[0],ue=oe[1],je=ue.plainFiles,de=ue.filesContent,be=ue.clear,Oe=function(){h(!1)},he=function(){M(),A(),P(),R(),Oe(),p(!1)};return Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)(Ge.a,{disabled:t,size:"small",variant:"contained",startIcon:Object(X.jsx)(qe.a,{}),color:"inherit",onClick:function(){h(!0)},children:"Add a Task"}),Object(X.jsx)("div",{children:Object(X.jsxs)(la.a,{open:O,onClose:Oe,children:[Object(X.jsx)(da.a,{children:"Add a Task"}),Object(X.jsxs)(ua.a,{children:[Object(X.jsx)(_e.a,{autoFocus:!0,margin:"dense",id:"subject",label:"Subject",type:"subject",fullWidth:!0,variant:"standard",autoComplete:"off",value:C,onChange:function(e){return A(e.target.value)},sx:{mb:2}}),Object(X.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(X.jsx)(ra,{required:!0,title:"Assigned To",labelname:"USERLOGIN",items:r,onChange:function(e,t){return M(t)}}),Object(X.jsx)(ra,{title:"WBS",labelname:"WBS",items:s,onChange:function(e,t){return G(t)},description:"ACTDES"})]}),Object(X.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(X.jsx)(ra,{title:"Task Type",labelname:"CUSTNOTETYPEDES",items:a,onChange:function(e,t){return P(t)}}),Object(X.jsx)(ra,{title:"Task Size",labelname:"SIZENAME",items:c,onChange:function(e,t){return R(t)},description:"SIZEDES"})]}),Object(X.jsx)(ya.a,{dateAdapter:ka.a,children:Object(X.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},disableGutters:!0,children:[Object(X.jsx)(Aa.a,{disablePast:!0,ampm:!1,label:"Start Date & Time",value:V,onChange:function(e){return q(e)},renderInput:function(e){return Object(X.jsx)(_e.a,Object(l.a)({fullWidth:!0,sx:{m:1}},e))}}),Object(X.jsx)(Aa.a,{disablePast:!0,ampm:!1,label:"End Date & Time",value:H,onChange:function(e){return Z(e)},renderInput:function(e){return Object(X.jsx)(_e.a,Object(l.a)({fullWidth:!0,sx:{m:1}},e))}})]})}),Object(X.jsxs)(v.a,{maxWidth:!1,sx:{mt:1},children:[Object(X.jsx)(g.a,{variant:"subtitle",children:"Explanation of Task"}),Object(X.jsx)(ne.a,{children:Object(X.jsx)(Pt.Editor,{editorStyle:{height:"150px"},editorState:ce,onEditorStateChange:function(e){se(e)},toolbar:{image:{uploadCallback:Yt,previewImage:!0}}})})]}),Object(X.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex",flexWrap:"wrap",gap:"3px",mt:1},children:[0!=je.length?Object(X.jsx)(S.a,{color:"error","aria-label":"delete",component:"label",children:Object(X.jsx)(fa.a,{onClick:function(e){be()}})}):Object(X.jsx)(X.Fragment,{}),je.map((function(e,t){return Object(X.jsx)(ge.a,{label:e.name})}))]})]}),Object(X.jsxs)(Ca.a,{children:[Object(X.jsx)(Ge.a,{onClick:function(){return le()},variant:"outlined",startIcon:Object(X.jsx)(Ia.a,{}),children:"Add File"}),Object(X.jsx)(Ge.a,{onClick:Oe,children:"Cancel"}),Object(X.jsx)(Ge.a,{disabled:f,onClick:function(){var e,t,a;if(1===Object(Ut.convertToRaw)(ce.getCurrentContent()).blocks.length&""===Object(Ut.convertToRaw)(ce.getCurrentContent()).blocks[0].text)$("The task must have an explanation.",{variant:"error"});else if(C)if(void 0!==F){p(!0);var n=[];for(var c in de){var r={EXTFILEDES:de[c].name.split(".")[0],EXTFILENAME:de[c].content};n.push(r)}console.log(n);var s={SUBJECT:C,CUSTNOTETYPEDES:null!==(e=null===D||void 0===D?void 0:D.CUSTNOTETYPEDES)&&void 0!==e?e:"",ZMED_TASKSIZENAME:null!==(t=null===N||void 0===N?void 0:N.SIZENAME)&&void 0!==t?t:"",USERLOGIN:null===F||void 0===F?void 0:F.USERLOGIN,CURDATE:V.format("YYYY-MM-DD"),TILLDATE:H.format("YYYY-MM-DD"),STIME:V.format("HH:mm"),ETIME:H.format("HH:mm"),PROJDOCNO:o.DOCNO,WBS:null!==(a=null===_||void 0===_?void 0:_.WBS)&&void 0!==a?a:"",STATDES:j,TEXT:wt()(Object(Ut.convertToRaw)(null===ce||void 0===ce?void 0:ce.getCurrentContent())),CUSTNOTEEXTFILES:n};console.log(s),re.createTask(s).then((function(e){$("Task created succesfully.",{variant:"success"}),u(e.data),he(),console.log(e)})).catch((function(e){$("Error creating task.",{variant:"error"}),he(),console.log(e)}))}else $("Please select an Assigned To.",{variant:"error"});else $("Please fill out the Subject field.",{variant:"error"})},children:"Add"})]})]})})]})}var Na=Object(ia.a)(ne.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"}),Ra=function(e){var t=e.title,a=e.tasks,n=e.project,c=e.taskTypes,r=e.taskSizes,s=e.users,i=e.projectWBS,o=e.handleUpdateTasks,u=e.refreshTasks,j=e.handleTaskStatusChange;return Object(X.jsx)(Ta.c,{droppableId:t,type:"COLUMN",children:function(e,d){return Object(X.jsx)("div",Object(l.a)(Object(l.a)({},e.droppableProps),{},{ref:e.innerRef,children:Object(X.jsxs)(Na,{children:[Object(X.jsx)(g.a,{component:"h2",variant:"h6",color:"inherit",gutterBottom:!0,children:t||"Title"}),Object(X.jsx)("div",{style:{overflowY:"auto"},children:null===a||void 0===a?void 0:a.map((function(e,t){return Object(X.jsx)(Ta.b,{draggableId:e.CUSTNOTE.toString(),index:t,type:"TASK",children:function(t,a){return Object(X.jsx)("div",Object(l.a)(Object(l.a)(Object(l.a)({ref:t.innerRef},t.draggableProps),t.dragHandleProps),{},{children:Object(X.jsx)(Ea,{task:e,refreshTasks:u,handleTaskStatusChange:j},e.CUSTNOTE)}))}},e.CUSTNOTE.toString())}))}),e.placeholder,Object(X.jsx)(wa,{disabled:""===n,taskTypes:c,taskSizes:r,users:s,project:n,projectWBS:i,handleUpdateTasks:o,STATDES:t})]})}))}})},Ua=function(){return Object(X.jsx)(X.Fragment,{children:Object(de.a)(Array(6)).map((function(e,t){return Object(X.jsx)(Oe.a,{sx:{marginLeft:2,padding:8,display:"flex",flexDirection:"column"},variant:"rectangular",width:250,height:"75vh",style:{marginBottom:5}},t)}))})},La=function(){var e=Object(n.useState)([]),t=Object(i.a)(e,2),a=t[0],c=t[1],r=Object(n.useState)(""),s=Object(i.a)(r,2),o=s[0],u=s[1],j=Object(n.useState)([]),d=Object(i.a)(j,2),b=d[0],O=d[1],h=Object(n.useState)(!0),x=Object(i.a)(h,2),m=x[0],f=x[1],g=Object(fe.b)(),p=g.enqueueSnackbar,S=(g.closeSnackbar,Object(n.useState)()),E=Object(i.a)(S,2),T=E[0],C=E[1],A=Object(n.useState)([]),y=Object(i.a)(A,2),k=y[0],D=y[1],P=Object(n.useState)([]),I=Object(i.a)(P,2),w=I[0],N=I[1],R=Object(n.useState)([]),U=Object(i.a)(R,2),L=U[0],F=U[1],M=Object(n.useState)([]),W=Object(i.a)(M,2),B=W[0],_=W[1],G=Object(n.useState)(Pa()()),z=Object(i.a)(G,2),Y=(z[0],z[1],Object(n.useState)(Pa()())),V=Object(i.a)(Y,2),q=(V[0],V[1],Object(n.useMemo)((function(){if(!T)return b;var e=b.map((function(e){var t,a=null===e||void 0===e||null===(t=e.TASKS)||void 0===t?void 0:t.filter((function(e){var t=!0;for(var a in T)if(T[a]&&(void 0===e[a]||e[a]!==T[a])){t=!1;break}return t}));return Object(l.a)(Object(l.a)({},e),{},{TASKS:a})}));return e}),[T,b]));function Q(e,t){return t.forEach((function(t){var a=e.find((function(e){return e.STATDES===t.STATDES}));void 0!==a&&(a.TASKS||(a.TASKS=[]),a.TASKS.push(Object.assign({},t)))})),e}var K=function(e){if(!e)return[];var t=new Set;return e.forEach((function(e){e.TASKS&&e.TASKS.forEach((function(e){e.USERLOGIN&&t.add(e.USERLOGIN),e.USERLOGIN2&&t.add(e.USERLOGIN2),e.USERLOGIN3&&t.add(e.USERLOGIN3),e.USERLOGIN4&&t.add(e.USERLOGIN4),e.USERLOGIN5&&t.add(e.USERLOGIN5),e.USERLOGIN6&&t.add(e.USERLOGIN6),e.USERLOGIN7&&t.add(e.USERLOGIN7),e.USERLOGIN8&&t.add(e.USERLOGIN8)}))})),Object(de.a)(t)};function H(e,t){return e.filter((function(e){return void 0!==t.find((function(t){return t.STATDES===e.STATDES}))}))}Object(n.useEffect)(Object(At.a)(Ct.a.mark((function e(){var t,a,n,r,s,o;return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Promise.all([re.getTaskStatuses(),re.getUserProjects()]);case 3:t=e.sent,a=Object(i.a)(t,2),n=a[0],r=a[1],s=n.data.value,o=s.push({STATDES:"Cancelled"}),console.log(o),O(s),c(r.data.value),f(!1),e.next=18;break;case 15:e.prev=15,e.t0=e.catch(0),console.log(e.t0);case 18:case"end":return e.stop()}}),e,null,[[0,15]])}))),[]),Object(n.useEffect)(Object(At.a)(Ct.a.mark((function e(){var t,a,n,c,r;return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Promise.all([re.getTaskTypes(),re.getTaskSizes(),re.getUsers()]);case 3:t=e.sent,a=Object(i.a)(t,3),n=a[0],c=a[1],r=a[2],D(n.data.value),N(c.data.value),F(r.data.value),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(0),console.log(e.t0);case 16:case"end":return e.stop()}}),e,null,[[0,13]])}))),[]);var Z=function(e){o&&J(e,o)},J=function(){var e=Object(At.a)(Ct.a.mark((function e(t,a){return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==a&&(f(!0),u(a),void 0!=b&&O(((t=b).forEach((function(e){e.TASKS&&delete e.TASKS})),t)),re.getProjectTasks(a.DOCNO).then((function(e){var t=H(e.data.value,b),a=Q(b,t);O(a),console.log(a),console.log(K(a)),f(!1)})).catch((function(e){console.log(e)})),re.getProjectWBS(a.DOCNO).then((function(e){_(e.data.value)})).catch((function(e){console.log(e)})));case 1:case"end":return e.stop()}var t}),e)})));return function(t,a){return e.apply(this,arguments)}}(),$=function(){var e=Object(At.a)(Ct.a.mark((function e(t,a){return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:re.changeTaskStatus({CUSTNOTE:t,STATDES:a}).then((function(e){console.log(e)})).catch((function(e){p("Error updating task status in Priority.",{variant:"error"}),console.log(e)}));case 1:case"end":return e.stop()}}),e)})));return function(t,a){return e.apply(this,arguments)}}(),ee=function(e,t,a){var n=function(e,t,a,n){var c=e.find((function(e){return e.STATDES===t}));if(!c||!c.TASKS)return null;var r=c.TASKS.findIndex((function(e){return e.CUSTNOTE===n}));if(-1===r)return null;var s=c.TASKS.splice(r,1),o=Object(i.a)(s,1)[0],l=e.find((function(e){return e.STATDES===a}));if(!l)return null;l.TASKS||(l.TASKS=[]);return l.TASKS.push(o),e}(Object(de.a)(b),e,t,a);$(a,t),O(n)},te=function(){var e=Object(At.a)(Ct.a.mark((function e(t){var a,n,c;return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.destination){e.next=2;break}return e.abrupt("return");case 2:a=t.source.droppableId,n=t.destination.droppableId,c=parseInt(t.draggableId),ee(a,n,c);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var ae=function(e){var t=Q(Object(de.a)(b),[e]);O(t)};return Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)(v.a,{maxWidth:!1,sx:{display:"flex"},children:Object(X.jsx)(Ge.a,{disabled:!o||m,onClick:Z,sx:{m:1},size:"small",variant:"contained",children:"Refresh Tasks"})}),Object(X.jsxs)(v.a,{maxWidth:!1,sx:{display:"flex"},children:[Object(X.jsx)(ra,{title:"Project",labelname:"DOCNO",items:a,onChange:J,description:"PROJDES"}),Object(X.jsx)(ra,{disabled:""===o,title:"Assigned To",labelname:"",items:K(b),onChange:function(e,t){return C(Object(l.a)(Object(l.a)({},T),{},{USERLOGIN:t}))}}),Object(X.jsx)(ra,{disabled:""===o,title:"WBS",labelname:"",items:function(e){if(!e)return[];var t=new Set;return e.forEach((function(e){e.TASKS&&e.TASKS.forEach((function(e){e.WBS&&t.add(e.WBS)}))})),Object(de.a)(t)}(b),onChange:function(e,t){return C(Object(l.a)(Object(l.a)({},T),{},{WBS:t}))}}),Object(X.jsx)(ra,{disabled:""===o,title:"Task Type",labelname:"",items:function(e){if(!e)return[];var t=new Set;return e.forEach((function(e){e.TASKS&&e.TASKS.forEach((function(e){e.CUSTNOTETYPEDES&&t.add(e.CUSTNOTETYPEDES)}))})),Object(de.a)(t)}(b),onChange:function(e,t){return C(Object(l.a)(Object(l.a)({},T),{},{CUSTNOTETYPEDES:t}))}})]}),Object(X.jsx)(Ta.a,{onDragEnd:te,children:Object(X.jsx)(v.a,{maxWidth:!1,sx:{display:"flex",mt:2,mb:4},children:m?Object(X.jsx)(Ua,{}):null===q||void 0===q?void 0:q.filter((function(e){return"Cancelled"!==e.STATDES})).map((function(e){return Object(X.jsx)(Ra,{title:e.STATDES,tasks:e.TASKS,project:o,taskTypes:k,taskSizes:w,users:L,projectWBS:B,handleUpdateTasks:ae,refreshTasks:Z,handleTaskStatusChange:ee},e.DOCSTATUSSORT)}))})})]})},Fa=a(96);var Ma=function(e){return Object(X.jsx)(g.a,{component:"h2",variant:"h6",color:"primary",gutterBottom:!0,children:e.children})},Wa=a(605),Ba=a(632),_a=a(633),Ga=a(584);function za(e){var t=e.title,a=e.data,r=e.statusLabel,s=a.hasOwnProperty("value"),o=Object(n.useState)([]),l=Object(i.a)(o,2),u=l[0],j=l[1];return Object(n.useEffect)((function(){s&&r&&j(function(){var e,t={},n=Object(Fa.a)(a.value);try{for(n.s();!(e=n.n()).done;){var c=e.value[r];t[c]?t[c]+=1:t[c]=1}}catch(s){n.e(s)}finally{n.f()}return t}())}),[a]),Object(X.jsxs)(c.a.Fragment,{children:[Object(X.jsxs)(ne.a,{sx:{p:2,display:"flex",flexDirection:"column",minHeight:120},children:[Object(X.jsx)(Ma,{children:t}),s?Object(X.jsxs)(g.a,{component:"p",variant:"h4",children:[a.value.length," ",t]}):Object(X.jsx)(be.a,{})]}),Object(X.jsxs)(Wa.a,{disabled:0===u.length,children:[Object(X.jsx)(Ba.a,{expandIcon:Object(X.jsx)(Ga.a,{}),"aria-controls":"panel1a-content",id:"panel1a-header",children:Object(X.jsx)(g.a,{children:"Status Breakdown"})}),Object(X.jsx)(_a.a,{children:Object(X.jsx)("div",{children:Object.entries(u).map((function(e){var t=Object(i.a)(e,2),a=t[0],n=t[1];return Object(X.jsxs)(g.a,{color:"text.secondary",sx:{flex:1},children:[a,": ",n]},a)}))})})]})]})}var Ya=a(175),Va=[{type:"string",label:"Task ID"},{type:"string",label:"Task Name"},{type:"string",label:"Resource"},{type:"date",label:"Start Date"},{type:"date",label:"End Date"},{type:"number",label:"Duration"},{type:"number",label:"Percent Complete"},{type:"string",label:"Dependencies"}],qa={height:750,annotations:{style:"line",items:[{id:"Today",type:"line",mode:"horizontal",scaleID:"x",value:(new Date).toISOString(),style:{stroke:"red",strokeWidth:10}}]},gantt:{criticalPathEnabled:!1,defaultStartDateMillis:new Date,sortTasks:!1,innerGridHorizLine:{stroke:"#ffe0b2",strokeWidth:2},arrow:{angle:100,width:2,color:"green",radius:0}}};var Qa=function(){var e=function(e){return e.map((function(e){return[e.WBS,"".concat(e.WBS,": ").concat(e.ACTDES," ").concat(100===e.EXECPERCENT?"\u2705":""),e.WBS.substring(0,1),new Date(e.STARTDATE),new Date(e.ENDDATE),(t=new Date(e.ENDDATE)-new Date(e.STARTDATE),24*t*60*60*1e3/864e5+1),e.EXECPERCENT,e.PROJACTPRED_SUBFORM.filter((function(t){return t.WBS!==e.WBS})).map((function(e){return e.WBS})).join(", ")];var t}))},t=Object(n.useState)([]),a=Object(i.a)(t,2),c=a[0],r=a[1],s=Object(n.useState)(""),o=Object(i.a)(s,2),l=o[0],u=o[1],j=Object(n.useState)([]),d=Object(i.a)(j,2),b=d[0],O=d[1],h=[Va].concat(Object(de.a)(e(b)));return Object(n.useEffect)(Object(At.a)(Ct.a.mark((function e(){return Ct.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:re.getUserProjects().then((function(e){r(e.data.value)})).catch((function(e){console.log(e)}));case 1:case"end":return e.stop()}}),e)}))),[]),Object(n.useEffect)((function(){l&&re.getGanttWBS(l.DOCNO).then((function(t){var a=t.data.value[0].PROJACTS_SUBFORM;a[0].STARTDATE=new Date,a[0].ENDDATE=new Date,console.log(e(a)),console.log(a),O(a),qa.height=42*t.data.value[0].PROJACTS_SUBFORM.length})).catch((function(e){console.log(e)}))}),[l]),Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)(v.a,{maxWidth:!1,sx:{mt:2,display:"flex",maxWidth:500},children:Object(X.jsx)(ra,{title:"Project",labelname:"DOCNO",items:c,onChange:function(e,t){return u(t)},description:"PROJDES"})}),Object(X.jsx)(v.a,{maxWidth:!1,sx:{mt:2,display:"flex"},children:0!==b.length?Object(X.jsx)(Ya.a,{chartType:"Gantt",width:"100%",height:"50%",data:h,options:qa,chartEvents:[{callback:function(e){e.chartWrapper,e.google;!function(){for(var e=document.querySelectorAll("[id^=reactgooglegraph]")[0],t=e.getElementsByTagName("svg")[0].getElementsByTagName("g")[1].getElementsByTagName("text"),a=Number(t[0].getAttribute("y"))-25,n=0;n0?(n=t.data.value[0].ZMED_COMPANYCODE,r=t.data.value[0].CUSTDES,n===C?(c(e),a("Verification success.Please enter the user details",{variant:"success"}),l(!0),S(r)):(c(e),a("Invalid Company Code. Verification Failed",{variant:"error"}))):(c(e),a("Customer ID Not Exist",{variant:"error"}))})).catch((function(e){console.log("error:",e)})))},variant:"contained",sx:{mt:3,mb:2},children:"Verify Company"}),Object(X.jsx)(sn,{sx:{mt:1}})]})," "]}):Object(X.jsx)(X.Fragment,{}),o?Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)(g.a,{component:"h1",variant:"h5",children:"User Sign Up"}),Object(X.jsxs)(h.a,{component:"form",noValidate:!0,sx:{mt:1},children:[Object(X.jsx)(_e.a,{margin:"normal",required:!0,fullWidth:!0,id:"firstname",label:"Firstname",name:"firstname",autoComplete:"firstname",inputProps:{maxLength:16},onChange:function(e){return R(e.target.value)},autoFocus:!0}),Object(X.jsx)(_e.a,{margin:"normal",required:!0,fullWidth:!0,id:"lastname",label:"Lastname",name:"lastname",autoComplete:"lastname",inputProps:{maxLength:20},onChange:function(e){return M(e.target.value)},autoFocus:!0}),Object(X.jsx)(_e.a,{margin:"normal",required:!0,fullWidth:!0,id:"email",label:"Email",name:"email",autoComplete:"email",onChange:function(e){return q(e.target.value)},autoFocus:!0}),Object(X.jsx)(_e.a,{margin:"normal",fullWidth:!0,id:"phone",label:"Phone",name:"phone",autoComplete:"phone",onChange:function(e){return G(e.target.value)},autoFocus:!0}),Object(X.jsx)(_e.a,{margin:"normal",required:!0,fullWidth:!0,id:"username",label:"Username",name:"username",autoComplete:"username",inputProps:{maxLength:48},onChange:function(e){return Z(e.target.value)},autoFocus:!0}),Object(X.jsx)(Ge.a,{type:"submit",fullWidth:!0,sx:{mt:3,backgroundColor:"#C00932",color:"white","&:hover":{backgroundColor:"#C00932"}},disabled:""===N||""===F||""===V||""===H,onClick:function(t){e=a("User Signup is in progress...",{variant:"warning"}),t.preventDefault();var n=N+" "+F;re.checkContact(n).then((function(e){0===e.data.value.length?function(){var e={FIRSTNAME:N,LASTNAME:F,EMAIL:V,FIRM:p,PHONENUM:_,CUSTNAME:O};re.createContact(e).then((function(e){200===e.status||201===e.status?ae(e.data.NAME):a("Contact Creation Failed",{variant:"error"})})).catch((function(e){console.log("error:",e)}))}():ae(n)})).catch((function(e){console.log("error:",e)}))},children:"Sign up"}),Object(X.jsx)(sn,{sx:{mt:1}})]})]}):Object(X.jsx)(X.Fragment,{})," "]})})]})]})}function un(e){return Object(X.jsxs)(g.a,Object(l.a)(Object(l.a)({variant:"body2",color:"text.secondary",align:"center"},e),{},{children:["Copyright \xa9 ",Object(X.jsx)(nn.a,{color:"inherit",href:"https://medatechuk.com/",children:"Medatech UK"})," ",(new Date).getFullYear(),"."]}))}on=Object(j.a)(on,{palette:{red:on.palette.augmentColor({color:{main:"#C00932"},name:"red"})}});var jn=Object(j.a)();function dn(){var e=Object(fe.b)(),t=e.enqueueSnackbar,a=(e.closeSnackbar,c.a.useState(!1)),n=Object(i.a)(a,2),r=n[0],s=n[1],u=c.a.useState(!1),j=Object(i.a)(u,2),O=j[0],x=j[1],m=c.a.useState({}),f=Object(i.a)(m,2),p=f[0],S=f[1],v=c.a.useState(!1),T=Object(i.a)(v,2),C=T[0],A=T[1],y=function(e){return S((function(t){return Object(l.a)(Object(l.a)({},t),{},Object(o.a)({},e.target.name,e.target.value))}))};return Object(X.jsxs)(d.a,{theme:jn,children:[r?Object(X.jsx)(We.a,{to:"/dashboard"}):null,C?Object(X.jsx)(ln,{}):Object(X.jsxs)(E.a,{container:!0,component:"main",sx:{height:"100vh"},children:[Object(X.jsx)(b.a,{}),Object(X.jsx)(E.a,{item:!0,xs:!1,sm:4,md:7,sx:{backgroundImage:"url(https://www.bloorresearch.com/wp-content/uploads/2016/01/medatech-transparent-logo.png)",backgroundRepeat:"no-repeat",backgroundColor:function(e){return"light"===e.palette.mode?e.palette.grey[50]:e.palette.grey[900]},backgroundSize:"natural",backgroundPosition:"center"}}),Object(X.jsx)(E.a,{item:!0,xs:12,sm:8,md:5,component:ne.a,elevation:6,square:!0,children:Object(X.jsxs)(h.a,{sx:{my:8,mx:4,display:"flex",flexDirection:"column",alignItems:"center"},children:[Object(X.jsx)(lt.a,{sx:{m:1,bgcolor:"primary.main"},children:Object(X.jsx)(rn.a,{})}),Object(X.jsx)(g.a,{component:"h1",variant:"h5",children:O?"Change Password":"Sign in"}),Object(X.jsxs)(h.a,{component:"form",noValidate:!0,onSubmit:function(e){e.preventDefault();var a=new FormData(e.currentTarget);O?a.get("password")==a.get("confirmpassword")?_.changePassword(a).then((function(e){200==e.status?(t("Successfully changed password! Please login.",{variant:"success"}),x(!1)):t("Problem occurred changing password.",{variant:"error"})})):t("Passwords do not match.",{variant:"warning"}):_.login(a).then((function(e){1==e.data.newUser?(t("Please change your password.",{variant:"warning"}),x(!0)):(t("Successfully logged in!",{variant:"success"}),localStorage.setItem("token",e.data.token),s(!0),window.location.reload())})).catch((function(e){t(e.response.data.message,{variant:"error"})}))},sx:{mt:1},children:[Object(X.jsx)(_e.a,{margin:"normal",required:!0,fullWidth:!0,id:"username",label:"Username",name:"username",autoComplete:"username",onChange:y,sx:{pointerEvents:O?"none":"auto"},autoFocus:!0}),Object(X.jsx)(_e.a,{margin:"normal",required:!0,fullWidth:!0,name:"password",label:O?"New Password":"Password",type:"password",id:"password",autoComplete:"current-password",onChange:y}),O?Object(X.jsx)(_e.a,{margin:"normal",required:!0,fullWidth:!0,name:"confirmpassword",label:"Confirm Password",type:"password",id:"confirmpassword",onChange:y}):null,O?Object(X.jsx)(Ge.a,{type:"submit",fullWidth:!0,variant:"contained",sx:{mt:3,mb:2},children:"Change Password"}):Object(X.jsxs)(X.Fragment,{children:[Object(X.jsx)(Ge.a,{type:"submit",fullWidth:!0,variant:"contained",sx:{mt:3},children:"Sign In"}),Object(X.jsx)(Ge.a,{type:"submit",fullWidth:!0,onClick:function(e){e.preventDefault(),A(!0)},sx:{mt:1},children:"Sign Up"}),Object(X.jsx)(Ge.a,{onClick:function(e){console.log(p),_.forgotPassword(p).then((function(e){console.log(e.data)})).catch((function(e){console.log(e)}))},fullWidth:!0,sx:{mt:3},children:"Forgot password?"})]}),Object(X.jsx)(un,{sx:{mt:1}})]})]})})]})]})}var bn=function(){return Object(X.jsx)("div",{className:"App",children:Object(X.jsx)(ga.a,{children:Object(X.jsx)(fe.a,{children:Object(X.jsx)(U.a,{children:Object(X.jsxs)(We.d,{children:[Object(X.jsx)(ht,{exact:!0,path:"/",children:Object(X.jsx)(We.a,{to:"/dashboard"})}),Object(X.jsx)(ht,{path:"/dashboard",component:an}),Object(X.jsx)(We.b,{exact:!0,path:"/login",component:dn}),Object(X.jsx)(ht,{component:an})]})})})})})},On=function(e){e&&e instanceof Function&&a.e(3).then(a.bind(null,634)).then((function(t){var a=t.getCLS,n=t.getFID,c=t.getFCP,r=t.getLCP,s=t.getTTFB;a(e),n(e),c(e),r(e),s(e)}))};s.a.render(Object(X.jsx)(c.a.StrictMode,{children:Object(X.jsx)(bn,{})}),document.getElementById("root")),On()}},[[477,1,2]]]); //# sourceMappingURL=main.87c0a157.chunk.js.map