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:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user