71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import Background from '../../Layout/Background';
|
||
import { useFilteredQueries } from './lib/hooks';
|
||
import { QueryList } from './QueryList';
|
||
import { reset } from '@/api/cache/query';
|
||
import { min } from '@/styles/mq';
|
||
import styled from 'styled-components';
|
||
import { Button, Collapse, Divider, Input } from 'ui/elements';
|
||
|
||
const Wrapper = styled(Background)`
|
||
padding: 4px 6px;
|
||
width: 100vw;
|
||
|
||
${min('tablet')} {
|
||
min-height: 790px;
|
||
}
|
||
|
||
${min('laptop')} {
|
||
padding: 4px 18px 10px;
|
||
width: 1280px;
|
||
}
|
||
`;
|
||
|
||
const Flex = styled.div`
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
`;
|
||
|
||
const ButtonWrapper = styled.div`
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
`;
|
||
|
||
export function Cache() {
|
||
const { filteredQueries, refetch, setFilterString } = useFilteredQueries();
|
||
|
||
function handleDeleteQuery() {
|
||
return reset().then(() => refetch());
|
||
}
|
||
|
||
if (!filteredQueries) {
|
||
return <div>Загрузка...</div>;
|
||
}
|
||
|
||
return (
|
||
<Wrapper>
|
||
<Divider>Управление кэшем</Divider>
|
||
<Flex>
|
||
<Input
|
||
placeholder="Поиск по запросу"
|
||
allowClear
|
||
onChange={(e) => setFilterString(e.target.value)}
|
||
/>
|
||
<Collapse
|
||
accordion
|
||
items={Object.keys(filteredQueries).map((queryGroupName) => ({
|
||
children: <QueryList {...filteredQueries[queryGroupName]} />,
|
||
key: queryGroupName,
|
||
label: queryGroupName,
|
||
}))}
|
||
/>
|
||
<ButtonWrapper>
|
||
<Button type="primary" danger disabled={false} onClick={() => handleDeleteQuery()}>
|
||
Очистить кэш
|
||
</Button>
|
||
</ButtonWrapper>
|
||
</Flex>
|
||
</Wrapper>
|
||
);
|
||
}
|