PageSourceSearch

https://healthserve.ae/assets/AdminBlogEdit-7FZS4mxV.js

js healthserve.ae collected 2026-10-04 02:40:17 UTC 7,322 bytes, 7 lines download raw bytes

1import{a$ as E,a6 as F,r as o,y as g,aO as p,j as e,L as b,b0 as L,I as $,b6 as D}from"./index-CzMEFmtw.js";import{P as w,a as I,C as d}from"./ui-BklIU2Vp.js";import{M as _}from"./MediaPicker-D2IJuFJa.js";import{a as h}from"./blog-DP5q8ac2.js";import{E as H}from"./external-link-DRUqUc_B.js";import{S as O}from"./save-Bu384Y2v.js";import"./file-video-DCRmgGhD.js";import"./image-DUijihr1.js";import"./upload-C1EWCH4L.js";const r=({label:c,children:u,hint:a})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:c}),u,a&&e.jsx("div",{className:"text-xs text-gray-400 mt-1",children:a})]}),i="w-full h-10 px-3 rounded-lg border border-gray-200 text-sm bg-white text-gray-900 placeholder:text-gray-400 focus:outline-none focus:border-[#F9A01B]";function J(){const{id:c}=E(),u=F(),[a,j]=o.useState(null),[S,C]=o.useState([]),[k,P]=o.useState([]),[v,f]=o.useState(!1),[m,A]=o.useState(!1),[y,N]=o.useState("");if(o.useEffect(()=>{(async()=>{const[{data:s},{data:t},{data:n}]=await Promise.all([g.from("blog_posts").select("*").eq("id",c).maybeSingle(),g.from("blog_authors").select("id,name").order("name"),g.from("blog_categories").select("id,name").order("name")]);if(!s){p.error("Post not found"),u("/admin/blog");return}j(s),N((s.tags??[]).join(", ")),C(t??[]),P(n??[])})()},[c,u]),!a)return e.jsx(w,{children:e.jsx("div",{className:"text-sm text-gray-500",children:"Loading…"})});const l=(s,t)=>j({...a,[s]:t}),M=async()=>{f(!0);const s=y.split(",").map(x=>x.trim()).filter(Boolean),t={...a,tags:s,slug:a.slug||h(a.title)};t.status==="published"&&!t.published_at&&(t.published_at=new Date().toISOString());const{error:n}=await g.from("blog_posts").update(t).eq("id",a.id);if(f(!1),n)return p.error(n.message);p.success("Saved")},B=s=>{if(!s)return"";const t=new Date(s),n=x=>String(x).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`};return e.jsxs(w,{children:[e.jsx(I,{title:a.title||"(untitled)",description:`Status: ${a.status}`,actions:e.jsxs(e.Fragment,{children:[e.jsxs(b,{to:"/admin/blog",className:"h-9 px-3 rounded-lg border border-gray-300 text-sm font-semibold flex items-center gap-1.5 hover:bg-gray-50",children:[e.jsx(L,{className:"w-4 h-4"})," Back"]}),a.status==="published"&&e.jsxs("a",{href:`/blog/${a.slug}`,target:"_blank",rel:"noreferrer",className:"h-9 px-3 rounded-lg border border-gray-300 text-sm font-semibold flex items-center gap-1.5 hover:bg-gray-50",children:[e.jsx(H,{className:"w-4 h-4"})," View"]}),e.jsxs("button",{onClick:M,disabled:v,className:"h-9 px-4 rounded-lg bg-[#F9A01B] text-white text-sm font-semibold flex items-center gap-1.5 hover:brightness-105 disabled:opacity-60",children:[e.jsx(O,{className:"w-4 h-4"})," ",v?"Saving…":"Save"]})]})}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-5",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs(d,{className:"p-5 space-y-4",children:[e.jsx(r,{label:"Title",children:e.jsx("input",{className:i,value:a.title,onChange:s=>{const t=s.target.value;l("title",t),(!a.slug||a.slug===h(a.title))&&l("slug",h(t))}})}),e.jsx(r,{label:"Slug",hint:"URL: /blog/your-slug — lowercase, dashes only.",children:e.jsx("input",{className:i,value:a.slug,onChange:s=>l("slug",h(s.target.value))})}),e.jsx(r,{label:"Excerpt",hint:"Short summary shown in the blog list.",children:e.jsx("textarea",{rows:2,className:i+" h-auto py-2",value:a.excerpt??"",onChange:s=>l("excerpt",s.target.value)})})]}),e.jsxs(d,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold",children:"Body (Markdown)"}),e.jsxs("button",{onClick:()=>A(!m),className:"h-8 px-3 rounded-lg border border-gray-200 text-xs font-semibold flex items-center gap-1.5 hover:bg-gray-50",children:[e.jsx($,{className:"w-3.5 h-3.5"})," ",m?"Edit":"Preview"]})]}),m?e.jsx("div",{className:"prose prose-sm max-w-none min-h-[400px] p-4 border border-gray-100 rounded-lg bg-gray-50",children:e.jsx(D,{children:a.body_md||"*Nothing to preview yet.*"})}):e.jsx("textarea",{rows:22,value:a.body_md,onChange:s=>l("body_md",s.target.value),placeholder:`# Heading
2
3Write your post in **Markdown** here.
4
5- Bullets
6- Links: [text](https://…)
7- Images: ![alt](https://…)`,className:"w-full font-mono text-sm p-4 border border-gray-200 rounded-lg focus:outline-none focus:border-[#F9A01B] bg-white text-gray-900"})]}),e.jsxs(d,{className:"p-5 space-y-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold",children:"SEO"}),e.jsx(r,{label:"Meta title",hint:"Shown in search results. Aim for under 60 characters.",children:e.jsx("input",{className:i,value:a.meta_title??"",onChange:s=>l("meta_title",s.target.value),placeholder:a.title})}),e.jsx(r,{label:"Meta description",hint:"Under 160 characters.",children:e.jsx("textarea",{rows:2,className:i+" h-auto py-2",value:a.meta_description??"",onChange:s=>l("meta_description",s.target.value),placeholder:a.excerpt??""})}),e.jsx(_,{label:"Social share image (OG)",value:a.og_image_url,onChange:s=>l("og_image_url",s)})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(d,{className:"p-5 space-y-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold",children:"Publish"}),e.jsx(r,{label:"Status",children:e.jsxs("select",{className:i,value:a.status,onChange:s=>l("status",s.target.value),children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"scheduled",children:"Scheduled"}),e.jsx("option",{value:"published",children:"Published"})]})}),(a.status==="scheduled"||a.status==="published")&&e.jsx(r,{label:a.status==="scheduled"?"Publish at":"Published at",hint:a.status==="scheduled"?"Post becomes visible at this time.":"",children:e.jsx("input",{type:"datetime-local",className:i,value:B(a.published_at),onChange:s=>l("published_at",s.target.value?new Date(s.target.value).toISOString():null)})})]}),e.jsx(d,{className:"p-5",children:e.jsx(_,{label:"Cover image",value:a.cover_image_url,onChange:s=>l("cover_image_url",s)})}),e.jsxs(d,{className:"p-5 space-y-4",children:[e.jsxs(r,{label:"Author",children:[e.jsxs("select",{className:i,value:a.author_id??"",onChange:s=>l("author_id",s.target.value||null),children:[e.jsx("option",{value:"",children:"— None —"}),S.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]}),e.jsx(b,{to:"/admin/blog/authors",className:"text-xs text-[#F9A01B] font-semibold mt-1 inline-block",children:"Manage authors →"})]}),e.jsxs(r,{label:"Category",children:[e.jsxs("select",{className:i,value:a.category_id??"",onChange:s=>l("category_id",s.target.value||null),children:[e.jsx("option",{value:"",children:"— None —"}),k.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]}),e.jsx(b,{to:"/admin/blog/categories",className:"text-xs text-[#F9A01B] font-semibold mt-1 inline-block",children:"Manage categories →"})]}),e.jsx(r,{label:"Tags",hint:"Comma separated. e.g. licensing, DHA, exams",children:e.jsx("input",{className:i,value:y,onChange:s=>N(s.target.value),placeholder:"licensing, DHA, exams"})})]})]})]})]})}export{J 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.