"use client" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table" import { resolveOwnerShop } from "@/lib/domain/resolve-current-shop" import { useAuthStore } from "@/store/auth" import { usePlayerStore } from "@/store/players" import { useServiceStore } from "@/store/services" import { useShopStore } from "@/store/shops" import { Edit, Plus, Trash2 } from "lucide-react" import Link from "next/link" export default function ServicesPage() { const userId = useAuthStore((state) => state.user?.id) const currentRole = useAuthStore((state) => state.currentRole) const shops = useShopStore((state) => state.shops) const players = usePlayerStore((state) => state.players) const services = useServiceStore((state) => state.services) const deleteService = useServiceStore((state) => state.deleteService) const ownerShop = resolveOwnerShop(userId, shops) const scopedPlayerIds = currentRole === "player" ? userId ? [userId] : [] : currentRole === "owner" ? ownerShop ? players.filter((player) => player.shopId === ownerShop.id).map((player) => player.id) : [] : [] const scopedPlayerIdSet = new Set(scopedPlayerIds) const scopedServices = services.filter((service) => scopedPlayerIdSet.has(service.playerId)) return (