PageSourceSearch

https://www.skyringai.com/assets/AdminPageEditor-B6Mibvam.js

js skyringai.com collected 2026-10-07 03:08:32 UTC 6,180 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-Bxj8wnBw.js";import{j as S,f as C,r as x}from"./vendor-react-BKm_nskA.js";import{u as P}from"./useQuery-CGZ3Uohl.js";import{Y as D,Q as o,O as d,P as j,w as l,J as f}from"./index-B6y-6NMh.js";import{u as L}from"./useMutation-C9oja-Zd.js";import{C as v,b as y,c as b,a as _}from"./card-TCtUEEWn.js";import{T as q}from"./textarea-BTwRgUvI.js";import{B as E}from"./badge-D34NJrSA.js";import{S as F}from"./switch-Dm4RiLKe.js";import{S as k,a as I,b as T,c as B,d as c}from"./select-P6IcSvO8.js";import{A as M}from"./arrow-left-D6KtzfbU.js";import{E as O}from"./eye-D2aUhwc_.js";import{S as Q}from"./save-BC0wI7se.js";import"./vendor-supabase-eX84kb_r.js";import"./vendor-charts-oAE8AkWo.js";import"./index-Pu3V9z69.js";import"./index-DhMU-bfg.js";import"./chevron-down-DVCcfrm1.js";const re=()=>{const{pageId:r}=S(),p=C(),h=D(),[a,i]=x.useState({page_name:"",route:"",description:"",page_type:"public",status:"draft"}),{data:t,isLoading:w}=P({queryKey:["page",r],queryFn:async()=>{const{data:s,error:n}=await l.from("site_pages").select("*").eq("id",r).single();if(n)throw n;return s},enabled:!!r});x.useEffect(()=>{t&&i({page_name:t.page_name,route:t.route,description:t.description||"",page_type:t.page_type,status:t.status})},[t]);const u=L({mutationFn:async s=>{const{data:{user:n}}=await l.auth.getUser(),m={...s,last_modified_by:n?.id,updated_at:new Date().toISOString()};s.status==="live"&&t?.status!=="live"&&(m.published_by=n?.id,m.published_at=new Date().toISOString());const{error:g}=await l.from("site_pages").update(m).eq("id",r);if(g)throw g;await l.from("page_versions").insert({page_id:r,version_number:Date.now(),action:s.status==="live"?"published":"updated",performed_by:n?.id}),await l.from("system_logs").insert({source:"page-editor",log_level:"info",message:"Page updated - metadata refresh required",details:{page_id:r,route:s.route,status:s.status}})},onSuccess:()=>{f.success("Page updated successfully"),h.invalidateQueries({queryKey:["page",r]}),h.invalidateQueries({queryKey:["admin-pages"]})},onError:s=>{f.error("Failed to update page",{description:s.message})}}),N=s=>{s.preventDefault(),u.mutate(a)};return w?e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading page..."})})}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsxs(o,{variant:"ghost",onClick:()=>p("/admin/page-manager"),className:"mb-4",children:[e.jsx(M,{className:"mr-2 h-4 w-4"}),"Back to Page Manager"]}),e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Edit Page"}),e.jsx("p",{className:"text-muted-foreground",children:"Modify page details and metadata"})]}),e.jsx("div",{className:"flex gap-2",children:t?.route&&e.jsxs(o,{variant:"outline",onClick:()=>window.open(t.route,"_blank"),children:[e.jsx(O,{className:"mr-2 h-4 w-4"}),"Preview"]})})]}),e.jsxs(v,{children:[e.jsx(y,{children:e.jsx(b,{children:"Page Details"})}),e.jsx(_,{children:e.jsxs("form",{onSubmit:N,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{htmlFor:"page_name",children:"Page Name"}),e.jsx(j,{id:"page_name",value:a.page_name,onChange:s=>i({...a,page_name:s.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"route",children:"Route (URL Path)"}),e.jsx(j,{id:"route",value:a.route,onChange:s=>i({...a,route:s.target.value}),placeholder:"/example-page",required:!0}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"The URL path where this page will be accessible"})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"description",children:"Description (SEO)"}),e.jsx(q,{id:"description",value:a.description,onChange:s=>i({...a,description:s.target.value}),rows:3,placeholder:"Brief description for search engines (max 160 characters)",maxLength:160}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[a.description.length,"/160 characters"]})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"page_type",children:"Page Type"}),e.jsxs(k,{value:a.page_type,onValueChange:s=>i({...a,page_type:s}),children:[e.jsx(I,{children:e.jsx(T,{})}),e.jsxs(B,{children:[e.jsx(c,{value:"public",children:"Public"}),e.jsx(c,{value:"admin",children:"Admin"}),e.jsx(c,{value:"customer",children:"Customer"}),e.jsx(c,{value:"onboarding",children:"Onboarding"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(d,{htmlFor:"status",children:"Page Status"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.status==="live"?"Page is live and publicly accessible":"Page is in draft mode"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:a.status==="live"?"default":"secondary",children:a.status==="live"?"Live":"Draft"}),e.jsx(F,{id:"status",checked:a.status==="live",onCheckedChange:s=>i({...a,status:s?"live":"draft"})})]})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs(o,{type:"submit",disabled:u.isPending,children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),u.isPending?"Saving...":"Save Changes"]}),e.jsx(o,{type:"button",variant:"outline",onClick:()=>p("/admin/page-manager"),children:"Cancel"})]})]})})]}),t&&e.jsxs(v,{children:[e.jsx(y,{children:e.jsx(b,{children:"Page Information"})}),e.jsxs(_,{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Created:"}
1),e.jsx("span",{children:new Date(t.created_at).toLocaleString()})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last Modified:"}),e.jsx("span",{children:new Date(t.updated_at).toLocaleString()})]}),t.published_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Published:"}),e.jsx("span",{children:new Date(t.published_at).toLocaleString()})]})]})]})]})};export{re 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.