diff options
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/Page.tsx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/containers/Page.tsx b/src/containers/Page.tsx index 458bf15..69f3513 100644 --- a/src/containers/Page.tsx +++ b/src/containers/Page.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { useLocation } from 'react-router-dom'; import Paper from '../components/Paper'; import Button from '../components/Button'; import { Action, Filter } from '../lib/ServiceContext'; @@ -9,12 +10,15 @@ interface Props { actions?: Action[]; filters?: Filter[]; applyFilter?: (key: string, value: string) => void; + resetFilters?: () => void; className?: string; } const style = 'mb-2 flex justify-between md:flex-row md:items-center'; -const Page: React.FC<Props> = ({ title, actions, filters, applyFilter, className, children }) => { +const Page: React.FC<Props> = ({ title, actions, filters, applyFilter, resetFilters, className, children }) => { + const location = useLocation(); + const handleFilterChange = (key: string) => (event: React.ChangeEvent<HTMLSelectElement>) => { if (applyFilter) applyFilter(key, event.target.value); }; @@ -24,7 +28,16 @@ const Page: React.FC<Props> = ({ title, actions, filters, applyFilter, className <div className={`${style} ${(actions?.length || 0) > 1 ? 'flex-col items-start' : 'flex-row items-center'}`}> <span className="text-2xl font-bold">{title}</span> <div className="flex"> - <div className="mr-6 flex"> + <div className="mr-6 flex items-center"> + {filters && location.search && ( + <span + onClick={resetFilters} + role="presentation" + className="underline mr-2 cursor-pointer" + > + Сбросить фильтры + </span> + )} {filters?.map(filter => ( <SelectBase key={filter.key} |