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:
megaproxy 2026-04-23 11:50:28 +00:00
parent 8ef3bb2965
commit 6111424f47
5 changed files with 455 additions and 22 deletions

View 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);