Compare commits

...

1 Commits

Author SHA1 Message Date
Dhruwang
0c866aee66 fix: delete response 2024-01-16 12:24:42 +05:30
2 changed files with 5 additions and 4 deletions

View File

@@ -65,7 +65,7 @@ export default function ResponseTimeline({
observer.unobserve(currentLoadingRef); observer.unobserve(currentLoadingRef);
} }
}; };
}, [responses, responsesPerPage, page, survey.id, fetchedResponses.length, hasMoreResponses]); }, [responsesPerPage, page, survey.id, fetchedResponses.length, hasMoreResponses]);
return ( return (
<div className="space-y-4"> <div className="space-y-4">
@@ -89,6 +89,7 @@ export default function ResponseTimeline({
environmentTags={environmentTags} environmentTags={environmentTags}
pageType="response" pageType="response"
environment={environment} environment={environment}
setFetchedResponses={setFetchedResponses}
/> />
</div> </div>
); );

View File

@@ -4,7 +4,6 @@ import { TrashIcon } from "@heroicons/react/24/outline";
import { CheckCircleIcon } from "@heroicons/react/24/solid"; import { CheckCircleIcon } from "@heroicons/react/24/solid";
import clsx from "clsx"; import clsx from "clsx";
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/navigation";
import { ReactNode, useState } from "react"; import { ReactNode, useState } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
@@ -41,6 +40,7 @@ export interface SingleResponseCardProps {
pageType: string; pageType: string;
environmentTags: TTag[]; environmentTags: TTag[];
environment: TEnvironment; environment: TEnvironment;
setFetchedResponses: React.Dispatch<React.SetStateAction<TResponse[]>>;
} }
interface TooltipRendererProps { interface TooltipRendererProps {
@@ -79,9 +79,9 @@ export default function SingleResponseCard({
pageType, pageType,
environmentTags, environmentTags,
environment, environment,
setFetchedResponses,
}: SingleResponseCardProps) { }: SingleResponseCardProps) {
const environmentId = survey.environmentId; const environmentId = survey.environmentId;
const router = useRouter();
const displayIdentifier = response.person ? getPersonIdentifier(response.person) : null; const displayIdentifier = response.person ? getPersonIdentifier(response.person) : null;
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const [isDeleting, setIsDeleting] = useState(false); const [isDeleting, setIsDeleting] = useState(false);
@@ -152,7 +152,7 @@ export default function SingleResponseCard({
throw new Error("You are not authorized to perform this action."); throw new Error("You are not authorized to perform this action.");
} }
await deleteResponseAction(response.id); await deleteResponseAction(response.id);
router.refresh(); setFetchedResponses((prevResponses) => prevResponses.filter((r) => r.id !== response.id));
toast.success("Submission deleted successfully."); toast.success("Submission deleted successfully.");
setDeleteDialogOpen(false); setDeleteDialogOpen(false);
} catch (error) { } catch (error) {