import { FC } from "react"; import { DialogTitle, DialogContent, Dialog, DialogHeader, Form, FormItem, FormControl, FormMessage, FormLabel, Input, FormField, Checkbox, Button } from '@marzneshin/components'; import { useTranslation } from 'react-i18next'; import { NodeType, NodeSchema, useNodesCreationMutation, useNodesUpdateMutation } from ".."; import { useMutationDialog } from "@marzneshin/hooks"; interface MutationDialogProps { entity: NodeType | null; open: boolean; onOpenChange: (state: boolean) => void; } const getDefaultValue = (): NodeType => ({ name: '', address: '', status: 'none', port: 62050, usage_coefficient: 1, add_as_new_host: true, }); export const MutationDialog: FC = ({ entity, open, onOpenChange, }) => { const updateMutation = useNodesUpdateMutation(); const createMutation = useNodesCreationMutation(); const { t } = useTranslation(); const { form, handleSubmit } = useMutationDialog({ onOpenChange, entity, schema: NodeSchema, createMutation, updateMutation, getDefaultValue }) return ( {entity ? t('page.nodes.dialogs.edition.title') : t('page.nodes.dialogs.creation.title')}
( {t('name')} )} />
( {t('address')} )} /> ( {t('port')} )} /> ( {t('page.nodes.usage_coefficient')} )} />
(
{t('page.nodes.add_as_new_host')}
)} />
); };