1import{r as s,j as e,o as f,ak as E,a9 as g,u as I,ai as L,a as q,a7 as z,b as i}from"./index-BWR2MJxN.js";import{o as G}from"./imageOptimizer-DQPMF8kR.js";function B(){const[r,m]=s.useState(1),[h,j]=s.useState([]),[A,o]=s.useState(!0),[l,w]=s.useState(null),[n,N]=s.useState(null),[u,v]=s.useState(""),[c,p]=s.useState(!1),[d,y]=s.useState(null),[F,S]=s.useState(!1),[C,b]=s.useState(!1);s.useEffect(()=>{async function t(){try{const a=await i.auth.me();if(!a){b(!0),o(!1);return}y(a);const U=new Date,P=(await i.entities.MinistryEvent.filter({published:!0})).filter(x=>new Date(x.start_date)<U).sort((x,D)=>new Date(D.start_date)-new Date(x.start_date));j(P),o(!1)}catch{b(!0),o(!1)}}t()},[]);const k=t=>{var a;N(((a=t.target.files)==null?void 0:a[0])||null)},_=async()=>{if(!(!n||!l)){p(!0);try{const t=await G(n),{file_url:a}=await i.integrations.Core.UploadFile({file:t});await i.entities.PhotoApproval.create({user_id:d.id,user_email:d.email,user_name:d.full_name,event_id:l.id,event_name:l.title,photo_url:a,caption:u||"",status:"pending",uploaded_at:new Date().toISOString()}),S(!0)}catch(t){console.error("Upload failed:",t),alert("Failed to upload photo. Please try again.")}p(!1)}};return A?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(f,{className:"w-8 h-8 text-[#e71d32] animate-spin"})}):C?e.jsx("div",{className:"min-h-screen bg-[#F9F8F6] flex items-center justify-center px-4",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-5",children:e.jsx(E,{className:"w-8 h-8 text-red-600"})}),e.jsx("h2",{className:"text-3xl font-light text-[#1A1A1A] mb-3",style:{fontFamily:"'Cormorant Garamond', serif"},children:"Sign In Required"}),e.jsx("p",{className:"text-[#1A1A1A]/50 text-sm mb-6",children:"You must be logged in to upload photos."}),e.jsx("button",{onClick:()=>window.location.href="/login",className:"inline-block px-6 py-2.5 bg-[#1A1A1A] text-white rounded-xl text-sm font-semibold hover:bg-[#e71d32] transition-all",children:"Sign In"})]})}):F?e.jsx("div",{className:"min-h-screen bg-[#F9F8F6] flex items-center justify-center px-4",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-5",children:e.jsx(g,{className:"w-8 h-8 text-green-600"})}),e.jsx("h2",{className:"text-3xl font-light text-[#1A1A1A] mb-3",style:{fontFamily:"'Cormorant Garamond', serif"},children:"Photo Submitted"}),e.jsx("p",{className:"text-[#1A1A1A]/50 text-sm mb-6",children:"Thanks for sharing! Your photo is now in our review queue. We'll let you know once it's been approved for the gallery."}),e.jsx("button",{onClick:()=>window.location.href="/my-shore",className:"inline-block px-6 py-2.5 bg-[#1A1A1A] text-white rounded-xl text-sm font-semibold hover:bg-[#e71d32] transition-all",children:"Back to My Shore"})]})}):e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(I,{eyebrow:"Share Your Moments",title:"Upload Event Photos",subtitle:"Upload photos from past church events. They'll be reviewed before appearing in our galleries.",imageUrl:"https://images.unsplash.com/photo-1511632765486-a01980e01a18?w=1600&q=80",children:e.jsx("div",{className:"flex items-center gap-2 mt-6",children:[1,2].map(t=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold transition-all ${r>=t?"bg-white text-[#1A1A1A]":"bg-white/20 text-white/60"}`,children:t}),t<2&&e.jsx("div",{className:`w-8 h-0.5 ${r>t?"bg-white":"bg-white/20"}`})]},t))})}),e.jsx("div",{className:"max-w-2xl mx-auto px-6 md:px-10 py-10 pb-20",children:e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl p-6 md:p-8",children:[r===1&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"font-semibold text-[#1A1A1A] text-lg mb-5",children:"Select an Event"}),h.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(L,{className:"w-12 h-12 text-[#1A1A1A]/20 mx-auto mb-3"}),e.jsx("p",{className:"text-[#1A1A1A]/50",children:"No past events available for uploads."})]}):e.jsx("div",{className:"space-y-2",children:h.map(t=>e.jsx("button",{onClick:()=>{w(t),m(2)},className:"w-full text-left p-4 border border-gray-200 rounded-xl hover:border-[#e71d32] hover:bg-[#F9F8F6] transition-all group",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-[#1A1A1A]",children:t.title}),e.jsxs("p",{className:"text-sm text-[#1A1A1A]/40 mt-1",children:[new Date(t.start_date).toLocaleDateString()," ⢠",t.ministry_slug||"General"]})]}),e.jsx(q,{className:"w-5 h-5 text-[#1A1A1A]/20 group-hover:text-[#e71d32]"})]})},t.id))})]}),r===2&&l&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("h2",{className:"font-semibold text-[#1A1A1A] text-lg mb-5",children:"Upload Photo"}),e.jsxs("div",{className:"mb-4 p-4 bg-[#F9F8F6] rounded-xl border border-gray-200",children:[e.jsx("p",{className:"text-sm text-[#1A1A1A]/60",children:e.jsx("strong",{children:l.title})}),e.jsx("p",{className:"text-xs text-[#1A1A1A]/40 mt-1",children:new Date(l.start_date).toLocaleDateString()})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-3",children:"Upload Photo *"}),e.jsxs("label",{className:"flex items-center justify-center gap-2 px-6 py-8 border-2 border-dashed border-gray-200 rounded-xl cursor-pointer hover:border-[#e71d32] hover:bg-[#FFF5F5] transition-all",children:[e.jsx(z,{className:"w-5 h-5 text-[#e71d32]"}),e.jsx("span",{className:"text-sm text-[#1A1A1A]/50",children:n?n.name:"Click to select photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:k})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1.5",children:"Photo Caption (optional)"}),e.jsx("textarea",{value:u,onChange:t=>v(t.target.value),rows:3,className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm outline-none focus:border-[#e71d32] resize-none",placeholder:"Add a caption..."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>m(1),className:"px-5 py-3 border border-gray-200 rounded-xl text-sm text-gray-500 hover:border-gray-400",children:"Back"}),e.jsxs("button",{onClick:_,disabled:!n||c,className:"flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-[#e71d32] text-white rounded-xl text-sm font-semibold hover:bg-[#c41929] disabled:opacity-50",children:[c?e.jsx(f,{className:"w-4 h-4 animate-spin"}):e.jsx(g,{className:"w-4 h-4"}),c?"Uploading...":"Submit Photo"]})]})]})]})})]})}export{B 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.