diff --git a/client/src/pages/admin.tsx b/client/src/pages/admin.tsx index 0507f49..8e29f98 100644 --- a/client/src/pages/admin.tsx +++ b/client/src/pages/admin.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import { useAuth } from "@/hooks/useAuth"; import { Button } from "@/components/ui/button"; @@ -217,6 +217,17 @@ function EditVideoDialog({ genre: video.genre, customThumbnailUrl: video.customThumbnailUrl || "", }); + + // Update form data when video prop changes + useEffect(() => { + setFormData({ + title: video.title, + description: video.description, + contentType: video.contentType, + genre: video.genre, + customThumbnailUrl: video.customThumbnailUrl || "", + }); + }, [video]); const [isGeneratingAI, setIsGeneratingAI] = useState(false); const updateMutation = useMutation({ @@ -226,9 +237,11 @@ function EditVideoDialog({ title: "Success", description: "Video updated successfully", }); - // Invalidate cache to refresh the video list + // Invalidate cache to refresh the video list - don't await since this function isn't async queryClient.invalidateQueries({ queryKey: ["/api/admin/videos"] }); queryClient.invalidateQueries({ queryKey: ["/api/videos"] }); + // Force immediate refetch + queryClient.refetchQueries({ queryKey: ["/api/admin/videos"] }); onOpenChange(false); onSuccess(); },