import { type FC, useMemo } from "react"; import { DialogTitle, DialogContent, Dialog, DialogHeader, Form, FormItem, FormControl, FormMessage, FormLabel, Input, FormField, Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, FormDescription, HStack, } from "@marzneshin/components"; import { useTranslation } from "react-i18next"; import { NodeSchema, useNodesCreationMutation, useNodesUpdateMutation, } from "../.."; import type { NodeType } from "../.."; import { useMutationDialog, MutationDialogProps } from "@marzneshin/hooks"; export const MutationDialog: FC> = ({ entity, onClose, }) => { const updateMutation = useNodesUpdateMutation(); const createMutation = useNodesCreationMutation(); const { t } = useTranslation(); const defaultValue = useMemo(() => ({ id: 0, name: "", address: "", status: "none", port: 62050, usage_coefficient: 1, connection_backend: "grpclib", }), []); const { onOpenChange, open, form, handleSubmit } = useMutationDialog({ entity, onClose, schema: NodeSchema, createMutation, updateMutation, defaultValue, }); return ( {entity ? t("page.nodes.dialogs.edition.title") : t("page.nodes.dialogs.creation.title")}
( {t("name")} )} />
( {t("address")} )} /> ( {t("port")} )} />
( {t("page.nodes.connection_backend")} {t("page.nodes.connection_backend_desc")} )} /> ( {t("page.nodes.usage_coefficient")} )} />
); };