From d05f2190e85568ebd84c12f5fcbd7f2bbd9ebe7f Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Thu, 7 Aug 2025 01:25:26 +0400 Subject: [PATCH] refactor: ensure that only profiles without group are shown in the default list --- src/app/page.tsx | 4 ++-- src/components/group-badges.tsx | 4 ++-- src/components/profile-data-table.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index fcedc7f..983c0ff 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -58,7 +58,7 @@ export default function Home() { useState(false); const [groupAssignmentDialogOpen, setGroupAssignmentDialogOpen] = useState(false); - const [selectedGroupId, setSelectedGroupId] = useState(null); + const [selectedGroupId, setSelectedGroupId] = useState("default"); const [selectedProfilesForGroup, setSelectedProfilesForGroup] = useState< string[] >([]); @@ -82,7 +82,7 @@ export default function Home() { const { isMicrophoneAccessGranted, isCameraAccessGranted, isInitialized } = usePermissions(); - const handleSelectGroup = useCallback((groupId: string | null) => { + const handleSelectGroup = useCallback((groupId: string) => { setSelectedGroupId(groupId); setSelectedProfiles([]); }, []); diff --git a/src/components/group-badges.tsx b/src/components/group-badges.tsx index 008eda1..4999498 100644 --- a/src/components/group-badges.tsx +++ b/src/components/group-badges.tsx @@ -5,7 +5,7 @@ import type { GroupWithCount } from "@/types"; interface GroupBadgesProps { selectedGroupId: string | null; - onGroupSelect: (groupId: string | null) => void; + onGroupSelect: (groupId: string) => void; refreshTrigger?: number; groups: GroupWithCount[]; isLoading: boolean; @@ -39,7 +39,7 @@ export function GroupBadges({ variant={selectedGroupId === group.id ? "default" : "secondary"} className="cursor-pointer hover:bg-primary/80 transition-colors flex items-center gap-2 px-3 py-1" onClick={() => { - onGroupSelect(selectedGroupId === group.id ? null : group.id); + onGroupSelect(selectedGroupId === group.id ? "default" : group.id); }} > {group.name} diff --git a/src/components/profile-data-table.tsx b/src/components/profile-data-table.tsx index 162e366..239cd7c 100644 --- a/src/components/profile-data-table.tsx +++ b/src/components/profile-data-table.tsx @@ -147,10 +147,10 @@ export function ProfilesDataTable({ // Filter data by selected group const filteredData = React.useMemo(() => { - if (!selectedGroupId) return data; - if (selectedGroupId === "default") { + if (!selectedGroupId || selectedGroupId === "default") { return data.filter((profile) => !profile.group_id); } + return data.filter((profile) => profile.group_id === selectedGroupId); }, [data, selectedGroupId]);