PageSourceSearch

https://hintermoos.at/assets/ForumCategoryEdit-CVPUDILE.js

js hintermoos.at collected 2026-10-09 22:02:02 UTC 8,659 bytes, 6 lines download raw bytes

1import{c as Y,E as ee,a as te,t as ae,r,s as n,j as e,m as x,w as B,K as T,N as Z,x as G,y as l,I as v,B as f}from"./index-MoAbC8_9.js";import{A as K}from"./AdminPageLayout-DL0avA2R.js";import{T as V}from"./textarea-4z16PwID.js";import{D as re,a as se}from"./dialog-DrI7Oddz.js";import{S as oe}from"./sparkles-OdPvYVOS.js";import{S as ie}from"./save-DWdLHugL.js";import"./Layout-jB2m3rBw.js";import"./Header-CnJGZ8vQ.js";import"./mountain-BHfTfCFy.js";import"./user-Cvsz7Lm_.js";import"./collapsible-BIxz44zB.js";import"./breadcrumb-CmKLwRya.js";import"./AdminSidebar-B1OFksO6.js";import"./scroll-area-CoT3wSM0.js";import"./index-BdQq_4o_.js";import"./bell-CKHJStUz.js";import"./clipboard-list-CzdQdj9P.js";import"./file-text-Bif0RP8Y.js";import"./users-xui-UtA1.js";import"./building-crte1H4H.js";import"./calculator-GhS8BFwe.js";import"./upload-BH1HltYO.js";import"./wallet-e9E2tgeo.js";import"./calendar-CnsXUgOr.js";import"./trending-up-Cg9WFJWB.js";import"./trending-down-EHPUNHPt.js";import"./settings-BUFFH3UG.js";import"./database-yc2noHJi.js";import"./file-search-B2CpYcS_.js";import"./chevron-down-BDe4YKQW.js";import"./house-DjS1WMqx.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ne=Y("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),Te=()=>{const{id:o}=ee(),y=te(),{toast:i}=ae(),s=o==="new",[H,q]=r.useState(!s),[w,j]=r.useState(!1),[c,C]=r.useState(""),[z,S]=r.useState(""),[I,P]=r.useState(""),[m,_]=r.useState(null),[d,E]=r.useState(null),[u,F]=r.useState(!1),[g,N]=r.useState(""),[b,A]=r.useState(!1),[R,U]=r.useState(!1),[k,L]=r.useState("");r.useEffect(()=>{!s&&o&&$(o)},[o]);const $=async t=>{var h;const{data:a,error:p}=await n.from("forum_categories").select("*").eq("id",t).single();if(p||!a){i({variant:"destructive",title:"Chyba",description:"Kategorie nenalezena."}),y("/admin?section=forum");return}C(a.name),S(a.slug),P(a.description||""),_(a.image_url),N(a.ai_image_prompt||""),L(((h=a.sort_order)==null?void 0:h.toString())||""),q(!1)},J=async()=>{if(!(!o||s)){A(!0);try{const{data:t,error:a}=await n.functions.invoke("generate-category-image",{body:{categoryId:o,action:"build_prompt"}});if(a)throw a;if(t!=null&&t.prompt)N(t.prompt),i({title:"Hotovo",description:"Automatický prompt byl načten – můžete ho upravit."});else throw new Error((t==null?void 0:t.error)||"Nepodařilo se sestavit prompt.")}catch(t){i({variant:"destructive",title:"Chyba",description:t instanceof Error?t.message:"Nepodařilo se sestavit prompt."})}finally{A(!1)}}},M=async()=>{if(!(!o||s)){F(!0);try{const{data:t,error:a}=await n.functions.invoke("generate-category-image",{body:{categoryId:o,customPrompt:g.trim()||void 0}});if(a)throw a;if(t!=null&&t.imageUrl)_(t.imageUrl),E(null),i({title:"Hotovo",description:"Obrázek byl vygenerován pomocí AI."});else throw new Error((t==null?void 0:t.error)||"AI nevrátila obrázek.")}catch(t){i({variant:"destructive",title:"Chyba",description:t instanceof Error?t.message:"Nepodařilo se vygenerovat obrázek."})}finally{F(!1)}}},Q=async()=>{if(!c.trim()){i({variant:"destructive",title:"Chyba",description:"Název je povinný."});return}j(!0);let t=m;if(d){const h=d.name.split(".").pop(),D=`${Date.now()}.${h}`,{error:W}=await n.storage.from("forum-images").upload(D,d);if(W){i({variant:"destructive",title:"Chyba",description:"Nepodařilo se nahrát obrázek."}),j(!1);return}const{data:X}=n.storage.from("forum-images").getPublicUrl(D);t=X.publicUrl}const a={name:c.trim(),slug:z.trim()||c.trim().toLowerCase().replace(/\s+/g,"-"),description:I.trim()||null,image_url:t,ai_image_prompt:g.trim()||null,sort_order:k?parseInt(k):null};let p;s?{error:p}=await n.from("forum_categories").insert([a]):{error:p}=await n.from("forum_categories").update(a).eq("id",o),p?i({variant:"destructive",title:"Chyba",description:"Nepodařilo se uložit kategorii."}):(i({title:"Uloženo",description:s?"Kategorie byla vytvořena.":"Kategorie byla aktualizována."}),y("/admin?section=forum")),j(!1)};if(H)return e.jsx(K,{title:"Načítám...",activeSection:"forum",breadcrumbs:[{label:"Fórum",href:"/admin?section=forum"}],children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(x,{className:"h-8 w-8 animate-spin text-primary"})})});const O=s?"Nová kategorie":c;return e.jsxs(K,{title:O,activeSection:"forum",breadcrumbs:[{label:"Fórum",href:"/admin?section=forum"},{label:O}],children:[e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs(B,{children:[e.jsx(T,{children:e.jsx(Z,{className:"font-serif",children:"Základní údaje"})}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Název"}),e.jsx(v,{id:"name",value:c,onChange:t=>C(t.target.value),placeholder:"Název kategorie"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"slug",children:"Slug (URL)"}),e.jsx(v,{id:"slug",value:z,onChange:t=>S(t.target.value),placeholder:"automaticky z názvu"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"sortOrder",children:"Pořadí řazení"}),e.jsx(v,{id:"sortOrder",type:"number",value:k,onChange:t=>L(t.target.value),placeholder:"0",className:"max-w-[120px]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Popis"}),e.jsx(V,{id:"description",value:I,onChange:t=>P(t.target.value),rows:3,placeholder:"Popis kategorie"})]})]})]}),e.jsxs(B,{children:[e.jsx(T,{children:e.jsx(Z,{className:"font-serif",children:"Obrázek"})}),e.jsxs(G,{className:"space-y-4",children:[m&&!d&&e.jsxs("button",{type:"button",onClick:()=>U(!0),className:"group relative block rounded border overflow-hidden focu
6s:outline-none focus:ring-2 focus:ring-primary",title:"Zobrazit ve větším",children:[e.jsx("img",{src:m,alt:"Aktuální obrázek",className:"h-32 w-48 object-cover"}),e.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(ne,{className:"h-6 w-6 text-white"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"image",children:"Nahrát nový obrázek"}),e.jsx(v,{id:"image",type:"file",accept:"image/*",onChange:t=>{var a;return E(((a=t.target.files)==null?void 0:a[0])||null)},className:"max-w-sm"})]}),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx(l,{children:"Nebo nechat vytvořit AI"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{htmlFor:"aiPrompt",className:"text-xs font-normal text-muted-foreground",children:"Výchozí prompt pro AI (nepovinné, uloží se s kategorií) – když je vyplněný, použije se jako kompletní zadání"}),e.jsx(V,{id:"aiPrompt",value:g,onChange:t=>N(t.target.value),rows:5,maxLength:5e3,placeholder:"Nechte prázdné pro automatický prompt, nebo klikněte na „Načíst automatický prompt“ a upravte ho."}),e.jsxs("p",{className:"text-[11px] text-muted-foreground text-right",children:[g.length,"/5000"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{type:"button",variant:"outline",onClick:M,disabled:u||b||s,children:[u?e.jsx(x,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(oe,{className:"h-4 w-4 mr-2"}),u?"Generuji obrázek…":"Vygenerovat pomocí AI"]}),e.jsxs(f,{type:"button",variant:"ghost",onClick:J,disabled:u||b||s,children:[b&&e.jsx(x,{className:"h-4 w-4 mr-2 animate-spin"}),"Načíst automatický prompt"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s?"Nejprve kategorii uložte, poté můžete obrázek vygenerovat.":"Vytvoří fotorealistický obrázek podle názvu a popisu kategorie a ihned ho uloží. „Načíst automatický prompt“ vloží plné automatické zadání do pole, kde ho můžete upravit."})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(f,{onClick:Q,disabled:w,children:[w?e.jsx(x,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ie,{className:"h-4 w-4 mr-2"}),s?"Vytvořit kategorii":"Uložit změny"]}),e.jsx(f,{variant:"outline",onClick:()=>y("/admin?section=forum"),children:"Zrušit"})]})]}),e.jsx(re,{open:R,onOpenChange:U,children:e.jsx(se,{className:"max-w-4xl p-2",children:m&&e.jsx("img",{src:m,alt:"Náhled obrázku kategorie",className:"w-full h-auto max-h-[85vh] object-contain rounded"})})})]})};export{Te 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.