Fix: Display new service immediately

- Ensure that newly created services are immediately visible in the services table list on the Uptime Monitoring dashboard, without requiring a manual refresh or a delay.
This commit is contained in:
Tola Leng
2025-07-23 22:13:20 +07:00
parent 4ff92b4c4d
commit fda91aedb9
2 changed files with 18 additions and 1 deletions
@@ -8,6 +8,7 @@ import {
} from "@/components/ui/dialog";
import { ServiceForm } from "./ServiceForm";
import { ScrollArea } from "@/components/ui/scroll-area";
import { useQueryClient } from "@tanstack/react-query";
interface AddServiceDialogProps {
open: boolean;
@@ -15,7 +16,11 @@ interface AddServiceDialogProps {
}
export function AddServiceDialog({ open, onOpenChange }: AddServiceDialogProps) {
const handleSuccess = () => {
const queryClient = useQueryClient();
const handleSuccess = async () => {
// Immediately invalidate and refetch services data
await queryClient.invalidateQueries({ queryKey: ["services"] });
await queryClient.refetchQueries({ queryKey: ["services"] });
onOpenChange(false);
};