PageSourceSearch

https://sendunlimitedemail.com/sue/mod-BNaf23Mm.js

js sendunlimitedemail.com collected 2026-10-05 06:25:22 UTC 13,683 bytes, 1 lines download raw bytes

1import{r as o,e as d,t as i,j as e,a0 as _,h as w}from"./edge-BOITG1XR.js";import{R as W}from"./mod-RPxq32x0.js";import{P as X}from"./mod-BHbsKpbp.js";import{S as Y}from"./mod-CKg_ZYcm.js";import{L as h}from"./mod-DxqX0N6D.js";import{E as H}from"./mod-OWtIy5n2.js";import{E as J}from"./mod-DlaYEcom.js";import{P as Q}from"./mod-4f-rbCW3.js";import{T as V}from"./mod-BuHkwEt_.js";import{X as Z}from"./mod-C3kaoPgB.js";import{S as A}from"./mod-CIn4OWcr.js";const ee=n=>n?new Date(n).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"}):"—",C={title:"",slug:"",content:"",excerpt:"",category:"",status:"draft",featured_image:""},me=()=>{const[n,c]=o.useState([]),[L,S]=o.useState(!0),[k,P]=o.useState(null),[p,R]=o.useState(""),[b,z]=o.useState("all"),[B,f]=o.useState(!1),[x,g]=o.useState(null),[a,r]=o.useState(C),[v,D]=o.useState(!1),[j,E]=o.useState(!1),N=o.useCallback(async()=>{S(!0);try{const t=await d.get("/admin/blog"),s=Array.isArray(t.data)?t.data:t.data?.data??[];c(s)}catch{c([]),i.error("Failed to load blog posts")}finally{S(!1)}},[]);o.useEffect(()=>{N()},[N]);const F=()=>{r(C),g(null),f(!0)},G=t=>{r({title:t.title||"",slug:t.slug||"",content:t.content||"",excerpt:t.excerpt||"",category:t.category||"",status:t.status||"draft",featured_image:t.featured_image||""}),g(t.id),f(!0)},u=()=>{f(!1),g(null),r(C)},y=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),I=async()=>{if(!a.title.trim()){i.error("Title is required");return}D(!0);try{const t={...a,slug:a.slug||y(a.title)};if(x)await d.put(`/admin/blog/${x}`,t),c(s=>s.map(l=>l.id===x?{...l,...t}:l)),i.success("Post updated");else{const s=await d.post("/admin/blog",t),l=s.data?.data??s.data??t;c(m=>[{...l,id:l.id??Date.now()},...m]),i.success("Post created")}u()}catch(t){i.error(t?.response?.data?.message||"Failed to save post")}finally{D(!1)}},$=async t=>{if(confirm("Delete this post?")){P(t);try{await d.delete(`/admin/blog/${t}`),c(s=>s.filter(l=>l.id!==t)),i.success("Post deleted")}catch{i.error("Failed to delete post")}finally{P(null)}}},M=async t=>{const s=t.status==="published"?"draft":"published";try{await d.put(`/admin/blog/${t.id}`,{status:s}),c(l=>l.map(m=>m.id===t.id?{...m,status:s}:m)),i.success(s==="published"?"Post published":"Post set to draft")}catch{i.error("Failed to update post")}},O=async()=>{if(!a.title.trim()){i.error("Enter a title first");return}E(!0);try{const t=await d.post("/ai/generate-blog",{title:a.title,category:a.category}),s=t.data?.data||t.data;r(l=>({...l,content:s.content||l.content,excerpt:s.excerpt||l.excerpt,slug:s.slug||l.slug||y(l.title),category:s.suggested_category||s.category||l.category,featured_image:s.featured_image||l.featured_image})),i.success("AI content generated!")}catch{const t=y(a.title),s=`Discover everything about ${a.title}. Read our comprehensive guide at AIKart DigiLicense.`;r(l=>({...l,slug:l.slug||t,excerpt:l.excerpt||s})),i.success("Basic content filled in")}finally{E(!1)}},U=["all","published","draft"],T=n.filter(t=>{const s=b==="all"||t.status===b,l=!p||t.title?.toLowerCase().includes(p.toLowerCase());return s&&l}),q=n.filter(t=>t.status==="published").length,K=n.filter(t=>t.status==="draft").length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[e.jsx(_,{className:"h-6 w-6 text-violet-600"})," Blog Manager"]}),e.jsxs("p",{className:"text-sm text-slate-500 mt-0.5",children:[n.length," posts total"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:N,className:"flex items-center gap-1.5 rounded-xl border border-slate-200 px-3 py-2 text-sm font-semibold text-slate-600 hover:bg-slate-50 transition",children:[e.jsx(W,{className:"h-4 w-4"})," Refresh"]}),e.jsxs("button",{onClick:F,className:"flex items-center gap-2 rounded-xl bg-violet-600 px-4 py-2 text-sm font-bold text-white hover:bg-violet-700 transition",children:[e.jsx(X,{className:"h-4 w-4"})," New Post"]})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[{label:"Total Posts",value:n.length,color:"bg-violet-50 border-violet-100 text-violet-700"},{label:"Published",value:q,color:"bg-emerald-50 border-emerald-100 text-emerald-700"}
1,{label:"Drafts",value:K,color:"bg-amber-50 border-amber-100 text-amber-700"}].map(t=>e.jsxs("div",{className:w("rounded-2xl border p-4",t.color),children:[e.jsx("p",{className:"text-2xl font-bold",children:t.value}),e.jsx("p",{className:"text-xs font-semibold mt-0.5 opacity-80",children:t.label})]},t.label))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-sm",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx("input",{value:p,onChange:t=>R(t.target.value),placeholder:"Search posts...",className:"w-full rounded-xl border border-slate-200 pl-9 pr-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100"})]}),e.jsx("div",{className:"flex gap-1 p-1 rounded-xl bg-slate-100",children:U.map(t=>e.jsx("button",{onClick:()=>z(t),className:w("rounded-lg px-3 py-1.5 text-xs font-semibold capitalize transition",b===t?"bg-white text-violet-700 shadow-sm":"text-slate-500 hover:text-slate-700"),children:t},t))})]}),e.jsx("div",{className:"rounded-2xl border border-slate-100 bg-white shadow-sm overflow-hidden",children:L?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(h,{className:"h-8 w-8 animate-spin text-violet-500"})}):T.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-3 text-slate-400",children:[e.jsx(_,{className:"h-10 w-10"}),e.jsx("p",{className:"font-semibold",children:"No posts found"}),e.jsx("button",{onClick:F,className:"text-sm font-bold text-violet-600 hover:underline",children:"Create your first post →"})]}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"border-b border-slate-100 bg-slate-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Post"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider hidden sm:table-cell",children:"Category"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider hidden md:table-cell",children:"Date"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-500 uppercase tracking-wider hidden md:table-cell",children:"Status"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-50",children:T.map(t=>e.jsxs("tr",{className:"hover:bg-slate-50 transition",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"font-semibold text-slate-900 line-clamp-1",children:t.title}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:t.author?.name||t.seller?.store_name||"Admin"})]}),e.jsx("td",{className:"px-4 py-3 hidden sm:table-cell",children:e.jsx("span",{className:"rounded-full bg-violet-100 px-2 py-0.5 text-[10px] font-bold text-violet-600",children:t.category||"—"})}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-500 hidden md:table-cell",children:ee(t.created_at)}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsx("span",{className:w("roun
1ded-full px-2 py-0.5 text-[10px] font-bold",t.status==="published"?"bg-emerald-100 text-emerald-600":"bg-amber-100 text-amber-600"),children:t.status==="published"?"Published":"Draft"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[e.jsx("button",{onClick:()=>M(t),title:t.status==="published"?"Set Draft":"Publish",className:"flex h-8 w-8 items-center justify-center rounded-lg text-slate-400 hover:bg-slate-100 hover:text-slate-700 transition",children:t.status==="published"?e.jsx(H,{className:"h-4 w-4"}):e.jsx(J,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>G(t),className:"flex h-8 w-8 items-center justify-center rounded-lg text-slate-400 hover:bg-violet-100 hover:text-violet-600 transition",children:e.jsx(Q,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>$(t.id),disabled:k===t.id,className:"flex h-8 w-8 items-center justify-center rounded-lg text-slate-400 hover:bg-red-100 hover:text-red-600 transition disabled:opacity-50",children:k===t.id?e.jsx(h,{className:"h-4 w-4 animate-spin"}):e.jsx(V,{className:"h-4 w-4"})})]})})]},t.id))})]})}),B&&e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-black/30 backdrop-blur-sm",onClick:u}),e.jsxs("div",{className:"w-full max-w-lg bg-white h-full overflow-y-auto shadow-2xl flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-100",children:[e.jsx("h2",{className:"font-bold text-slate-900 text-lg",children:x?"Edit Post":"New Blog Post"}),e.jsx("button",{onClick:u,className:"flex h-8 w-8 items-center justify-center rounded-lg text-slate-400 hover:bg-slate-100",children:e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 p-6 space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-violet-50 border border-violet-100",children:[e.jsx(A,{className:"h-4 w-4 text-violet-600 flex-shrink-0"}),e.jsx("p",{className:"text-xs text-violet-700 flex-1",children:"Enter a title, then AI fills content, excerpt & slug"}),e.jsxs("button",{onClick:O,disabled:j||!a.title.trim(),className:"flex items-center gap-1.5 rounded-lg bg-violet-600 px-3 py-1.5 text-xs font-bold text-white hover:bg-violet-700 disabled:opacity-50 transition",children:[j?e.jsx(h,{className:"h-3 w-3 animate-spin"}):e.jsx(A,{className:"h-3 w-3"}),j?"Generating...":"AI Fill"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Title *"}),e.jsx("input",{value:a.title,onChange:t=>r(s=>({...s,title:t.target.value})),placeholder:"Post title...",className:"w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Slug"}),e.jsx("input",{value:a.slug,onChange:t=>r(s=>({...s,slug:t.target.value})),placeholder:"url-friendly-slug",className:"w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100 font-mono"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Category"}),e.jsx("input",{value:a.category,onChange:t=>r(s=>({...s,category:t.target.value})),placeholder:"Tech, Guides, News...",className:"w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Status"}),e.jsxs("select",{value:a.status,onChange:t=>r(s=>({...s,status:t.target.value})),className:"w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100 bg-white",children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"published",children:"Published"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Excerpt"}),e.jsx("textarea",{value:a.excerpt,onChange:t=>r(s=>({...s,excerpt:t.target.value})),rows:2,placeholder:"Short summary...",className:"w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100 resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Content"}),e.jsx("textarea",{value:a.content,onChange:t=>r(s=>({...s,content:t.target.value})),rows:10,placeholder:"Write your blog post content...",className:"w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100 resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Featured Image URL"}),e.jsx("input",{value:a.featured_image,onChange:t=>r(s=>({...s,featured_image:t.target.value})),placeholder:"https://...",className:"w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100"})]})]}),e.jsxs("div",{className:"border-t border-slate-100 px-6 py-4 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:u,className:"rounded-xl border border-slate-200 px-4 py-2 text-sm font-semibold text-slate-600 hover:bg-slate-50 transition",children:"Cancel"}),e.jsxs("button",{onClick:I,disabled:v,className:"flex items-center gap-2 rounded-xl bg-violet-600 px-5 py-2 text-sm font-bold text-white hover:bg-violet-700 disabled:opacity-60 transition",children:[v?e.jsx(h,{className:"h-4 w-4 animate-spin"}):null,v?"Saving...":x?"Update Post":"Publish Post"]})]})]})]})]})};export{me 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.