import Link from "next/link"; import { desc, sql } from "drizzle-orm"; import { ArrowUpRight, Plus } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { db } from "@/db"; import { shareTexts } from "@/db/schema"; export const dynamic = "force-dynamic"; function formatBangkok(date: Date) { return new Intl.DateTimeFormat("en-GB", { dateStyle: "medium", timeStyle: "short", timeZone: "Asia/Bangkok", }).format(date); } export default async function AllSharesPage() { const shares = await db .select({ id: shareTexts.id, authorName: shareTexts.authorName, source: shareTexts.source, description: shareTexts.description, contentPreview: sql`left(${shareTexts.content}, 160)`, createdAt: shareTexts.createdAt, }) .from(shareTexts) .orderBy(desc(shareTexts.createdAt)); return (

Share

{shares.length.toLocaleString("th-TH")} ลิงก์สาธารณะ

ข้อความที่แชร์ทั้งหมด เลือกข้อความเพื่อเปิดหน้าสาธารณะ
Share Preview Author Source Created Open {shares.length === 0 ? ( ยังไม่มีข้อความที่แชร์ ) : ( shares.map((share) => ( {share.id}

{share.description || share.contentPreview}

{share.authorName} {share.source === "bot" ? "Bot" : "Web"} {formatBangkok(share.createdAt)}
)) )}
{shares.length === 0 ? (

ยังไม่มีข้อความที่แชร์

) : ( shares.map((share) => ( {share.id} {share.authorName} · {formatBangkok(share.createdAt)}

{share.description || share.contentPreview}

{share.source === "bot" ? "Bot" : "Web"}
)) )}
); }