1import{r as a,u as k,j as e,H as B,T as C,B as E}from"./index-CRzFJT5-.js";import{C as P,a as I,b as z,c as q}from"./card-C-j4uAIC.js";import{I as i}from"./input-OMPQu2El.js";import{C as A}from"./checkbox-BSzaqy8c.js";import"./index-DxrObFQ3.js";import"./check-CqkF_iWq.js";function J(){const[c,d]=a.useState(""),[u,l]=a.useState(""),[m,h]=a.useState(""),[g,p]=a.useState(""),[x,b]=a.useState("Sleutelslim.nl"),[j,v]=a.useState(!0),[f,S]=a.useState(!1),[n,o]=a.useState(""),{toast:N}=k(),w=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),F=t=>{const s=t.target.value;d(s),l(w(s))},T=async t=>{t.preventDefault(),S(!0),o("");try{const s={title:c,slug:u,summary:m,content:g,author:x,published:j};console.log("Verzenden van blogpost:",s);const y=await fetch("/api/blog/posts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),r=await y.json();if(console.log("Server antwoord:",r),!y.ok)throw new Error(r.message||"Er is een fout opgetreden");o("Blog succesvol gepubliceerd: "+r.message),N({title:"Success",description:"Blog succesvol gepubliceerd"}),d(""),l(""),h(""),p(""),b("Sleutelslim.nl"),v(!0)}catch(s){console.error("Fout bij verzenden:",s),o("Fout: "+(s instanceof Error?s.message:"Onbekende fout")),N({title:"Fout",description:"Er is een fout opgetreden bij het publiceren",variant:"destructive"})}finally{S(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(B,{children:[e.jsx("meta",{name:"description",content:"Internal admin tool voor het aanmaken van blog posts"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"container mx-auto py-8 max-w-4xl",children:[e.jsx("h1",{className:"text-3xl font-bold mb-6",children:"Eenvoudige Blog Post"}),n&&e.jsx("div",{className:`p-4 mb-6 rounded ${n.includes("Fout")?"bg-red-100 text-red-700":"bg-green-100 text-green-700"}`,children:n}),e.jsxs(P,{children:[e.jsx(I,{children:e.jsx(z,{children:"Nieuwe blogpost maken"})}),e.jsx(q,{children:e.jsxs("form",{onSubmit:T,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"title",className:"text-sm font-medium",children:"Titel"}),e.jsx(i,{id:"title",value:c,onChange:F,placeholder:"Titel van de blogpost",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"slug",className:"text-sm font-medium",children:"Slug"}),e.jsx(i,{id:"slug",value:u,onChange:t=>l(t.target.value),placeholder:"url-vriendelijke-naam"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Automatisch gegenereerd, kan handmatig worden aangepast"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"summary",className:"text-sm font-medium",children:"Samenvatting"}),e.jsx(C,{id:"summary",value:m,onChange:t=>h(t.target.value),placeholder:"Korte samenvatting van de blogpost",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"content",className:"text-sm font-medium",children:"Inhoud"}),e.jsx(C,{id:"content",value:g,onChange:t=>p(t.target.value),placeholder:"Volledige inhoud van de blogpost",className:"min-h-[200px]",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"author",className:"text-sm font-medium",children:"Auteur"}),e.jsx(i,{id:"author",value:x,onChange:t=>b(t.target.value),placeholder:"Naam van de auteur"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(A,{id:"published",checked:j,onCheckedChange:t=>v(t)}),e.jsx("label",{htmlFor:"published",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Publiceren"})]}),e.jsx(E,{type:"submit",disabled:f,className:"w-full",children:f?"Bezig met publiceren...":"Publiceren"})]})})]})]})]})}export{J 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.