File size: 1,854 Bytes
362ec6c 6b8fc2c 362ec6c 6b8fc2c fad2ec7 362ec6c fad2ec7 6b8fc2c 362ec6c 7b71fb2 362ec6c 6b8fc2c 362ec6c 7b71fb2 362ec6c 6b8fc2c 7b71fb2 362ec6c 7b71fb2 362ec6c 7b71fb2 362ec6c 7b71fb2 362ec6c 7b71fb2 362ec6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
import { Form, Input, Modal } from 'antd';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'umi';
type FieldType = {
name?: string;
};
interface kFProps {
getKfList: () => void;
kb_id: string;
}
const FileCreatingModal: React.FC<kFProps> = ({ getKfList, kb_id }) => {
const dispatch = useDispatch();
const [form] = Form.useForm();
const kFModel = useSelector((state: any) => state.kFModel);
const { isShowCEFwModal } = kFModel;
const { t } = useTranslation();
const handleCancel = () => {
dispatch({
type: 'kFModel/updateState',
payload: {
isShowCEFwModal: false,
},
});
};
const createDocument = async () => {
try {
const values = await form.validateFields();
const retcode = await dispatch<any>({
type: 'kFModel/document_create',
payload: {
name: values.name,
kb_id,
},
});
if (retcode === 0) {
getKfList && getKfList();
}
} catch (errorInfo) {
console.log('Failed:', errorInfo);
}
};
const handleOk = async () => {
createDocument();
};
return (
<Modal
title="File Name"
open={isShowCEFwModal}
onOk={handleOk}
onCancel={handleCancel}
>
<Form
form={form}
name="validateOnly"
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
style={{ maxWidth: 600 }}
autoComplete="off"
>
<Form.Item<FieldType>
label="File Name"
name="name"
rules={[{ required: true, message: 'Please input name!' }]}
>
<Input />
</Form.Item>
</Form>
</Modal>
);
};
export default FileCreatingModal;
|