Add clean-pdf tool page with web form and Zotero section
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
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 { buildZoteroScript } from "@/lib/clean-pdf/zotero-script";
|
||||
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";
|
||||
const zoteroScript = buildZoteroScript({ apiKey: key, baseUrl });
|
||||
|
||||
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} script={zoteroScript} baseUrl={baseUrl} />
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user