import { useState } from "react"; import { useQuery, useMutation } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { useToast } from "@/hooks/use-toast"; import { Send, Bell, Users, ArrowLeft } from "lucide-react"; import { Link } from "wouter"; import { apiRequest } from "@/lib/queryClient"; export default function AdminPushPage() { const [title, setTitle] = useState(""); const [body, setBody] = useState(""); const [url, setUrl] = useState(""); const { toast } = useToast(); const { data: countData } = useQuery<{ count: number }>({ queryKey: ["/api/push/count"], refetchInterval: 10000, }); const sendMutation = useMutation({ mutationFn: async () => { const res = await apiRequest("POST", "/api/admin/push/send", { title, body, url: url || "/" }); return res.json(); }, onSuccess: (data: any) => { toast({ title: "Push gesendet", description: `Erfolgreich: ${data.sent}, Fehlgeschlagen: ${data.failed} von ${data.total} Abonnenten`, }); setTitle(""); setBody(""); setUrl(""); }, onError: () => { toast({ title: "Fehler", description: "Push-Nachricht konnte nicht gesendet werden.", variant: "destructive" }); }, }); return (

Push-Benachrichtigungen

Abonnenten

{countData?.count ?? 0}

aktive Push-Abonnenten

Neue Benachrichtigung senden
setTitle(e.target.value)} placeholder="z.B. Neuer Artikel auf FOLX TV" data-testid="input-push-title" />