PageSourceSearch

https://ewto.cz/assets/clenska-sekce.admin.wingtsun.index-CaQxXB-f.js

js ewto.cz collected 2026-10-03 00:59:48 UTC 8,236 bytes, 1 lines download raw bytes

1import{u as W,r as i,s as o,F as $,j as e,L as u,t as d}from"./index-BU9aKsLO.js";import{A as R}from"./AdminShell-yAchtskS.js";import{P as p}from"./Panel-Co6GLb7W.js";import{R as U}from"./RichTextEditor-BbVlNpN9.js";import{P as z}from"./PlacementToggles-C7j6HLzg.js";import{P as A}from"./plus-C-WgneQM.js";import{P as N}from"./pencil-BjJ3L7HS.js";import{C as E}from"./chevron-up-CGBcZk2C.js";import{C as M}from"./chevron-down-BMQ2b0oc.js";import"./MemberNav-d-q_MhYr.js";import"./ResizeHandle-D8TyJDKv.js";import"./youtube-B2IkwWNv.js";function X(){const _=W(),[x,h]=i.useState(""),[b,v]=i.useState(!1),[g,f]=i.useState(!1),[l,C]=i.useState({}),[w,P]=i.useState([]);async function m(){const[t,s]=await Promise.all([o.from("site_pages").select("slug, body_html, updated_at, sort_order, show_in_wingtsun, show_in_clanky").like("slug","wingtsun-%"),o.from("articles").select("id, slug, title, body_html, sort_order, show_in_wingtsun, show_in_clanky").eq("show_in_wingtsun",!0)]),n={};for(const r of t.data??[])n[r.slug.replace(/^wingtsun-/,"")]={hasContent:!!(r.body_html&&r.body_html.trim()),updatedAt:r.updated_at,sortOrder:r.sort_order??0,showWingtsun:r.show_in_wingtsun,showClanky:r.show_in_clanky};C(n),P((s.data??[]).map(r=>({kind:"article",id:r.id,slug:r.slug,title:r.title,subtitle:r.slug,hasContent:!!(r.body_html&&r.body_html.trim()),sortOrder:r.sort_order??0,showWingtsun:r.show_in_wingtsun,showClanky:r.show_in_clanky})))}i.useEffect(()=>{(async()=>{const{data:t}=await o.from("site_pages").select("body_html").eq("slug","wingtsun").maybeSingle();h(t?.body_html??""),v(!0),await m()})()},[]);const c=i.useMemo(()=>[...$.filter(s=>l[s.slug]?.showWingtsun!==!1).map(s=>({kind:"page",id:s.slug,slug:s.slug,title:s.title,subtitle:`wingtsun-${s.slug}`,hasContent:l[s.slug]?.hasContent??!1,sortOrder:l[s.slug]?.sortOrder??0,showWingtsun:l[s.slug]?.showWingtsun??!0,showClanky:l[s.slug]?.showClanky??!1})),...w].sort((s,n)=>{const r=s.sortOrder||9999,a=n.sortOrder||9999;return r!==a?r-a:s.title.localeCompare(n.title,"cs")}),[l,w]);async function y(t){for(let s=0;s<t.length;s++){const n=t[s];if(n.sortOrder===s+1)continue;const{error:r}=n.kind==="page"?await o.from("site_pages").upsert({slug:`wingtsun-${n.slug}`,sort_order:s+1},{onConflict:"slug"}):await o.from("articles").update({sort_order:s+1}).eq("id",n.id);if(r){d.error(r.message);break}}m()}function j(t,s){const n=[...c],r=Math.max(0,Math.min(n.length-1,s)),[a]=n.splice(t,1);return n.splice(r,0,a),n}async function k(t,s){const n=c.findIndex(r=>
1r.id===t);n<0||n+s<0||n+s>=c.length||await y(j(n,n+s))}async function S(t,s){const n=c.findIndex(r=>r.id===t);n<0||!Number.isFinite(s)||s!==n+1&&(await y(j(n,Math.round(s)-1)),d.success("Pořadí uloženo."))}async function T(t,s,n){const r=s==="show_in_wingtsun"?t.showClanky:t.showWingtsun;if(!n&&!r){d.error("Článek musí být alespoň v jedné sekci.");return}const{error:a}=t.kind==="page"?await o.from("site_pages").upsert({slug:`wingtsun-${t.slug}`,[s]:n},{onConflict:"slug"}):await o.from("articles").update({[s]:n}).eq("id",t.id);if(a){d.error(a.message);return}m()}async function O(t){t.preventDefault(),f(!0);const{error:s}=await o.from("site_pages").upsert({slug:"wingtsun",body_html:x||null,updated_at:new Date().toISOString()});if(f(!1),s){d.error(s.message);return}d.success("Text stránky WingTsun uložen.")}return e.jsxs(R,{title:"WINGTSUN",children:[e.jsx("form",{onSubmit:O,children:e.jsxs(p,{className:"mb-6",children:[e.jsx("h3",{className:"mb-4 text-sm font-semibold uppercase tracking-widest text-brand",children:"Text stránky WingTsun"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Obsah stránky"}),b?e.jsx(U,{value:x,onChange:h,placeholder:"Napište text stránky WingTsun…"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Načítám…"})]}),e.jsx("div",{className:"flex items-center justify-end gap-3",children:e.jsx("button",{type:"submit",disabled:g||!b,className:"rounded-md bg-brand px-5 py-2 text-sm font-bold uppercase text-brand-foreground hover:opacity-90 disabled:opacity-50",children:g?"Ukládám…":"Uložit text"})})]})]})}),e.jsx(p,{className:"mb-6 p-3 md:p-4",children:e.jsx("div",{className:"flex justify-center",children:e.jsxs("button",{type:"button",onClick:()=>_.navigate({to:"/clenska-sekce/admin/wingtsun/clanek/$id",params:{id:"new"}}),className:"inline-flex items-center gap-2 rounded-md bg-brand px-4 py-2 text-sm font-bold uppercase text-brand-foreground hover:opacity-90",children:[e.jsx(A,{size:14}),"Nový článek"]})})}),e.jsxs(p,{children:[e.jsx("h3",{className:"mb-4 text-sm font-semibold uppercase tracking-widest text-brand",children:"Články na stránce WingTsun"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left text-xs uppercase tracking-widest text-muted-foreground",children:[e.jsx("th",{className:"w-[320px] min-w-[320px] py-2 pr-3 font-semibold",children:"Titulek"}),e.jsx("th",{className:"w-full","aria-hidden":"true"}),e.jsx("th",{className:"whitespace-nowrap py-2 pr-3 font-semibold",children:"Umístění"}),e.jsx("th",{className:"whitespace-nowrap py-2 pr-3 font-semibold",children:"Stav"}),e.jsx("th",{className:"whitespace-nowrap py-2 pr-3 font-semibold",children:"Pořadí"}),e.jsx("th",{className:"whitespace-nowrap py-2 pr-0 text-left font-semibold",children:"Akce"})]})}),e.jsx("tbody",{children:c.map((t,s)=>{const n=t.kind==="page"?e.jsxs(u,{to:"/clenska-sekce/admin/wingtsun/$slug",params:{slug:t.slug},className:"inline-flex items-center gap-1 rounded-md border border-border bg-card px-2 py-1 text-xs hover:border-brand",children:[e.jsx(N,{size:12})," Upravit"]}):e.jsxs(u,{to:"/clenska-sekce/admin/wingtsun/clanek/$id",params:{id:t.id},className:"inline-flex items-center gap-1 rounded-md border border-border bg-card px-2 py-1 text-xs hover:border-brand",children:[e.jsx(N,{size:12})," Upravit"]});return e.jsxs("tr",{className:"border-b border-border/60 last:border-0",children:[e.jsxs("td",{className:"w-[320px] min-w-[320px] py-2 pr-3",children:[t.kind==="page"?e.jsx(u,{to:"/clenska-sekce/admin/wingtsun/$slug",params:{slug:t.slug},className:"font-medium hover:text-brand",children:t.title}):e.jsx(u,{to:"/clenska-sekce/admin/wingtsun/clanek/$id",params:{id:t.id},className:"font-medium hover:text-brand",children:t.title}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.subtitle})]}),e.jsx("td",{className:"w-full","aria-hidden":"true"}),e.jsx("td",{className:"whitespace-nowrap py-2 pr-3",children:e.jsx(z,{wingtsun:t.showWingtsun,clanky:t.showClanky,onToggle:(r,a)=>T(t,r,a)})}),e.jsx("td",{className:"whitespace-nowrap py-2 pr-3",children:t.hasContent?e.jsx("span",{className:"inline-flex items-center rounded-full border border-brand/40 bg-brand/10 px-2 py-0.5 text-xs font-semibold uppercase text-brand",children:"Publikováno"}):e.jsx("span",{className:"inline-flex items-center rounded-full border border-border bg-card px-2 py-0.5 text-xs text-muted-foreground",children:"Prázdné"})}),e.jsx("td",{className:"whitespace-nowrap py-2 pr-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",inputMode:"numeric",defaultValue:s+1,onBlur:r=>S(t.id,Number(r.target.value)),onKeyDown:r=>{r.key==="Enter"&&r.target.blur()},className:"w-12 rounded-md border border-border bg-input px-2 py-1 text-center text-xs"},`${t.id}-${s}-${t.sortOrder}`),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{type:"button","aria-label":"Posunout nahoru",onClick:()=>k(t.id,-1),className:"rounded-t-md border border-border bg-card px-1 hover:border-brand hover:text-brand",children:e.jsx(E,{size:12})}),e.jsx("button",{type:"button","aria-label":"Posunout dolů",onClick:()=>k(t.id,1),className:"-mt-px rounded-b-md border border-border bg-card px-1 hover:border-brand hover:text-brand",children:e.jsx(M,{size:12})})]})]})}),e.jsx("td",{className:"whitespace-nowrap py-2 pr-0 text-left",children:n})]},t.id)})})]})})]})]})}export{X as component};

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.