From c61b68274ccaababf384a1c128ce5b22166bcd5e Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Mon, 14 Oct 2024 09:50:50 -0700 Subject: [PATCH] fix #1448 --- apps/web/ui/modals/delete-workspace-modal.tsx | 4 +++- apps/web/ui/workspaces/create-workspace-form.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/web/ui/modals/delete-workspace-modal.tsx b/apps/web/ui/modals/delete-workspace-modal.tsx index d575d5403f..fbee8ae389 100644 --- a/apps/web/ui/modals/delete-workspace-modal.tsx +++ b/apps/web/ui/modals/delete-workspace-modal.tsx @@ -1,6 +1,7 @@ import useWorkspace from "@/lib/swr/use-workspace"; import { Button, Logo, Modal, useMediaQuery } from "@dub/ui"; import { cn } from "@dub/utils"; +import { useSession } from "next-auth/react"; import { useParams, useRouter } from "next/navigation"; import { Dispatch, @@ -19,6 +20,7 @@ function DeleteWorkspaceModal({ showDeleteWorkspaceModal: boolean; setShowDeleteWorkspaceModal: Dispatch>; }) { + const { update } = useSession(); const router = useRouter(); const { slug } = useParams() as { slug: string }; const { id, isOwner } = useWorkspace(); @@ -35,7 +37,7 @@ function DeleteWorkspaceModal({ }, }).then(async (res) => { if (res.ok) { - await mutate("/api/workspaces"); + await Promise.all([mutate("/api/workspaces"), update()]); router.push("/"); resolve(null); } else { diff --git a/apps/web/ui/workspaces/create-workspace-form.tsx b/apps/web/ui/workspaces/create-workspace-form.tsx index 3152e3a11d..b2ece3ac95 100644 --- a/apps/web/ui/workspaces/create-workspace-form.tsx +++ b/apps/web/ui/workspaces/create-workspace-form.tsx @@ -4,6 +4,7 @@ import { AlertCircleFill } from "@/ui/shared/icons"; import { Button, InfoTooltip, useMediaQuery } from "@dub/ui"; import { cn } from "@dub/utils"; import slugify from "@sindresorhus/slugify"; +import { useSession } from "next-auth/react"; import { usePlausible } from "next-plausible"; import posthog from "posthog-js"; import { useForm } from "react-hook-form"; @@ -22,6 +23,7 @@ export function CreateWorkspaceForm({ onSuccess?: (data: FormData) => void; className?: string; }) { + const { update } = useSession(); const plausible = usePlausible(); const { @@ -59,7 +61,7 @@ export function CreateWorkspaceForm({ workspace_name: data.name, workspace_slug: data.slug, }); - await mutate("/api/workspaces"); + await Promise.all([mutate("/api/workspaces"), update()]); onSuccess?.(data); } else { const { error } = await res.json();