refactor: Remove series-related fields and components to streamline novel management
Build and Push Reader Image / docker (push) Successful in 41s
Build and Push Reader Image / docker (push) Successful in 41s
- Eliminated seriesId and related fields from various models and components to simplify the data structure. - Updated UI components to reflect the removal of series dependencies, enhancing clarity and maintainability. - Adjusted API calls and data handling to ensure compatibility with the new structure.
This commit is contained in:
@@ -186,6 +186,7 @@ export function ImportBatchClient() {
|
|||||||
formParse.append("preview", "true")
|
formParse.append("preview", "true")
|
||||||
formParse.append("splitMode", splitMode)
|
formParse.append("splitMode", splitMode)
|
||||||
if (splitMode === "regex") formParse.append("chapterRegex", chapterStartPattern)
|
if (splitMode === "regex") formParse.append("chapterRegex", chapterStartPattern)
|
||||||
|
formParse.append("enforceMaxChapters", "true")
|
||||||
|
|
||||||
const r3 = await fetch("/api/mod/epub", { method: "POST", credentials: "include", body: formParse, signal })
|
const r3 = await fetch("/api/mod/epub", { method: "POST", credentials: "include", body: formParse, signal })
|
||||||
const d3 = await r3.json().catch(() => ({}))
|
const d3 = await r3.json().catch(() => ({}))
|
||||||
@@ -199,7 +200,7 @@ export function ImportBatchClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const chapterCount = Number(d3?.novel?.totalChapters ?? d3?.chapterCount ?? 0)
|
const chapterCount = Number(d3?.novel?.totalChapters ?? d3?.chapterCount ?? 0)
|
||||||
if (d3?.importBlocked === true || chapterCount > BATCH_IMPORT_MAX_CHAPTERS) {
|
if (d3?.importBlocked === true) {
|
||||||
return {
|
return {
|
||||||
fileName: displayPath,
|
fileName: displayPath,
|
||||||
ok: false,
|
ok: false,
|
||||||
@@ -234,6 +235,7 @@ export function ImportBatchClient() {
|
|||||||
formImport.append("description", description)
|
formImport.append("description", description)
|
||||||
formImport.append("genreIds", genreIds.join(","))
|
formImport.append("genreIds", genreIds.join(","))
|
||||||
formImport.append("replaceExisting", String(replaceExisting))
|
formImport.append("replaceExisting", String(replaceExisting))
|
||||||
|
formImport.append("enforceMaxChapters", "true")
|
||||||
|
|
||||||
const r4 = await fetch("/api/mod/epub", { method: "POST", credentials: "include", body: formImport, signal })
|
const r4 = await fetch("/api/mod/epub", { method: "POST", credentials: "include", body: formImport, signal })
|
||||||
const d4 = await r4.json().catch(() => ({}))
|
const d4 = await r4.json().catch(() => ({}))
|
||||||
@@ -367,8 +369,8 @@ export function ImportBatchClient() {
|
|||||||
Ghi đè nếu trùng tiêu đề (tắt = batch chỉ skip khi đã có truyện cùng tiêu đề)
|
Ghi đè nếu trùng tiêu đề (tắt = batch chỉ skip khi đã có truyện cùng tiêu đề)
|
||||||
</label>
|
</label>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
An toàn batch: tối đa {BATCH_IMPORT_MAX_CHAPTERS.toLocaleString()} chương sau khi tách mỗi file; quá{" "}
|
An toàn batch (chỉ khi import nhiều): tối đa {BATCH_IMPORT_MAX_CHAPTERS.toLocaleString()} chương sau khi tách mỗi file; quá{" "}
|
||||||
{Math.round(BATCH_IMPORT_MAX_MS_PER_FILE / 60000)} phút/file thì bỏ qua và xử lý file tiếp theo.
|
{Math.round(BATCH_IMPORT_MAX_MS_PER_FILE / 60000)} phút/file thì bỏ qua và xử lý file tiếp theo. Import một EPUB trên trang khác không bị giới hạn này.
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -11,7 +11,6 @@ export default async function ModDashboardPage() {
|
|||||||
let novelCount = 0
|
let novelCount = 0
|
||||||
let totalViews = 0
|
let totalViews = 0
|
||||||
let commentCount = 0
|
let commentCount = 0
|
||||||
let seriesCount = 0
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const accessToken = (await cookies()).get(AUTH_COOKIE_NAME)?.value || ""
|
const accessToken = (await cookies()).get(AUTH_COOKIE_NAME)?.value || ""
|
||||||
@@ -24,7 +23,6 @@ export default async function ModDashboardPage() {
|
|||||||
novelCount = Number(data?.novelCount || 0)
|
novelCount = Number(data?.novelCount || 0)
|
||||||
totalViews = Number(data?.totalViews || 0)
|
totalViews = Number(data?.totalViews || 0)
|
||||||
commentCount = Number(data?.commentCount || 0)
|
commentCount = Number(data?.commentCount || 0)
|
||||||
seriesCount = Number(data?.seriesCount || 0)
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch mod overview", error)
|
console.error("Failed to fetch mod overview", error)
|
||||||
@@ -37,7 +35,7 @@ export default async function ModDashboardPage() {
|
|||||||
Chào mừng bạn đến với trang quản trị dành cho Moderator.
|
Chào mừng bạn đến với trang quản trị dành cho Moderator.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||||
<div className="rounded-xl border bg-card text-card-foreground shadow p-6">
|
<div className="rounded-xl border bg-card text-card-foreground shadow p-6">
|
||||||
<h3 className="font-semibold text-lg">Tổng truyện</h3>
|
<h3 className="font-semibold text-lg">Tổng truyện</h3>
|
||||||
<p className="text-3xl font-bold mt-2">{novelCount}</p>
|
<p className="text-3xl font-bold mt-2">{novelCount}</p>
|
||||||
@@ -50,10 +48,6 @@ export default async function ModDashboardPage() {
|
|||||||
<h3 className="font-semibold text-lg">Bình luận mới</h3>
|
<h3 className="font-semibold text-lg">Bình luận mới</h3>
|
||||||
<p className="text-3xl font-bold mt-2">{commentCount}</p>
|
<p className="text-3xl font-bold mt-2">{commentCount}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded-xl border bg-card text-card-foreground shadow p-6">
|
|
||||||
<h3 className="font-semibold text-lg">Tổng series</h3>
|
|
||||||
<p className="text-3xl font-bold mt-2">{seriesCount}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { requireModSessionUser } from "@/lib/server-auth"
|
|
||||||
import { SeriesClient } from "./series-client"
|
|
||||||
|
|
||||||
export default async function ModSeriesPage() {
|
|
||||||
await requireModSessionUser()
|
|
||||||
|
|
||||||
return <SeriesClient />
|
|
||||||
}
|
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
"use client"
|
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from "react"
|
|
||||||
import { Layers, Loader2, Pencil, Plus, Save, Trash2, X } from "lucide-react"
|
|
||||||
import { toast } from "sonner"
|
|
||||||
import { Button } from "@/components/ui/button"
|
|
||||||
import { Input } from "@/components/ui/input"
|
|
||||||
import { Textarea } from "@/components/ui/textarea"
|
|
||||||
|
|
||||||
interface SeriesItem {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
slug: string
|
|
||||||
description?: string | null
|
|
||||||
_count?: {
|
|
||||||
novels: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SeriesClient() {
|
|
||||||
const [series, setSeries] = useState<SeriesItem[]>([])
|
|
||||||
const [loading, setLoading] = useState(true)
|
|
||||||
const [submitting, setSubmitting] = useState(false)
|
|
||||||
const [name, setName] = useState("")
|
|
||||||
const [description, setDescription] = useState("")
|
|
||||||
const [editingId, setEditingId] = useState<string | null>(null)
|
|
||||||
const [keyword, setKeyword] = useState("")
|
|
||||||
|
|
||||||
const filteredSeries = useMemo(() => {
|
|
||||||
const q = keyword.trim().toLowerCase()
|
|
||||||
if (!q) return series
|
|
||||||
return series.filter((item) => {
|
|
||||||
return (
|
|
||||||
item.name.toLowerCase().includes(q) ||
|
|
||||||
item.slug.toLowerCase().includes(q) ||
|
|
||||||
(item.description || "").toLowerCase().includes(q)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}, [keyword, series])
|
|
||||||
|
|
||||||
const fetchSeries = async () => {
|
|
||||||
try {
|
|
||||||
const res = await fetch("/api/mod/series")
|
|
||||||
if (!res.ok) throw new Error("Không thể tải danh sách series")
|
|
||||||
const data = await res.json()
|
|
||||||
setSeries(data)
|
|
||||||
} catch (error: any) {
|
|
||||||
toast.error(error.message || "Không thể tải danh sách series")
|
|
||||||
} finally {
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetchSeries()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const resetForm = () => {
|
|
||||||
setEditingId(null)
|
|
||||||
setName("")
|
|
||||||
setDescription("")
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
|
||||||
e.preventDefault()
|
|
||||||
if (!name.trim()) {
|
|
||||||
toast.error("Vui lòng nhập tên series")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setSubmitting(true)
|
|
||||||
try {
|
|
||||||
const payload = {
|
|
||||||
id: editingId,
|
|
||||||
name: name.trim(),
|
|
||||||
description: description.trim(),
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await fetch("/api/mod/series", {
|
|
||||||
method: editingId ? "PUT" : "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
})
|
|
||||||
|
|
||||||
const data = await res.json()
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error(data.error || "Không thể lưu series")
|
|
||||||
}
|
|
||||||
|
|
||||||
toast.success(editingId ? "Đã cập nhật series" : "Đã tạo series")
|
|
||||||
resetForm()
|
|
||||||
fetchSeries()
|
|
||||||
} catch (error: any) {
|
|
||||||
toast.error(error.message || "Không thể lưu series")
|
|
||||||
} finally {
|
|
||||||
setSubmitting(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleEdit = (item: SeriesItem) => {
|
|
||||||
setEditingId(item.id)
|
|
||||||
setName(item.name)
|
|
||||||
setDescription(item.description || "")
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDelete = async (id: string) => {
|
|
||||||
if (!confirm("Bạn chắc chắn muốn xóa series này?")) return
|
|
||||||
|
|
||||||
setSubmitting(true)
|
|
||||||
try {
|
|
||||||
const res = await fetch(`/api/mod/series?id=${id}`, { method: "DELETE" })
|
|
||||||
const data = await res.json()
|
|
||||||
if (!res.ok) {
|
|
||||||
throw new Error(data.error || "Không thể xóa series")
|
|
||||||
}
|
|
||||||
|
|
||||||
toast.success("Đã xóa series")
|
|
||||||
if (editingId === id) resetForm()
|
|
||||||
fetchSeries()
|
|
||||||
} catch (error: any) {
|
|
||||||
toast.error(error.message || "Không thể xóa series")
|
|
||||||
} finally {
|
|
||||||
setSubmitting(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-6">
|
|
||||||
<div className="bg-card rounded-xl border shadow-sm p-4 flex items-center justify-between">
|
|
||||||
<h1 className="text-2xl font-bold flex items-center gap-2">
|
|
||||||
<Layers className="h-6 w-6 text-primary" /> Quản lý series
|
|
||||||
</h1>
|
|
||||||
<Input
|
|
||||||
value={keyword}
|
|
||||||
onChange={(e) => setKeyword(e.target.value)}
|
|
||||||
placeholder="Tìm series..."
|
|
||||||
className="max-w-xs"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-1 xl:grid-cols-3 gap-4">
|
|
||||||
<div className="xl:col-span-1 rounded-xl border bg-card p-4 shadow-sm">
|
|
||||||
<h2 className="text-base font-semibold mb-3">{editingId ? "Chỉnh sửa series" : "Tạo series mới"}</h2>
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-3">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium">Tên series</label>
|
|
||||||
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder="Ví dụ: Overlord" />
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium">Mô tả</label>
|
|
||||||
<Textarea
|
|
||||||
value={description}
|
|
||||||
onChange={(e) => setDescription(e.target.value)}
|
|
||||||
placeholder="Mô tả ngắn về series"
|
|
||||||
rows={4}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<Button type="submit" disabled={submitting} className="gap-2">
|
|
||||||
{submitting && <Loader2 className="h-4 w-4 animate-spin" />}
|
|
||||||
{editingId ? <Save className="h-4 w-4" /> : <Plus className="h-4 w-4" />}
|
|
||||||
{editingId ? "Lưu" : "Tạo"}
|
|
||||||
</Button>
|
|
||||||
{editingId && (
|
|
||||||
<Button type="button" variant="outline" onClick={resetForm} className="gap-2">
|
|
||||||
<X className="h-4 w-4" /> Hủy
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="xl:col-span-2 rounded-xl border bg-card shadow-sm overflow-hidden">
|
|
||||||
<div className="overflow-x-auto">
|
|
||||||
<table className="w-full text-sm text-left">
|
|
||||||
<thead className="text-xs uppercase bg-muted/50 text-muted-foreground border-b border-border">
|
|
||||||
<tr>
|
|
||||||
<th className="px-4 py-3 font-semibold">Tên</th>
|
|
||||||
<th className="px-4 py-3 font-semibold">Slug</th>
|
|
||||||
<th className="px-4 py-3 font-semibold">Số truyện</th>
|
|
||||||
<th className="px-4 py-3 font-semibold">Mô tả</th>
|
|
||||||
<th className="px-4 py-3 text-right font-semibold">Thao tác</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{loading ? (
|
|
||||||
<tr>
|
|
||||||
<td colSpan={5} className="p-8 text-center text-muted-foreground">
|
|
||||||
<Loader2 className="w-5 h-5 animate-spin mx-auto" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
) : filteredSeries.length === 0 ? (
|
|
||||||
<tr>
|
|
||||||
<td colSpan={5} className="p-8 text-center text-muted-foreground">
|
|
||||||
Chưa có series nào
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
) : (
|
|
||||||
filteredSeries.map((item) => (
|
|
||||||
<tr key={item.id} className="border-b border-border last:border-0 hover:bg-muted/30">
|
|
||||||
<td className="px-4 py-3 font-medium">{item.name}</td>
|
|
||||||
<td className="px-4 py-3 text-muted-foreground">{item.slug}</td>
|
|
||||||
<td className="px-4 py-3">{item._count?.novels ?? 0}</td>
|
|
||||||
<td className="px-4 py-3 text-muted-foreground max-w-sm truncate">{item.description || "-"}</td>
|
|
||||||
<td className="px-4 py-3">
|
|
||||||
<div className="flex items-center justify-end gap-2">
|
|
||||||
<Button size="icon" variant="outline" className="h-8 w-8" onClick={() => handleEdit(item)}>
|
|
||||||
<Pencil className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="outline"
|
|
||||||
className="h-8 w-8 text-red-600 border-red-200 hover:bg-red-50"
|
|
||||||
onClick={() => handleDelete(item.id)}
|
|
||||||
>
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -24,11 +24,6 @@ type MissingNovel = {
|
|||||||
description: string
|
description: string
|
||||||
totalChapters: number
|
totalChapters: number
|
||||||
updatedAt: string
|
updatedAt: string
|
||||||
series: {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
slug: string
|
|
||||||
} | null
|
|
||||||
genres: Genre[]
|
genres: Genre[]
|
||||||
missing: Record<MissingKey, boolean>
|
missing: Record<MissingKey, boolean>
|
||||||
}
|
}
|
||||||
@@ -528,7 +523,7 @@ export function MissingFieldsClient() {
|
|||||||
<Input
|
<Input
|
||||||
value={queryInput}
|
value={queryInput}
|
||||||
onChange={(e) => setQueryInput(e.target.value)}
|
onChange={(e) => setQueryInput(e.target.value)}
|
||||||
placeholder="Tìm theo tên truyện, slug, tác giả, series..."
|
placeholder="Tìm theo tên truyện, slug, tác giả..."
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
setSearchKeyword(queryInput)
|
setSearchKeyword(queryInput)
|
||||||
@@ -658,7 +653,7 @@ export function MissingFieldsClient() {
|
|||||||
<Link href={`/truyen/${item.slug}`} className="font-semibold text-primary hover:underline" target="_blank">
|
<Link href={`/truyen/${item.slug}`} className="font-semibold text-primary hover:underline" target="_blank">
|
||||||
{item.title}
|
{item.title}
|
||||||
</Link>
|
</Link>
|
||||||
<p className="text-xs text-muted-foreground">{item.series?.name || "Độc lập"} - {item.totalChapters} chương</p>
|
<p className="text-xs text-muted-foreground">{item.totalChapters} chương</p>
|
||||||
<div className="flex flex-wrap gap-1">
|
<div className="flex flex-wrap gap-1">
|
||||||
{allMissingKeys.filter((key) => item.missing[key]).map((key) => (
|
{allMissingKeys.filter((key) => item.missing[key]).map((key) => (
|
||||||
<span key={key} className="rounded-full border border-amber-300 bg-amber-100 px-2 py-0.5 text-[11px] font-medium text-amber-700">
|
<span key={key} className="rounded-full border border-amber-300 bg-amber-100 px-2 py-0.5 text-[11px] font-medium text-amber-700">
|
||||||
|
|||||||
@@ -28,11 +28,6 @@ interface Novel {
|
|||||||
status: string
|
status: string
|
||||||
totalChapters: number
|
totalChapters: number
|
||||||
coverUrl?: string
|
coverUrl?: string
|
||||||
series?: {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
slug: string
|
|
||||||
} | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Genre {
|
interface Genre {
|
||||||
@@ -40,15 +35,6 @@ interface Genre {
|
|||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SeriesOption {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
slug: string
|
|
||||||
_count?: {
|
|
||||||
novels: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EpubPreviewData {
|
interface EpubPreviewData {
|
||||||
fileName: string
|
fileName: string
|
||||||
splitMode: "toc" | "regex"
|
splitMode: "toc" | "regex"
|
||||||
@@ -139,9 +125,6 @@ export function NovelClient() {
|
|||||||
const [epubTitle, setEpubTitle] = useState("")
|
const [epubTitle, setEpubTitle] = useState("")
|
||||||
const [epubAuthorName, setEpubAuthorName] = useState("")
|
const [epubAuthorName, setEpubAuthorName] = useState("")
|
||||||
const [epubDescription, setEpubDescription] = useState("")
|
const [epubDescription, setEpubDescription] = useState("")
|
||||||
const [epubSeriesMode, setEpubSeriesMode] = useState<"none" | "existing" | "new">("none")
|
|
||||||
const [epubSeriesId, setEpubSeriesId] = useState("")
|
|
||||||
const [epubSeriesName, setEpubSeriesName] = useState("")
|
|
||||||
const [epubSplitMode, setEpubSplitMode] = useState<"toc" | "regex">("toc")
|
const [epubSplitMode, setEpubSplitMode] = useState<"toc" | "regex">("toc")
|
||||||
const [epubRegexPreset, setEpubRegexPreset] = useState<string>("vi_chuong_hoi")
|
const [epubRegexPreset, setEpubRegexPreset] = useState<string>("vi_chuong_hoi")
|
||||||
const [epubCustomRegex, setEpubCustomRegex] = useState("")
|
const [epubCustomRegex, setEpubCustomRegex] = useState("")
|
||||||
@@ -155,9 +138,6 @@ export function NovelClient() {
|
|||||||
const [originalAuthorName, setOriginalAuthorName] = useState("")
|
const [originalAuthorName, setOriginalAuthorName] = useState("")
|
||||||
const [description, setDescription] = useState("")
|
const [description, setDescription] = useState("")
|
||||||
const [coverUrl, setCoverUrl] = useState("")
|
const [coverUrl, setCoverUrl] = useState("")
|
||||||
const [seriesMode, setSeriesMode] = useState<"none" | "existing" | "new">("none")
|
|
||||||
const [selectedSeriesId, setSelectedSeriesId] = useState("")
|
|
||||||
const [newSeriesName, setNewSeriesName] = useState("")
|
|
||||||
const [status, setStatus] = useState("Đang ra")
|
const [status, setStatus] = useState("Đang ra")
|
||||||
|
|
||||||
// View state
|
// View state
|
||||||
@@ -171,7 +151,6 @@ export function NovelClient() {
|
|||||||
|
|
||||||
// Genre states
|
// Genre states
|
||||||
const [genres, setGenres] = useState<Genre[]>([])
|
const [genres, setGenres] = useState<Genre[]>([])
|
||||||
const [seriesList, setSeriesList] = useState<SeriesOption[]>([])
|
|
||||||
const [selectedGenres, setSelectedGenres] = useState<string[]>([])
|
const [selectedGenres, setSelectedGenres] = useState<string[]>([])
|
||||||
const [genreQuery, setGenreQuery] = useState("")
|
const [genreQuery, setGenreQuery] = useState("")
|
||||||
const [addingGenre, setAddingGenre] = useState(false)
|
const [addingGenre, setAddingGenre] = useState(false)
|
||||||
@@ -340,14 +319,9 @@ export function NovelClient() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchSeries = async () => {
|
|
||||||
setSeriesList([])
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchNovels()
|
fetchNovels()
|
||||||
fetchGenres()
|
fetchGenres()
|
||||||
fetchSeries()
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const normalizeGenreName = (value: string) => value.trim().toLowerCase()
|
const normalizeGenreName = (value: string) => value.trim().toLowerCase()
|
||||||
@@ -359,9 +333,6 @@ export function NovelClient() {
|
|||||||
setOriginalAuthorName("")
|
setOriginalAuthorName("")
|
||||||
setDescription("")
|
setDescription("")
|
||||||
setCoverUrl("")
|
setCoverUrl("")
|
||||||
setSeriesMode("none")
|
|
||||||
setSelectedSeriesId("")
|
|
||||||
setNewSeriesName("")
|
|
||||||
setStatus("Đang ra")
|
setStatus("Đang ra")
|
||||||
setSelectedGenres([])
|
setSelectedGenres([])
|
||||||
setGenreQuery("")
|
setGenreQuery("")
|
||||||
@@ -377,9 +348,6 @@ export function NovelClient() {
|
|||||||
setOriginalAuthorName((prefill.originalAuthorName || nextAuthor).trim())
|
setOriginalAuthorName((prefill.originalAuthorName || nextAuthor).trim())
|
||||||
setDescription((prefill.description || "").trim())
|
setDescription((prefill.description || "").trim())
|
||||||
setCoverUrl((prefill.coverUrl || "").trim())
|
setCoverUrl((prefill.coverUrl || "").trim())
|
||||||
setSeriesMode("none")
|
|
||||||
setSelectedSeriesId("")
|
|
||||||
setNewSeriesName("")
|
|
||||||
setGenreQuery("")
|
setGenreQuery("")
|
||||||
|
|
||||||
const validStatus = ["Đang ra", "Hoàn thành", "Tạm ngưng"].includes(prefill.status || "")
|
const validStatus = ["Đang ra", "Hoàn thành", "Tạm ngưng"].includes(prefill.status || "")
|
||||||
@@ -448,7 +416,7 @@ export function NovelClient() {
|
|||||||
if (!keyword) return novels
|
if (!keyword) return novels
|
||||||
|
|
||||||
return novels.filter((novel) => {
|
return novels.filter((novel) => {
|
||||||
const searchable = [novel.title, novel.authorName, novel.series?.name || ""].join(" ").toLowerCase()
|
const searchable = [novel.title, novel.authorName].join(" ").toLowerCase()
|
||||||
return searchable.includes(keyword)
|
return searchable.includes(keyword)
|
||||||
})
|
})
|
||||||
}, [novels, searchKeyword])
|
}, [novels, searchKeyword])
|
||||||
@@ -546,7 +514,6 @@ export function NovelClient() {
|
|||||||
toast.success(`Đã xóa ${data.deletedCount || selectedNovelIds.length} truyện`)
|
toast.success(`Đã xóa ${data.deletedCount || selectedNovelIds.length} truyện`)
|
||||||
setSelectedNovelIds([])
|
setSelectedNovelIds([])
|
||||||
fetchNovels()
|
fetchNovels()
|
||||||
fetchSeries()
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast.error(error.message || "Lỗi khi xóa hàng loạt")
|
toast.error(error.message || "Lỗi khi xóa hàng loạt")
|
||||||
} finally {
|
} finally {
|
||||||
@@ -720,20 +687,6 @@ export function NovelClient() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolvedNewSeriesName = seriesMode === "new"
|
|
||||||
? (newSeriesName.trim() || title.trim())
|
|
||||||
: ""
|
|
||||||
|
|
||||||
if (seriesMode === "existing" && !selectedSeriesId) {
|
|
||||||
toast.error("Vui lòng chọn series đã có")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seriesMode === "new" && !resolvedNewSeriesName) {
|
|
||||||
toast.error("Vui lòng nhập tên series mới")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setSubmitting(true)
|
setSubmitting(true)
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/api/mod/truyen", {
|
const res = await fetch("/api/mod/truyen", {
|
||||||
@@ -747,8 +700,6 @@ export function NovelClient() {
|
|||||||
description,
|
description,
|
||||||
coverUrl,
|
coverUrl,
|
||||||
genreIds: selectedGenres,
|
genreIds: selectedGenres,
|
||||||
seriesId: seriesMode === "existing" ? selectedSeriesId : undefined,
|
|
||||||
seriesName: seriesMode === "new" ? resolvedNewSeriesName : undefined,
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
if (!res.ok) throw new Error("Thêm mới thất bại")
|
if (!res.ok) throw new Error("Thêm mới thất bại")
|
||||||
@@ -756,7 +707,6 @@ export function NovelClient() {
|
|||||||
setOpenAdd(false)
|
setOpenAdd(false)
|
||||||
resetAddForm()
|
resetAddForm()
|
||||||
fetchNovels()
|
fetchNovels()
|
||||||
fetchSeries()
|
|
||||||
} catch {
|
} catch {
|
||||||
toast.error("Lỗi khi thêm truyện mới")
|
toast.error("Lỗi khi thêm truyện mới")
|
||||||
} finally {
|
} finally {
|
||||||
@@ -775,9 +725,6 @@ export function NovelClient() {
|
|||||||
setEpubTitle("")
|
setEpubTitle("")
|
||||||
setEpubAuthorName("")
|
setEpubAuthorName("")
|
||||||
setEpubDescription("")
|
setEpubDescription("")
|
||||||
setEpubSeriesMode("none")
|
|
||||||
setEpubSeriesId("")
|
|
||||||
setEpubSeriesName("")
|
|
||||||
setEpubSplitMode("toc")
|
setEpubSplitMode("toc")
|
||||||
setEpubRegexPreset("vi_chuong_hoi")
|
setEpubRegexPreset("vi_chuong_hoi")
|
||||||
setEpubCustomRegex("")
|
setEpubCustomRegex("")
|
||||||
@@ -811,9 +758,6 @@ export function NovelClient() {
|
|||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append("file", file)
|
formData.append("file", file)
|
||||||
formData.append("preview", "true")
|
formData.append("preview", "true")
|
||||||
formData.append("seriesMode", epubSeriesMode)
|
|
||||||
if (epubSeriesMode === "existing") formData.append("seriesId", epubSeriesId)
|
|
||||||
if (epubSeriesMode === "new") formData.append("seriesName", epubSeriesName)
|
|
||||||
formData.append("splitMode", splitMode)
|
formData.append("splitMode", splitMode)
|
||||||
|
|
||||||
if (splitMode === "regex") {
|
if (splitMode === "regex") {
|
||||||
@@ -930,25 +874,12 @@ export function NovelClient() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epubSeriesMode === "existing" && !epubSeriesId) {
|
|
||||||
toast.error("Vui lòng chọn series đã có")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (epubSeriesMode === "new" && !epubSeriesName.trim()) {
|
|
||||||
toast.error("Vui lòng nhập tên series mới")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setUploadingEpub(true)
|
setUploadingEpub(true)
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append("file", pendingEpubFile)
|
formData.append("file", pendingEpubFile)
|
||||||
formData.append("title", epubTitle)
|
formData.append("title", epubTitle)
|
||||||
formData.append("authorName", epubAuthorName)
|
formData.append("authorName", epubAuthorName)
|
||||||
formData.append("description", epubDescription)
|
formData.append("description", epubDescription)
|
||||||
formData.append("seriesMode", epubSeriesMode)
|
|
||||||
if (epubSeriesMode === "existing") formData.append("seriesId", epubSeriesId)
|
|
||||||
if (epubSeriesMode === "new") formData.append("seriesName", epubSeriesName.trim())
|
|
||||||
formData.append("splitMode", epubSplitMode)
|
formData.append("splitMode", epubSplitMode)
|
||||||
|
|
||||||
if (epubSplitMode === "regex") {
|
if (epubSplitMode === "regex") {
|
||||||
@@ -988,7 +919,6 @@ export function NovelClient() {
|
|||||||
}
|
}
|
||||||
resetEpubPreviewState()
|
resetEpubPreviewState()
|
||||||
fetchNovels()
|
fetchNovels()
|
||||||
fetchSeries()
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
toast.error(err.message || "Có lỗi xảy ra khi xuất bản truyện")
|
toast.error(err.message || "Có lỗi xảy ra khi xuất bản truyện")
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1002,16 +932,6 @@ export function NovelClient() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epubSeriesMode === "existing" && !epubSeriesId) {
|
|
||||||
toast.error("Vui lòng chọn series đã có")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (epubSeriesMode === "new" && !epubSeriesName.trim()) {
|
|
||||||
toast.error("Vui lòng nhập tên series mới")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setUploadingEpub(true)
|
setUploadingEpub(true)
|
||||||
initializeBulkProgress(pendingEpubFiles)
|
initializeBulkProgress(pendingEpubFiles)
|
||||||
|
|
||||||
@@ -1026,9 +946,6 @@ export function NovelClient() {
|
|||||||
try {
|
try {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append("file", file)
|
formData.append("file", file)
|
||||||
formData.append("seriesMode", epubSeriesMode)
|
|
||||||
if (epubSeriesMode === "existing") formData.append("seriesId", epubSeriesId)
|
|
||||||
if (epubSeriesMode === "new") formData.append("seriesName", epubSeriesName.trim())
|
|
||||||
formData.append("splitMode", "toc")
|
formData.append("splitMode", "toc")
|
||||||
|
|
||||||
setBulkProgressItem(fileKey, {
|
setBulkProgressItem(fileKey, {
|
||||||
@@ -1119,7 +1036,6 @@ export function NovelClient() {
|
|||||||
|
|
||||||
resetEpubPreviewState()
|
resetEpubPreviewState()
|
||||||
fetchNovels()
|
fetchNovels()
|
||||||
fetchSeries()
|
|
||||||
} finally {
|
} finally {
|
||||||
setUploadingEpub(false)
|
setUploadingEpub(false)
|
||||||
}
|
}
|
||||||
@@ -1161,15 +1077,6 @@ export function NovelClient() {
|
|||||||
setEditingNovel(novel)
|
setEditingNovel(novel)
|
||||||
setTitle(novel.title)
|
setTitle(novel.title)
|
||||||
setAuthorName(novel.authorName)
|
setAuthorName(novel.authorName)
|
||||||
if (novel.series?.id) {
|
|
||||||
setSeriesMode("existing")
|
|
||||||
setSelectedSeriesId(novel.series.id)
|
|
||||||
setNewSeriesName("")
|
|
||||||
} else {
|
|
||||||
setSeriesMode("none")
|
|
||||||
setSelectedSeriesId("")
|
|
||||||
setNewSeriesName("")
|
|
||||||
}
|
|
||||||
setStatus(novel.status)
|
setStatus(novel.status)
|
||||||
setDescription("")
|
setDescription("")
|
||||||
setGenreQuery("")
|
setGenreQuery("")
|
||||||
@@ -1186,11 +1093,6 @@ export function NovelClient() {
|
|||||||
setDescription(data.description || "")
|
setDescription(data.description || "")
|
||||||
setOriginalTitle(data.originalTitle || "")
|
setOriginalTitle(data.originalTitle || "")
|
||||||
setOriginalAuthorName(data.originalAuthorName || "")
|
setOriginalAuthorName(data.originalAuthorName || "")
|
||||||
if (data.series?.id) {
|
|
||||||
setSeriesMode("existing")
|
|
||||||
setSelectedSeriesId(data.series.id)
|
|
||||||
setNewSeriesName("")
|
|
||||||
}
|
|
||||||
if (data.genres && Array.isArray(data.genres)) {
|
if (data.genres && Array.isArray(data.genres)) {
|
||||||
setSelectedGenres(data.genres.map((g: any) => g.id))
|
setSelectedGenres(data.genres.map((g: any) => g.id))
|
||||||
} else {
|
} else {
|
||||||
@@ -1213,16 +1115,6 @@ export function NovelClient() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seriesMode === "existing" && !selectedSeriesId) {
|
|
||||||
toast.error("Vui lòng chọn series đã có")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seriesMode === "new" && !newSeriesName.trim()) {
|
|
||||||
toast.error("Vui lòng nhập tên series mới")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setSubmitting(true)
|
setSubmitting(true)
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/api/mod/truyen", {
|
const res = await fetch("/api/mod/truyen", {
|
||||||
@@ -1247,7 +1139,6 @@ export function NovelClient() {
|
|||||||
toast.success("Cập nhật truyện thành công!")
|
toast.success("Cập nhật truyện thành công!")
|
||||||
setOpenEdit(false)
|
setOpenEdit(false)
|
||||||
fetchNovels()
|
fetchNovels()
|
||||||
fetchSeries()
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast.error(error.message)
|
toast.error(error.message)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1501,53 +1392,6 @@ export function NovelClient() {
|
|||||||
<label className="text-xs font-medium text-muted-foreground">Mô tả</label>
|
<label className="text-xs font-medium text-muted-foreground">Mô tả</label>
|
||||||
<Textarea value={epubDescription} onChange={(e) => setEpubDescription(e.target.value)} rows={3} />
|
<Textarea value={epubDescription} onChange={(e) => setEpubDescription(e.target.value)} rows={3} />
|
||||||
</div>
|
</div>
|
||||||
<div className="grid gap-2">
|
|
||||||
<label className="text-xs font-medium text-muted-foreground">Series (tùy chọn)</label>
|
|
||||||
<select
|
|
||||||
value={epubSeriesMode}
|
|
||||||
onChange={(e) => {
|
|
||||||
const mode = e.target.value as "none" | "existing" | "new"
|
|
||||||
setEpubSeriesMode(mode)
|
|
||||||
if (mode !== "existing") setEpubSeriesId("")
|
|
||||||
if (mode === "new" && !epubSeriesName.trim()) {
|
|
||||||
setEpubSeriesName(epubTitle.trim())
|
|
||||||
}
|
|
||||||
if (mode !== "new") setEpubSeriesName("")
|
|
||||||
}}
|
|
||||||
className="flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
||||||
>
|
|
||||||
<option value="none">Không gán series</option>
|
|
||||||
<option value="existing">Thêm vào series có sẵn</option>
|
|
||||||
<option value="new">Tạo series mới</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{epubSeriesMode === "existing" && (
|
|
||||||
<div className="grid gap-2">
|
|
||||||
<label className="text-xs font-medium text-muted-foreground">Chọn series</label>
|
|
||||||
<select
|
|
||||||
value={epubSeriesId}
|
|
||||||
onChange={(e) => setEpubSeriesId(e.target.value)}
|
|
||||||
className="flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
||||||
>
|
|
||||||
<option value="">-- Chọn series --</option>
|
|
||||||
{seriesList.map((series) => (
|
|
||||||
<option key={series.id} value={series.id}>{series.name}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{epubSeriesMode === "new" && (
|
|
||||||
<div className="grid gap-2">
|
|
||||||
<label className="text-xs font-medium text-muted-foreground">Tên series mới</label>
|
|
||||||
<Input
|
|
||||||
value={epubSeriesName}
|
|
||||||
onChange={(e) => setEpubSeriesName(e.target.value)}
|
|
||||||
placeholder="Ví dụ: Harry Potter"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -1604,8 +1448,6 @@ export function NovelClient() {
|
|||||||
!epubPreviewData ||
|
!epubPreviewData ||
|
||||||
!epubTitle.trim() ||
|
!epubTitle.trim() ||
|
||||||
!epubAuthorName.trim() ||
|
!epubAuthorName.trim() ||
|
||||||
(epubSeriesMode === "existing" && !epubSeriesId) ||
|
|
||||||
(epubSeriesMode === "new" && !epubSeriesName.trim()) ||
|
|
||||||
(epubSplitMode === "regex" && epubRegexPreset === "custom" && !epubCustomRegex.trim())
|
(epubSplitMode === "regex" && epubRegexPreset === "custom" && !epubCustomRegex.trim())
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -1628,9 +1470,9 @@ export function NovelClient() {
|
|||||||
>
|
>
|
||||||
<DialogContent className="w-[96vw] max-w-[96vw] sm:!max-w-[920px] max-h-[85vh] overflow-y-auto">
|
<DialogContent className="w-[96vw] max-w-[96vw] sm:!max-w-[920px] max-h-[85vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Import nhiều EPUB vào series</DialogTitle>
|
<DialogTitle>Import nhiều EPUB</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Đã chọn {pendingEpubFiles.length} file EPUB (từ file lẻ hoặc thư mục con). Mỗi file sẽ tạo thành một truyện và được gán vào cùng series.
|
Đã chọn {pendingEpubFiles.length} file EPUB (từ file lẻ hoặc thư mục con). Mỗi file sẽ tạo thành một truyện riêng.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
@@ -1716,55 +1558,6 @@ export function NovelClient() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-2">
|
|
||||||
<label className="text-sm font-medium">Series</label>
|
|
||||||
<select
|
|
||||||
value={epubSeriesMode}
|
|
||||||
onChange={(e) => {
|
|
||||||
const mode = e.target.value as "none" | "existing" | "new"
|
|
||||||
setEpubSeriesMode(mode)
|
|
||||||
if (mode !== "existing") setEpubSeriesId("")
|
|
||||||
if (mode === "new" && !epubSeriesName.trim()) {
|
|
||||||
const fallbackTitle = pendingEpubFiles[0]?.name?.replace(/\.epub$/i, "") || ""
|
|
||||||
setEpubSeriesName(fallbackTitle)
|
|
||||||
}
|
|
||||||
if (mode !== "new") setEpubSeriesName("")
|
|
||||||
}}
|
|
||||||
className="flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
||||||
>
|
|
||||||
<option value="none">Không gán series</option>
|
|
||||||
<option value="existing">Thêm vào series có sẵn</option>
|
|
||||||
<option value="new">Tạo series mới</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{epubSeriesMode === "existing" && (
|
|
||||||
<div className="grid gap-2">
|
|
||||||
<label className="text-sm font-medium">Chọn series</label>
|
|
||||||
<select
|
|
||||||
value={epubSeriesId}
|
|
||||||
onChange={(e) => setEpubSeriesId(e.target.value)}
|
|
||||||
className="flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
||||||
>
|
|
||||||
<option value="">-- Chọn series --</option>
|
|
||||||
{seriesList.map((series) => (
|
|
||||||
<option key={series.id} value={series.id}>{series.name}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{epubSeriesMode === "new" && (
|
|
||||||
<div className="grid gap-2">
|
|
||||||
<label className="text-sm font-medium">Tên series mới</label>
|
|
||||||
<Input
|
|
||||||
value={epubSeriesName}
|
|
||||||
onChange={(e) => setEpubSeriesName(e.target.value)}
|
|
||||||
placeholder="Ví dụ: Chronicles of Narnia"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogFooter className="sticky bottom-0 bg-background pt-2">
|
<DialogFooter className="sticky bottom-0 bg-background pt-2">
|
||||||
@@ -1773,9 +1566,7 @@ export function NovelClient() {
|
|||||||
onClick={handleBulkEpubUpload}
|
onClick={handleBulkEpubUpload}
|
||||||
disabled={
|
disabled={
|
||||||
uploadingEpub ||
|
uploadingEpub ||
|
||||||
pendingEpubFiles.length === 0 ||
|
pendingEpubFiles.length === 0
|
||||||
(epubSeriesMode === "existing" && !epubSeriesId) ||
|
|
||||||
(epubSeriesMode === "new" && !epubSeriesName.trim())
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{uploadingEpub && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
{uploadingEpub && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||||
@@ -1808,14 +1599,7 @@ export function NovelClient() {
|
|||||||
<label className="text-sm font-medium">Tên truyện</label>
|
<label className="text-sm font-medium">Tên truyện</label>
|
||||||
<Input
|
<Input
|
||||||
value={title}
|
value={title}
|
||||||
onChange={(e) => {
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
const nextTitle = e.target.value
|
|
||||||
const shouldSyncSeriesName = seriesMode === "new" && (!newSeriesName.trim() || newSeriesName === title)
|
|
||||||
setTitle(nextTitle)
|
|
||||||
if (shouldSyncSeriesName) {
|
|
||||||
setNewSeriesName(nextTitle)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
placeholder="Ví dụ: Phàm Nhân Tu Tiên"
|
placeholder="Ví dụ: Phàm Nhân Tu Tiên"
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
@@ -1832,51 +1616,6 @@ export function NovelClient() {
|
|||||||
<label className="text-sm font-medium">Tác giả gốc (Tùy chọn)</label>
|
<label className="text-sm font-medium">Tác giả gốc (Tùy chọn)</label>
|
||||||
<Input value={originalAuthorName} onChange={(e) => setOriginalAuthorName(e.target.value)} placeholder="Ví dụ: 忘语" />
|
<Input value={originalAuthorName} onChange={(e) => setOriginalAuthorName(e.target.value)} placeholder="Ví dụ: 忘语" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium">Series</label>
|
|
||||||
<select
|
|
||||||
value={seriesMode}
|
|
||||||
onChange={(e) => {
|
|
||||||
const mode = e.target.value as "none" | "existing" | "new"
|
|
||||||
setSeriesMode(mode)
|
|
||||||
if (mode !== "existing") setSelectedSeriesId("")
|
|
||||||
if (mode === "new" && !newSeriesName.trim()) {
|
|
||||||
setNewSeriesName(title.trim())
|
|
||||||
}
|
|
||||||
if (mode !== "new") setNewSeriesName("")
|
|
||||||
}}
|
|
||||||
className="flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
||||||
>
|
|
||||||
<option value="none">Không gán series</option>
|
|
||||||
<option value="existing">Chọn series có sẵn</option>
|
|
||||||
<option value="new">Tạo series mới</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
{seriesMode === "existing" && (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium">Chọn series</label>
|
|
||||||
<select
|
|
||||||
value={selectedSeriesId}
|
|
||||||
onChange={(e) => setSelectedSeriesId(e.target.value)}
|
|
||||||
className="flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm"
|
|
||||||
>
|
|
||||||
<option value="">-- Chọn series --</option>
|
|
||||||
{seriesList.map((series) => (
|
|
||||||
<option key={series.id} value={series.id}>{series.name}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{seriesMode === "new" && (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium">Tên series mới</label>
|
|
||||||
<Input
|
|
||||||
value={newSeriesName}
|
|
||||||
onChange={(e) => setNewSeriesName(e.target.value)}
|
|
||||||
placeholder="Ví dụ: Chronicles of Narnia"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-medium">Ảnh bìa (Tùy chọn)</label>
|
<label className="text-sm font-medium">Ảnh bìa (Tùy chọn)</label>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
@@ -1937,17 +1676,6 @@ export function NovelClient() {
|
|||||||
<label className="text-sm font-medium">Tác giả gốc (Tùy chọn)</label>
|
<label className="text-sm font-medium">Tác giả gốc (Tùy chọn)</label>
|
||||||
<Input value={originalAuthorName} onChange={(e) => setOriginalAuthorName(e.target.value)} />
|
<Input value={originalAuthorName} onChange={(e) => setOriginalAuthorName(e.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium">Series</label>
|
|
||||||
<Input
|
|
||||||
value={editingNovel?.series?.name || "Độc lập"}
|
|
||||||
disabled
|
|
||||||
className="bg-muted"
|
|
||||||
/>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Không thể chỉnh sửa series tại màn hình sửa truyện.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-medium">Ảnh bìa (Tùy chọn)</label>
|
<label className="text-sm font-medium">Ảnh bìa (Tùy chọn)</label>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
@@ -2028,7 +1756,7 @@ export function NovelClient() {
|
|||||||
<Input
|
<Input
|
||||||
value={searchKeyword}
|
value={searchKeyword}
|
||||||
onChange={(e) => setSearchKeyword(e.target.value)}
|
onChange={(e) => setSearchKeyword(e.target.value)}
|
||||||
placeholder="Tìm theo tên truyện, tác giả, series..."
|
placeholder="Tìm theo tên truyện, tác giả..."
|
||||||
className="pl-8"
|
className="pl-8"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -2114,7 +1842,6 @@ export function NovelClient() {
|
|||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-5 py-4 font-semibold">Tên truyện</th>
|
<th scope="col" className="px-5 py-4 font-semibold">Tên truyện</th>
|
||||||
<th scope="col" className="px-5 py-4 font-semibold">Tác giả</th>
|
<th scope="col" className="px-5 py-4 font-semibold">Tác giả</th>
|
||||||
<th scope="col" className="px-5 py-4 font-semibold">Series</th>
|
|
||||||
<th scope="col" className="px-5 py-4 font-semibold">Số chương</th>
|
<th scope="col" className="px-5 py-4 font-semibold">Số chương</th>
|
||||||
<th scope="col" className="px-5 py-4 font-semibold">Trạng thái</th>
|
<th scope="col" className="px-5 py-4 font-semibold">Trạng thái</th>
|
||||||
<th scope="col" className="px-5 py-4 text-right font-semibold">Thao tác</th>
|
<th scope="col" className="px-5 py-4 text-right font-semibold">Thao tác</th>
|
||||||
@@ -2122,9 +1849,9 @@ export function NovelClient() {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<tr><td colSpan={7} className="p-8 text-center text-muted-foreground"><Loader2 className="h-6 w-6 animate-spin mx-auto" /></td></tr>
|
<tr><td colSpan={6} className="p-8 text-center text-muted-foreground"><Loader2 className="h-6 w-6 animate-spin mx-auto" /></td></tr>
|
||||||
) : filteredNovels.length === 0 ? (
|
) : filteredNovels.length === 0 ? (
|
||||||
<tr><td colSpan={7} className="p-8 text-center text-muted-foreground">Không có truyện phù hợp với từ khóa tìm kiếm.</td></tr>
|
<tr><td colSpan={6} className="p-8 text-center text-muted-foreground">Không có truyện phù hợp với từ khóa tìm kiếm.</td></tr>
|
||||||
) : (
|
) : (
|
||||||
pagedNovels.map((novel) => (
|
pagedNovels.map((novel) => (
|
||||||
<tr key={novel.id} className="border-b border-border hover:bg-muted/30 transition-colors last:border-0">
|
<tr key={novel.id} className="border-b border-border hover:bg-muted/30 transition-colors last:border-0">
|
||||||
@@ -2145,11 +1872,6 @@ export function NovelClient() {
|
|||||||
{novel.title}
|
{novel.title}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-5 py-4 text-muted-foreground">{novel.authorName}</td>
|
<td className="px-5 py-4 text-muted-foreground">{novel.authorName}</td>
|
||||||
<td className="px-5 py-4">
|
|
||||||
<span className={`inline-flex items-center justify-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${novel.series ? "bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300" : "bg-muted text-muted-foreground"}`}>
|
|
||||||
{novel.series?.name || "Độc lập"}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="px-5 py-4">
|
<td className="px-5 py-4">
|
||||||
<span className="inline-flex items-center justify-center rounded-full bg-primary/10 px-2.5 py-0.5 text-xs font-semibold text-primary">
|
<span className="inline-flex items-center justify-center rounded-full bg-primary/10 px-2.5 py-0.5 text-xs font-semibold text-primary">
|
||||||
{novel.totalChapters}
|
{novel.totalChapters}
|
||||||
@@ -2224,11 +1946,6 @@ export function NovelClient() {
|
|||||||
<div className="p-3 flex flex-col flex-1">
|
<div className="p-3 flex flex-col flex-1">
|
||||||
<h3 className="font-semibold text-sm line-clamp-2 leading-tight mb-1" title={novel.title}>{novel.title}</h3>
|
<h3 className="font-semibold text-sm line-clamp-2 leading-tight mb-1" title={novel.title}>{novel.title}</h3>
|
||||||
<p className="text-xs text-muted-foreground mb-3">{novel.authorName}</p>
|
<p className="text-xs text-muted-foreground mb-3">{novel.authorName}</p>
|
||||||
<p className="text-[11px] mb-3">
|
|
||||||
<span className={`inline-flex items-center rounded-full px-2 py-0.5 font-semibold ${novel.series ? "bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300" : "bg-muted text-muted-foreground"}`}>
|
|
||||||
{novel.series?.name || "Độc lập"}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div className="mt-auto grid grid-cols-3 gap-1.5">
|
<div className="mt-auto grid grid-cols-3 gap-1.5">
|
||||||
<Button size="sm" variant="outline" className="w-full h-7 text-xs px-0 text-emerald-600 hover:text-emerald-700 hover:bg-emerald-50" asChild>
|
<Button size="sm" variant="outline" className="w-full h-7 text-xs px-0 text-emerald-600 hover:text-emerald-700 hover:bg-emerald-50" asChild>
|
||||||
|
|||||||
+3
-5
@@ -20,7 +20,6 @@ type HomeNovel = {
|
|||||||
status: string
|
status: string
|
||||||
description: string
|
description: string
|
||||||
bookmarkCount: number
|
bookmarkCount: number
|
||||||
seriesId: string | null
|
|
||||||
updatedAt: string | null
|
updatedAt: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ type RecommendedByCountItem = {
|
|||||||
|
|
||||||
type RankingEntry = {
|
type RankingEntry = {
|
||||||
id: string
|
id: string
|
||||||
seriesId: string | null
|
|
||||||
novel: HomeNovel
|
novel: HomeNovel
|
||||||
aggregatedViews: number
|
aggregatedViews: number
|
||||||
}
|
}
|
||||||
@@ -188,9 +186,9 @@ export default async function HomePage() {
|
|||||||
randomNovels = [...popularItems].sort(() => Math.random() - 0.5).slice(0, 12)
|
randomNovels = [...popularItems].sort(() => Math.random() - 0.5).slice(0, 12)
|
||||||
latestNovels = latestItems
|
latestNovels = latestItems
|
||||||
recentComments = []
|
recentComments = []
|
||||||
weeklyRanking = popularItems.slice(0, 5).map((novel) => ({ id: novel.id, seriesId: novel.seriesId, novel, aggregatedViews: novel.views }))
|
weeklyRanking = popularItems.slice(0, 5).map((novel) => ({ id: novel.id, novel, aggregatedViews: novel.views }))
|
||||||
monthlyRanking = popularItems.slice(5, 10).map((novel) => ({ id: novel.id, seriesId: novel.seriesId, novel, aggregatedViews: novel.views }))
|
monthlyRanking = popularItems.slice(5, 10).map((novel) => ({ id: novel.id, novel, aggregatedViews: novel.views }))
|
||||||
allTimeRanking = popularItems.slice(10, 15).map((novel) => ({ id: novel.id, seriesId: novel.seriesId, novel, aggregatedViews: novel.views }))
|
allTimeRanking = popularItems.slice(10, 15).map((novel) => ({ id: novel.id, novel, aggregatedViews: novel.views }))
|
||||||
|
|
||||||
for (const novel of latestNovels) {
|
for (const novel of latestNovels) {
|
||||||
latestChapterMap.set(novel.id, {
|
latestChapterMap.set(novel.id, {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ type BrowseNovel = {
|
|||||||
views: number
|
views: number
|
||||||
totalChapters: number
|
totalChapters: number
|
||||||
status: string
|
status: string
|
||||||
seriesId?: string | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BrowseResponse = {
|
type BrowseResponse = {
|
||||||
@@ -55,7 +54,7 @@ export default async function GenreDetailPage({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const browse = await readerApiFetch<BrowseResponse>(
|
const browse = await readerApiFetch<BrowseResponse>(
|
||||||
`/api/novels/browse?genre=${encodeURIComponent(slug)}&sort=${sort}&page=${requestedPage}&limit=${PAGE_SIZE}&collapse_series=true`
|
`/api/novels/browse?genre=${encodeURIComponent(slug)}&sort=${sort}&page=${requestedPage}&limit=${PAGE_SIZE}`
|
||||||
)
|
)
|
||||||
|
|
||||||
const totalPages = Math.max(1, browse.totalPages || 1)
|
const totalPages = Math.max(1, browse.totalPages || 1)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ type BrowseNovel = {
|
|||||||
views: number
|
views: number
|
||||||
totalChapters: number
|
totalChapters: number
|
||||||
status: string
|
status: string
|
||||||
seriesId?: string | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BrowseResponse = {
|
type BrowseResponse = {
|
||||||
@@ -34,24 +33,6 @@ type GenreItem = {
|
|||||||
slug: string
|
slug: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function collapseSeriesRows<T extends { id: string; seriesId?: string | null }>(rows: T[]): T[] {
|
|
||||||
const pickedSeries = new Set<string>()
|
|
||||||
const output: T[] = []
|
|
||||||
|
|
||||||
for (const row of rows) {
|
|
||||||
if (!row.seriesId) {
|
|
||||||
output.push(row)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pickedSeries.has(row.seriesId)) continue
|
|
||||||
pickedSeries.add(row.seriesId)
|
|
||||||
output.push(row)
|
|
||||||
}
|
|
||||||
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildBrowsePath(params: Record<string, string>) {
|
function buildBrowsePath(params: Record<string, string>) {
|
||||||
const search = new URLSearchParams(params)
|
const search = new URLSearchParams(params)
|
||||||
return `/api/novels/browse?${search.toString()}`
|
return `/api/novels/browse?${search.toString()}`
|
||||||
@@ -100,7 +81,6 @@ export default async function SearchPage({
|
|||||||
status: statusFilter === "all" ? "" : statusFilter,
|
status: statusFilter === "all" ? "" : statusFilter,
|
||||||
page: String(requestedPage),
|
page: String(requestedPage),
|
||||||
limit: String(PAGE_SIZE),
|
limit: String(PAGE_SIZE),
|
||||||
collapse_series: "true",
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { notFound } from "next/navigation"
|
import { notFound } from "next/navigation"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { BookOpen, Eye, BookMarked, User, Clock, Layers } from "lucide-react"
|
|
||||||
import { formatViews } from "@/lib/utils"
|
import { formatViews } from "@/lib/utils"
|
||||||
import { GenreBadge } from "@/components/genre-badge"
|
import { GenreBadge } from "@/components/genre-badge"
|
||||||
import { StarRating } from "@/components/star-rating"
|
import { StarRating } from "@/components/star-rating"
|
||||||
@@ -18,15 +17,6 @@ type NovelGenre = {
|
|||||||
slug: string
|
slug: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SeriesNovel = {
|
|
||||||
id: string
|
|
||||||
slug: string
|
|
||||||
title: string
|
|
||||||
status: string
|
|
||||||
totalChapters: number
|
|
||||||
coverUrl: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
type NovelDetail = {
|
type NovelDetail = {
|
||||||
id: string
|
id: string
|
||||||
title: string
|
title: string
|
||||||
@@ -41,14 +31,7 @@ type NovelDetail = {
|
|||||||
views: number
|
views: number
|
||||||
ratingCount: number
|
ratingCount: number
|
||||||
bookmarkCount: number
|
bookmarkCount: number
|
||||||
seriesId: string | null
|
|
||||||
genres: NovelGenre[]
|
genres: NovelGenre[]
|
||||||
series: {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
slug: string
|
|
||||||
novels: SeriesNovel[]
|
|
||||||
} | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChaptersResponse = {
|
type ChaptersResponse = {
|
||||||
@@ -100,28 +83,15 @@ export default async function NovelDetailPage({
|
|||||||
let totalChapters = 0
|
let totalChapters = 0
|
||||||
let totalPages = 1
|
let totalPages = 1
|
||||||
let firstChapterNumber: number | undefined
|
let firstChapterNumber: number | undefined
|
||||||
let seriesVolumes: Array<{
|
|
||||||
id: string
|
|
||||||
slug: string
|
|
||||||
title: string
|
|
||||||
status: string
|
|
||||||
totalChapters: number
|
|
||||||
coverUrl: string | null
|
|
||||||
}> = []
|
|
||||||
const [firstChapterData, commentsData, chapterCommentsData, chaptersData] = await Promise.all([
|
const [firstChapterData, commentsData, chapterCommentsData, chaptersData] = await Promise.all([
|
||||||
readerApiFetch<ChaptersResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/chapters?page=1&limit=1`),
|
readerApiFetch<ChaptersResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/chapters?page=1&limit=1`),
|
||||||
readerApiFetch<CommentsResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/comments?page=1&limit=50`),
|
readerApiFetch<CommentsResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/comments?page=1&limit=50`),
|
||||||
readerApiFetch<CommentsResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/comments?scope=chapter&page=1&limit=50`),
|
readerApiFetch<CommentsResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/comments?scope=chapter&page=1&limit=50`),
|
||||||
novel.seriesId
|
readerApiFetch<ChaptersResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/chapters?page=${currentPage}&limit=${limit}`),
|
||||||
? Promise.resolve(null)
|
|
||||||
: readerApiFetch<ChaptersResponse>(`/api/truyen/${encodeURIComponent(novel.id)}/chapters?page=${currentPage}&limit=${limit}`),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
firstChapterNumber = firstChapterData.chapters[0]?.number
|
firstChapterNumber = firstChapterData.chapters[0]?.number
|
||||||
|
|
||||||
if (novel.seriesId) {
|
|
||||||
seriesVolumes = novel.series?.novels || []
|
|
||||||
} else if (chaptersData) {
|
|
||||||
totalChapters = chaptersData.totalChapters
|
totalChapters = chaptersData.totalChapters
|
||||||
totalPages = Math.max(1, chaptersData.totalPages || 1)
|
totalPages = Math.max(1, chaptersData.totalPages || 1)
|
||||||
formattedChapters = chaptersData.chapters.map((chapter) => ({
|
formattedChapters = chaptersData.chapters.map((chapter) => ({
|
||||||
@@ -136,7 +106,6 @@ export default async function NovelDetailPage({
|
|||||||
views: chapter.views || 0,
|
views: chapter.views || 0,
|
||||||
content: "",
|
content: "",
|
||||||
}))
|
}))
|
||||||
}
|
|
||||||
|
|
||||||
const comments = commentsData.comments.map((comment) => ({
|
const comments = commentsData.comments.map((comment) => ({
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
@@ -242,35 +211,6 @@ export default async function NovelDetailPage({
|
|||||||
<div className="text-sm leading-relaxed text-foreground/80 whitespace-pre-wrap">{novel.description || ""}</div>
|
<div className="text-sm leading-relaxed text-foreground/80 whitespace-pre-wrap">{novel.description || ""}</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* Chapter list or series volumes */}
|
|
||||||
{novel.seriesId ? (
|
|
||||||
<section className="mt-8">
|
|
||||||
<h2 className="mb-3 text-lg font-bold text-foreground">Danh Sách Quyển</h2>
|
|
||||||
<div className="rounded-lg border border-border bg-card divide-y divide-border">
|
|
||||||
{seriesVolumes.map((volume, idx) => (
|
|
||||||
<Link
|
|
||||||
key={volume.id}
|
|
||||||
href={`/truyen/${volume.slug}`}
|
|
||||||
className={`flex items-center gap-4 px-4 py-3 hover:bg-muted/40 transition-colors ${volume.id === novel.id ? "bg-primary/5" : ""}`}
|
|
||||||
>
|
|
||||||
<span className="w-8 text-center text-sm font-semibold text-muted-foreground">{idx + 1}</span>
|
|
||||||
<img
|
|
||||||
src={volume.coverUrl || "/default-cover.svg"}
|
|
||||||
alt={volume.title}
|
|
||||||
className="h-14 w-10 rounded bg-muted object-contain"
|
|
||||||
/>
|
|
||||||
<div className="min-w-0 flex-1">
|
|
||||||
<p className="font-medium text-foreground truncate">{volume.title}</p>
|
|
||||||
<p className="text-xs text-muted-foreground">{volume.totalChapters} chương</p>
|
|
||||||
</div>
|
|
||||||
<span className={`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-semibold ${getNovelStatusBadgeClass(volume.status)}`}>
|
|
||||||
{volume.status}
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
) : (
|
|
||||||
<section className="mt-8">
|
<section className="mt-8">
|
||||||
<h2 className="mb-3 text-lg font-bold text-foreground">Danh Sách Chương</h2>
|
<h2 className="mb-3 text-lg font-bold text-foreground">Danh Sách Chương</h2>
|
||||||
<div className="rounded-lg border border-border bg-card">
|
<div className="rounded-lg border border-border bg-card">
|
||||||
@@ -283,7 +223,6 @@ export default async function NovelDetailPage({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Comments */}
|
{/* Comments */}
|
||||||
<section className="mt-8">
|
<section className="mt-8">
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ type SearchSuggestion = {
|
|||||||
slug: string
|
slug: string
|
||||||
authorName: string
|
authorName: string
|
||||||
coverUrl?: string | null
|
coverUrl?: string | null
|
||||||
series?: { id: string; name: string } | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function roleLabel(role?: "USER" | "MOD" | "ADMIN") {
|
function roleLabel(role?: "USER" | "MOD" | "ADMIN") {
|
||||||
@@ -149,11 +148,6 @@ export function Header() {
|
|||||||
<p className="truncate text-sm font-medium text-foreground">{item.title}</p>
|
<p className="truncate text-sm font-medium text-foreground">{item.title}</p>
|
||||||
<p className="truncate text-xs text-muted-foreground">{item.authorName}</p>
|
<p className="truncate text-xs text-muted-foreground">{item.authorName}</p>
|
||||||
</div>
|
</div>
|
||||||
{item.series?.name && (
|
|
||||||
<span className="max-w-[120px] truncate text-[11px] font-medium text-primary">
|
|
||||||
{item.series.name}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ export interface Novel {
|
|||||||
title: string
|
title: string
|
||||||
slug: string
|
slug: string
|
||||||
authorName: string
|
authorName: string
|
||||||
series?: {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
slug: string
|
|
||||||
} | null
|
|
||||||
coverColor: string
|
coverColor: string
|
||||||
description: string
|
description: string
|
||||||
genres: string[]
|
genres: string[]
|
||||||
|
|||||||
@@ -82,8 +82,6 @@ model Novel {
|
|||||||
title String
|
title String
|
||||||
originalTitle String?
|
originalTitle String?
|
||||||
slug String @unique
|
slug String @unique
|
||||||
seriesId String?
|
|
||||||
series Series? @relation(fields: [seriesId], references: [id], onDelete: SetNull)
|
|
||||||
authorName String // Tên tác giả nguyên bản của truyện
|
authorName String // Tên tác giả nguyên bản của truyện
|
||||||
originalAuthorName String?
|
originalAuthorName String?
|
||||||
uploaderId String? // Tham chiếu đến User (Mod/Admin) đã upload
|
uploaderId String? // Tham chiếu đến User (Mod/Admin) đã upload
|
||||||
@@ -123,18 +121,6 @@ model NovelViewDaily {
|
|||||||
@@index([day])
|
@@index([day])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Series {
|
|
||||||
id String @id @default(cuid())
|
|
||||||
name String
|
|
||||||
slug String @unique
|
|
||||||
description String? @db.Text
|
|
||||||
|
|
||||||
novels Novel[]
|
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
model Genre {
|
model Genre {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
name String @unique
|
name String @unique
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user