Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

567 B
Raw Blame
import { prismaEdge } from "@/lib/prisma/edge";
import { UserProps } from "@/lib/types";
import { NextRequest } from "next/server";

export async function hasPendingInvites({
  req,
  user,
}: {
  req: NextRequest;
  user: UserProps;
}) {
  if (
    req.nextUrl.searchParams.get("invite") ||
    req.nextUrl.pathname.startsWith("/invites/")
  ) {
    return true;
  }

  const pendingInvites = await prismaEdge.projectInvite.count({
    where: {
      email: user.email,
      expires: {
        gte: new Date(),
      },
    },
  });

  return pendingInvites > 0;
}