Skip to content

Commit

Permalink
fix deleted responses still shown in frontend (formbricks#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattinannt committed Jun 26, 2023
1 parent b02f202 commit a6ab9c7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import DeleteDialog from "@/components/shared/DeleteDialog";
import { deleteSubmission, useResponses } from "@/lib/responses/responses";
import { deleteSubmission } from "@/lib/responses/responses";
import { truncate } from "@/lib/utils";
import { timeSince } from "@formbricks/lib/time";
import { QuestionType } from "@formbricks/types/questions";
Expand All @@ -11,6 +11,7 @@ import { TrashIcon } from "@heroicons/react/24/outline";
import { CheckCircleIcon } from "@heroicons/react/24/solid";
import clsx from "clsx";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast";
import { RatingResponse } from "../RatingResponse";
Expand Down Expand Up @@ -38,17 +39,17 @@ function findEmail(person) {
}

export default function SingleResponse({ data, environmentId, surveyId }: OpenTextSummaryProps) {
const router = useRouter();
const email = data.person && findEmail(data.person);
const displayIdentifier = email || (data.person && truncate(data.person.id, 16)) || null;
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const { mutateResponses } = useResponses(environmentId, surveyId);
const [isDeleting, setIsDeleting] = useState(false);
const [isOpen, setIsOpen] = useState(false);

const handleDeleteSubmission = async () => {
setIsDeleting(true);
const deleteResponse = await deleteSubmission(environmentId, data?.surveyId, data?.id);
mutateResponses();
router.refresh();
if (deleteResponse?.id?.length > 0) toast.success("Submission deleted successfully.");
setDeleteDialogOpen(false);
setIsDeleting(false);
Expand Down

0 comments on commit a6ab9c7

Please sign in to comment.