blob: 9862453b0f4023b6343c7de71e7c9ac2b0249f13 [file] [log] [blame]
Adrien Béraudab519ff2022-05-03 15:34:48 -04001import { SearchRounded } from '@mui/icons-material';
simon07b4eb02022-09-29 17:50:26 -04002import { InputAdornment, InputBase } from '@mui/material';
3import { useState } from 'react';
Larbi Gharibe9af9732021-03-31 15:08:01 +01004
Adrien Béraud150b4782021-04-21 19:40:59 -04005export default function NewContactForm(props) {
simond47ef9e2022-09-28 22:24:28 -04006 const [value, setValue] = useState('');
Adrien Béraud150b4782021-04-21 19:40:59 -04007
simond47ef9e2022-09-28 22:24:28 -04008 const handleChange = (event) => {
9 setValue(event.target.value);
10 if (props.onChange) props.onChange(event.target.value);
11 };
Adrien Béraud35e7d7c2021-04-13 03:28:39 -040012
simond47ef9e2022-09-28 22:24:28 -040013 const handleSubmit = (event) => {
14 event.preventDefault();
15 if (value && props.onSubmit) props.onSubmit(value);
16 };
Adrien Béraud35e7d7c2021-04-13 03:28:39 -040017
simond47ef9e2022-09-28 22:24:28 -040018 return (
19 <form className="main-search" onSubmit={handleSubmit} noValidate autoComplete="off">
20 <InputBase
21 className="main-search-input"
22 type="search"
23 placeholder="Ajouter un contact"
24 value={value}
25 onChange={handleChange}
26 startAdornment={
27 <InputAdornment position="start">
28 <SearchRounded />
29 </InputAdornment>
30 }
31 />
32 </form>
33 );
Larbi Gharibe9af9732021-03-31 15:08:01 +010034}