feat(defter): haftanın girişleri, düzenle/sil + geri al, haftalık özet

- Girişler gün gün, gün toplamıyla; satırda kategori, grup, ödeme türü, açıklama
- Düzenleme aynı formda (sürüm kontrolü, pasif kategori korunur)
- Silmede "Geri al" bildirimi; grup bazlı bütçe / harcanan / kalan özeti

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 11:29:33 +03:00
parent f930f2fbcc
commit 16535ad7f3
13 changed files with 472 additions and 62 deletions
+28
View File
@@ -7,6 +7,7 @@
import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import type { Entry } from '@/types/Entry'
import type { EntryCreateRequest } from '@/types/EntryCreateRequest'
import type { EntryUpdateRequest } from '@/types/EntryUpdateRequest'
import { api } from './api'
import { queryKeys } from './query'
@@ -28,3 +29,30 @@ export function useCreateEntry(periodId: string) {
onSuccess: () => qc.invalidateQueries({ queryKey: queryKeys.period(periodId) }),
})
}
/** Düzenle (`version` ile: başkası değiştirdiyse 409). Hata da olsa liste yenilenir. */
export function useUpdateEntry(periodId: string) {
const qc = useQueryClient()
return useMutation({
mutationFn: ({ id, ...body }: EntryUpdateRequest & { id: string }) =>
api.patch<Entry>(`/entries/${id}`, body),
onSettled: () => qc.invalidateQueries({ queryKey: queryKeys.period(periodId) }),
})
}
/** Sil (soft) → `useRestoreEntry` ile geri alınabilir */
export function useDeleteEntry(periodId: string) {
const qc = useQueryClient()
return useMutation({
mutationFn: (id: string) => api.delete(`/entries/${id}`),
onSettled: () => qc.invalidateQueries({ queryKey: queryKeys.period(periodId) }),
})
}
export function useRestoreEntry(periodId: string) {
const qc = useQueryClient()
return useMutation({
mutationFn: (id: string) => api.post<Entry>(`/entries/${id}/restore`),
onSettled: () => qc.invalidateQueries({ queryKey: queryKeys.period(periodId) }),
})
}