Converted mutation queries.

This commit is contained in:
Mike Cao 2025-08-24 15:20:19 -07:00
parent 3f167e05ba
commit 0f9669f886
34 changed files with 259 additions and 350 deletions

View file

@ -2,10 +2,10 @@ import { useApi, useModified } from '@/components/hooks';
export function useDeleteQuery(path: string, params?: Record<string, any>) {
const { del, useMutation } = useApi();
const { mutate, isPending, error } = useMutation({
const query = useMutation({
mutationFn: () => del(path, params),
});
const { touch } = useModified();
return { mutate, isPending, error, touch };
return { ...query, touch };
}

View file

@ -4,11 +4,11 @@ import { useToast } from '@umami/react-zen';
export function useUpdateQuery(path: string, params?: Record<string, any>) {
const { post, useMutation } = useApi();
const { mutate, isPending, error } = useMutation({
const query = useMutation({
mutationFn: (data: Record<string, any>) => post(path, { ...data, ...params }),
});
const { touch } = useModified();
const { toast } = useToast();
return { mutate, isPending, error, touch, toast };
return { ...query, touch, toast };
}

View file

@ -68,13 +68,7 @@ export function MetricsTable({
};
return (
<LoadingPanel
data={data}
isFetching={isFetching}
isLoading={isLoading}
error={error}
height="100%"
>
<LoadingPanel data={data} isFetching={isFetching} isLoading={isLoading} error={error}>
{data && <ListTable {...props} data={filteredData} renderLabel={renderLabel} />}
{showMore && limit && (
<Row justifyContent="center">

View file

@ -31,6 +31,7 @@ export function PageviewsChart({ data, unit, minDate, maxDate, ...props }: Pagev
__id: new Date().getTime(),
datasets: [
{
type: data.compare ? 'line' : 'bar',
label: formatMessage(labels.visitors),
data: generateTimeSeries(data.sessions, minDate, maxDate, unit, dateLocale),
borderWidth: 1,
@ -40,6 +41,7 @@ export function PageviewsChart({ data, unit, minDate, maxDate, ...props }: Pagev
order: 3,
},
{
type: data.compare ? 'line' : 'bar',
label: formatMessage(labels.views),
data: generateTimeSeries(data.pageviews, minDate, maxDate, unit, dateLocale),
barPercentage: 0.9,