redirect to even types after deletion (#4707)

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
Carina Wollendorfer
2022-09-26 13:31:33 +01:00
committed by GitHub
co-authored by CarinaWolli Alex van Andel
parent 74f0d39997
commit 0695ce7edb
@@ -1,4 +1,5 @@
import { TFunction } from "next-i18next";
import { useRouter } from "next/router";
import { EventTypeSetupInfered, FormValues } from "pages/v2/event-types/[type]";
import { useMemo, useState } from "react";
import { Loader } from "react-feather";
@@ -110,6 +111,7 @@ function EventTypeSingleLayout({
}: Props) {
const utils = trpc.useContext();
const { t } = useLocale();
const router = useRouter();
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const hasPermsToDelete = currentUserMembership?.role !== "MEMBER" || !currentUserMembership;
@@ -118,6 +120,7 @@ function EventTypeSingleLayout({
onSuccess: async () => {
await utils.invalidateQueries(["viewer.eventTypes"]);
showToast(t("event_type_deleted_successfully"), "success");
await router.push("/event-types");
setDeleteDialogOpen(false);
},
onError: (err) => {