Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

feat(groups): add server-side search and URL filters (#1139) (#1140)

Danny Feliz2da7cab09c93
diff --git a/backend/app/api/groups.py b/backend/app/api/groups.py
index f5acea39..7312725b 100644
--- a/backend/app/api/groups.py
+++ b/backend/app/api/groups.py
@@ -1,4 +1,5 @@
import uuid
+from typing import Literal
from fastapi import APIRouter, Depends, HTTPException, Query, status
from sqlalchemy.ext.asyncio import AsyncSession
@@ -32,11 +33,14 @@ router = APIRouter(prefix="/api/groups", tags=["groups"])
@router.get("", response_model=list[GroupRead])
async def list_groups(
include_archived: bool = Query(False),
+ q: str | None = Query(None),
+ group_status: Literal['active', 'archived', 'all'] | None = Query(None, alias='status'),
ctx: WorkspaceContext = Depends(current_workspace),
session: AsyncSession = Depends(get_async_session),
):
return await group_service.list_groups(
- session, ctx.workspace.id, ctx.user_id, include_archived=include_archived
+ session, ctx.workspace.id, ctx.user_id, include_archived=include_archived,
+ q=q, status=group_status,
)
diff --git a/backend/app/services/group_service.py b/backend/app/services/group_service.py
index 8f3707b5..fa368d6a 100644
--- a/backend/app/services/group_service.py
+++ b/backend/app/services/group_service.py
@@ -1,5 +1,6 @@
+import unicodedata
import uuid
-from typing import Optional
+from typing import Literal, Optional
from sqlalchemy import func, or_, select
from sqlalchemy.exc import IntegrityError
@@ -100,6 +101,8 @@ async def list_groups(
workspace_id: uuid.UUID,
user_id: uuid.UUID,
include_archived: bool = False,
+ q: Optional[str] = None,
+ status: Optional[Literal['active', 'archived', 'all']] = None,
) -> list[Group]:
query = (
select(Group)
@@ -107,10 +110,22 @@ async def list_groups(
.options(selectinload(Group.members))
.order_by(Group.created_at.desc())
)
- if not include_archived:
+ if status == 'archived':
+ query = query.where(Group.is_archived.is_(True))
+ elif status == 'active' or (status is None and not include_archived):
query = query.where(Group.is_archived.is_(False))
result = await session.execute(query)
- return [_tag_owner(g, user_id) for g in result.scalars().all()]
+ groups = result.scalars().all()
+ if q and q.strip():
+ def normalize(value: str) -> str:
+ return ''.join(
+ char for char in unicodedata.normalize('NFD', value.casefold())
+ if not unicodedata.combining(char)
+ )
+
+ search = normalize(q.strip())
+ groups = [group for group in groups if search in normalize(group.name)]
+ return [_tag_owner(g, user_id) for g in groups]
async def get_group(
diff --git a/backend/tests/test_group_visibility.py b/backend/tests/test_group_visibility.py
index 8a8b4b7a..4f2e091f 100644
--- a/backend/tests/test_group_visibility.py
+++ b/backend/tests/test_group_visibility.py
@@ -105,6 +105,11 @@ async def test_linked_member_sees_group_in_list(
# Linked member sees is_owner=False; the original owner sees True.
assert visible[0].is_owner is False
+ searched = await group_service.list_groups(
+ session, other_ws.id, other.id, q="SHARED", status="all"
+ )
+ assert {g.id for g in searched} == {group.id}
+
owners_view = await group_service.list_groups(
session, test_workspace.id, test_user.id
)
@@ -125,6 +130,11 @@ async def test_unrelated_user_does_not_see_group(
visible = await group_service.list_groups(session, stranger_ws.id, stranger.id)
assert visible == []
+ searched = await group_service.list_groups(
+ session, stranger_ws.id, stranger.id, q="Private", status="all"
+ )
+ assert searched == []
+
@pytest.mark.asyncio
async def test_visible_get_works_for_linked_member(
diff --git a/backend/tests/test_groups_api.py b/backend/tests/test_groups_api.py
index c3d0008d..343ad6ca 100644
--- a/backend/tests/test_groups_api.py
+++ b/backend/tests/test_groups_api.py
@@ -36,6 +36,51 @@ async def test_create_list_get_group(client: AsyncClient, auth_headers, test_use
assert detail["members"] == []
+async def test_list_groups_search_and_status(client, auth_headers, test_user):
+ active = await _create_group(client, auth_headers, name="Vacación familiar")
+ archived = await _create_group(client, auth_headers, name="Vacación pasada")
+ await _create_group(client, auth_headers, name="Trabajo")
+ response = await client.patch(
+ f"/api/groups/{archived['id']}", headers=auth_headers, json={"is_archived": True}
+ )
+ assert response.status_code == 200
+
+ for group_status, expected_ids in [
+ ("active", {active["id"]}),
+ ("archived", {archived["id"]}),
+ ("all", {active["id"], archived["id"]}),
+ ]:
+ response = await client.get(
+ "/api/groups", headers=auth_headers,
+ params={"q": " VACACION ", "status": group_status},
+ )
+ assert response.status_code == 200
+ assert {group["id"] for group in response.json()} == expected_ids
+
+ response = await client.get(
+ "/api/groups", headers=auth_headers, params={"q": "missing", "status": "all"}
+ )
+ assert response.status_code == 200
+ assert response.json() == []
+
+
+async def test_list_groups_literal_search_and_invalid_status(client, auth_headers, test_user):
+ literal = await _create_group(client, auth_headers, name="100%_complete")
+ other = await _create_group(client, auth_headers, name="Other")
+ response = await client.get("/api/groups", headers=auth_headers, params={"q": "%_"})
+ assert response.status_code == 200
+ assert {group["id"] for group in response.json()} == {literal["id"]}
+
+ response = await client.get("/api/groups", headers=auth_headers, params={"q": " "})
+ assert response.status_code == 200
+ assert {group["id"] for group in response.json()} == {literal["id"], other["id"]}
+
+ response = await client.get("/api/groups", headers=auth_headers, params={"status": "invalid"})
+ assert response.status_code == 422
+
+
@pytest.mark.asyncio
async def test_duplicate_group_name_returns_400(client, auth_headers, test_user):
await _create_group(client, auth_headers, name="Same")
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index f1786c18..ed8812f1 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -926,8 +926,8 @@ export interface GroupSettlementPayload {
}
export const groups = {
- list: async (includeArchived = false): Promise<Group[]> => {
- const { data } = await api.get('/groups', { params: { include_archived: includeArchived } })
+ list: async (includeArchived = false, filters: { q?: string; status?: 'active' | 'archived' | 'all' } = {}): Promise<Group[]> => {
+ const { data } = await api.get('/groups', { params: { include_archived: includeArchived, ...filters } })
return data
},
get: async (id: string): Promise<Group> => {
diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json
index 1fd4fbce..ef2e06d9 100644
--- a/frontend/src/locales/de.json
+++ b/frontend/src/locales/de.json
@@ -2148,6 +2148,8 @@
"remove": "Entfernen"
},
"splitGroups": {
+ "searchPlaceholder": "Gruppen suchen...",
+ "clearSearch": "Suche löschen",
"title": "Gruppen",
"section": "Einrichtung",
"add": "Gruppe hinzufügen",
diff --git a/frontend/src/locales/el.json b/frontend/src/locales/el.json
index a96927b6..c9523230 100644
--- a/frontend/src/locales/el.json
+++ b/frontend/src/locales/el.json
@@ -2147,6 +2147,8 @@
"remove": "Αφαίρεση"
},
"splitGroups": {
+ "searchPlaceholder": "Αναζήτηση ομάδων...",
+ "clearSearch": "Εκκαθάριση αναζήτησης",
"title": "Ομάδες",
"section": "Ρύθμιση",
"add": "Προσθήκη ομάδας",
diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json
index 4667137f..e9ec2c48 100644
--- a/frontend/src/locales/en.json
+++ b/frontend/src/locales/en.json
@@ -2147,6 +2147,8 @@
"remove": "Remove"
},
"splitGroups": {
+ "searchPlaceholder": "Search groups...",
+ "clearSearch": "Clear search",
"title": "Groups",
"section": "Setup",
"add": "Add group",
diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json
index aca3297f..0d306358 100644
--- a/frontend/src/locales/es.json
+++ b/frontend/src/locales/es.json
@@ -2151,6 +2151,8 @@
"remove": "Quitar"
},
"splitGroups": {
+ "searchPlaceholder": "Buscar grupos...",
+ "clearSearch": "Limpiar búsqueda",
"title": "Grupos",
"section": "Configuración",
"add": "Agregar grupo",
diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json
index 059ee64c..867d76f5 100644
--- a/frontend/src/locales/fr.json
+++ b/frontend/src/locales/fr.json
@@ -2151,6 +2151,8 @@
"remove": "Supprimer"
},
"splitGroups": {
+ "searchPlaceholder": "Rechercher des groupes...",
+ "clearSearch": "Effacer la recherche",
"title": "Groupes",
"section": "Configuration",
"add": "Ajouter un groupe",
diff --git a/frontend/src/locales/hi.json b/frontend/src/locales/hi.json
index 957568b9..c6cbe771 100644
--- a/frontend/src/locales/hi.json
+++ b/frontend/src/locales/hi.json
@@ -2147,6 +2147,8 @@
"remove": "हटाएँ"
},
"splitGroups": {
+ "searchPlaceholder": "समूह खोजें...",
+ "clearSearch": "खोज साफ़ करें",
"title": "समूह",
"section": "सेटअप",
"add": "समूह जोड़ें",
diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.json
index c8fcb804..76eef661 100644
--- a/frontend/src/locales/it.json
+++ b/frontend/src/locales/it.json
@@ -2151,6 +2151,8 @@
"remove": "Rimuovi"
},
"splitGroups": {
+ "searchPlaceholder": "Cerca gruppi...",
+ "clearSearch": "Cancella ricerca",
"title": "Gruppi",
"section": "Configurazione",
"add": "Aggiungi gruppo",
diff --git a/frontend/src/locales/ja.json b/frontend/src/locales/ja.json
index 5a005343..d073cae9 100644
--- a/frontend/src/locales/ja.json
+++ b/frontend/src/locales/ja.json
@@ -2147,6 +2147,8 @@
"remove": "削除"
},
"splitGroups": {
+ "searchPlaceholder": "グループを検索...",
+ "clearSearch": "検索をクリア",
"title": "グループ",
"section": "設定",
"add": "グループを追加",
diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json
index 54b7403c..28773f87 100644
--- a/frontend/src/locales/nl.json
+++ b/frontend/src/locales/nl.json
@@ -2149,6 +2149,8 @@
"remove": "Verwijderen"
},
"splitGroups": {
+ "searchPlaceholder": "Groepen zoeken...",
+ "clearSearch": "Zoekopdracht wissen",
"title": "Groepen",
"section": "Instellen",
"add": "Groep toevoegen",
diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.json
index 806f93b0..2fb47210 100644
--- a/frontend/src/locales/pl.json
+++ b/frontend/src/locales/pl.json
@@ -2245,6 +2245,8 @@
"remove": "Usuń"
},
"splitGroups": {
+ "searchPlaceholder": "Szukaj grup...",
+ "clearSearch": "Wyczyść wyszukiwanie",
"title": "Grupy",
"section": "Konfiguracja",
"add": "Dodaj grupę",
diff --git a/frontend/src/locales/pt-BR.json b/frontend/src/locales/pt-BR.json
index 87a338d6..ed107360 100644
--- a/frontend/src/locales/pt-BR.json
+++ b/frontend/src/locales/pt-BR.json
@@ -2151,6 +2151,8 @@
"remove": "Remover"
},
"splitGroups": {
+ "searchPlaceholder": "Buscar grupos...",
+ "clearSearch": "Limpar busca",
"title": "Grupos",
"section": "Configuração",
"add": "Adicionar grupo",
diff --git a/frontend/src/locales/pt-PT.json b/frontend/src/locales/pt-PT.json
index 3c4d7a8d..a300a462 100644
--- a/frontend/src/locales/pt-PT.json
+++ b/frontend/src/locales/pt-PT.json
@@ -2151,6 +2151,8 @@
"remove": "Remover"
},
"splitGroups": {
+ "searchPlaceholder": "Pesquisar grupos...",
+ "clearSearch": "Limpar pesquisa",
"title": "Grupos",
"section": "Configuração",
"add": "Adicionar grupo",
diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.json
index 2498465b..d9d2d3fc 100644
--- a/frontend/src/locales/ru.json
+++ b/frontend/src/locales/ru.json
@@ -2164,6 +2164,8 @@
"remove": "Удалить"
},
"splitGroups": {
+ "searchPlaceholder": "Поиск групп...",
+ "clearSearch": "Очистить поиск",
"title": "Группы",
"section": "Настройка",
"add": "Добавить группу",
diff --git a/frontend/src/locales/sk.json b/frontend/src/locales/sk.json
index 279b06b1..b90b7d6f 100644
--- a/frontend/src/locales/sk.json
+++ b/frontend/src/locales/sk.json
@@ -2275,6 +2275,8 @@
"remove": "Odstrániť"
},
"splitGroups": {
+ "searchPlaceholder": "Hľadať skupiny...",
+ "clearSearch": "Vymazať vyhľadávanie",
"title": "Skupiny",
"section": "Nastavenie",
"add": "Pridať skupinu",
diff --git a/frontend/src/locales/uk.json b/frontend/src/locales/uk.json
index 75aa883b..b6385335 100644
--- a/frontend/src/locales/uk.json
+++ b/frontend/src/locales/uk.json
@@ -2164,6 +2164,8 @@
"remove": "Видалити"
},
"splitGroups": {
+ "searchPlaceholder": "Пошук груп...",
+ "clearSearch": "Очистити пошук",
"title": "Групи",
"section": "Налаштування",
"add": "Додати групу",
diff --git a/frontend/src/pages/groups.test.tsx b/frontend/src/pages/groups.test.tsx
new file mode 100644
index 00000000..7066e08f
--- /dev/null
+++ b/frontend/src/pages/groups.test.tsx
@@ -0,0 +1,121 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { screen, waitFor } from '@testing-library/react'
+import { useLocation, useNavigate } from 'react-router-dom'
+
+import GroupsPage from '@/pages/groups'
+import { renderWithProviders, t } from '@/test/utils'
+
+const api = vi.hoisted(() => ({ list: vi.fn() }))
+
+vi.mock('@/lib/api', () => ({
+ groups: { list: api.list },
+ currencies: { list: vi.fn() },
+}))
+
+vi.mock('@/contexts/auth-context', () => ({
+ useAuth: () => ({ user: { preferences: { currency_display: 'USD' } } }),
+}))
+
+vi.mock('@/contexts/workspace-context', () => ({
+ useWorkspace: () => ({ canWrite: false }),
+}))
+
+const groups = [
+ { id: '1', name: 'Vacación familiar', is_archived: false },
+ { id: '2', name: 'Trabajo', is_archived: false },
+ { id: '3', name: 'Vacación pasada', is_archived: true },
+].map((group) => ({
+ ...group, kind: 'social', color: '#123456', members: [], default_currency: 'USD', is_owner: true,
+}))
+
+function LocationProbe() {
+ const location = useLocation()
+ const navigate = useNavigate()
+ return (
+ <>
+ <output data-testid="location">{location.pathname}{location.search}</output>
+ <button onClick={() => navigate(-1)}>Back</button>
+ </>
+ )
+}
+
+describe('GroupsPage search', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ api.list.mockResolvedValue([groups[0], groups[1]])
+ })
+
+ it('sends a trimmed search to the server, renders its response, and clears the search', async () => {
+ const { user } = renderWithProviders(<><GroupsPage /><LocationProbe /></>, { route: '/groups' })
+ await screen.findByText('Vacación familiar')
+ // Only the server decides whether a returned group matches the query.
+ api.list.mockResolvedValue([groups[1]])
+ await user.type(screen.getByRole('searchbox'), ' VACACION ')
+
+ await waitFor(() => expect(api.list).toHaveBeenLastCalledWith(false, { q: 'VACACION', status: 'active' }))
+ await screen.findByText('Trabajo')
+ expect(screen.queryByText('Vacación familiar')).not.toBeInTheDocument()
+
+ api.list.mockResolvedValue([groups[0], groups[1]])
+ await user.click(screen.getByRole('button', { name: t('splitGroups.clearSearch') }))
+ expect(screen.getByRole('searchbox')).toHaveValue('')
+ await screen.findByText('Vacación familiar')
+ expect(screen.getByTestId('location').textContent).toBe('/groups')
+ })
+
+ it('combines search with status filters and distinguishes no matches from an empty list', async () => {
+ const { user } = renderWithProviders(<><GroupsPage /><LocationProbe /></>, { route: '/groups' })
+ await screen.findByText('Vacación familiar')
+ await user.type(screen.getByRole('searchbox'), 'vacacion')
+ api.list.mockResolvedValue([groups[2]])
+ await user.click(screen.getByRole('button', { name: t('splitGroups.filter.archived') }))
+
+ await screen.findByText('Vacación pasada')
+ expect(screen.queryByText('Vacación familiar')).not.toBeInTheDocument()
+
+ api.list.mockResolvedValue([groups[0], groups[2]])
+ await user.click(screen.getByRole('button', { name: t('splitGroups.filter.all') }))
+ await screen.findByText('Vacación familiar')
+ expect(screen.getByText('Vacación pasada')).toBeInTheDocument()
+ expect(screen.queryByText('Trabajo')).not.toBeInTheDocument()
+
+ api.list.mockResolvedValue([])
+ await user.clear(screen.getByRole('searchbox'))
+ await user.type(screen.getByRole('searchbox'), 'missing')
+ await screen.findByText(t('common.noResults'))
+ const params = new URL(screen.getByTestId('location').textContent!, 'http://localhost').searchParams
+ expect(Object.fromEntries(params)).toEqual({ q: 'missing', status: 'all' })
+ expect(screen.queryByText(t('splitGroups.emptyHint'))).not.toBeInTheDocument()
+ })
+
+ it('restores search and status from a bookmarked URL, preserving other parameters when clearing', async () => {
+ api.list.mockResolvedValue([groups[2]])
+ const { user } = renderWithProviders(<><GroupsPage /><LocationProbe /></>, {
+ route: '/groups?q=vacacion&status=archived&other=value',
+ })
+ await screen.findByText('Vacación pasada')
+ expect(api.list).toHaveBeenLastCalledWith(true, { q: 'vacacion', status: 'archived' })
+ expect(screen.getByRole('searchbox')).toHaveValue('vacacion')
+ expect(screen.queryByText('Vacación familiar')).not.toBeInTheDocument()
+
+ await user.click(screen.getByRole('button', { name: t('splitGroups.clearSearch') }))
+ expect(screen.getByTestId('location')).toHaveTextContent('/groups?status=archived&other=value')
+ await waitFor(() => expect(api.list).toHaveBeenLastCalledWith(true, { q: undefined, status: 'archived' }))
+ })
+
+ it('restores results on back navigation and uses active for an invalid status', async () => {
+ const { user } = renderWithProviders(<><GroupsPage /><LocationProbe /></>, {
+ route: '/groups?q=vacacion&status=invalid',
+ })
+ await screen.findByText('Vacación familiar')
+ expect(api.list).toHaveBeenLastCalledWith(false, { q: 'vacacion', status: 'active' })
+ api.list.mockResolvedValue([groups[2]])
+ await user.click(screen.getByRole('button', { name: t('splitGroups.filter.archived') }))
+ await screen.findByText('Vacación pasada')
+ api.list.mockResolvedValue([groups[0]])
+ await user.click(screen.getByRole('button', { name: /^Back$/ }))
+ await screen.findByText('Vacación familiar')
+ expect(screen.queryByText('Vacación pasada')).not.toBeInTheDocument()
+ expect(screen.getByRole('searchbox')).toHaveValue('vacacion')
+ })
+})
diff --git a/frontend/src/pages/groups.tsx b/frontend/src/pages/groups.tsx
index 502cdd8e..b26b882e 100644
--- a/frontend/src/pages/groups.tsx
+++ b/frontend/src/pages/groups.tsx
@@ -1,6 +1,6 @@
-import { useState } from 'react'
+import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useNavigate } from 'react-router-dom'
+import { useNavigate, useSearchParams } from 'react-router-dom'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
@@ -19,7 +19,7 @@ import {
} from '@/components/ui/dialog'
import { GroupForm } from '@/components/group-form'
import { PageHeader } from '@/components/page-header'
-import { Archive, ChevronRight, Plus, Trash2, Users } from 'lucide-react'
+import { Archive, ChevronRight, Plus, Search, Trash2, Users, X } from 'lucide-react'
import type { Group, GroupKind } from '@/types'
type StatusFilter = 'active' | 'archived' | 'all'
@@ -28,15 +28,33 @@ type StatusFilter = 'active' | 'archived' | 'all'
export default function GroupsPage() {
const { t } = useTranslation()
const navigate = useNavigate()
+ const [searchParams, setSearchParams] = useSearchParams()
const queryClient = useQueryClient()
const { user } = useAuth()
const { canWrite } = useWorkspace()
const userCurrency = user?.preferences?.currency_display ?? 'USD'
- const [statusFilter, setStatusFilter] = useState<StatusFilter>('active')
+ const statusParam = searchParams.get('status')
+ const statusFilter: StatusFilter = statusParam === 'archived' || statusParam === 'all' ? statusParam : 'active'
+ const search = searchParams.get('q') ?? ''
+ const [searchQuery, setSearchQuery] = useState(search.trim())
const [dialogOpen, setDialogOpen] = useState(false)
const [editing, setEditing] = useState<Group | null>(null)
const [deletingGroup, setDeletingGroup] = useState<Group | null>(null)
- const includeArchived = statusFilter !== 'active'
+
+ useEffect(() => {
+ const timer = setTimeout(() => setSearchQuery(search.trim()), 300)
+ return () => clearTimeout(timer)
+ }, [search])
+
+ const updateFilter = (key: 'q' | 'status', value: string) => {
+ if (key === 'status') setSearchQuery(search.trim())
+ setSearchParams((previous) => {
+ const next = new URLSearchParams(previous)
+ if (value && !(key === 'status' && value === 'active')) next.set(key, value)
+ else next.delete(key)
+ return next
+ }, { replace: key === 'q' })
+ }
const [name, setName] = useState('')
const [kind, setKind] = useState<GroupKind>('social')
@@ -44,9 +62,9 @@ export default function GroupsPage() {
const [notes, setNotes] = useState('')
- const { data: list, isLoading } = useQuery({
- queryKey: ['groups', { includeArchived }],
- queryFn: () => groupsApi.list(includeArchived),
+ const { data: list = [], isLoading } = useQuery({
+ queryKey: ['groups', { q: searchQuery, status: statusFilter }],
+ queryFn: () => groupsApi.list(statusFilter !== 'active', { q: searchQuery || undefined, status: statusFilter }),
})
const createMutation = useMutation({
@@ -128,14 +146,6 @@ export default function GroupsPage() {
}
}
- const visibleGroups = (list ?? []).filter((g) =>
- statusFilter === 'active'
- ? !g.is_archived
- : statusFilter === 'archived'
- ? g.is_archived
- : true,
- )
-
return (
<div>
<PageHeader
@@ -158,7 +168,7 @@ export default function GroupsPage() {
{(['active', 'archived', 'all'] as StatusFilter[]).map((s) => (
<button
key={s}
- onClick={() => setStatusFilter(s)}
+ onClick={() => updateFilter('status', s)}
className={`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${
statusFilter === s
? 'bg-primary text-primary-foreground'
@@ -170,6 +180,27 @@ export default function GroupsPage() {
))}
</div>
+ <div className="rounded-xl border border-border bg-card shadow-sm transition-colors mb-4 focus-within:border-primary/40 focus-within:ring-[3px] focus-within:ring-primary/10">
+ <div className="flex items-center gap-1.5 px-2 py-1.5">
+ <div className="relative flex min-w-0 flex-1 items-center gap-1 px-2.5 py-1 min-h-9">
+ <Search size={15} className="pointer-events-none shrink-0 text-muted-foreground/70" />
+ <input
+ type="search"
+ aria-label={t('splitGroups.searchPlaceholder')}
+ placeholder={t('splitGroups.searchPlaceholder')}
+ value={search}
+ onChange={(e) => updateFilter('q', e.target.value)}
+ className="min-w-0 flex-1 bg-transparent px-1.5 text-[13.5px] outline-none placeholder:text-muted-foreground/75"
+ />
+ </div>
+ {search && (
+ <Button variant="ghost" size="icon-sm" aria-label={t('splitGroups.clearSearch')} onClick={() => updateFilter('q', '')}>
+ <X size={15} />
+ </Button>
+ )}
+ </div>
+ </div>
+
<div className="bg-card rounded-xl border border-border shadow-sm overflow-hidden mb-4">
{isLoading ? (
<div className="p-6 space-y-3">
@@ -177,15 +208,17 @@ export default function GroupsPage() {
<Skeleton key={i} className="h-14 w-full" />
))}
</div>
- ) : visibleGroups.length === 0 ? (
+ ) : list.length === 0 ? (
<div className="text-center py-16 text-muted-foreground">
<Users size={32} className="mx-auto mb-2 opacity-50" />
- <p>{t('splitGroups.empty')}</p>
- <p className="text-xs mt-1">{t('splitGroups.emptyHint')}</p>
+ <p>{t(searchQuery ? 'common.noResults' : 'splitGroups.empty')}</p>
+ {!searchQuery && (
+ <p className="text-xs mt-1">{t('splitGroups.emptyHint')}</p>
+ )}
</div>
) : (
<ul className="divide-y divide-border">
- {visibleGroups.map((group) => (
+ {list.map((group) => (
<li
key={group.id}
className="flex items-center gap-3 px-4 py-3.5 hover:bg-muted cursor-pointer transition-colors"