Blame view
imports/ui/components/add-document.js
693 Bytes
d1f05315d
|
1 |
import React from 'react'; |
76dd62c7b
|
2 |
import { Input } from 'react-bootstrap'; |
d1f05315d
|
3 |
import { insertDocument } from '../../api/documents/methods.js'; |
f0c912bf1
|
4 5 6 |
const handleInsertDocument = (event) => { const target = event.target; const title = target.value.trim(); |
d1f05315d
|
7 |
|
f0c912bf1
|
8 |
if (title !== '' && event.keyCode === 13) { |
d1f05315d
|
9 |
insertDocument.call({ |
f0c912bf1
|
10 11 12 13 |
title, }, (error) => { if (error) { Bert.alert(error.reason, 'danger'); |
d1f05315d
|
14 15 |
} else { target.value = ''; |
f0c912bf1
|
16 |
Bert.alert('Document added!', 'success'); |
d1f05315d
|
17 18 19 20 21 22 23 24 25 26 27 |
} }); } }; export const AddDocument = () => ( <Input type="text" onKeyUp={ handleInsertDocument } placeholder="Type a document title and press enter..." /> |
f0c912bf1
|
28 |
); |