blob: 21ead27f7601e734236643959f4be6384b405b93 [file] [log] [blame]
simon26e79f72022-10-05 22:16:08 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
Adrien Béraudab519ff2022-05-03 15:34:48 -040018import { SearchRounded } from '@mui/icons-material';
simon07b4eb02022-09-29 17:50:26 -040019import { InputAdornment, InputBase } from '@mui/material';
simon21f7d9f2022-11-28 14:21:54 -050020import { ChangeEvent, useContext, useState } from 'react';
Larbi Gharibe9af9732021-03-31 15:08:01 +010021
simon21f7d9f2022-11-28 14:21:54 -050022import { MessengerContext } from '../contexts/MessengerProvider';
simon6b9ddfb2022-10-03 00:04:50 -040023
simon21f7d9f2022-11-28 14:21:54 -050024export default function NewContactForm() {
25 const { setSearchQuery } = useContext(MessengerContext);
simond47ef9e2022-09-28 22:24:28 -040026 const [value, setValue] = useState('');
Adrien Béraud150b4782021-04-21 19:40:59 -040027
simon6b9ddfb2022-10-03 00:04:50 -040028 const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
simond47ef9e2022-09-28 22:24:28 -040029 setValue(event.target.value);
simon21f7d9f2022-11-28 14:21:54 -050030 setSearchQuery(event.target.value);
simond47ef9e2022-09-28 22:24:28 -040031 };
Adrien Béraud35e7d7c2021-04-13 03:28:39 -040032
simond47ef9e2022-09-28 22:24:28 -040033 return (
simon21f7d9f2022-11-28 14:21:54 -050034 <form className="main-search" noValidate autoComplete="off">
simond47ef9e2022-09-28 22:24:28 -040035 <InputBase
36 className="main-search-input"
37 type="search"
38 placeholder="Ajouter un contact"
39 value={value}
40 onChange={handleChange}
41 startAdornment={
42 <InputAdornment position="start">
43 <SearchRounded />
44 </InputAdornment>
45 }
46 />
47 </form>
48 );
Larbi Gharibe9af9732021-03-31 15:08:01 +010049}