import{u as b,r as t,j as e,L as S,C as f,t as d,s as y}from"./index-BH-cN4KT.js";import{u as C}from"./Combination-CBlSanWE.js";import{u as L}from"./use-auth-wvxHCDzg.js";import{B as w}from"./button-ChRro_zr.js";import{L as a,I as o}from"./index-JcJvmTtT.js";import{T as N}from"./textarea-CoYww7K9.js";import{S as I,a as B,b as E,c as T,d as k}from"./select-BNBMX4QM.js";import{S as _,a as R}from"./SiteFooter-QgwBtC-h.js";import"./index-BwAEo5n7.js";import"./index-BqQI1ugW.js";import"./upload-9grwbX0d.js";function M(){const x=b(),{user:n}=L(),[r,h]=t.useState(""),[i,g]=t.useState(""),[l,j]=t.useState(""),[u,p]=t.useState("opinion"),[m,v]=t.useState(""),c=C({mutationFn:async()=>{const{error:s}=await y.from("citizen_submissions").insert({submitter_id:n.id,submitter_name:n.email?.split("@")[0],title:r,body:i,location:l,category:u,image_url:m||null});if(s)throw s},onSuccess:()=>{d.success("Submission received — our editors will review."),x({to:"/"})},onError:s=>d.error(s.message)});return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(_,{}),e.jsxs("main",{className:"container mx-auto px-4 py-12 max-w-2xl",children:[e.jsx(S,{to:"/",className:"text-xs text-muted-foreground",children:"← Back"}),e.jsx("h1",{className:"font-serif text-4xl font-black italic mt-2 mb-2",children:"Submit a Story"}),e.jsx("p",{className:"text-muted-foreground mb-8",children:"Share news from your community. Our editors review every submission before publishing."}),e.jsxs("form",{onSubmit:s=>{s.preventDefault(),c.mutate()},className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Headline"}),e.jsx(o,{required:!0,value:r,onChange:s=>h(s.target.value),maxLength:200})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Category"}),e.jsxs(I,{value:u,onValueChange:p,children:[e.jsx(B,{children:e.jsx(E,{})}),e.jsx(T,{children:f.map(s=>e.jsx(k,{value:s.slug,children:s.name},s.slug))})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Location"}),e.jsx(o,{value:l,onChange:s=>j(s.target.value),placeholder:"e.g. Blantyre",maxLength:120})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Image URL (optional)"}),e.jsx(o,{type:"url",value:m,onChange:s=>v(s.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Your story"}),e.jsx(N,{required:!0,rows:10,value:i,onChange:s=>g(s.target.value),maxLength:5e3})]}),e.jsx(w,{type:"submit",disabled:c.isPending||!r||!i,children:"Submit for review"})]})]}),e.jsx(R,{})]})}export{M as component};
