refactor: update front api endpoints

This commit is contained in:
Sonny
2023-06-04 00:43:02 +02:00
parent 7cd0a92562
commit 5c2c2de1bd
6 changed files with 47 additions and 38 deletions

View File

@@ -7,6 +7,7 @@ import FormLayout from "components/FormLayout";
import PageTransition from "components/PageTransition";
import TextBox from "components/TextBox";
import PATHS from "constants/paths";
import useAutoFocus from "hooks/useAutoFocus";
import { redirectWithoutClientCache } from "utils/client";
import { HandleAxiosError } from "utils/front";
@@ -36,8 +37,10 @@ function CreateCategory() {
try {
const { data } = await axios.post("/api/category/create", { name });
const { data } = await axios.post(PATHS.API.CATEGORY, { name });
redirectWithoutClientCache(router, "");
router.push(`/?categoryId=${data?.categoryId}`);
router.push(`${PATHS.HOME}?categoryId=${data?.categoryId}`);
setSubmitted(true);
} catch (error) {
setError(HandleAxiosError(error));