The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fix accept invite issues
Steven Tey3cbd4768f7c4
diff --git a/components/app/modals/accept-invite-modal.tsx b/components/app/modals/accept-invite-modal.tsxindex 767518ce6b..02c45a9834 100644--- a/components/app/modals/accept-invite-modal.tsx+++ b/components/app/modals/accept-invite-modal.tsx@@ -59,9 +59,13 @@ function AcceptInviteModal({headers: { "Content-Type": "application/json" },}).then(() => {toast.success("You now are a part of this project!");- mutate("/api/projects");- mutate(`/api/projects/${slug}`);- mutate(`/api/projects/${slug}/users`);+ mutate(+ (key) =>+ typeof key === "string" &&+ key.startsWith(`/api/projects`),+ undefined,+ { revalidate: true },+ );});}}disabled={accepting}diff --git a/lib/utils.ts b/lib/utils.tsindex 41a55973c8..8ab492a1f0 100644--- a/lib/utils.ts+++ b/lib/utils.ts@@ -25,14 +25,10 @@ export async function fetcher<JSON = any>(const res = await fetch(input, init);if (!res.ok) {- const json = await res.json();- if (json.error) {- const error = new Error(json.error) as SWRError;- error.status = res.status;- throw error;- } else {- throw new Error("An unexpected error occurred");- }+ const error = await res.text();+ const err = new Error(error) as SWRError;+ err.status = res.status;+ throw err;}return res.json();diff --git a/pages/app/[slug]/index.tsx b/pages/app/[slug]/index.tsxindex 7557173211..2a20eb9d08 100644--- a/pages/app/[slug]/index.tsx+++ b/pages/app/[slug]/index.tsx@@ -13,6 +13,7 @@ export default function ProjectLinks() {const { slug, error } = useProject();const { AddEditLinkModal, AddEditLinkButton } = useAddEditLinkModal();+const { AcceptInviteModal, setShowAcceptInviteModal } =useAcceptInviteModal();const { CompleteSetupModal, setShowCompleteSetupModal } =@@ -24,11 +25,17 @@ export default function ProjectLinks() {useEffect(() => {if (error && (error.status === 409 || error.status === 410)) {setShowAcceptInviteModal(true);- } else if (!verified && !loading) {- setShowCompleteSetupModal(true);}}, [error, verified, loading]);+ useEffect(() => {+ if (!verified && !loading && !error) {+ setShowCompleteSetupModal(true);+ } else {+ setShowCompleteSetupModal(false);+ }+ }, [verified, loading, error]);+if (error && error.status === 404) {return <ErrorPage statusCode={404} />;}