MCPcopy Create free account
hub / github.com/coderabbit214/bibliothecarius / DocumentDrawer

Function DocumentDrawer

web/components/document/document-drawer.tsx:19–101  ·  view source on GitHub ↗
({
                                                         visible,
                                                         onClose
                                                       })

Source from the content-addressed store, hash-verified

17}
18
19const DocumentDrawer: React.FC<DocumentDrawerProps> = ({
20 visible,
21 onClose
22 }) => {
23 const [form] = Form.useForm();
24 const [tags, setTags] = useState<string[]>();
25
26 const getTags = (val: string[]) => {
27 setTags(val);
28 };
29
30 const router = useRouter();
31 const {name: datasetName} = router.query;
32 const handleSubmit = async (values: DocumentUpload) => {
33 try {
34 var files: File[] = Array(values.fileList.length);
35 for (let i = 0; i < values.fileList.length; i++) {
36 files[i] = values.fileList[i].originFileObj;
37 }
38 await uploadDocument(datasetName as string, files, tags)
39 form.resetFields();
40 onClose();
41 } catch (error) {
42 if (error instanceof HttpError) {
43 message.error(error.message);
44 } else {
45 message.error("Operation failed");
46 }
47 }
48 };
49
50 const normFile = (e: any) => {
51 console.log('Upload event:', e);
52 if (Array.isArray(e)) {
53 return e;
54 }
55 return e?.fileList;
56 };
57
58
59 return (
60 <Drawer
61 title={"Create document"}
62 width={720}
63 onClose={onClose}
64 open={visible}
65 bodyStyle={{paddingBottom: 80}}
66 >
67 <Form
68 form={form}
69 layout="vertical"
70 onFinish={handleSubmit}
71 initialValues={{createTime: null, updateTime: null, vectorType: "openaiVector"}}
72 >
73 <Form.Item
74 name="fileList"
75 label="FileList"
76 valuePropName="fileList"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected