blob: 532add37177a8f91d22598f7ea8442d98c19df16 (
plain)
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
|
import PropTypes from 'prop-types'
import React, { useRef } from 'react'
import { Button, Form, FormGroup, Input } from 'reactstrap'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faPlus } from '@fortawesome/free-solid-svg-icons'
function UnitAddComponent({ units, onAdd }) {
const unitSelect = useRef(null)
return (
<Form inline>
<FormGroup className="w-100">
<Input type="select" className="w-70 mr-1" innerRef={unitSelect}>
{units.map((unit) => (
<option value={unit._id} key={unit._id}>
{unit.name}
</option>
))}
</Input>
<Button color="primary" outline onClick={() => onAdd(unitSelect.current.value)}>
<FontAwesomeIcon icon={faPlus} className="mr-2" />
Add
</Button>
</FormGroup>
</Form>
)
}
UnitAddComponent.propTypes = {
units: PropTypes.array.isRequired,
onAdd: PropTypes.func.isRequired,
}
export default UnitAddComponent
|