PageSourceSearch

https://hotelinnovationexpo.co.uk/assets/AdminIntegrations-BPehfddh.js

js hotelinnovationexpo.co.uk collected 2026-10-09 18:30:01 UTC 7,655 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-BstwIhD_.js";import{r,f as B}from"./vendor-react-B-LUs8MM.js";import{s as n,H as a,ab as V,N as q,B as c,A as H,L as m,R as S,U as E,V as b,M,a2 as P,aw as C,W as K,a3 as x,j as u,b8 as f,F as Y}from"./index-Bfpmv7XO.js";import{A as z,a as W}from"./alert-DOGVlOeP.js";import"./vendor-data-0YQfH_sM.js";import"./vendor-charts-BiE86gGW.js";import"./vendor-editor-DvQDoTDn.js";import"./vendor-dnd-D9eei3Si.js";const ae=()=>{const[R,g]=r.useState(!0),[j,y]=r.useState(!1),[N,F]=r.useState(null),[i,v]=r.useState(""),[d,A]=r.useState(""),[_,I]=r.useState(!1),[k,w]=r.useState(!1),p=B(),[t,h]=r.useState({resend_domain:"",resend_from_name:""});r.useEffect(()=>{U()},[]);const U=async()=>{const{data:{user:s}}=await n.auth.getUser();if(!s){a.error("Authentication required"),p("/login");return}const{data:l,error:o}=await n.rpc("is_admin_or_cs_or_pm",{_user_id:s.id});if(o||!l){a.error("Access denied. Admin privileges required."),p("/");return}L()},L=async()=>{g(!0);const{data:s,error:l}=await n.from("event_settings").select("id, resend_domain, resend_from_name").order("updated_at",{ascending:!1}).limit(1).maybeSingle();if(l)console.error("Error loading settings:",l),a.error("Failed to load integration settings");else if(s){F(s.id);const o=s;h({resend_domain:o.resend_domain||"",resend_from_name:o.resend_from_name||""})}g(!1)},O=async()=>{if(!N)return;y(!0);const{error:s}=await n.from("event_settings").update({resend_domain:t.resend_domain||null,resend_from_name:t.resend_from_name||null}).eq("id",N);s?(a.error("Failed to save integration settings"),console.error("Error saving:",s)):a.success("Integration settings saved successfully"),y(!1)},D=async()=>{if(!i.trim()){a.error("Please enter an API key");return}I(!0);try{const{error:s}=await n.functions.invoke("update-secret",{body:{secretName:"RESEND_API_KEY",secretValue:i}});if(s)throw s;a.success("Resend API key updated successfully"),v("")}catch(s){console.error("Error updating Resend API key:",s),a.error("Failed to update Resend API key")}finally{I(!1)}},T=async()=>{if(!d.trim()){a.error("Please enter an API key");return}w(!0);try{const{error:s}=await n.functions.invoke("update-secret",{body:{secretName:"SEO_ARTICLE_API_KEY",secretValue:d}});if(s)throw s;a.success("SEO Article API key updated successfully"),A("")}catch(s){console.error("Error updating SEO API key:",s),a.error("Failed to update SEO Article API key")}finally{w(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(V,{children:[e.jsx("title",{children:"Integration Settings - Admin"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(q,{}),e.jsx("div",{className:"flex-1 bg-muted/30 pt-[168px] pb-16",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold mb-2 text-foreground",children:"Integration Settings"}),e.jsx("p",{className:"text-muted-foreground",children:"Configure API keys and external service integrations"})]}),e.jsxs(c,{onClick:()=>p("/admin"),variant:"outline",className:"flex-shrink-0",children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Back to Admin"]})]}),R?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(m,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(S,{children:[e.jsxs(E,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(M,{className:"h-5 w-5"}),"Resend Email Configuration"]}),e.jsx(P,{children:"Configure your Resend email settings. The API key is stored as a secret."})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm border rounded-full px-3 py-1",children:[e.jsx(C,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"API Key Configured"})]})]}),e.jsxs(K,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"resend-from-name",children:"From Name"}),e.jsx(u,{id:"resend-from-name",value:t.resend_from_name,onChange:s=>h({...t,resend_from_name:s.target.value}),placeholder:"e.g., Event Team"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'The display name that will appear in the email "From" field'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"resend-domain",children:"Sender Domain"}),e.jsx(u,{id:"resend-domain",value:t.resend_domain,onChange:s=>h({...t,resend_domain:s.target.value}),placeholder:"e.g., mail.yourdomain.com"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The email address to send from (must be verified in Resend)"})]}),e.jsx(z,{className:"bg-muted/50 border-muted",children:e.jsxs(W,{className:"text-sm",children:[e.jsx("strong",{children:"📌 Important:"}),e.jsxs("ul",{className:"list-disc list-inside mt-1 space-y-1",children:[e.jsxs("li",{children:["Verify your domain at ",e.jsx("a",{href:"https://resend.com/domains",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"resend.com/domains"})]}),e.jsx("li",{children:"The RESEND_API_KEY secret is already configured"})]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(x,{htmlFor:"resend-api-key",className:"flex items-center gap-2",children:[e.jsx(f,{className:"h-4 w-4"}
1),"Update API Key"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{id:"resend-api-key",type:"password",value:i,onChange:s=>v(s.target.value),placeholder:"Enter new Resend API key...",className:"flex-1"}),e.jsx(c,{onClick:D,disabled:_||!i.trim(),variant:"default",children:_?e.jsx(m,{className:"h-4 w-4 animate-spin"}):"Update Key"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter a new API key to replace the existing one. Leave empty to keep the current key."})]})]})]}),e.jsxs(S,{children:[e.jsxs(E,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(f,{className:"h-5 w-5"}),"SEO Article API"]}),e.jsx(P,{children:"API key for generating SEO-optimized article content"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm border rounded-full px-3 py-1",children:[e.jsx(C,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"API Key Configured"})]})]}),e.jsxs(K,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md bg-muted p-3",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This API key is used for article content generation features."})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(x,{htmlFor:"seo-api-key",className:"flex items-center gap-2",children:[e.jsx(f,{className:"h-4 w-4"}),"Update API Key"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{id:"seo-api-key",type:"password",value:d,onChange:s=>A(s.target.value),placeholder:"Enter new SEO Article API key...",className:"flex-1"}),e.jsx(c,{onClick:T,disabled:k||!d.trim(),variant:"default",children:k?e.jsx(m,{className:"h-4 w-4 animate-spin"}):"Update Key"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter a new API key to replace the existing one. Leave empty to keep the current key."})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(c,{onClick:O,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(m,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save Settings"})})]})]})})}),e.jsx(Y,{})]})]})};export{ae 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.