PageSourceSearch

https://delphigrc.org/assets/AdminAbout-DRRtMeK6.js

js delphigrc.org collected 2026-10-04 00:27:18 UTC 12,276 bytes, 1 lines download raw bytes

1import{b as e,r as s,e as t,j as a}from"./vendor-react-BH6F5oQJ.js";import{u as r}from"./usePages-B42aSg8W.js";import{A as i}from"./AdminLayout-CKCESQT6.js";import{s as l,D as n,H as o,f as d,G as c}from"./index-dRqPaCFl.js";import{L as u}from"./label-RVODh2pd.js";import{T as m,a as x,b as h,c as p}from"./tabs-Bc5GG4D6.js";import{L as v}from"./LazyRichTextEditor-ByQjI7gT.js";import{A as g,a as j,b,c as f,d as y,e as N,f as S,g as w}from"./alert-dialog-Ba-RZ__8.js";import{m as C,b as E,O as k,V as A}from"./vendor-icons-CaI5__By.js";import"./vendor-query-CC4VRGyP.js";import"./vendor-ui-B4WC06Sp.js";import"./separator-KtQ1mSuG.js";import"./index-CCdGLatk.js";import"./Combination-DzDAyqvK.js";import"./vendor-supabase-COwyE4EW.js";import"./index-B3FPD4RS.js";import"./en-US-DUAJ-5Wt.js";import"./index-D5Ei2fSx.js";const O=()=>{const{getPageBySlug:O}=r();e();const[L,T]=s.useState(""),[F,V]=s.useState(!0),[D,M]=s.useState(null),[U,P]=s.useState(!1),[R,I]=s.useState(!1),[G,K]=s.useState(null),[$,q]=s.useState(!1),[W,z]=s.useState(!1),[B,H]=s.useState(!1),X=s.useRef(null),Y=s.useRef(null),[_,J]=s.useState(""),[Q,Z]=s.useState(""),[ee,se]=s.useState(""),[te,ae]=s.useState(""),[re,ie]=s.useState("Our Mission"),[le,ne]=s.useState(""),[oe,de]=s.useState("Our Vision"),[ce,ue]=s.useState(""),[me,xe]=s.useState("Our Values"),[he,pe]=s.useState(""),[ve,ge]=s.useState("Eurasian Security Studies"),[je,be]=s.useState("Analysis of military developments, strategic competition, and security architecture across the Eurasian landmass, with particular focus on the Caucasus and Central Asia.");s.useEffect(()=>{(async()=>{var e,s,t,a,r,i,l,n,o,d,c,u;const m=await O("about");if(m){M(m.id);const x=m.content;T((null==x?void 0:x.html)||""),J((null==(e=null==x?void 0:x.seo)?void 0:e.title)||"About Us | Delphi Global Research Center"),Z((null==(s=null==x?void 0:x.seo)?void 0:s.description)||""),se((null==(t=null==x?void 0:x.seo)?void 0:t.keywords)||""),ae((null==(a=null==x?void 0:x.seo)?void 0:a.ogImage)||""),ie((null==(r=null==x?void 0:x.mission)?void 0:r.title)||"Our Mission"),ne((null==(i=null==x?void 0:x.mission)?void 0:i.text)||""),de((null==(l=null==x?void 0:x.vision)?void 0:l.title)||"Our Vision"),ue((null==(n=null==x?void 0:x.vision)?void 0:n.text)||""),xe((null==(o=null==x?void 0:x.values)?void 0:o.title)||"Our Values"),pe((null==(d=null==x?void 0:x.values)?void 0:d.text)||""),ge((null==(c=null==x?void 0:x.focusArea)?void 0:c.title)||"Eurasian Security Studies"),be((null==(u=null==x?void 0:x.focusArea)?void 0:u.description)||"")}V(!1)})()},[]),s.useEffect(()=>{!F&&G&&z(!0)},[L,_,Q,ee,te,re,le,oe,ce,me,he,ve,je,F,G]),s.useEffect(()=>{const e=e=>{if(W&&!R)return e.preventDefault(),e.returnValue="",""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[W,R]);const fe=t(({currentLocation:e,nextLocation:s})=>W&&!R&&e.pathname!==s.pathname);s.useEffect(()=>{"blocked"===fe.state&&(H(!0),Y.current=fe)},[fe]);const ye=s.useCallback(async(e=!0)=>{if(!D)return;const s={html:L,seo:{title:_,description:Q,keywords:ee,ogImage:te},mission:{title:re,text:le},vision:{title:oe,text:ce},values:{title:me,text:he},focusArea:{title:ve,description:je}};try{const{data:t,error:a}=await l.from("pages").update({content:s}).eq("id",D).select().maybeSingle();if(a)throw a;K(new Date),z(!1),e&&n({title:"Success",description:"About page updated successfully"})}catch(t){e&&n({title:"Error",description:t.message||"Failed to update page",variant:"destructive"})}},[D,L,_,Q,ee,te,re,le,oe,ce,me,he,ve,je]),Ne=async()=>{await ye(!0),q(!1)};return s.useEffect(()=>{if(D&&!F)return X.current&&clearTimeout(X.current),I(!0),X.current=setTimeout(async()=>{await ye(!1),I(!1)},2e3),()=>{X.current&&clearTimeout(X.current)}},[D,F,L,_,Q,ee,te,re,le,oe,ce,me,he,ve,je,ye]),s.useEffect(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key&&(e.preventDefault(),Ne())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[Ne]),F?a.jsx(i,{children:a.jsx("div",{className:"p-8",children:a.jsx("div",{className:"flex items-center justify-center h-64",children:a.jsx(C,{className:"h-8 w-8 animate-spin text-primary"})})})}):a.jsxs(i,{children:[a.jsxs(o,{children:[a.jsx("meta",{name:"robots",content:"noindex,nofollow"}),a.jsx("title",{children:"About Page - Admin - Delphi Global Research Center"})]}),a.jsxs("div",{className:"p-8",children:[a.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"font-heading text-3xl font-bold text-foreground",children:"About Page"}),a.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[a.jsx("p",{className:"text-muted-foreground",children:"Manage the content and SEO settings for the About page"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"(Press Ctrl+S or Cmd+S to save)"}),R&&a.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[a.jsx(E,{className:"h-3 w-3 animate-pulse"}),"Saving..."]}),!R&&G&&a.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[a.jsx(k,{className:"h-3 w-3 text-green-600"}),"Saved ",new Date(G).toLocaleTimeString()]})]})]}),a.jsx(d,{onClick:()=>q(!0),children:"Save Now"})]}),a.jsx(g,{open:$,onOpenChange:q,children:a.jsxs(j,{children:[a.jsxs(b,{children:[a.jsx(f,{children:"Save Changes"}),a.jsx(y,{children:"Are you sure you want to save all changes to the About page? This will update the live content immediately."})]}),a.jsxs(N,{children:[a.jsx(S,{children:"Cancel"}),a.jsx(w,{onClick:Ne,children:"Save Changes"})]})]})}),a.jsx(g,{open:B,onOpenChange:H,children:a.jsxs(j,{children:[a.jsxs(b,{children:[a.jsxs(f,{className:"flex items-center gap-2",children:[a.jsx(A,{className:"h-5 w-5 text-orange-500"}),"Unsaved Changes"]}),a.jsx(y,{children:"You have unsaved changes. Auto-save is active, but some changes may not be saved yet. Are you sure you want to leave this page?"})]}),a.jsxs(N,{children:[a.jsx(S,{onClick:()=>{Y.current&&Y.current.reset(),H(!1)},children:"Stay on Page"}),a.jsx(w,{onClick:()=>{Y.current&&Y.current.proceed(),H(!1)},className:"bg-destructive hover:bg-destructive/90",children:"Leave Without Saving"})]})]})}),a.jsxs(m,{defaultValue:"mission",className:"space-y-6",children:[a.jsxs(x,{children:[a.jsx(h,{value:"mission",children:"Mission, Vision, Values"}),a.jsx(h,{value:"content",children:"Content"}),a.jsx(h,{value:"images",children:"Images"}),a.jsx(h,{value:"seo",children:"SEO & Meta Tags"})]}),a.jsxs(p,{value:"mission",className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[a.jsx("h3",{className:"mb-4 text-lg font-semibold",children:"Our Mission"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(u,{htmlFor:"mission-title",children:"Title"}),a.jsx(c,{id:"mission-title",value:re,onChange:e=>ie(e.target.value),placeholder:"Our Mission"})]}),a.jsxs("div",{children:[a.jsx(u,{htmlFor:"mission-text",children:"Text"}),a.jsx("textarea",{id:"mission-text",value:le,onChange:e=>ne(e.target.value),className:"min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Enter mission text..."})]})]})]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[a.jsx("h3",{className:"mb-4 text-lg font-semibold",children:"Our Vision"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(u,{htmlFor:"vision-title",children:"Title"}),a.jsx(c,{id:"vision-title",value:oe,onChange:e=>de(e.target.value),placeholder:"Our Vision"})]}),a.jsxs("div",{children:[a.jsx(u,{htmlFor:"vision-text",children:"Text"}),a.jsx("textarea",{id:"vision-text",value:ce,onChange:e=>ue(e.target.value),className:"min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Enter vision text..."})]})]})]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[a.jsx("h3",{className:"mb-4 text-lg font-semibold",children:"Our Values"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(u,{htmlFor:"values-title",children:"Title"}),a.jsx(c,{id:"values-title",value:me,onChange:e=>xe(e.target.value),placeholder:"Our Values"})]}),a.jsxs("div",{children:[a.jsx(u,{htmlFor:"values-text",children:"Text"}
1),a.jsx("textarea",{id:"values-text",value:he,onChange:e=>pe(e.target.value),className:"min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Enter values text..."})]})]})]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[a.jsx("h3",{className:"mb-4 text-lg font-semibold",children:"Research Focus Area"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(u,{htmlFor:"focus-title",children:"Title"}),a.jsx(c,{id:"focus-title",value:ve,onChange:e=>ge(e.target.value),placeholder:"Eurasian Security Studies"})]}),a.jsxs("div",{children:[a.jsx(u,{htmlFor:"focus-description",children:"Description"}),a.jsx("textarea",{id:"focus-description",value:je,onChange:e=>be(e.target.value),className:"min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Enter focus area description..."})]})]})]})]}),a.jsx(p,{value:"content",className:"space-y-6",children:a.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[a.jsx(u,{className:"mb-4 block text-lg font-semibold",children:"Page Content"}),a.jsx(v,{content:L,onChange:T,placeholder:"Write the About page content..."})]})}),a.jsx(p,{value:"images",className:"space-y-6",children:a.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[a.jsx(u,{className:"mb-4 block text-lg font-semibold",children:"Upload Images"}),a.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Upload images for use in the About page content"}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(c,{type:"file",accept:"image/*",onChange:async e=>{var s;const t=null==(s=e.target.files)?void 0:s[0];if(!t)return;const a=await(async e=>{try{P(!0);const s=e.name.split(".").pop(),t=`about/${Math.random()}.${s}`,{error:a}=await l.storage.from("media").upload(t,e);if(a)throw a;const{data:{publicUrl:r}}=l.storage.from("media").getPublicUrl(t);return n({title:"Success",description:"Image uploaded successfully"}),r}catch(s){return n({title:"Error",description:s.message||"Failed to upload image",variant:"destructive"}),null}finally{P(!1)}})(t);a&&ae(a)},disabled:U,className:"max-w-md"}),U&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[a.jsx(C,{className:"h-4 w-4 animate-spin"}),a.jsx("span",{children:"Uploading..."})]})]})]})}),a.jsx(p,{value:"seo",className:"space-y-6",children:a.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[a.jsx(u,{className:"mb-4 block text-lg font-semibold",children:"SEO Settings"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(u,{htmlFor:"seo-title",children:"Meta Title"}),a.jsx(c,{id:"seo-title",value:_,onChange:e=>J(e.target.value),placeholder:"About Us | Delphi Global Research Center",maxLength:60}),a.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[_.length,"/60 characters"]})]}),a.jsxs("div",{children:[a.jsx(u,{htmlFor:"seo-description",children:"Meta Description"}),a.jsx(c,{id:"seo-description",value:Q,onChange:e=>Z(e.target.value),placeholder:"Learn about our mission, vision, and values",maxLength:160}),a.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[Q.length,"/160 characters"]})]}),a.jsxs("div",{children:[a.jsx(u,{htmlFor:"seo-keywords",children:"Keywords (comma-separated)"}),a.jsx(c,{id:"seo-keywords",value:ee,onChange:e=>se(e.target.value),placeholder:"think tank, research, Eurasia, regional analysis"})]}),a.jsxs("div",{children:[a.jsx(u,{htmlFor:"og-image",children:"Open Graph Image URL"}),a.jsx(c,{id:"og-image",value:te,onChange:e=>ae(e.target.value),placeholder:"https://example.com/image.jpg"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Image shown when sharing on social media"})]})]})]})})]})]})]})};export{O 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.