Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleted responses are no longer shown in frontend #436

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading