Revize e57fa805
Přidáno uživatelem Václav Honzík před téměř 3 roky(ů)
frontend/src/features/Catalog/Catalog.tsx | ||
---|---|---|
1 | 1 |
import { |
2 | 2 |
Box, |
3 | 3 |
Button, |
4 |
Collapse, |
|
4 | 5 |
Container, |
5 | 6 |
Grid, |
6 | 7 |
Paper, |
... | ... | |
10 | 11 |
import { CatalogDto } from '../../swagger/data-contracts' |
11 | 12 |
import CatalogTable from './CatalogTable' |
12 | 13 |
import { faker } from '@faker-js/faker' |
13 |
|
|
14 |
import { useState } from 'react' |
|
14 | 15 |
|
15 | 16 |
const Catalog = () => { |
17 |
const [filterOpen, setFilterOpen] = useState(false) |
|
18 |
const toggleFilter = () => { |
|
19 |
setFilterOpen(!filterOpen) |
|
20 |
} |
|
16 | 21 |
|
17 | 22 |
// Creates a generic row for the table |
18 | 23 |
const createRow = (): CatalogDto => ({ |
... | ... | |
26 | 31 |
countries: [faker.address.country()], |
27 | 32 |
alternativeNames: [faker.commerce.productName()], |
28 | 33 |
}) |
29 |
const data: CatalogDto[] = Array(33).fill({}).map(() => createRow()) |
|
34 |
const data: CatalogDto[] = Array(33) |
|
35 |
.fill({}) |
|
36 |
.map(() => createRow()) |
|
30 | 37 |
|
31 | 38 |
return ( |
32 | 39 |
<> |
33 | 40 |
<Paper sx={{ py: 2 }}> |
34 | 41 |
<Container sx={{ mt: 4 }}> |
35 |
<Button variant="contained">Filter</Button> |
|
42 |
<Button variant="contained" onClick={toggleFilter}>Filter</Button> |
|
43 |
<Collapse in={filterOpen} timeout="auto" unmountOnExit> |
|
36 | 44 |
<Grid container spacing={1} alignItems="stretch"> |
37 | 45 |
<Grid item xs={6}> |
38 | 46 |
<Stack |
... | ... | |
71 | 79 |
</Stack> |
72 | 80 |
</Grid> |
73 | 81 |
</Grid> |
82 |
</Collapse> |
|
74 | 83 |
|
75 | 84 |
<Box sx={{ mt: 4 }}> |
76 | 85 |
<CatalogTable data={data} /> |
Také k dispozici: Unified diff
re #9130 catalog filter toggle