refactor: simplify frontend state and mutation boundaries
Frontend verify / commits (pull_request) Successful in 31s
Frontend verify / security (pull_request) Successful in 11s
Frontend verify / verify (pull_request) Successful in 9m1s
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 10s
Frontend verify / verify (push) Successful in 9m59s

This commit was merged in pull request #44.
This commit is contained in:
2026-09-28 20:01:37 +03:00
parent a4046dbe87
commit a7537da344
25 changed files with 414 additions and 547 deletions
@@ -5,7 +5,10 @@ import { useRef, useState } from "react";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { useBankMutations } from "../../api/mutations";
import {
useCreateExpenseCategory,
useUpdateExpenseCategory,
} from "../../api/mutations";
import { type ExpenseCategory, useBankCategories } from "../../api/queries";
import { categorySchema } from "../../model/category.schema";
import { useBankFormFocus } from "../useBankFormFocus";
@@ -22,7 +25,8 @@ function useCategoryManagerVm(props: CategoryManagerProps) {
const [opened, setOpened] = useState(true);
const { t } = useTranslation();
const categories = useBankCategories();
const mutation = useBankMutations();
const categoryCreation = useCreateExpenseCategory();
const updateCategory = useUpdateExpenseCategory();
const [editing, setEditing] = useState<ExpenseCategory>();
const editSessionRef = useRef(0);
const [error, setError] = useState<unknown>();
@@ -43,12 +47,12 @@ function useCategoryManagerVm(props: CategoryManagerProps) {
try {
if (editing)
await mutation.updateCategory.mutateAsync({
await updateCategory.mutateAsync({
body: { name: values.name, version: editing.version },
id: editing.id,
});
else {
const result = await mutation.createCategory.mutateAsync({
const result = await categoryCreation.mutateAsync({
name: values.name,
});