import { useTranslate } from '@/hooks/common-hooks'; import { Form, Input, Modal } from 'antd'; import { useEffect } from 'react'; import { IModalManagerChildrenProps } from '../modal-manager'; interface IProps extends Omit { loading: boolean; initialName: string; onOk: (name: string) => void; showModal?(): void; } const RenameModal = ({ visible, hideModal, loading, initialName, onOk, }: IProps) => { const [form] = Form.useForm(); const { t } = useTranslate('common'); type FieldType = { name?: string; }; const handleOk = async () => { const ret = await form.validateFields(); return onOk(ret.name); }; const handleCancel = () => { hideModal(); }; const onFinish = (values: any) => { console.log('Success:', values); }; const onFinishFailed = (errorInfo: any) => { console.log('Failed:', errorInfo); }; useEffect(() => { if (visible) { form.setFieldValue('name', initialName); } }, [initialName, form, visible]); return (
label={t('name')} name="name" rules={[{ required: true, message: t('namePlaceholder') }]} >
); }; export default RenameModal;