The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
final touches
Steven Teyc207fbb55452
diff --git a/app/ui/modal-provider.tsx b/app/ui/modal-provider.tsxindex 6aae881076..0b9a9a3003 100644--- a/app/ui/modal-provider.tsx+++ b/app/ui/modal-provider.tsx@@ -36,25 +36,22 @@ export default function ModalProvider({ children }: { children: ReactNode }) {useAddEditDomainModal({});const { setShowTagLinkModal, TagLinkModal } = useTagLinkModal({});+ const { error, loading } = useProject();const { data: session } = useSession();++ // handle invite and oauth modalsuseEffect(() => {- if (+ if (error && (error.status === 409 || error.status === 410)) {+ setShowAcceptInviteModal(true);+ } else if (+ !loading &&session?.user?.email &&!session.user?.name &&!Cookies.get("hideGoogleOauthModal")) {- console.log(session);setShowGoogleOauthModal(true);}- }, [session]);-- const { error } = useProject();- // handle errors- useEffect(() => {- if (error && (error.status === 409 || error.status === 410)) {- setShowAcceptInviteModal(true);- }- }, [error]);+ }, [error, session]);if (error && error.status === 404) {return <ErrorPage statusCode={404} />;diff --git a/components/layout/app/index.tsx b/components/layout/app/index.tsxindex 34ca0576d0..327a52e31b 100644--- a/components/layout/app/index.tsx+++ b/components/layout/app/index.tsx@@ -57,11 +57,21 @@ export default function AppLayout({plan,...(stripeId && { stripeId }),});- if (plan === "free" && Cookies.get("hideProBanner") !== slug) {+ /* show pro banner if:+ - free plan+ - not hidden by user for this project+ - project is created more than 24 hours ago+ */+ if (+ plan === "free" &&+ Cookies.get("hideProBanner") !== slug &&+ createdAt &&+ Date.now() - new Date(createdAt).getTime() > 24 * 60 * 60 * 1000+ ) {setShowProBanner(true);}}- }, [plan, id, name, slug, stripeId]);+ }, [plan, id, name, slug, stripeId, createdAt]);return (<div>diff --git a/lib/auth.ts b/lib/auth.tsindex 85c01001ce..f2d7b882ee 100644--- a/lib/auth.ts+++ b/lib/auth.ts@@ -63,6 +63,7 @@ const withProjectAuth =plan: true,stripeId: true,billingCycleStart: true,+ createdAt: true,users: {where: {userId: session.user.id,diff --git a/lib/swr/use-project.ts b/lib/swr/use-project.tsindex 69bba60aab..1ae388b560 100644--- a/lib/swr/use-project.ts+++ b/lib/swr/use-project.ts@@ -29,5 +29,6 @@ export default function useProject() {...project,exceededUsage,error,+ loading: !router.isReady || (slug && !project && !error),};}diff --git a/pages/api/stripe/webhook.ts b/pages/api/stripe/webhook.tsindex 38c9530021..e2e78e1681 100644--- a/pages/api/stripe/webhook.ts+++ b/pages/api/stripe/webhook.ts@@ -50,21 +50,11 @@ export default async function webhookHandler(if (event.type === "checkout.session.completed") {const checkoutSession = event.data.object as Stripe.Checkout.Session;- if (checkoutSession.client_reference_id === null) {- await log(- "Missing client reference ID in Stripe webhook callback",- "cron",- true,- );- return;- }-- if (checkoutSession.customer === null) {- await log(- "Missing customer ID in Stripe webhook callback",- "cron",- true,- );+ if (+ checkoutSession.client_reference_id === null ||+ checkoutSession.customer === null+ ) {+ await log("Missing items in Stripe webhook callback", "cron", true);return;}@@ -81,6 +71,9 @@ export default async function webhookHandler(billingCycleStart: new Date().getDate(),},});++ // TODO - send thank you email to project owner+ //} else if (event.type === "customer.subscription.updated") {const subscriptionUpdated = event.data.object as Stripe.Subscription;const newPriceId = subscriptionUpdated.items.data[0].price.id;@@ -176,7 +169,7 @@ export default async function webhookHandler(return res.status(400).send(`🤷♀️ Unhandled event type: ${event.type}`);}- res.json({ received: true });+ res.status(200).json({ received: true });} else {res.setHeader("Allow", ["POST"]);return res.status(405).json({ error: `Method ${req.method} Not Allowed` });diff --git a/pages/app/[slug]/index.tsx b/pages/app/[slug]/index.tsxindex 57bb3af2e9..d016b69401 100644--- a/pages/app/[slug]/index.tsx+++ b/pages/app/[slug]/index.tsx@@ -8,22 +8,20 @@ import { useCompleteSetupModal } from "@/components/app/modals/complete-setup-moimport useDomains from "@/lib/swr/use-domains";export default function ProjectLinks() {- const { slug, error } = useProject();+ const { slug, error, loading: loadingProject } = useProject();const { AddEditLinkModal, AddEditLinkButton } = useAddEditLinkModal();const { CompleteSetupModal, setShowCompleteSetupModal } =useCompleteSetupModal();- const { verified, loading } = useDomains();+ const { verified, loading: loadingDomains } = useDomains();useEffect(() => {- if (!verified && !loading && !error) {+ if (!verified && !loadingProject && !loadingDomains && !error) {setShowCompleteSetupModal(true);- } else {- setShowCompleteSetupModal(false);}- }, [verified, loading, error]);+ }, [verified, loadingProject, loadingDomains, error]);return (<AppLayout>