Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/dashboard/subscriptions-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type Subscriptions = SubscriptionActionHandlers & {
const statusColor = {
active: "bg-income text-white",
cancelled: "bg-destructive text-white",
paused: "bg-yellow text-black",
};

type SubscriptionSummaryCardsProps = {
Expand Down Expand Up @@ -103,8 +102,11 @@ function SubscriptionInfo({
{payment.name}
</p>
<Badge
variant="secondary"
className={cn("shrink-0 text-xs", statusColor[payment.status])}
variant={payment.status === "paused" ? "warning" : "secondary"}
className={cn(
"shrink-0 text-xs",
payment.status !== "paused" ? statusColor[payment.status] : undefined,
)}
>
{t(`common.${payment.status}`)}
</Badge>
Expand Down
2 changes: 2 additions & 0 deletions components/ui/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const badgeVariants = cva(
'rounded-full bg-needs-bg text-needs border-needs/20',
wants:
'rounded-full bg-wants-bg text-wants border-wants/20',
warning:
'rounded-full bg-warning-bg text-warning border-warning/20',
},
},
defaultVariants: {
Expand Down
14 changes: 14 additions & 0 deletions tests/components/badge.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render } from "@testing-library/react";
import { describe, expect, it } from "vitest";

import { Badge } from "@/components/ui/badge";

describe("Badge warning variant", () => {
it("renders with theme-safe warning background and text classes", () => {
const { container } = render(<Badge variant="warning">Paused</Badge>);
const el = container.firstElementChild;
expect(el?.className).toContain("bg-warning-bg");
expect(el?.className).toContain("text-warning");
expect(el?.className).not.toContain("bg-yellow");
});
});
Loading