fix: refetch server data when share embed modal is closed (#2185)

This commit is contained in:
Anshuman Pandey
2024-03-05 13:40:49 +05:30
committed by GitHub
parent c5bdbc89ca
commit 7c09dd9d10
@@ -5,6 +5,7 @@ import { ArrowLeftIcon, CodeBracketIcon, EnvelopeIcon, LinkIcon } from "@heroico
import { DocumentDuplicateIcon } from "@heroicons/react/24/solid";
import { BellRing, BlocksIcon, Code2Icon, RefreshCcw } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useRef, useState } from "react";
import toast from "react-hot-toast";
@@ -28,6 +29,7 @@ interface ShareEmbedSurveyProps {
user: TUser;
}
export default function ShareEmbedSurvey({ survey, open, setOpen, webAppUrl, user }: ShareEmbedSurveyProps) {
const router = useRouter();
const environmentId = survey.environmentId;
const isSingleUseLinkSurvey = survey.singleUse?.enabled ?? false;
const { email } = user;
@@ -73,6 +75,9 @@ export default function ShareEmbedSurvey({ survey, open, setOpen, webAppUrl, use
setActiveId(tabs[0].id);
setOpen(open);
setShowInitialPage(open); // Reset to initial page when modal opens
// fetch latest responses
router.refresh();
};
const handleInitialPageButton = () => {