/opt/canhelp/apps/web/.next/static/chunks
Edit: /opt/canhelp/apps/web/.next/static/chunks/7797.f44d1d20dafa108a.js (5364B)
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7797],{7797:(e,t,r)=>{r.r(t),r.d(t,{TaskMapClient:()=>f});var a=r(4568),n=r(9742),s=r.n(n);r(8162),r(5114),r(9144),r(7230);var i=r(7620),l=r(9664),o=r.n(l),c=r(9906),d=r(4017);let u={athens:[37.9838,23.7275],thessaloniki:[40.6401,22.9444],patras:[38.2466,21.7346],heraklion:[35.3387,25.1442],larissa:[39.6386,22.4191],volos:[39.3666,22.9427],ioannina:[39.665,20.8537],chania:[35.5138,24.018],rhodes:[36.4341,28.2176],kavala:[40.9396,24.404],"athens-center":[37.9838,23.7275],kolonaki:[37.9784,23.7447],exarchia:[37.9869,23.7339],monastiraki:[37.9755,23.7235],piraeus:[37.9497,23.6458],glyfada:[37.8636,23.7523],kifissia:[38.0736,23.8139],marousi:[38.05,23.8063],chalandri:[38.0215,23.8008],holargos:[37.998,23.7946],"nea-smyrni":[37.9458,23.7176],kallithea:[37.9568,23.7063],"thessaloniki-center":[40.6401,22.9444],kalamaria:[40.5832,22.9622],stavroupoli:[40.6703,22.918]},h=[38,23.7];function f(e){var t,r;let{filterParams:n,catMap:l,locMap:f,mode:m="all",fullscreen:x=!1}=e,{locale:p}=(0,c.Y)(),g=(0,i.useRef)(null),b=(0,i.useRef)(null),k=(0,i.useRef)(null),[y,v]=(0,i.useState)([]),[w,j]=(0,i.useState)(!0),[N,C]=(0,i.useState)(null),z=(0,i.useCallback)(async()=>{j(!0);try{var e;let t=new URLSearchParams({...n,limit:"200"}),r="for_me"===m?"/tasks/for-me":"/tasks",a=await fetch("".concat("https://api.canhelp.gr","/api").concat(r,"?").concat(t),{credentials:"include"}),s=await a.json();v(null!=(e=s.data)?e:[])}catch(e){v([])}finally{j(!1)}},[n,m]);return(0,i.useEffect)(()=>{z()},[z]),(0,i.useEffect)(()=>{if(!g.current||b.current)return;let e=s().map(g.current,{center:h,zoom:7,zoomControl:!0});return s().tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"\xa9 OpenStreetMap contributors",maxZoom:19}).addTo(e),b.current=e,()=>{e.remove(),b.current=null}},[]),(0,i.useEffect)(()=>{let e=b.current;if(!e||w)return;k.current&&(e.removeLayer(k.current),k.current=null);let t=s().markerClusterGroup({maxClusterRadius:60,disableClusteringAtZoom:13,iconCreateFunction:e=>{let t=e.getChildCount();return s().divIcon({html:'
'.concat(t,"
"),className:"",iconSize:[44,44],iconAnchor:[22,22]})}});y.forEach((e,r)=>{let a=e.task||e,[n,i]=function(e,t){let r=31337*t;return[e[0]+(r%100/100-.5)*.006,e[1]+(7*r%100/100-.5)*.008]}(function(e){if(!e)return h;if(u[e])return u[e];for(let[t,r]of Object.entries(u))if(t.startsWith(e)||e.startsWith(t))return r;return h}(a.location),r),l=a.budget,o=l?"€".concat(l):"\uD83E\uDD1D",c=l?9*o.length+20:36,d=s().divIcon({html:'
'.concat(o,"
"),className:"",iconSize:[c,30],iconAnchor:[c/2,15]}),f=s().marker([n,i],{icon:d});f.on("click",()=>C(a)),t.addLayer(f)}),e.addLayer(t),k.current=t},[y,w]),(0,a.jsxs)("div",{className:"relative ".concat(x?"w-full h-full":"rounded-xl overflow-hidden border border-gray-200"),style:x?void 0:{height:580},children:[(0,a.jsx)("div",{ref:g,className:"w-full h-full"}),w&&(0,a.jsx)("div",{className:"absolute inset-0 bg-white/80 flex items-center justify-center z-[1000]",children:(0,a.jsx)("div",{className:"w-8 h-8 border-2 border-green-500 border-t-transparent rounded-full animate-spin"})}),!w&&(0,a.jsxs)("div",{className:"absolute top-3 left-3 z-[1000] bg-white/90 backdrop-blur-sm rounded-lg px-3 py-1.5 text-sm font-medium text-gray-700 shadow-sm border border-gray-200",children:[y.length," ","ru"===p?"заказов":"en"===p?"tasks":"εργασίες"]}),N&&(0,a.jsx)("div",{className:"absolute bottom-0 left-0 right-0 z-[1000] bg-white border-t border-gray-200 p-4 shadow-lg",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[N.category&&(0,a.jsx)("span",{className:"text-xs font-medium text-green-600 bg-green-50 px-2 py-0.5 rounded-full",children:null!=(t=l[N.category])?t:N.category}),N.location&&(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:["\uD83D\uDCCD ",null!=(r=f[N.location])?r:N.location]})]}),(0,a.jsx)("p",{className:"font-semibold text-gray-900 truncate",children:(0,d.Oj)(N,p)}),N.budget&&(0,a.jsxs)("p",{className:"text-sm text-green-600 font-bold mt-0.5",children:["€",N.budget]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsx)(o(),{href:"/tasks/".concat(N.id),className:"px-4 py-1.5 bg-green-500 text-white text-sm font-medium rounded-lg hover:bg-green-600 transition",children:"ru"===p?"Открыть":"en"===p?"View":"Άνοιγμα"}),(0,a.jsx)("button",{onClick:()=>C(null),className:"p-1.5 text-gray-400 hover:text-gray-600 transition",children:(0,a.jsx)("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})})]})}}}]);