Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 2x 20x 20x 4x 4x 20x 4x 20x | import Button from 'common-components/Button';
import Pagination from 'components/Pagination';
import React, { useState } from 'react';
import styles from './NavSearch.module.scss';
type Props = {
pagination?: Pagination;
page: number;
isPreviousData: boolean;
onPaginate: (page: number) => void;
onSearch: (query: string) => void;
}
const NavSearch = ({ onSearch, pagination, onPaginate, page, isPreviousData }: Props) => {
const [query, setQuery] = useState("");
const handleSearch = (e: React.FormEvent) => {
e.preventDefault();
onSearch(query);
}
const handleQuery = (e: React.FormEvent<HTMLInputElement>) => {
setQuery((e.target as HTMLInputElement).value);
}
return (
<nav className={styles.nav}>
<h1 className={styles.nav__h1}>DiscogsPedia</h1>
<summary className={styles.nav__summary}>Find your favourite release right here.</summary>
<form onSubmit={handleSearch} className={styles.nav__form}>
<input
aria-describedby="Query"
data-testid="query"
className={styles.nav__search}
type="search"
name="query"
onChange={handleQuery}
value={query}
placeholder="Type Moderat..."
/>
<Button data-testid="btn-query" className={styles.nav__btn}>Search</Button>
</form>
{!!pagination && (
<Pagination
pagination={pagination}
isPreviousData={isPreviousData}
page={page}
onPaginate={onPaginate}
/>
)}
</nav>
)
}
export default NavSearch;
|