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