peppa/apps/web/components/SubscriptionRequest.tsx
peppa-bot 380b6fb5dc PEP-206: «Попросить подписку у администратора» всегда в «Настройки проекта → Подписки»
Запрос заранее, пока агенты работают: суперадмину «Одолжить на сутки» /
«Отказать», запрос не закрывается сам и не показывается полосой лимита.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 00:06:39 +05:00

29 lines
1.5 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.

// PEP-186: «Попросить подписку у администратора» — agents stand on a limit (or a broken sign-in)
// of the project's subscription; the owner or a member asks the superadmin to lend one.
import { HandHelping } from "lucide-react";
import { getT } from "@/lib/i18n";
import { Hidden } from "@/components/cards";
import { Button } from "@/components/ui/button";
import { requestSubscriptionAction } from "@/app/(app)/actions";
export async function SubscriptionRequestButton({ projectId, offer, back, name, size = "sm", ahead }: { projectId: number; offer: "can" | "sent"; back: string; name?: string; size?: "xs" | "sm"; /** PEP-206: may be asked while the agents still work. */ ahead?: boolean }) {
const t = await getT();
if (offer === "sent") {
return (
<span data-subscription-request="sent" className="text-muted-foreground">
{name ? `${name}: ` : ""}
{t("Запрос отправлен — ждём ответа администратора")}
</span>
);
}
return (
<form action={requestSubscriptionAction} data-subscription-request="can" className="inline">
<Hidden fields={{ projectId, back, ahead: ahead ? "1" : null }} />
<Button size={size} variant="outline">
<HandHelping className="size-3.5" />
{name ? t("Попросить подписку у администратора — {project}", { project: name }) : t("Попросить подписку у администратора")}
</Button>
</form>
);
}