import { t, Trans } from "@lingui/macro" import { Box, Button, Group, Stack, TextInput } from "@mantine/core" import { useForm } from "@mantine/form" import { client, errorToStrings } from "app/client" import { redirectToSelectedSource } from "app/redirect/thunks" import { useAppDispatch } from "app/store" import { reloadTree } from "app/tree/thunks" import { type AddCategoryRequest } from "app/types" import { Alert } from "components/Alert" import { useAsyncCallback } from "react-async-hook" import { TbFolderPlus } from "react-icons/tb" import { CategorySelect } from "./CategorySelect" export function AddCategory() { const dispatch = useAppDispatch() const form = useForm() const addCategory = useAsyncCallback(client.category.add, { onSuccess: () => { dispatch(reloadTree()) dispatch(redirectToSelectedSource()) }, }) return ( <> {addCategory.error && ( )}
Category} placeholder={t`Category`} {...form.getInputProps("name")} required /> Parent} {...form.getInputProps("parentId")} clearable />
) }