49 lines
2.2 KiB
TypeScript
49 lines
2.2 KiB
TypeScript
import { headers } from "next/headers";
|
||
import { auth } from "@/lib/auth";
|
||
import { getMonthlyLimit, getMonthlyUsage, hasPaidAccess } from "@/lib/clean-pdf/access";
|
||
import { getOrCreatePdfKey } from "@/lib/clean-pdf/keys";
|
||
import { CleanPdfForm } from "./CleanPdfForm";
|
||
import { ZoteroSection } from "./ZoteroSection";
|
||
|
||
export const metadata = { title: "Чистый PDF — Obsidian Toolbox" };
|
||
|
||
export default async function CleanPdfToolPage() {
|
||
const session = await auth.api.getSession({ headers: await headers() });
|
||
const userId = session?.user.id;
|
||
const paid = userId ? await hasPaidAccess(userId) : false;
|
||
|
||
if (!userId || !paid) {
|
||
return (
|
||
<main className="mx-auto w-full max-w-5xl px-6 py-8">
|
||
<h1 className="text-2xl font-bold tracking-wide" style={{ color: "var(--foreground)" }}>Чистый PDF</h1>
|
||
<div className="mt-6 card-aubade p-4">
|
||
<p className="text-sm" style={{ color: "var(--muted-foreground)" }}>
|
||
Инструмент доступен студентам платных курсов школы. Если у вас есть купленный курс — проверьте, что вы вошли в нужный аккаунт.
|
||
</p>
|
||
</div>
|
||
</main>
|
||
);
|
||
}
|
||
|
||
const [key, used] = await Promise.all([getOrCreatePdfKey(userId), getMonthlyUsage(userId)]);
|
||
const limit = getMonthlyLimit();
|
||
const baseUrl = process.env.NEXT_PUBLIC_APP_URL ?? "https://school.second-brain.ru";
|
||
|
||
return (
|
||
<main className="mx-auto w-full max-w-5xl px-6 py-8">
|
||
<h1 className="text-2xl font-bold tracking-wide" style={{ color: "var(--foreground)" }}>Чистый PDF</h1>
|
||
<p className="mt-1 text-sm" style={{ color: "var(--muted-foreground)" }}>
|
||
Превращает любую веб-страницу в аккуратный PDF: без рекламы, меню и мусора — только текст, картинки и оглавление.
|
||
</p>
|
||
|
||
<div className="mt-6 card-aubade p-4">
|
||
<CleanPdfForm initialUsed={used} limit={limit} />
|
||
</div>
|
||
|
||
<div className="mt-6 card-aubade p-4">
|
||
<ZoteroSection apiKey={key} baseUrl={baseUrl} />
|
||
</div>
|
||
</main>
|
||
);
|
||
}
|