simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 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éraud | ab519ff | 2022-05-03 15:34:48 -0400 | [diff] [blame] | 18 | import { SearchRounded } from '@mui/icons-material'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 19 | import { InputAdornment, InputBase } from '@mui/material'; |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 20 | import { ChangeEvent, useContext, useState } from 'react'; |
Gabriel Rochon | 59fc3cd | 2022-11-30 22:07:23 -0500 | [diff] [blame] | 21 | import { useTranslation } from 'react-i18next'; |
Larbi Gharib | e9af973 | 2021-03-31 15:08:01 +0100 | [diff] [blame] | 22 | |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 23 | import { MessengerContext } from '../contexts/MessengerProvider'; |
simon | 6b9ddfb | 2022-10-03 00:04:50 -0400 | [diff] [blame] | 24 | |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 25 | export default function NewContactForm() { |
| 26 | const { setSearchQuery } = useContext(MessengerContext); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 27 | const [value, setValue] = useState(''); |
Gabriel Rochon | 59fc3cd | 2022-11-30 22:07:23 -0500 | [diff] [blame] | 28 | const { t } = useTranslation(); |
Adrien Béraud | 150b478 | 2021-04-21 19:40:59 -0400 | [diff] [blame] | 29 | |
simon | 6b9ddfb | 2022-10-03 00:04:50 -0400 | [diff] [blame] | 30 | const handleChange = (event: ChangeEvent<HTMLInputElement>) => { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 31 | setValue(event.target.value); |
simon | 21f7d9f | 2022-11-28 14:21:54 -0500 | [diff] [blame] | 32 | setSearchQuery(event.target.value); |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 33 | }; |
Adrien Béraud | 35e7d7c | 2021-04-13 03:28:39 -0400 | [diff] [blame] | 34 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 35 | return ( |
Gabriel Rochon | 59fc3cd | 2022-11-30 22:07:23 -0500 | [diff] [blame] | 36 | <div className="main-search"> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 37 | <InputBase |
| 38 | className="main-search-input" |
| 39 | type="search" |
Gabriel Rochon | 59fc3cd | 2022-11-30 22:07:23 -0500 | [diff] [blame] | 40 | placeholder={t('conversation_add_contact_form')} |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 41 | value={value} |
| 42 | onChange={handleChange} |
| 43 | startAdornment={ |
| 44 | <InputAdornment position="start"> |
| 45 | <SearchRounded /> |
| 46 | </InputAdornment> |
| 47 | } |
| 48 | /> |
Gabriel Rochon | 59fc3cd | 2022-11-30 22:07:23 -0500 | [diff] [blame] | 49 | </div> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 50 | ); |
Larbi Gharib | e9af973 | 2021-03-31 15:08:01 +0100 | [diff] [blame] | 51 | } |