63 lines
2.8 KiB
TypeScript
63 lines
2.8 KiB
TypeScript
// PEP-197: the acceptance agent's list in the project chat — per item «Делать» / «Не надо»,
|
||
// below «Делать важные» / «Отклонить всё». Once an item is decided the buttons give way to the outcome.
|
||
import { proposalAction } from "@/app/(app)/actions";
|
||
import { Badge } from "@/components/ui/badge";
|
||
import { Button } from "@/components/ui/button";
|
||
import { getT } from "@/lib/i18n";
|
||
import type { ProposalItem } from "@peppa/core";
|
||
import { m } from "@peppa/shared/i18n";
|
||
|
||
const SEVERITY = {
|
||
breakage: { label: m("Поломка"), variant: "danger" },
|
||
important: { label: m("Важно"), variant: "warn" },
|
||
minor: { label: m("Мелочь"), variant: "muted" },
|
||
} as const;
|
||
|
||
export async function ProposalList({ items, back }: { items: ProposalItem[]; back: string }) {
|
||
const t = await getT();
|
||
const open = items.filter((i) => i.open);
|
||
return (
|
||
<div data-proposals className="mt-1 flex flex-col gap-2">
|
||
{items.map((i) => (
|
||
<div key={i.id} className="flex flex-col gap-2 rounded-md border bg-card p-2 text-sm">
|
||
<div className="flex flex-wrap items-center gap-2">
|
||
<span className="font-mono text-xs text-primary">{i.key}</span>
|
||
<span className="min-w-0 break-words">{i.title}</span>
|
||
{i.severity && (
|
||
<Badge variant={SEVERITY[i.severity].variant} className="ml-auto">
|
||
{t(SEVERITY[i.severity].label)}
|
||
</Badge>
|
||
)}
|
||
</div>
|
||
{i.open ? (
|
||
<form action={proposalAction} className="flex flex-wrap gap-2">
|
||
<input type="hidden" name="ids" value={i.id} />
|
||
<input type="hidden" name="back" value={back} />
|
||
<Button size="sm" name="choice" value="do" className="min-h-11 min-w-11">
|
||
{t("Делать")}
|
||
</Button>
|
||
<Button size="sm" variant="outline" name="choice" value="no" className="min-h-11 min-w-11">
|
||
{t("Не надо")}
|
||
</Button>
|
||
</form>
|
||
) : (
|
||
<span className="text-xs text-muted-foreground">{i.decision === "rejected" ? t("Отклонено") : t("Взято в бэклог")}</span>
|
||
)}
|
||
</div>
|
||
))}
|
||
{open.length > 0 && (
|
||
<form action={proposalAction} className="flex flex-wrap gap-2">
|
||
<input type="hidden" name="ids" value={open.map((i) => i.id).join(",")} />
|
||
<input type="hidden" name="back" value={back} />
|
||
<Button size="sm" name="choice" value="important" className="min-h-11">
|
||
{t("Делать важные")}
|
||
</Button>
|
||
<Button size="sm" variant="outline" name="choice" value="none" className="min-h-11">
|
||
{t("Отклонить всё")}
|
||
</Button>
|
||
</form>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|