1import{r as d,j as t}from"./main-Bmw7chmx.js";import{u as c}from"./useQuery-CraJ5e4a.js";import{u}from"./useMutation-DOeBEZLC.js";function x(){const{data:l,refetch:n}=c({queryKey:["todos"],queryFn:()=>fetch("/demo/api/tq-todos").then(e=>e.json()),initialData:[]}),{mutate:a}=u({mutationFn:e=>fetch("/demo/api/tq-todos",{method:"POST",body:JSON.stringify(e)}).then(i=>i.json()),onSuccess:()=>n()}),[o,s]=d.useState(""),r=d.useCallback(async()=>{await a(o),s("")},[a,o]);return t.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gradient-to-br from-red-900 via-red-800 to-black p-4 text-white",style:{backgroundImage:"radial-gradient(50% 50% at 80% 20%, #3B021F 0%, #7B1028 60%, #1A000A 100%)"},children:t.jsxs("div",{className:"w-full max-w-2xl p-8 rounded-xl backdrop-blur-md bg-black/50 shadow-xl border-8 border-black/10",children:[t.jsx("h1",{className:"text-2xl mb-4",children:"TanStack Query Todos list"}),t.jsx("ul",{className:"mb-4 space-y-2",children:l?.map(e=>t.jsx("li",{className:"bg-white/10 border border-white/20 rounded-lg p-3 backdrop-blur-sm shadow-md",children:t.jsx("span",{className:"text-lg text-white",children:e.name})},e.id))}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("input",{type:"text",value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&r()},placeholder:"Enter a new todo...",className:"w-full px-4 py-3 rounded-lg border border-white/20 bg-white/10 backdrop-blur-sm text-white placeholder-white/60 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent"}),t.jsx("button",{disabled:o.trim().length===0,onClick:r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-blue-500/50 disabled:cursor-not-allowed text-white font-bold py-3 px-4 rounded-lg transition-colors",children:"Add todo"})]})]})})}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.