import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import { client } from '@/ui/api/client' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card' import { Switch } from '@/ui/components/ui/switch' import { Loader2, MessageSquare, MessageCircle, AtSign, UploadCloud, Activity, Bell, } from 'lucide-react' import { toast } from 'sonner' import type { NotificationSettings as Settings } from '@shumai/dtos' export function NotificationSettings({ teamId }: { teamId: string }) { const queryClient = useQueryClient() const { data: settings, isLoading } = useQuery({ queryKey: ['teams', teamId, 'notification-settings'], queryFn: async () => { const res = await client.api.teams[':teamId'].notifications.settings.$get({ param: { teamId }, }) if (!res.ok) throw new Error('Failed to fetch notification settings') return (await res.json()) as Settings }, }) const { mutate: updateSettings, isPending: isUpdating } = useMutation({ mutationFn: async (updated: Settings) => { const res = await client.api.teams[':teamId'].notifications.settings.$post({ param: { teamId }, json: updated, }) if (!res.ok) throw new Error('Failed to update notification settings') return await res.json() }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'notification-settings'] }) queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'notifications'] }) toast.success('Notification settings updated') }, onError: (err) => { toast.error(err instanceof Error ? err.message : 'Failed to update notification settings') }, }) const handleToggle = (key: keyof Settings) => { if (!settings) return const updated = { ...settings, [key]: !settings[key], } updateSettings(updated) } if (isLoading) { return (
When someone comments on an asset
When someone replies to your comment
When someone @mentions you in a comment
When you upload assets
When other users upload assets
When someone changes an asset’s status