peppa/apps/web/components/SubscriptionRequest.tsx

29 lines
1.4 KiB
TypeScript
Raw Permalink 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" }: { projectId: number; offer: "can" | "sent"; back: string; name?: string; size?: "xs" | "sm" }) {
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 }} />
<Button size={size} variant="outline">
<HandHelping className="size-3.5" />
{name ? t("Попросить подписку у администратора — {project}", { project: name }) : t("Попросить подписку у администратора")}
</Button>
</form>
);
}