PageSourceSearch

https://novelzy.com/assets/novels-BHDwhrdA.js

js novelzy.com collected 2026-10-02 01:38:01 UTC 9,308 bytes, 3 lines download raw bytes

1import{b as O,u as S,a as R,j as e}from"./vendor-query-6nO0aXI-.js";import{r as x,L as v}from"./vendor-router-yscda1MA.js";import{a as j}from"./api-B7OcOsYd.js";import{r as U}from"./index-BOKZ6oQA.js";import{J as $,i as G,l as Q,n as V,S as W,ab as Y,N as H}from"./vendor-ui-CtoxC0Mt.js";import"./vendor-react-k6yPa1qy.js";const J={romance:"#ec4899",fantasy:"#8b5cf6",mystery:"#f59e0b",thriller:"#ef4444",scifi:"#06b6d4",historical:"#d97706",classic:"#64748b",contemporary:"#10b981",philosophical:"#6366f1",humor:"#f97316"},C={completed:{bg:"#dcfce7",text:"#166534"},ongoing:{bg:"#dbeafe",text:"#1e40af"},draft:{bg:"#f3f4f6",text:"#4b5563"},paused:{bg:"#fef9c3",text:"#854d0e"}},k={en:"🇺🇸",fa:"🇮🇷",ar:"🇸🇦",tr:"🇹🇷",es:"🇪🇸",fr:"🇫🇷",de:"🇩🇪",pt:"🇧🇷",hi:"🇮🇳",ru:"🇷🇺"};function i(r){return r?r>=1e6?(r/1e6).toFixed(1)+"M":r>=1e3?(r/1e3).toFixed(1)+"K":String(r):"0"}function se(){const r=O(),{toast:N}=U(),[o,n]=x.useState(1),[u,L]=x.useState(""),[p,A]=x.useState(""),[g,F]=x.useState(""),[h,T]=x.useState(""),{data:m,isLoading:_}=S({queryKey:["admin-novels",o,u,p,g],queryFn:()=>j.adminGetNovels({page:o,limit:20,search:u,status:p,category:g})}),{data:P}=S({queryKey:["categories"],queryFn:()=>j.getCategories()}),w=R({mutationFn:t=>j.deleteNovel(t),onSuccess:(t,s)=>{r.setQueriesData({queryKey:["admin-novels"]},a=>{if(!a)return a;const d=a?.novels??a;if(!Array.isArray(d))return a;const c=d.filter(K=>K.id!==s);return a?.novels!==void 0?{...a,novels:c,total:Math.max(0,(a.total??c.length)-1)}:c}),r.invalidateQueries({queryKey:["admin-novels"]}),N({title:"Novel deleted successfully"})},onError:t=>{N({title:"Delete failed",description:t.message||"Could not delete novel",variant:"destructive"})}}),l=m?.novels||m||[],y=m?.total||l.length,f=m?.totalPages||Math.ceil(y/20)||1,q=l.filter(t=>t.status!=="draft").length,z=l.filter(t=>t.status==="draft").length,E=l.reduce((t,s)=>t+(s.total_words||0),0),D=l.reduce((t,s)=>t+(s.views||0),0),M=l.reduce((t,s)=>t+(s.likes||0),0),b=h?l.filter(t=>t.language===h):l;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[22px] font-extrabold text-gray-900 flex items-center gap-2",children:"📚 Novel Management"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Manage all novels, chapters, and content"})]}),e.jsxs(v,{href:"/admin/novels/new",className:"flex items-center gap-2 px-5 py-2.5 bg-[#7c3aed] text-white rounded-[10px] text-sm font-semibold hover:bg-[#6d28d9] shadow-md no-underline",children:[e.jsx($,{size:16})," Add New Novel"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4",children:[{label:"Total Novels",value:y,icon:"📚",color:"#7c3aed"},{label:"Published",value:q,icon:"✅",color:"#10b981"},{label:"Drafts",value:z,icon:"📝",color:"#6b7280"},{label:"Total Words",value:i(E),icon:"📖",color:"#3b82f6"},{label:"Total Views",value:i(D),icon:"👁",color:"#f59e0b"},{label:"Total Loves",value:i(M),icon:"❤️",color:"#ec4899"}].map(t=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4 shadow-sm",style:{borderLeft:`4px solid ${t.color}`}
1,children:[e.jsxs("div",{className:"text-xs text-gray-500 mb-1",children:[t.icon," ",t.label]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:t.value})]},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-md",children:[e.jsx(G,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{value:u,onChange:t=>{L(t.target.value),n(1)},placeholder:"Search title or author...",className:"w-full pl-9 pr-3 py-2.5 border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-[#7c3aed]/20 focus:border-[#7c3aed] outline-none"})]}),e.jsxs("select",{value:g,onChange:t=>{F(t.target.value),n(1)},className:"px-3 py-2.5 border border-gray-200 rounded-lg text-sm text-gray-600",children:[e.jsx("option",{value:"",children:"All Categories"}),(P||[]).map(t=>e.jsx("option",{value:t.key,children:t.name_en},t.key))]}),e.jsxs("select",{value:p,onChange:t=>{A(t.target.value),n(1)},className:"px-3 py-2.5 border border-gray-200 rounded-lg text-sm text-gray-600",children:[e.jsx("option",{value:"",children:"All Status"}),e.jsx("option",{value:"ongoing",children:"Ongoing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"paused",children:"Paused"})]}),e.jsxs("select",{value:h,onChange:t=>T(t.target.value),className:"px-3 py-2.5 border border-gray-200 rounded-lg text-sm text-gray-600",children:[e.jsx("option",{value:"",children:"All Languages"}),Object.entries(k).map(([t,s])=>e.jsxs("option",{value:t,children:[s," ",t.toUpperCase()]},t))]}),e.jsxs("span",{className:"text-xs text-gray-400 ml-auto",children:["Showing ",b.length," of ",y," novels"]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-[#f9fafb]",children:["Cover","Title & Author","Category","Status","Lang","Chapters","Words","Views","Loves","Rating","Actions"].map(t=>e.jsx("th",{className:"text-left text-[11px] font-semibold text-gray-500 uppercase tracking-wider px-4 py-3",children:t},t))})}),e.jsx("tbody",{children:_?e.jsx("tr",{children:e.jsx("td",{colSpan:11,className:"text-center py-12 text-gray-400 text-sm",children:"Loading novels..."})}):b.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:11,className:"text-center py-12 text-gray-400 text-sm",children:"No novels found"})}):b.map((t,s)=>{const a=J[t.category_key]||"#6b7280",d=C[t.status]||C.draft;return e.jsxs("tr",{className:"border-b border-gray-100 hover:bg-[#f8f5ff] cursor-pointer transition-colors",style:{animationDelay:`${s*30}ms`},children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"w-10 aspect-[9/16] rounded-md overflow-hidden shadow-sm bg-gray-100 flex items-center justify-center",children:t.cover_url?e.jsx("img",{src:t.cover_url,className:"w-full h-full object-cover",alt:""}):e.jsx("span",{className:"text-[8px] font-bold text-gray-400",children:t.title?.substring(0,2).toUpperCase()})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs(v,{href:`/admin/novels/${t.id}/edit`,className:"no-underline",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 hover:text-[#7c3aed]",children:t.title}),e.jsx("div",{className:"text-[11px] text-gray-400",children:t.author_name}),t.is_featured&&e.jsx("span",{className:"text-[9px] bg-yellow-100 text-yellow-700 px-1.5 py-0.5 rounded font-bold mt-0.5 inline-block",children:"⭐ FEATURED"})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-[11px] font-medium px-2.5 py-1 rounded-md",style:{background:a+"1a",color:a},children:t.category_key})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-[11px] font-bold px-2.5 py-1 rounded-md capitalize",style:{background:d.bg,color:d.text},children:t.status})}),e.jsxs("td",{className:"px-4 py-3 text-xs text-gray-500",children:[k[t.language]||""," ",t.language?.toUpperCase()]}),e.jsx("td",{className:"px-4 py-3 text-sm font-medium text-gray-700",children:t.total_chapters||0}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-600",children:i(t.total_words||0)}),e.jsxs("td",{className:"px-4 py-3 text-sm text-gray-600",children:[e.jsx(Q,{size:12,className:"inline mr-1 opacity-50"}),i(t.views||0)]}),e.jsxs("td",{className:"px-4 py-3 text-sm text-gray-600",children:[e.jsx(V,{size:12,className:"inline mr-1 text-pink-400"}),i(t.likes||0)]}),e.jsxs("td",{className:"px-4 py-3 text-sm",children:[e.jsx(W,{size:12,className:"inline mr-1 text-yellow-400 fill-yellow-400"}),Number(t.rating||0).toFixed(1),e.jsx("span",{className:"text-[10px] text-gray-400",children:"/5"})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(v,{href:`/admin/novels/${t.id}/edit`,className:"p-1.5 hover:bg-[#7c3aed]/10 rounded-lg text-[#7c3aed] no-underline",children:e.jsx(Y,{size:14})}),e.jsx("button",{disabled:w.isPending,onClick:c=>{c.stopPropagation(),confirm(`Delete "${t.title}"?
2
3This will permanently remove all chapters, reviews, and related data. This cannot be undone.`)&&w.mutate(t.id)},className:"p-1.5 hover:bg-red-50 rounded-lg text-red-400 hover:text-red-600 disabled:opacity-40",children:e.jsx(H,{size:14})})]})})]},t.id)})})]})}),f>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100",children:[e.jsxs("span",{className:"text-xs text-gray-400",children:["Page ",o," of ",f]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{disabled:o<=1,onClick:()=>n(o-1),className:"px-3 py-1.5 text-xs rounded-lg border border-gray-200 disabled:opacity-30 hover:bg-gray-50",children:"Prev"}),e.jsx("button",{disabled:o>=f,onClick:()=>n(o+1),className:"px-3 py-1.5 text-xs rounded-lg border border-gray-200 disabled:opacity-30 hover:bg-gray-50",children:"Next"})]})]})]})]})}export{se 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.