PageSourceSearch

https://syrianorthodoxchurch.org/assets/ChurchEditor-ChPkslU8.js

js syrianorthodoxchurch.org collected 2026-10-02 12:33:48 UTC 7,308 bytes, 1 lines download raw bytes

1import{p as I,J as k,R as L,v as M,r as d,s as j,j as e,L as C,B as f,C as h,e as u,f as m,b as x}from"./index-QjZvXh_M.js";import{C as S}from"./CMSLayout-B7mnhu9I.js";import{I as r}from"./input-8p3tkI1x.js";import{L as t}from"./label-CU50YUya.js";import{T as A}from"./textarea-CuhoQxfW.js";import{S as E}from"./switch-Vl2pyG6V.js";import{S as T,a as D,b as V,c as W,d as H}from"./select-J7Goia6V.js";import{A as O}from"./arrow-left-DNTcRDXa.js";import{S as P}from"./save-DgbVhijP.js";import"./index-CyIuOkcK.js";import"./globe-BEfpLQ4p.js";import"./settings-DCDeOOmY.js";import"./chevron-left-itEEoLyZ.js";import"./log-out-D9-YzfMZ.js";import"./index-DO59c2GC.js";import"./chevron-up-Bx4Jvozi.js";import"./check-Be9RU9_a.js";const R=["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"],U={name:"",street:"",house_number:"",postal_code:"",city:"",state:"",country:"USA",phone:"",email:"",website:"",image_url:"",latitude:null,longitude:null,description:"",is_active:!0};function le(){const{id:n}=I(),p=k(),{canEdit:g}=L(),{toast:c}=M(),[a,i]=d.useState(U),[b,v]=d.useState(!1),[y,N]=d.useState(!1),o=n==="new";d.useEffect(()=>{!o&&n&&w(n)},[n]);const w=async s=>{v(!0);const{data:l,error:F}=await j.from("churches").select("*").eq("id",s).single();F?(c({title:"Error",description:"Failed to load church",variant:"destructive"}),p("/cms/churches")):l&&i({...l,latitude:l.latitude?Number(l.latitude):null,longitude:l.longitude?Number(l.longitude):null}),v(!1)},_=async()=>{if(!g())return;if(!a.name){c({title:"Error",description:"Name is required",variant:"destructive"});return}N(!0);const s={...a,latitude:a.latitude||null,longitude:a.longitude||null},{error:l}=o?await j.from("churches").insert(s):await j.from("churches").update(s).eq("id",n);l?c({title:"Error",description:"Failed to save church",variant:"destructive"}):(c({title:"Success",description:o?"Church created":"Church updated"}),p("/cms/churches")),N(!1)};return b?e.jsx(S,{children:e.jsx("div",{className:"flex h-[calc(100vh-200px)] items-center justify-center",children:e.jsx(C,{className:"h-8 w-8 animate-spin text-primary"})})}):e.jsx(S,{children:e.jsxs("div",{className:"p-6 lg:p-8",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f,{variant:"ghost",size:"icon",onClick:()=>p("/cms/churches"),children:e.jsx(O,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h1",{className:"font-heading text-2xl font-bold text-foreground",children:o?"New Church":"Edit Church"})})]}),e.jsxs(f,{onClick:_,disabled:y||!g(),children:[y?e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(P,{className:"mr-2 h-4 w-4"}),"Save"]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(h,{children:[e.jsx(u,{children:e.jsx(m,{children:"Basic Information"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"name",children:"Church Name *"}),e.jsx(r,{id:"name",value:a.name,onChange:s=>i({...a,name:s.target.value}),placeholder:"e.g. St. Mary's Syriac Orthodox Church"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"description",children:"Description"}),e.jsx(A,{id:"description",value:a.description,onChange:s=>i({...a,description:s.target.value}),rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"image_url",children:"Image URL"}),e.jsx(r,{id:"image_url",value:a.image_url,onChange:s=>i({...a,image_url:s.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t,{htmlFor:"is_active",children:"Active"}),e.jsx(E,{id:"is_active",checked:a.is_active,onCheckedChange:s=>i({...a,is_active:s})})]})]})]}),e.jsxs(h,{children:[e.jsx(u,{children:e.jsx(m,{children:"Address"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"street",children:"Street"}),e.jsx(r,{id:"street",value:a.street,onChange:s=>i({...a,street:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"house_number",children:"House Number"}),e.jsx(r,{id:"house_number",value:a.house_number,onChange:s=>i({...a,house_number:s.target.value})})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"postal_code",children:"ZIP Co
1de"}),e.jsx(r,{id:"postal_code",value:a.postal_code,onChange:s=>i({...a,postal_code:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"city",children:"City"}),e.jsx(r,{id:"city",value:a.city,onChange:s=>i({...a,city:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{children:"State"}),e.jsxs(T,{value:a.state,onValueChange:s=>i({...a,state:s}),children:[e.jsx(D,{children:e.jsx(V,{placeholder:"Select..."})}),e.jsx(W,{children:R.map(s=>e.jsx(H,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"country",children:"Country"}),e.jsx(r,{id:"country",value:a.country,onChange:s=>i({...a,country:s.target.value})})]})]})]}),e.jsxs(h,{children:[e.jsx(u,{children:e.jsx(m,{children:"Contact"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"phone",children:"Phone"}),e.jsx(r,{id:"phone",type:"tel",value:a.phone,onChange:s=>i({...a,phone:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"email",children:"Email"}),e.jsx(r,{id:"email",type:"email",value:a.email,onChange:s=>i({...a,email:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"website",children:"Website"}),e.jsx(r,{id:"website",type:"url",value:a.website,onChange:s=>i({...a,website:s.target.value}),placeholder:"https://..."})]})]})]}),e.jsxs(h,{children:[e.jsx(u,{children:e.jsx(m,{children:"Geocoordinates"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"latitude",children:"Latitude"}),e.jsx(r,{id:"latitude",type:"number",step:"any",value:a.latitude??"",onChange:s=>i({...a,latitude:s.target.value?parseFloat(s.target.value):null}),placeholder:"e.g. 40.7128"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{htmlFor:"longitude",children:"Longitude"}),e.jsx(r,{id:"longitude",type:"number",step:"any",value:a.longitude??"",onChange:s=>i({...a,longitude:s.target.value?parseFloat(s.target.value):null}),placeholder:"e.g. -74.0060"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Coordinates can be found using Google Maps."})]})]})]})]})})}export{le 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.