2024-03-25 15:08:08 +03:00

53 lines
1.2 KiB
TypeScript

import type { ResponseQueries } from './types';
import getUrls from '@/config/urls';
import { withHandleError } from '@/utils/axios';
import axios from 'axios';
const {
URL_CACHE_GET_QUERIES,
URL_CACHE_DELETE_QUERY,
URL_CACHE_RESET_QUERIES,
URL_CACHE_DELETE_QUERIES_BY_KEY,
URL_CACHE_GET_QUERY_VALUE,
} = getUrls();
export function getQueries() {
return withHandleError(axios.get<ResponseQueries>(URL_CACHE_GET_QUERIES)).then(
({ data }) => data
);
}
export function deleteQuery(queryName: string) {
return withHandleError(
axios.delete(URL_CACHE_DELETE_QUERY, {
params: {
queryName,
},
})
).then(({ data }) => data);
}
export function reset() {
return withHandleError(axios.delete(URL_CACHE_RESET_QUERIES)).then(({ data }) => data);
}
export function deleleteQueriesByKey(queriesGroup: string) {
return withHandleError(
axios.delete(URL_CACHE_DELETE_QUERIES_BY_KEY, {
params: {
queriesGroup,
},
})
).then(({ data }) => data);
}
export function getQueryValue(queryKey: string) {
return withHandleError(
axios.get<ResponseQueries>(URL_CACHE_GET_QUERY_VALUE, {
params: {
queryKey,
},
})
).then(({ data }) => data);
}