Files
starr-philproperties/apps/web/src/modules/admin/components/tiers/BundlesCell.jsx
T
kennethobsequio b37218f90e merge new_starr_app@qas history into apps/web
git-subtree-dir: apps/web
git-subtree-mainline: eaa6d2276a
git-subtree-split: 459af9d46a
2026-08-24 12:21:16 +08:00

28 lines
1.1 KiB
React

// BundlesCell — Tier Plans table cell showing the bundled content count for a
// plan. A bundle is single-type (Tier Plans v2), so only one of
// courseCount/unitCount/lessonCount is ever non-zero — show that one.
import { BookOpen, Book, BookOpenCheck } from "lucide-react";
import { Badge } from "@/components/ui/badge";
const BUNDLE_KINDS = [
{ key: "courseCount", icon: BookOpen, singular: "course", plural: "courses" },
{ key: "unitCount", icon: Book, singular: "unit", plural: "units" },
{ key: "lessonCount", icon: BookOpenCheck, singular: "lesson", plural: "lessons" },
];
export default function BundlesCell({ plan }) {
const active = BUNDLE_KINDS.find((k) => parseInt(plan[k.key] ?? 0, 10) > 0) ?? BUNDLE_KINDS[0];
const count = parseInt(plan[active.key] ?? 0, 10);
const Icon = active.icon;
return (
<div className="flex items-center gap-1.5">
<Icon className="h-3.5 w-3.5 text-muted-foreground" />
<Badge variant="secondary" className="text-xs font-medium tabular-nums">
{count} {count === 1 ? active.singular : active.plural}
</Badge>
</div>
);
}