(this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{269:function(e,t,n){},270:function(e,t,n){},428:function(e,t,n){"use strict";n.r(t);var a=n(0),c=n.n(a),r=n(24),i=n.n(r),s=(n(269),n.p,n(270),n(1)),o=n(2);var l,j,u=n(19),d=n(237),b=n(5),p=n(17),O=n(469),m=n(10),h=n(21),f=n(233),x=n(463),g=n(153),v=n(15),_=n(87),y=n(468),w=n(457),C=n(459),N=n(470),S=n(460),k=n(472),F=n(467),P=n(458),L=n(461),E=n(462),M=function(e){var t=e.options,n=e.optionLabel,r=e.name,i=e.setCurrentFilter,l=e.currentFilter,j=c.a.useState({}),u=Object(s.a)(j,2),d=u[0],b=u[1];return Object(a.useEffect)((function(){var e,t=Object.keys(d).filter((function(e){return!0===d[e]}));console.log(t),e=t,console.log(r),i(Object(_.a)(Object(_.a)({},l),{},Object(v.a)({},r,e)))}),[d]),Object(o.jsx)(o.Fragment,{children:Object(o.jsx)(O.a,{className:"filter-content",children:Object(o.jsxs)(y.a,{defaultExpanded:!0,children:[Object(o.jsx)(w.a,{style:{color:"#a20067",fontWeight:"600"},expandIcon:Object(o.jsx)(P.a,{width:"20px",style:{color:"#a20067"}}),children:n}),Object(o.jsx)(C.a,{style:{maxHeight:"250px",overflowY:"auto"},children:Object(o.jsx)(N.a,{component:"fieldset",variant:"standard",children:Object(o.jsx)(S.a,{children:null===t||void 0===t?void 0:t.map((function(e){return Object(o.jsx)(k.a,{className:"filter-row",control:Object(o.jsx)(F.a,{onChange:function(e){return t=e,console.log(t.target.name+t.target.checked),void b(Object(_.a)(Object(_.a)({},d),{},Object(v.a)({},t.target.name,t.target.checked)));var t},name:e,icon:Object(o.jsx)(L.a,{width:"20px"}),checkedIcon:Object(o.jsx)(E.a,{width:"20px",style:{color:"#a20067"}})}),label:e},e)}))})})})]})})})},A=function(e){e.data;var t=e.states,n=e.zips,a=e.currentFilter,c=e.setCurrentFilter,r=function(e){return e?e.sort((function(e,t){var n=e.toLowerCase(),a=t.toLowerCase();return na?1:0})):[]};return Object(o.jsx)(o.Fragment,{children:Object(o.jsxs)(O.a,{className:"filter-container",children:[Object(o.jsx)(M,{optionLabel:"State",options:r(t),setCurrentFilter:c,currentFilter:a,name:"impexium_org_addresses.state_or_province"}),Object(o.jsx)(M,{optionLabel:"Zip Code",options:r(n),setCurrentFilter:c,currentFilter:a,name:"impexium_org_addresses.postal_code"})]})})},z=n(473),I=n(464),T=n(429),R=n(14),B=n(88),U={width:"100%",height:"60vh"},D=40.745,H=-100.523,J=function(e){var t=e.data,n=Object(B.d)({googleMapsApiKey:"AIzaSyCjIVWhWhdqL3wce3e-Ldh-mfF73ZPgP_g"}).isLoaded,c=Object(a.useState)(null),r=Object(s.a)(c,2),i=(r[0],r[1]),l=Object(a.useState)({name:"",address:"",latLong:{lat:D,lng:H}}),j=Object(s.a)(l,2),u=j[0],d=j[1],b=Object(a.useState)([]),p=Object(s.a)(b,2),O=p[0],f=p[1],x=Object(a.useState)(!1),g=Object(s.a)(x,2),v=g[0],_=g[1],y=Object(a.useMemo)((function(){return{disableDefaultUI:!0}}),[]);Object(a.useEffect)((function(){N(t)}),[]);var w=Object(a.useCallback)((function(e){i(e)}),[]),C=Object(a.useCallback)((function(e){i(null)}),[]),N=function(){var e=Object(h.a)(Object(m.a)().mark((function e(t){return Object(m.a)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===t||void 0===t||t.map((function(e){if(e["impexium_org_addresses.location"]){var t={name:e["impexium_orgs.name"],address:e["impexium_org_addresses.address_line_1"]+", "+e["impexium_org_addresses.city"]+", "+e["impexium_org_addresses.state_or_province"]+", "+e["impexium_org_addresses.postal_code"],latLong:{lat:e["impexium_org_addresses.location"][0],lng:e["impexium_org_addresses.location"][1]}};f((function(e){return[].concat(Object(R.a)(e),[t])}))}}));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return Object(o.jsx)(o.Fragment,{children:n?Object(o.jsxs)(B.a,{mapContainerStyle:U,center:u.latLong,zoom:4,onLoad:w,onUnmount:C,options:y,children:[null===O||void 0===O?void 0:O.map((function(e){return Object(o.jsx)(B.c,{position:e.latLong,onClick:function(t){var n;n=e,_(!0),d(n)}})})),v?Object(o.jsx)(B.b,{onCloseClick:function(){return _(!1)},position:u.latLong,options:{pixelOffset:new window.google.maps.Size(0,-40)},children:Object(o.jsxs)("div",{children:[Object(o.jsx)("h4",{children:u.name}),Object(o.jsx)("div",{children:u.address})]})}):""]}):""})},q=n(89),G=n.n(q),W="...",Z=function(e,t){var n=t-e+1;return Array.from({length:n},(function(t,n){return n+e}))},K=function(e){var t=e.onPageChange,n=e.totalCount,c=e.siblingCount,r=void 0===c?1:c,i=e.currentPage,s=e.pageSize,l=e.className,j=function(e){var t=e.totalCount,n=e.pageSize,c=e.siblingCount,r=void 0===c?1:c,i=e.currentPage;return Object(a.useMemo)((function(){var e=Math.ceil(t/n);if(r+5>=e)return Z(1,e);var a=Math.max(i-r,1),c=Math.min(i+r,e),s=a>2,o=c0&&(e[t]=N[t].join(","))})),console.log(N),console.log(e),fetch("/api/upick/run_query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,type:"json"})}).then((function(e){return e.json()})).then((function(e){return i(e)})).then((function(e){return L(1)})).then((function(e){return q(!1)}))}),[N]);var ce=function(e,t){var n=new Blob([e],{type:"csv"}),a=document.createElement("a");a.download=t,a.href=window.URL.createObjectURL(n);var c=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});a.dispatchEvent(c),a.remove()},re=function(){te(!ee)};return Object(o.jsxs)(o.Fragment,{children:[Object(o.jsx)(z.a,{open:R,className:"load-backdrop",children:Object(o.jsx)("div",{className:"loader"})}),Object(o.jsxs)(x.a,{style:{alignItems:"flex-start"},children:[Object(o.jsxs)(O.a,{style:{flexGrow:"1"},children:[Object(o.jsxs)(x.a,{className:"data-details",children:[Object(o.jsxs)("h3",{className:"page-statistics",children:["Showing ",r.length," results"]}),Object(o.jsx)(I.a,{style:{fontFamily:"Poppins"},color:"primary",variant:"contained",onClick:function(){var e={};Object.keys(N).map((function(t){N[t].length>0&&(e[t]=N[t].join(","))})),V(!0),fetch("/api/upick/run_query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,type:"csv"})}).then((function(e){return e.json()})).then((function(e){return ce(e,"supplier_db.csv")})).then((function(e){return V(!1)}))},href:"#",children:"Download data"}),Object(o.jsx)(I.a,{style:{fontFamily:"Poppins"},color:"primary",variant:"contained",className:"show-filter-button",onClick:re,href:"#",children:"Show Filters"}),Z?Object(o.jsx)("div",{className:"loader relative-position"}):""]}),H?Object(o.jsx)("div",{className:"data-loading-backdrop",children:Object(o.jsx)("div",{className:"loader"})}):Object(o.jsxs)(o.Fragment,{children:[Object(o.jsx)("div",{className:"map-layout",children:Object(o.jsx)(J,{data:r})}),Object(o.jsxs)("div",{className:"grid-card-layout",children:[null===ne||void 0===ne?void 0:ne.map((function(e){return Object(o.jsx)(Y,{dataRow:e})})),Object(o.jsx)(K,{className:"pagination-bar",currentPage:P,totalCount:r.length,pageSize:8,onPageChange:function(e){return L(e)}})]})]})]}),Object(o.jsxs)(O.a,{style:{width:"300px"},className:ee?"filter-section active":"filter-section",children:[Object(o.jsxs)(x.a,{children:[Object(o.jsx)("h3",{children:"Filter By"}),Object(o.jsx)(T.a,{onClick:re,className:"mobile-button-exit",color:"primary",children:Object(o.jsx)(Q.a,{style:{color:"black",width:"20px"}})})]}),Object(o.jsx)(A,{data:r,states:u,zips:_,currentFilter:N,setCurrentFilter:S})]})]})]})};!function(e){e.APP_HOME="/",e.APP_HOME_PARAMS="/:params",e.CONFIG_ROUTE="/config"}(j||(j={}));var $=function(e){e.route,e.routeState;return Object(o.jsx)(d.a,{children:Object(o.jsx)(b.c,{children:Object(o.jsx)(b.a,{path:j.APP_HOME,element:Object(o.jsx)(X,{})})})})},ee=(Object(p.c)(O.a)(l||(l=Object(u.a)(["\n display: grid;\n grid-gap: 20px;\n grid-template-columns: 200px auto;\n width: 100vw;\n"]))),n(466)),te=function(){return Object(o.jsx)("div",{className:"App",children:Object(o.jsx)("header",{className:"App-header",children:Object(o.jsx)(ee.a,{loadGoogleFonts:!0,children:Object(o.jsx)($,{})})})})},ne=function(e){e&&e instanceof Function&&n.e(3).then(n.bind(null,474)).then((function(t){var n=t.getCLS,a=t.getFID,c=t.getFCP,r=t.getLCP,i=t.getTTFB;n(e),a(e),c(e),r(e),i(e)}))};i.a.render(Object(o.jsx)(c.a.StrictMode,{children:Object(o.jsx)(te,{})}),document.getElementById("root")),ne()}},[[428,1,2]]]); //# sourceMappingURL=main.6ec46318.chunk.js.map