mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-14 19:46:40 +07:00
feat: add free-form tags on transactions
Third of the four ideas picked from the Maybe/Sure feature audit. Tags are orthogonal to categories (category = what kind of spend, tag = which event/project) — many-to-many, created inline while typing in the transaction form, filterable from the Transactions page. Also adds tests/test_backup.py, the first test coverage the backup export/import path has ever had, and fixes a MissingGreenlet bug it surfaced in restore_backup's tag-wiring. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
25
frontend/src/hooks/useTags.ts
Normal file
25
frontend/src/hooks/useTags.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createTag, deleteTag, fetchTags } from "@/api/tags";
|
||||
|
||||
export function useTags() {
|
||||
return useQuery({ queryKey: ["tags"], queryFn: fetchTags });
|
||||
}
|
||||
|
||||
export function useCreateTag() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (name: string) => createTag(name),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["tags"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteTag() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: number) => deleteTag(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["tags"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["transactions"] });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user