Files
tonesc-red-packet/tonesc-red-packet/app/admin/[id]/page.tsx
2026-01-07 23:22:15 +08:00

89 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { getRedPacketByAdminId } from "@/app/server/actions/get-red-packet";
import { notFound } from "next/navigation"
import { PublicIdSection } from "./public-id-section";
import { DrawList } from "./draw-list.client";
import { getRedPacketDrawsByRedPacketId } from "@/app/server/actions/get-red-packet-draws";
import { getDecimalPlacesFromStep } from "@/lib/currency";
import { formatAmount } from "@/lib/format-amount";
export const metadata = {
title: "红包管理 - tonesc 红包",
description: "查看红包基本信息和抽取记录,支持后台发放及数据管理,保证高精度金额与并发安全。",
keywords: "红包管理, 红包后台, 抽取记录, 私有红包, tonesc",
robots: "noindex, nofollow", // 管理页不希望被搜索引擎收录
openGraph: {
title: "红包管理 - tonesc 红包",
description: "查看红包基本信息和抽取记录,支持后台发放及数据管理,保证高精度金额与并发安全。",
url: "https://redpacket.lab.tonesc.com/manage/[id]",
siteName: "tonesc 红包",
type: "website"
}
}
type Props = {
params: Promise<{ id: string }>
}
export default async function AdminRedPacketPage({ params }: Props) {
const { id: adminId } = await params;
const redPacket = await getRedPacketByAdminId(adminId)
if (!redPacket) {
notFound()
}
const { id: redPacketId } = redPacket;
const initialDraws = await getRedPacketDrawsByRedPacketId(redPacketId);
const precision = getDecimalPlacesFromStep(redPacket.currencyPrecision);
return (
<main className="mx-auto max-w-md p-4 space-y-4">
<h1 className="text-xl font-semibold"></h1>
<section className="rounded-lg border p-3 space-y-2">
<div>
<span className="text-gray-500"> ID</span>
<span className="font-mono">{redPacket.id}</span>
</div>
<div>
<span className="text-gray-500"></span>
<span>{redPacket.count}</span>
</div>
<div>
<span className="text-gray-500"></span>
<span>
{redPacket.currencyName} {formatAmount(redPacket.currencyPrecision, precision)}
</span>
</div>
{redPacket.maxDrawTimes !== null && (
<div>
<span className="text-gray-500"></span>
<span>{redPacket.maxDrawTimes}</span>
</div>
)}
</section>
<section className="rounded-lg border p-3">
<div className="text-gray-500 mb-1"></div>
<pre className="text-sm bg-gray-50 rounded p-2 overflow-x-auto">
{JSON.stringify(redPacket.rule, null, 2)}
</pre>
</section>
<DrawList
precision={precision}
redPacketId={redPacketId}
initialDraws={initialDraws}
/>
<PublicIdSection publicId={redPacket.publicId} />
</main>
)
}