1 line
5.7 KiB
JavaScript
1 line
5.7 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[8859],{8859:function(e,r,t){t.r(r),t.d(r,{default:function(){return z}});var n=t(29439),i=t(47313),o=t(7266),s=t(69099),c=t(51629),l=t(66835),a=t(23477),u=t(24076),d=t(67478),h=t(57861),x=t(42832),p=t(61113),f=t(66212),Z=t(85281),m=t(97316),g=t(25963),j=t(71049),b=t(19860),v=t(58467),y=t(1413),k=t(1550),w=t(49914),C=t(41727),S=t(47131),E=t(38393),N=t(23195),P=t(46417),L=function(e){var r=e.value,t=e.onChange,n=e.sx,o=e.placeholder,s=void 0===o?"Search (Ctrl + K)":o,c=(0,b.Z)(),l=(0,i.useRef)(null);return(0,i.useEffect)((function(){var e=function(e){var r;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(r=l.current)||void 0===r||r.focus());"Escape"===e.key&&document.activeElement===l.current&&l.current.blur()};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}),[]),(0,P.jsx)(k.Z,{fullWidth:!0,sx:{},children:(0,P.jsx)(w.Z,{inputRef:l,placeholder:s,sx:(0,y.Z)({borderRadius:0},n),value:r,onChange:t,autoComplete:"off",size:"large",startAdornment:(0,P.jsx)(C.Z,{position:"start",sx:{mr:-.5,color:c.palette.secondary.main},children:(0,P.jsx)(E.Z,{})}),endAdornment:(0,P.jsx)(S.Z,{sx:{visibility:r?"visible":"hidden"},onClick:function(){return t({target:{value:""}})},children:(0,P.jsx)(N.Z,{style:{fontSize:"large",color:c.palette.primary.main}})})})})},R=t(95569),z=function(){var e=(0,v.s0)(),r=(0,b.Z)(),t=(0,i.useRef)(),y=(0,i.useRef)(),k=i.useState(0),w=(0,n.Z)(k,2),C=(w[0],w[1],i.useState(10)),S=(0,n.Z)(C,2),E=S[0],N=(S[1],(0,i.useState)("")),z=(0,n.Z)(N,2),T=z[0],A=z[1],F=(0,i.useState)(""),H=(0,n.Z)(F,2),I=H[0],K=H[1];(0,i.useEffect)((function(){var e=setTimeout((function(){K(T)}),400);return function(){return clearTimeout(e)}}),[T]);var M=(0,g.N)({queryKey:["customers",E,I],queryFn:j.kc,getNextPageParam:function(e){return e.nextPage}}),W=M.data,_=(M.isLoading,M.isError,M.error,M.fetchNextPage),q=M.hasNextPage,D=M.isFetchingNextPage,O=W?W.pages.flatMap((function(e){return e.details})):[];(0,i.useEffect)((function(){W&&console.log(W)}),[W]),(0,i.useEffect)((function(){if(q){var e=new IntersectionObserver((function(e){e[0].isIntersecting&&_()}),{root:document.querySelector(".MuiTableContainer-root"),rootMargin:"0px",threshold:1});return t.current&&e.observe(t.current),function(){t.current&&e.unobserve(t.current)}}}),[q,_]);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(o.Z,{title:"Customers",secondary:(0,P.jsx)(s.Z,{variant:"contained",onClick:function(){return e("/nearle/customers/create")},children:"Create Customers"})}),(0,P.jsx)(m.Z,{content:!1,sx:{width:"100%",overflow:"hidden"},title:(0,P.jsx)(L,{value:T,placeholder:"Search Location",onChange:function(e){return A(e.target.value)},sx:{width:"100%",maxWidth:300,minWidth:200,bgcolor:"white"}}),children:(0,P.jsx)(c.Z,{onScroll:function(e){var r=e.currentTarget,t=r.scrollTop,n=r.scrollHeight;t+r.clientHeight>=n-50&&q&&!D&&_()},ref:y,sx:{width:"100%",borderBottom:1,borderColor:"divider",maxHeight:"calc(100vh - 200px)",overflow:"auto","&::-webkit-scrollbar":{width:"12px",cursor:"pointer"},"&::-webkit-scrollbar-thumb":{backgroundColor:r.palette.primary.main,borderRadius:"8px",cursor:"pointer"},"&::-webkit-scrollbar-thumb:hover":{backgroundColor:r.palette.primary.dark,cursor:"pointer"},"&::-webkit-scrollbar-track":{backgroundColor:r.palette.primary.lighter,cursor:"pointer"}},children:(0,P.jsxs)(l.Z,{stickyHeader:!0,children:[(0,P.jsx)(a.Z,{sx:{},children:(0,P.jsxs)(u.Z,{sx:{backgroundColor:r.palette.primary.main},children:[(0,P.jsx)(d.Z,{sx:{position:"sticky!important",bgcolor:"secondary.light"},children:"#"}),(0,P.jsx)(d.Z,{sx:{position:"sticky!important",bgcolor:"secondary.light"},children:"Name"}),(0,P.jsx)(d.Z,{sx:{position:"sticky!important",bgcolor:"secondary.light"},children:"suburb"}),(0,P.jsx)(d.Z,{sx:{position:"sticky!important",bgcolor:"secondary.light"},children:"Address"}),(0,P.jsx)(d.Z,{sx:{position:"sticky!important",bgcolor:"secondary.light"},children:"Lat/Lng"})]})}),(0,P.jsxs)(h.Z,{children:[0==(null===O||void 0===O?void 0:O.length)&&(0,P.jsx)(u.Z,{children:(0,P.jsx)(d.Z,{colSpan:5,children:(0,P.jsx)(R.Z,{description:"Customer Not Found"})})}),null===O||void 0===O?void 0:O.map((function(e,r){return(0,P.jsxs)(u.Z,{children:[(0,P.jsx)(d.Z,{children:r+1}),(0,P.jsx)(d.Z,{children:(0,P.jsxs)(x.Z,{children:[(0,P.jsx)(p.Z,{variant:"subtitle1",children:e.firstname}),(0,P.jsx)(p.Z,{variant:"subtitle2",children:e.contactno}),(0,P.jsx)(p.Z,{variant:"subtitle2",children:"ID : ".concat(e.customerid)})]})}),(0,P.jsx)(d.Z,{children:(0,P.jsxs)(x.Z,{children:[(0,P.jsx)(p.Z,{variant:"subtitle1",children:e.suburb}),(0,P.jsx)(p.Z,{variant:"subtitle2",children:e.city})]})}),(0,P.jsx)(d.Z,{children:e.address}),(0,P.jsx)(d.Z,{children:(0,P.jsxs)(x.Z,{display:"flex",flexDirection:"column",gap:2,children:[(0,P.jsx)(f.Z,{size:"small",label:e.latitude}),(0,P.jsx)(f.Z,{size:"small",label:e.longitude})]})})]},r)})),0!=(null===O||void 0===O?void 0:O.length)&&(0,P.jsx)(u.Z,{children:(0,P.jsx)(d.Z,{colSpan:15,rowSpan:3,children:(0,P.jsx)("div",{ref:t,style:{height:40,textAlign:"center"},children:D||q?(0,P.jsx)(Z.Z,{}):"No More Orders"})})})]})]})})})]})}},7266:function(e,r,t){var n=t(1413),i=(t(47313),t(19860)),o=t(9019),s=t(56104),c=t(42832),l=t(61113),a=t(46417);r.Z=function(e){var r=e.title,t=e.secondary,u=e.sx,d=(0,i.Z)();return(0,a.jsx)(o.ZP,{container:!0,spacing:2,children:(0,a.jsx)(s.Z,{sx:(0,n.Z)({position:"sticky",top:"60px",bgcolor:d.palette.background.default,zIndex:1,width:"100%"},u),children:(0,a.jsx)(o.ZP,{item:!0,xs:12,children:(0,a.jsxs)(c.Z,{direction:"row",justifyContent:"space-between",sx:{p:1,flexWrap:"wrap"},children:[(0,a.jsx)(l.Z,{variant:"h3",children:r}),t&&t]})})})})}}}]); |