PageSourceSearch

https://kohutka.ski/assets/AdminSlopesLifts-C_ogCaht.js

js kohutka.ski collected 2026-10-05 18:05:28 UTC 6,688 bytes, 1 lines download raw bytes

1import{b as P,u as C,c as _,j as e}from"./vendor-query-w13htfY7.js";import{r as z}from"./vendor-react-CpNMnHCI.js";import{B as u,C as f,l as h,i as k,j as $,J as q,K as D,A,f as E,q as K}from"./index-BW1oKuoX.js";import{S}from"./switch-CcVJOkcK.js";import{R as Q,I as T,L as F,b as H,af as I,Q as M,a1 as R}from"./vendor-ui-BUBC8xYC.js";import"./vendor-charts-CcRMfeTO.js";import"./vendor-supabase-BydePhaj.js";import"./index-BRkP7VGl.js";function Y(){const p=P(),{data:d,isLoading:j,refetch:O}=C({queryKey:["holiday-info-details"],queryFn:E,staleTime:60*1e3}),{data:l=[],isLoading:L}=C({queryKey:["slopes-lifts-overrides"],queryFn:K,staleTime:30*1e3}),c=_({mutationFn:q,onSuccess:()=>{p.invalidateQueries({queryKey:["slopes-lifts-overrides"]})}}),r=_({mutationFn:({id:s,updates:a})=>D(s,a),onSuccess:()=>{p.invalidateQueries({queryKey:["slopes-lifts-overrides"]}),A.success("Uloženo")},onError:s=>{A.error("Chyba: "+s.message)}});z.useEffect(()=>{if(!d||l.length>0)return;(async()=>{const a=d.slopesDetailed||[],i=d.liftsDetailed||[];for(const t of a)await c.mutateAsync({id:`slope_${t.id}`,type:"slope",name:t.name,is_open:t.status_code===2||t.status_code===6,mode:"auto"});for(const t of i)await c.mutateAsync({id:`lift_${t.id}`,type:"lift",name:t.name,is_open:t.status_code===1||t.status_code===3,mode:"auto"})})()},[d,l.length]);const o=(s,a)=>l.find(i=>i.id===`${s}_${a}`),g=(s,a,i)=>{const t=o(s,a);return t&&t.mode==="manual"?t.is_open:i},v=async(s,a,i,t)=>{const n=`${s}_${a}`,w=l.find(x=>x.id===n);if(w){const x=w.mode==="auto"?"manual":"auto";await r.mutateAsync({id:n,updates:{mode:x}})}else await c.mutateAsync({id:n,type:s,name:i,is_open:t,mode:"manual"})},y=async(s,a)=>{const i=`${s}_${a}`,t=l.find(n=>n.id===i);t&&t.mode==="manual"&&await r.mutateAsync({id:i,updates:{is_open:!t.is_open}})},m=j||L,N=(d==null?void 0:d.slopesDetailed)||[],b=(d==null?void 0:d.liftsDetailed)||[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Sjezdovky a lanovky"}),e.jsx("p",{className:"text-gray-600 mt-1",children:"Manuální přepis stavu sjezdovek a lanovek"})]}),e.jsxs(u,{variant:"outline",onClick:()=>O(),disabled:m,children:[e.jsx(Q,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),"Obnovit API data"]})]}),e.jsx(f,{className:"bg-blue-50 border-blue-200",children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(T,{className:"w-5 h-5 text-blue-500 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-800",children:[e.jsx("p",{className:"font-medium mb-1",children:"Jak to funguje:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Auto"})," - stav se načítá automaticky z Holiday Info API"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Manuální"})," - můžete přepsat stav ručně (otevřeno/zavřeno)"]})]})]})]})})}),m&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(F,{className:"w-8 h-8 animate-spin text-primary"})}),!m&&e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs(f,{children:[e.jsx(k,{className:"bg-primary text-primary-foreground rounded-t-lg",children:e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-5 h-5"}),"Sjezdovky (",N.length,")"]})}),e.jsx(h,{className:"p-0",children:e.jsx("div",{className:"divide-y",children:N.map(s=>{const a=s.status_code===2||s.status_code===6,i=o("slope",s.id),t=(i==null?void 0:i.mode)==="manual",n=g("slope",s.id,a);return e.jsxs("div",{className:`p-4 flex items-center justify-between ${t?"bg-primary/5":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${n?"bg-green-100":"bg-red-100"}`,children:n?e.jsx(I,{className:"w-5 h-5 text-green-600"}):e.jsx(M,{className:"w-5 h-5 text-red-600"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-6 mr-2 text-xs font-bold bg-primary/10 text-primary rounded",children:s.id}),s.name]}),e.jsxs("div",{className:"text-xs text-gray-500 ml-8",children:["API: ",a?"otevřeno":"zavřeno"]}
1)]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsx(u,{variant:n?"default":"destructive",size:"sm",onClick:()=>y("slope",s.id),disabled:r.isPending,children:n?"Otevřeno":"Zavřeno"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs ${t?"text-gray-500":"font-medium"}`,children:"Auto"}),e.jsx(S,{checked:t,onCheckedChange:()=>v("slope",s.id,s.name,a),disabled:r.isPending||c.isPending}),e.jsx("span",{className:`text-xs ${t?"font-medium":"text-gray-500"}`,children:"Manuální"})]})]})]},s.id)})})})]}),e.jsxs(f,{children:[e.jsx(k,{className:"bg-primary text-primary-foreground rounded-t-lg",children:e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5"}),"Vleky a lanovky (",b.length,")"]})}),e.jsx(h,{className:"p-0",children:e.jsx("div",{className:"divide-y",children:b.map(s=>{const a=s.status_code===1||s.status_code===3,i=o("lift",s.id),t=(i==null?void 0:i.mode)==="manual",n=g("lift",s.id,a);return e.jsxs("div",{className:`p-4 flex items-center justify-between ${t?"bg-primary/5":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${n?"bg-green-100":"bg-red-100"}`,children:n?e.jsx(I,{className:"w-5 h-5 text-green-600"}):e.jsx(M,{className:"w-5 h-5 text-red-600"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-6 mr-2 text-xs font-bold bg-primary/10 text-primary rounded",children:s.id}),s.name]}),e.jsxs("div",{className:"text-xs text-gray-500 ml-8",children:["API: ",a?"otevřeno":"zavřeno"," | ",s.type_text]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsx(u,{variant:n?"default":"destructive",size:"sm",onClick:()=>y("lift",s.id),disabled:r.isPending,children:n?"Otevřeno":"Zavřeno"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs ${t?"text-gray-500":"font-medium"}`,children:"Auto"}),e.jsx(S,{checked:t,onCheckedChange:()=>v("lift",s.id,s.name,a),disabled:r.isPending||c.isPending}),e.jsx("span",{className:`text-xs ${t?"font-medium":"text-gray-500"}`,children:"Manuální"})]})]})]},s.id)})})})]})]})]})}export{Y as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.