✨ Invalidate queries
This commit adds the functionality of query invalidation - when a config is created - when the calendar options are changed It also makes it so the calendar doesn't update if the widget is currently being edited
This commit is contained in:
@@ -4,6 +4,7 @@ import { useMutation } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useConfigContext } from '../../../config/provider';
|
||||
import { ConfigType } from '../../../types/config';
|
||||
import { queryClient } from '../../server/configurations/tanstack/queryClient.tool';
|
||||
|
||||
export const useCopyConfigMutation = (configName: string) => {
|
||||
const { config } = useConfigContext();
|
||||
@@ -14,13 +15,15 @@ export const useCopyConfigMutation = (configName: string) => {
|
||||
mutationFn: () => fetchCopy(configName, config),
|
||||
onSuccess() {
|
||||
showNotification({
|
||||
title: t('modal.events.configCopied.title'),
|
||||
title: t('modal.copy.events.configCopied.title'),
|
||||
icon: <IconCheck />,
|
||||
color: 'green',
|
||||
autoClose: 1500,
|
||||
radius: 'md',
|
||||
message: t('modal.events.configCopied.message', { configName }),
|
||||
message: t('modal.copy.events.configCopied.message', { configName }),
|
||||
});
|
||||
// Invalidate a query to fetch new config
|
||||
queryClient.invalidateQueries(['config/get-all']);
|
||||
},
|
||||
onError() {
|
||||
showNotification({
|
||||
|
||||
Reference in New Issue
Block a user