feature-based React PWA with Hono backend: - feed from abgeordnetenwatch.de API (polls by topic + politician) - follow topics, search and follow politicians - geo-based politician discovery via Nominatim - push notifications for new polls via web-push - service worker with offline caching - deploy to Uberspace 8 (systemd, PostgreSQL, web backend proxy) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
19 lines
488 B
TypeScript
19 lines
488 B
TypeScript
import { type Topic, fetchTopics } from "@/shared/lib/aw-api"
|
|
import { useEffect, useState } from "react"
|
|
|
|
export function useTopics() {
|
|
const [topics, setTopics] = useState<Topic[]>([])
|
|
const [loading, setLoading] = useState(false)
|
|
const [error, setError] = useState<string | null>(null)
|
|
|
|
useEffect(() => {
|
|
setLoading(true)
|
|
fetchTopics()
|
|
.then(setTopics)
|
|
.catch((e) => setError(String(e)))
|
|
.finally(() => setLoading(false))
|
|
}, [])
|
|
|
|
return { topics, loading, error }
|
|
}
|