diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-20 22:59:32 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-20 22:59:32 +0100 |
| commit | 168ed3215f659d44215fd02ac05cc1fe58be4e06 (patch) | |
| tree | 48d15a4743749f483f50f919ffa94e38185588a1 /src/components | |
| parent | b181f93f0f26570696d3a90b58a966c56ac61047 (diff) | |
chore: create search view
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/PostsList/PostsList.tsx | 2 | ||||
| -rw-r--r-- | src/components/SearchForm/SearchForm.tsx | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/components/PostsList/PostsList.tsx b/src/components/PostsList/PostsList.tsx index 03e8834..da72032 100644 --- a/src/components/PostsList/PostsList.tsx +++ b/src/components/PostsList/PostsList.tsx @@ -39,7 +39,7 @@ const PostsList = ({ const getPostsList = () => { return data.map((page) => { if (page.posts.length === 0) { - return <p>{t`No results found.`}</p>; + return <p key="no-result">{t`No results found.`}</p>; } else { return ( <Fragment key={page.pageInfo.endCursor}> diff --git a/src/components/SearchForm/SearchForm.tsx b/src/components/SearchForm/SearchForm.tsx index c02c224..e37ba9e 100644 --- a/src/components/SearchForm/SearchForm.tsx +++ b/src/components/SearchForm/SearchForm.tsx @@ -1,11 +1,13 @@ import { ButtonSubmit } from '@components/Buttons'; import { Form, Input } from '@components/Form'; import { t } from '@lingui/macro'; +import { useRouter } from 'next/router'; import { FormEvent, useEffect, useRef, useState } from 'react'; const SearchForm = ({ isOpened }: { isOpened: boolean }) => { const [query, setQuery] = useState(''); const inputRef = useRef<HTMLInputElement>(null); + const router = useRouter(); useEffect(() => { setTimeout(() => { @@ -17,6 +19,8 @@ const SearchForm = ({ isOpened }: { isOpened: boolean }) => { const launchSearch = (e: FormEvent) => { e.preventDefault(); + router.push({ pathname: '/recherche', query: { s: query } }); + setQuery(''); }; return ( |
