Compare commits

...

2 Commits

Author SHA1 Message Date
vchikalkin
a0a58f2363 fix layout 2024-06-21 15:56:00 +03:00
obarykina
d6cbf18dce added clear all cache button 2024-06-20 17:32:15 +03:00

View File

@ -1,9 +1,10 @@
import Background from '../../Layout/Background'; import Background from '../../Layout/Background';
import { useFilteredQueries } from './lib/hooks'; import { useFilteredQueries } from './lib/hooks';
import { QueryList } from './QueryList'; import { QueryList } from './QueryList';
import { reset } from '@/api/cache/query';
import { min } from '@/styles/mq'; import { min } from '@/styles/mq';
import styled from 'styled-components'; import styled from 'styled-components';
import { Collapse, Divider, Input } from 'ui/elements'; import { Button, Collapse, Divider, Input } from 'ui/elements';
const Wrapper = styled(Background)` const Wrapper = styled(Background)`
padding: 4px 6px; padding: 4px 6px;
@ -21,13 +22,21 @@ const Wrapper = styled(Background)`
const Flex = styled.div` const Flex = styled.div`
display: flex; display: flex;
margin-bottom: 16px; flex-direction: column;
justify-content: space-between;
gap: 10px; gap: 10px;
`; `;
const ButtonWrapper = styled.div`
display: flex;
justify-content: flex-end;
`;
export function Cache() { export function Cache() {
const { filteredQueries, setFilterString } = useFilteredQueries(); const { filteredQueries, refetch, setFilterString } = useFilteredQueries();
function handleDeleteQuery() {
return reset().then(() => refetch());
}
if (!filteredQueries) { if (!filteredQueries) {
return <div>Загрузка...</div>; return <div>Загрузка...</div>;
@ -42,7 +51,6 @@ export function Cache() {
allowClear allowClear
onChange={(e) => setFilterString(e.target.value)} onChange={(e) => setFilterString(e.target.value)}
/> />
</Flex>
<Collapse <Collapse
accordion accordion
items={Object.keys(filteredQueries).map((queryGroupName) => ({ items={Object.keys(filteredQueries).map((queryGroupName) => ({
@ -51,6 +59,12 @@ export function Cache() {
label: queryGroupName, label: queryGroupName,
}))} }))}
/> />
<ButtonWrapper>
<Button type="primary" danger disabled={false} onClick={() => handleDeleteQuery()}>
Очистить кэш
</Button>
</ButtonWrapper>
</Flex>
</Wrapper> </Wrapper>
); );
} }