blob: d3e328b63a1c5248e3d5cee9dd4c971ce7118570 [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';
Gabriel Rochon59fc3cd2022-11-30 22:07:23 -050021import { useTranslation } from 'react-i18next';
Larbi Gharibe9af9732021-03-31 15:08:01 +010022
simon21f7d9f2022-11-28 14:21:54 -050023import { MessengerContext } from '../contexts/MessengerProvider';
simon6b9ddfb2022-10-03 00:04:50 -040024
simon21f7d9f2022-11-28 14:21:54 -050025export default function NewContactForm() {
26 const { setSearchQuery } = useContext(MessengerContext);
simond47ef9e2022-09-28 22:24:28 -040027 const [value, setValue] = useState('');
Gabriel Rochon59fc3cd2022-11-30 22:07:23 -050028 const { t } = useTranslation();
Adrien Béraud150b4782021-04-21 19:40:59 -040029
simon6b9ddfb2022-10-03 00:04:50 -040030 const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
simond47ef9e2022-09-28 22:24:28 -040031 setValue(event.target.value);
simon21f7d9f2022-11-28 14:21:54 -050032 setSearchQuery(event.target.value);
simond47ef9e2022-09-28 22:24:28 -040033 };
Adrien Béraud35e7d7c2021-04-13 03:28:39 -040034
simond47ef9e2022-09-28 22:24:28 -040035 return (
Gabriel Rochon59fc3cd2022-11-30 22:07:23 -050036 <div className="main-search">
simond47ef9e2022-09-28 22:24:28 -040037 <InputBase
38 className="main-search-input"
39 type="search"
Gabriel Rochon59fc3cd2022-11-30 22:07:23 -050040 placeholder={t('conversation_add_contact_form')}
simond47ef9e2022-09-28 22:24:28 -040041 value={value}
42 onChange={handleChange}
43 startAdornment={
44 <InputAdornment position="start">
45 <SearchRounded />
46 </InputAdornment>
47 }
48 />
Gabriel Rochon59fc3cd2022-11-30 22:07:23 -050049 </div>
simond47ef9e2022-09-28 22:24:28 -040050 );
Larbi Gharibe9af9732021-03-31 15:08:01 +010051}