diff --git a/src/features/bundestag/components/bundestag-configure.tsx b/src/features/bundestag/components/bundestag-configure.tsx index 6edb879..5d51b9b 100644 --- a/src/features/bundestag/components/bundestag-configure.tsx +++ b/src/features/bundestag/components/bundestag-configure.tsx @@ -9,6 +9,7 @@ export function BundestagConfigure() { const db = useDb() const politicianSearch = useBundestagUI((s) => s.politicianSearch) const setPoliticianSearch = useBundestagUI((s) => s.setPoliticianSearch) + const showAll = useBundestagUI((s) => s.showAll) const [mandates, setMandates] = useState([]) const [userCity, setUserCity] = useState(null) @@ -34,6 +35,7 @@ export function BundestagConfigure() { diff --git a/src/features/bundestag/store.ts b/src/features/bundestag/store.ts index af85d38..ffa32cb 100644 --- a/src/features/bundestag/store.ts +++ b/src/features/bundestag/store.ts @@ -3,9 +3,13 @@ import { create } from "zustand" interface BundestagUIState { politicianSearch: string setPoliticianSearch: (query: string) => void + showAll: boolean + toggleShowAll: () => void } export const useBundestagUI = create((set) => ({ politicianSearch: "", setPoliticianSearch: (query) => set({ politicianSearch: query }), + showAll: false, + toggleShowAll: () => set((s) => ({ showAll: !s.showAll })), })) diff --git a/src/features/landtag/components/landtag-configure.tsx b/src/features/landtag/components/landtag-configure.tsx index 9777afd..d5cc7d3 100644 --- a/src/features/landtag/components/landtag-configure.tsx +++ b/src/features/landtag/components/landtag-configure.tsx @@ -10,6 +10,7 @@ export function LandtagConfigure() { const db = useDb() const search = useLandtagUI((s) => s.politicianSearch) const setSearch = useLandtagUI((s) => s.setPoliticianSearch) + const showAll = useLandtagUI((s) => s.showAll) const [mandates, setMandates] = useState([]) const [userCity, setUserCity] = useState(null) const [loaded, setLoaded] = useState(false) @@ -44,7 +45,13 @@ export function LandtagConfigure() {
) : ( - + )} ) diff --git a/src/features/landtag/store.ts b/src/features/landtag/store.ts index c12ee64..cf47bcf 100644 --- a/src/features/landtag/store.ts +++ b/src/features/landtag/store.ts @@ -3,9 +3,13 @@ import { create } from "zustand" interface LandtagUIState { politicianSearch: string setPoliticianSearch: (query: string) => void + showAll: boolean + toggleShowAll: () => void } export const useLandtagUI = create((set) => ({ politicianSearch: "", setPoliticianSearch: (query) => set({ politicianSearch: query }), + showAll: false, + toggleShowAll: () => set((s) => ({ showAll: !s.showAll })), })) diff --git a/src/routes/app/route.tsx b/src/routes/app/route.tsx index 9f79776..97d7f77 100644 --- a/src/routes/app/route.tsx +++ b/src/routes/app/route.tsx @@ -1,3 +1,5 @@ +import { useBundestagUI } from "@/features/bundestag/store" +import { useLandtagUI } from "@/features/landtag/store" import { DbProvider } from "@/shared/db/provider" import { Link, Outlet, createFileRoute, useMatches, useNavigate } from "@tanstack/react-router" import { Suspense } from "react" @@ -61,6 +63,14 @@ function AppLayout() { const isBundestag = currentPath.startsWith("/app/bundestag") const isLandtag = currentPath.startsWith("/app/landtag") + const bundestagShowAll = useBundestagUI((s) => s.showAll) + const toggleBundestag = useBundestagUI((s) => s.toggleShowAll) + const landtagShowAll = useLandtagUI((s) => s.showAll) + const toggleLandtag = useLandtagUI((s) => s.toggleShowAll) + + const showAll = isBundestag ? bundestagShowAll : landtagShowAll + const toggleShowAll = isBundestag ? toggleBundestag : toggleLandtag + // Determine parent path for back navigation from configure routes const parentPath = isConfigureRoute ? currentPath.replace(/\/configure$/, "") : null @@ -94,6 +104,32 @@ function AppLayout() {

{isConfigureRoute ? "Abgeordnete" : currentTab.label}

+ {isConfigureRoute && ( + + )} {!isConfigureRoute && configureTarget && ( void } -export function RepresentativeList({ mandates, userCity, searchQuery, onSearchChange }: RepresentativeListProps) { +export function RepresentativeList({ + mandates, + userCity, + showAll, + searchQuery, + onSearchChange, +}: RepresentativeListProps) { const { isFollowing, follow, unfollow } = useFollows() - // When userCity is set, default to showing only nearby. User can click "Alle anzeigen" to expand. - const [showAll, setShowAll] = useState(!userCity) + const effectiveShowAll = showAll ?? !userCity const [collapsed, setCollapsed] = useState>({}) const filtered = searchQuery @@ -149,8 +155,7 @@ export function RepresentativeList({ mandates, userCity, searchQuery, onSearchCh const meta = getPartyMeta(group.partyLabel) const isCollapsed = collapsed[group.partyLabel] ?? false const nearbyMembers = userCity ? group.members.filter((m) => isLocalConstituency(m, userCity)) : [] - // Default view (showAll=false): only nearby. After "Alle anzeigen": full list. - const visibleMembers = isCollapsed ? [] : showAll ? group.members : nearbyMembers + const visibleMembers = isCollapsed ? [] : effectiveShowAll ? group.members : nearbyMembers return ( @@ -213,12 +218,6 @@ export function RepresentativeList({ mandates, userCity, searchQuery, onSearchCh ) })} - {!showAll && userCity && ( - - )} - {groups.length === 0 && searchQuery && (

Keine Abgeordneten für „{searchQuery}"

)}