"use client";

import { PageHeader, Card, CardContent, Badge } from "@/components/ds";
import { LoyaltyBreadcrumbs } from "@/modules/loyalty/components/LoyaltyBreadcrumbs";
import {
  LOYALTY_PERMISSIONS,
  LOYALTY_PERMISSION_GROUPS,
} from "@/modules/loyalty/constants/permissions";

export default function PermissionsPage() {
  return (
    <div>
      <LoyaltyBreadcrumbs items={[{ label: "دسترسی‌ها" }]} />
      <PageHeader
        title="درخت دسترسی Loyalty"
        description="مرجع static از definitions.py — RBAC API جدا در سرویس نیست."
      />
      <div className="space-y-4">
        {LOYALTY_PERMISSION_GROUPS.map((g) => (
          <Card key={g.label}>
            <CardContent className="pt-5">
              <h3 className="mb-2 font-semibold">{g.label}</h3>
              <div className="flex flex-wrap gap-2">
                {g.permissions.map((p) => (
                  <Badge key={p} tone="default">
                    {p}
                  </Badge>
                ))}
              </div>
            </CardContent>
          </Card>
        ))}
        <Card>
          <CardContent className="pt-5">
            <h3 className="mb-2 font-semibold">همه ({LOYALTY_PERMISSIONS.length})</h3>
            <div className="flex flex-wrap gap-1">
              {LOYALTY_PERMISSIONS.map((p) => (
                <Badge key={p} tone="default">
                  {p}
                </Badge>
              ))}
            </div>
          </CardContent>
        </Card>
      </div>
    </div>
  );
}
