refactor(frontend): update category formDialog

This commit is contained in:
yassinedorbozgithub 2025-02-06 00:32:22 +01:00
parent 84b374c3f3
commit 06d40228cb

View File

@ -6,32 +6,19 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { FC } from "react";
import { FormDialog } from "@/app-components/dialogs";
import { useTranslate } from "@/hooks/useTranslate";
import { GenericFormDialog } from "@/app-components/dialogs";
import { ICategory } from "@/types/category.types";
import { ComponentFormDialogProps } from "@/types/common/dialogs.types";
import { CategoryForm } from "./CategoryForm";
export const CategoryFormDialog: FC<ComponentFormDialogProps<ICategory>> = ({
payload,
...rest
}) => {
const { t } = useTranslate();
return (
<CategoryForm
data={payload}
onSuccess={() => {
rest.onClose(true);
}}
Wrapper={FormDialog}
WrapperProps={{
title: payload ? t("title.edit_category") : t("title.new_category"),
...rest,
}}
/>
);
};
export const CategoryFormDialog = <T extends ICategory = ICategory>(
props: ComponentFormDialogProps<T>,
) => (
<GenericFormDialog<T>
Form={CategoryForm}
addText="title.new_category"
editText="title.edit_category"
{...props}
/>
);