Add category management UI and service layer
Users can now create, edit, and delete custom categories from Settings → Categories. System categories (45 built-in) are shown read-only. Backend adds update_category() and delete_category() service functions; frontend has a new categories API module and a full CRUD section in SettingsPage with filter tabs, colour picker, and delete confirmation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8ef3bb2965
commit
6111424f47
5 changed files with 455 additions and 22 deletions
37
frontend/src/api/categories.ts
Normal file
37
frontend/src/api/categories.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { api } from "./client";
|
||||
|
||||
export interface Category {
|
||||
id: string;
|
||||
name: string;
|
||||
type: "income" | "expense" | "transfer";
|
||||
icon: string | null;
|
||||
color: string | null;
|
||||
is_system: boolean;
|
||||
parent_id: string | null;
|
||||
sort_order: number;
|
||||
}
|
||||
|
||||
export interface CategoryCreate {
|
||||
name: string;
|
||||
type: "income" | "expense" | "transfer";
|
||||
color?: string | null;
|
||||
icon?: string | null;
|
||||
}
|
||||
|
||||
export interface CategoryUpdate {
|
||||
name?: string | null;
|
||||
color?: string | null;
|
||||
icon?: string | null;
|
||||
}
|
||||
|
||||
export const listCategories = (): Promise<Category[]> =>
|
||||
api.get("/categories").then((r: { data: Category[] }) => r.data);
|
||||
|
||||
export const createCategory = (data: CategoryCreate): Promise<Category> =>
|
||||
api.post("/categories", data).then((r: { data: Category }) => r.data);
|
||||
|
||||
export const updateCategory = (id: string, data: CategoryUpdate): Promise<Category> =>
|
||||
api.put(`/categories/${id}`, data).then((r: { data: Category }) => r.data);
|
||||
|
||||
export const deleteCategory = (id: string): Promise<void> =>
|
||||
api.delete(`/categories/${id}`).then(() => undefined);
|
||||
Loading…
Add table
Add a link
Reference in a new issue