Files
property-match/src/hooks/useReminders.ts
T
Benjamin Sutter 6aa4f96bd2 feat: responsive layout + Reminder Manager redesign
- Auto-collapse sidebar at <1536px (all laptops), expand at ≥1536px
- Responsive drawer/panel widths across Pipeline, Properties, MyListings, Anfragen, MatchDetail, AISearch
- Reminder Manager: dot+label priority badge, Fläche column removed, status only for non-active rows
- ReminderKpiBar: focal Überfällig card, three secondary KPIs
- ReminderDetailDrawer: Task Panel redesign — Finanzen removed, Notiz promoted, Pre-Market as inline badge, full create form
- useCreateReminder hook wired to reminderService.create with cache invalidation
- Mock data: contract-derived reminders (LEASE_EXPIRY, BREAK_OPTION, RENT_REVIEW, INSURANCE_RENEWAL, SCHATTENMARKT_RELEASE) now show auto-creation note in Verlauf

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 14:30:06 +02:00

102 lines
3.2 KiB
TypeScript

import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { reminderService } from '../services/reminderService'
import type { Reminder } from '../domain/reminder'
import { useToastStore } from '../stores/toastStore'
export function useReminders() {
return useQuery({
queryKey: ['reminders'],
queryFn: reminderService.getAll,
})
}
export function useReminder(id: string) {
return useQuery({
queryKey: ['reminder', id],
queryFn: () => reminderService.getById(id),
enabled: !!id,
})
}
export function useReminderInsights() {
return useQuery({
queryKey: ['reminder-insights'],
queryFn: reminderService.getInsights,
})
}
export function useCompleteReminder() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: ({ id, note }: { id: string; note?: string }) =>
reminderService.complete(id, note),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['reminders'] })
queryClient.invalidateQueries({ queryKey: ['reminder-insights'] })
},
onError: () => {
useToastStore.getState().showToast('Erinnerung konnte nicht abgeschlossen werden.', 'error')
},
})
}
export function useDismissReminder() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: ({ id, note }: { id: string; note?: string }) =>
reminderService.dismiss(id, note),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['reminders'] })
queryClient.invalidateQueries({ queryKey: ['reminder-insights'] })
},
onError: () => {
useToastStore.getState().showToast('Erinnerung konnte nicht verworfen werden.', 'error')
},
})
}
export function useSnoozeReminder() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: ({ id, until }: { id: string; until: string }) =>
reminderService.snooze(id, until),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['reminders'] })
queryClient.invalidateQueries({ queryKey: ['reminder-insights'] })
},
onError: () => {
useToastStore.getState().showToast('Erinnerung konnte nicht verschoben werden.', 'error')
},
})
}
export function useCreateReminder() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (data: Omit<Reminder, 'id' | 'activity' | 'createdAt' | 'updatedAt'>) =>
reminderService.create(data),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['reminders'] })
queryClient.invalidateQueries({ queryKey: ['reminder-insights'] })
},
onError: () => {
useToastStore.getState().showToast('Reminder konnte nicht erstellt werden.', 'error')
},
})
}
export function useUpdateReminder() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: ({ id, data }: { id: string; data: Partial<import('../domain/reminder').Reminder> }) =>
reminderService.update(id, data),
onSuccess: (_result, { id }) => {
queryClient.invalidateQueries({ queryKey: ['reminders'] })
queryClient.invalidateQueries({ queryKey: ['reminder', id] })
},
onError: () => {
useToastStore.getState().showToast('Erinnerung konnte nicht aktualisiert werden.', 'error')
},
})
}