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.

Improved team invite flow

Steven Tey260fa5698dc5
diff --git a/components/app/modals/accept-invite-modal.tsx b/components/app/modals/accept-invite-modal.tsx
index 180b0da498..3571e64e99 100644
--- a/components/app/modals/accept-invite-modal.tsx
+++ b/components/app/modals/accept-invite-modal.tsx
@@ -55,7 +55,7 @@ function AcceptInviteModal({
<button
onClick={() => {
setAccepting(true);
- fetch(`/api/projects/${slug}/invite/accept`, {
+ fetch(`/api/projects/${slug}/invites/accept`, {
method: "POST",
headers: { "Content-Type": "application/json" },
}).then(() => {
diff --git a/components/app/modals/delete-link-modal.tsx b/components/app/modals/delete-link-modal.tsx
index 4994ed3882..db5afdfc31 100644
--- a/components/app/modals/delete-link-modal.tsx
+++ b/components/app/modals/delete-link-modal.tsx
@@ -8,7 +8,6 @@ import {
} from "react";
import { mutate } from "swr";
import BlurImage from "#/ui/blur-image";
-import { LoadingDots } from "#/ui/icons";
import Modal from "@/components/shared/modal";
import { LinkProps } from "@/lib/types";
import { getApexDomain, getQueryString, linkConstructor } from "@/lib/utils";
diff --git a/components/app/modals/invite-teammate-modal.tsx b/components/app/modals/invite-teammate-modal.tsx
index 5c37fb70a1..71d250f485 100644
--- a/components/app/modals/invite-teammate-modal.tsx
+++ b/components/app/modals/invite-teammate-modal.tsx
@@ -52,7 +52,7 @@ function InviteTeammateModal({
onSubmit={async (e) => {
e.preventDefault();
setInviting(true);
- fetch(`/api/projects/${slug}/invite`, {
+ fetch(`/api/projects/${slug}/invites`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email }),
@@ -63,7 +63,7 @@ function InviteTeammateModal({
va.track("User invited teammate", {
project: slug,
});
- mutate(`/api/projects/${slug}/invite`);
+ mutate(`/api/projects/${slug}/invites`);
setShowInviteTeammateModal(false);
} else {
const error = await res.text();
diff --git a/components/app/modals/remove-teammate-modal.tsx b/components/app/modals/remove-teammate-modal.tsx
new file mode 100644
index 0000000000..ffb2ca1ae0
--- /dev/null
+++ b/components/app/modals/remove-teammate-modal.tsx
@@ -0,0 +1,138 @@
+import { useRouter } from "next/router";
+import {
+ Dispatch,
+ SetStateAction,
+ useCallback,
+ useMemo,
+ useState,
+} from "react";
+import { mutate } from "swr";
+import BlurImage from "#/ui/blur-image";
+import Modal from "@/components/shared/modal";
+import useProject from "@/lib/swr/use-project";
+import { toast } from "sonner";
+import Button from "#/ui/button";
+import { UserProps } from "@/lib/types";
+
+function RemoveTeammateModal({
+ showRemoveTeammateModal,
+ setShowRemoveTeammateModal,
+ user,
+ invite,
+}: {
+ showRemoveTeammateModal: boolean;
+ setShowRemoveTeammateModal: Dispatch<SetStateAction<boolean>>;
+ user: UserProps;
+ invite?: boolean;
+}) {
+ const router = useRouter();
+ const { slug } = router.query as { slug: string };
+ const [removing, setRemoving] = useState(false);
+ const { logo } = useProject();
+ const { id, name, email, image } = user;
+
+ return (
+ <Modal
+ showModal={showRemoveTeammateModal}
+ setShowModal={setShowRemoveTeammateModal}
+ >
+ <div className="inline-block w-full transform overflow-hidden bg-white align-middle shadow-xl transition-all sm:max-w-md sm:rounded-2xl sm:border sm:border-gray-200">
+ <div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
+ <BlurImage
+ src={logo || `/_static/logo.png`}
+ alt="Remove Teammate"
+ className="h-10 w-10 rounded-full"
+ width={20}
+ height={20}
+ />
+ <h3 className="text-lg font-medium">Remove Teammate</h3>
+ <p className="text-center text-sm text-gray-500">
+ This will remove{" "}
+ <span className="font-semibold text-black">{name || email}</span>
+ {invite
+ ? "'s invitation to join your project."
+ : " from your project. Are you sure you want to continue?"}
+ </p>
+ </div>
+
+ <div className="flex flex-col space-y-4 bg-gray-50 px-4 py-8 text-left sm:px-16">
+ <div className="flex items-center space-x-3 rounded-md border border-gray-300 bg-white p-3">
+ <BlurImage
+ src={
+ image || `https://avatars.dicebear.com/api/micah/${email}.svg`
+ }
+ alt={email}
+ width={40}
+ height={40}
+ className="overflow-hidden rounded-full border border-gray-200"
+ />
+ <div className="flex flex-col">
+ <h3 className="text-sm font-medium">{name || email}</h3>
+ <p className="text-xs text-gray-500">{email}</p>
+ </div>
+ </div>
+ <Button
+ text="Confirm remove"
+ variant="danger"
+ loading={removing}
+ onClick={() => {
+ setRemoving(true);
+ fetch(
+ `/api/projects/${slug}/${
+ invite ? `invites?email=${email}` : `users?userId=${id}`
+ }`,
+ {
+ method: "DELETE",
+ headers: { "Content-Type": "application/json" },
+ },
+ ).then(async (res) => {
+ setRemoving(false);
+ if (res.status === 200) {
+ toast.success(
+ `${invite ? "Invite" : "User"} removed from project!`,
+ );
+ mutate(
+ `/api/projects/${slug}/${invite ? "invites" : "users"}`,
+ );
+ setShowRemoveTeammateModal(false);
+ } else {
+ const error = await res.text();
+ toast.error(error);
+ }
+ });
+ }}
+ />
+ </div>
+ </div>
+ </Modal>
+ );
+}
+
+export function useRemoveTeammateModal({
+ user,
+ invite,
+}: {
+ user: UserProps;
+ invite?: boolean;
+}) {
+ const [showRemoveTeammateModal, setShowRemoveTeammateModal] = useState(false);
+
+ const RemoveTeammateModalCallback = useCallback(() => {
+ return (
+ <RemoveTeammateModal
+ showRemoveTeammateModal={showRemoveTeammateModal}
+ setShowRemoveTeammateModal={setShowRemoveTeammateModal}
+ user={user}
+ invite={invite}
+ />
+ );
+ }, [showRemoveTeammateModal, setShowRemoveTeammateModal]);
+
+ return useMemo(
+ () => ({
+ setShowRemoveTeammateModal,
+ RemoveTeammateModal: RemoveTeammateModalCallback,
+ }),
+ [setShowRemoveTeammateModal, RemoveTeammateModalCallback],
+ );
+}
diff --git a/pages/api/auth/decrypt-password.ts b/pages/api/auth/decrypt-password.ts
index 7758b21a2f..629a6fb84f 100644
--- a/pages/api/auth/decrypt-password.ts
+++ b/pages/api/auth/decrypt-password.ts
@@ -23,6 +23,6 @@ export default async function handler(
}
} else {
res.setHeader("Allow", ["POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
}
diff --git a/pages/api/domains/[domain]/exists.ts b/pages/api/domains/[domain]/exists.ts
index 03cf694b2f..5200171281 100644
--- a/pages/api/domains/[domain]/exists.ts
+++ b/pages/api/domains/[domain]/exists.ts
@@ -16,6 +16,6 @@ export default withUserAuth(async (req, res) => {
}
} else {
res.setHeader("Allow", ["GET"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/billing/manage.ts b/pages/api/projects/[slug]/billing/manage.ts
index 665ca4c0ad..aa93431f1b 100644
--- a/pages/api/projects/[slug]/billing/manage.ts
+++ b/pages/api/projects/[slug]/billing/manage.ts
@@ -19,6 +19,6 @@ export default withProjectAuth(async (req, res, project) => {
return res.status(200).json(url);
} else {
res.setHeader("Allow", ["POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/billing/upgrade.ts b/pages/api/projects/[slug]/billing/upgrade.ts
index 71878eed6f..3c7e4726fb 100644
--- a/pages/api/projects/[slug]/billing/upgrade.ts
+++ b/pages/api/projects/[slug]/billing/upgrade.ts
@@ -32,6 +32,6 @@ export default withProjectAuth(async (req, res, project, session) => {
return res.status(200).json(stripeSession);
} else {
res.setHeader("Allow", ["POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/domains/[domain]/clicks.ts b/pages/api/projects/[slug]/domains/[domain]/clicks.ts
index eae1e64677..809d14456b 100644
--- a/pages/api/projects/[slug]/domains/[domain]/clicks.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/clicks.ts
@@ -16,6 +16,6 @@ export default withProjectAuth(async (req, res) => {
return res.status(200).json(response);
} else {
res.setHeader("Allow", ["GET"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/domains/[domain]/exists.ts b/pages/api/projects/[slug]/domains/[domain]/exists.ts
index a3061997aa..a4ab27efe0 100644
--- a/pages/api/projects/[slug]/domains/[domain]/exists.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/exists.ts
@@ -14,6 +14,6 @@ export default withProjectAuth(async (req, res, project) => {
}
} else {
res.setHeader("Allow", ["GET"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/domains/[domain]/index.ts b/pages/api/projects/[slug]/domains/[domain]/index.ts
index a7eb15aaec..081f3d81ca 100644
--- a/pages/api/projects/[slug]/domains/[domain]/index.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/index.ts
@@ -112,6 +112,6 @@ export default withProjectAuth(async (req, res, project) => {
return res.status(200).json(response);
} else {
res.setHeader("Allow", ["PUT", "DELETE"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/domains/[domain]/verify.ts b/pages/api/projects/[slug]/domains/[domain]/verify.ts
index 85600e43b3..3a6a3b03bb 100644
--- a/pages/api/projects/[slug]/domains/[domain]/verify.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/verify.ts
@@ -85,6 +85,6 @@ export default withProjectAuth(async (req, res) => {
});
} else {
res.setHeader("Allow", ["GET"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/domains/index.ts b/pages/api/projects/[slug]/domains/index.ts
index 22f2a31988..063f31ae4c 100644
--- a/pages/api/projects/[slug]/domains/index.ts
+++ b/pages/api/projects/[slug]/domains/index.ts
@@ -67,6 +67,6 @@ export default withProjectAuth(async (req, res, project) => {
return res.status(200).json(response);
} else {
res.setHeader("Allow", ["GET", "POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/exists.ts b/pages/api/projects/[slug]/exists.ts
index 15ced0a7fc..fa5401cc1b 100644
--- a/pages/api/projects/[slug]/exists.ts
+++ b/pages/api/projects/[slug]/exists.ts
@@ -28,9 +28,7 @@ export default withUserAuth(
}
} else {
res.setHeader("Allow", ["GET"]);
- return res
- .status(405)
- .json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
},
);
diff --git a/pages/api/projects/[slug]/index.ts b/pages/api/projects/[slug]/index.ts
index 8d9dd13f75..e276de348b 100644
--- a/pages/api/projects/[slug]/index.ts
+++ b/pages/api/projects/[slug]/index.ts
@@ -55,6 +55,6 @@ export default withProjectAuth(async (req, res, project) => {
});
} else {
res.setHeader("Allow", ["GET", "PUT", "DELETE"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/invite/accept.ts b/pages/api/projects/[slug]/invites/accept.ts
similarity index 100%
rename from pages/api/projects/[slug]/invite/accept.ts
rename to pages/api/projects/[slug]/invites/accept.ts
diff --git a/pages/api/projects/[slug]/invite/index.tsx b/pages/api/projects/[slug]/invites/index.tsx
similarity index 77%
rename from pages/api/projects/[slug]/invite/index.tsx
rename to pages/api/projects/[slug]/invites/index.tsx
index a6517c2e21..f0f01a1510 100644
--- a/pages/api/projects/[slug]/invite/index.tsx
+++ b/pages/api/projects/[slug]/invites/index.tsx
@@ -11,7 +11,7 @@ const hashToken = (token: string) => {
};
export default withProjectAuth(async (req, res, project) => {
- // GET /api/projects/[slug]/invite - Get all pending invites for a project
+ // GET /api/projects/[slug]/invites - Get all pending invites for a project
if (req.method === "GET") {
const invites = await prisma.projectInvite.findMany({
where: {
@@ -29,7 +29,7 @@ export default withProjectAuth(async (req, res, project) => {
})),
);
- // POST /api/projects/[slug]/invite – invite a teammate
+ // POST /api/projects/[slug]/invites – invite a teammate
} else if (req.method === "POST") {
const { email } = req.body;
@@ -88,8 +88,24 @@ export default withProjectAuth(async (req, res, project) => {
} catch (error) {
return res.status(400).end("User already invited.");
}
+
+ // DELETE /api/projects/[slug]/invites – delete a pending invite
+ } else if (req.method === "DELETE") {
+ const { email } = req.query as { email?: string };
+ if (!email) {
+ return res.status(400).end("Missing email");
+ }
+ const response = await prisma.projectInvite.delete({
+ where: {
+ email_projectId: {
+ email,
+ projectId: project.id,
+ },
+ },
+ });
+ return res.status(200).json(response);
} else {
- res.setHeader("Allow", ["GET", "POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ res.setHeader("Allow", ["GET", "POST", "DELETE"]);
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/tags/[id].ts b/pages/api/projects/[slug]/tags/[id].ts
index da793e992c..cccbc51e09 100644
--- a/pages/api/projects/[slug]/tags/[id].ts
+++ b/pages/api/projects/[slug]/tags/[id].ts
@@ -27,6 +27,6 @@ export default withProjectAuth(async (req, res) => {
return res.status(200).json(response);
} else {
res.setHeader("Allow", ["PUT", "DELETE"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/tags/index.ts b/pages/api/projects/[slug]/tags/index.ts
index 0c132e2fd3..95610bd079 100644
--- a/pages/api/projects/[slug]/tags/index.ts
+++ b/pages/api/projects/[slug]/tags/index.ts
@@ -43,6 +43,6 @@ export default withProjectAuth(async (req, res, project) => {
return res.status(200).json(response);
} else {
res.setHeader("Allow", ["GET", "POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/[slug]/users.ts b/pages/api/projects/[slug]/users.ts
index 240976f0e1..1f34987cc0 100644
--- a/pages/api/projects/[slug]/users.ts
+++ b/pages/api/projects/[slug]/users.ts
@@ -4,10 +4,9 @@ import prisma from "@/lib/prisma";
export default withProjectAuth(async (req, res, project) => {
// GET /api/projects/[slug]/users – get users for a specific project
if (req.method === "GET") {
- const { id: projectId } = project;
const users = await prisma.projectUsers.findMany({
where: {
- projectId,
+ projectId: project.id,
},
select: {
user: {
@@ -27,8 +26,23 @@ export default withProjectAuth(async (req, res, project) => {
joinedAt: u.createdAt,
})),
);
+ } else if (req.method === "DELETE") {
+ // DELETE /api/projects/[slug]/users – remove a user from a project
+ const { userId } = req.query as { userId?: string };
+ if (!userId) {
+ return res.status(400).end("Missing userId");
+ }
+ const response = await prisma.projectUsers.delete({
+ where: {
+ userId_projectId: {
+ projectId: project.id,
+ userId,
+ },
+ },
+ });
+ return res.status(200).json(response);
} else {
- res.setHeader("Allow", ["GET"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ res.setHeader("Allow", ["GET", "DELETE"]);
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/api/projects/index.ts b/pages/api/projects/index.ts
index 73fe09900a..6d6b85f414 100644
--- a/pages/api/projects/index.ts
+++ b/pages/api/projects/index.ts
@@ -100,9 +100,7 @@ export default withUserAuth(
return res.status(200).json(response);
} else {
res.setHeader("Allow", ["GET", "POST"]);
- return res
- .status(405)
- .json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
},
);
diff --git a/pages/api/site/feedback.tsx b/pages/api/site/feedback.tsx
index 01bc98796a..eee64cc25a 100644
--- a/pages/api/site/feedback.tsx
+++ b/pages/api/site/feedback.tsx
@@ -31,6 +31,6 @@ export default async function handler(
res.status(200).json({ response });
} else {
res.setHeader("Allow", ["POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
}
diff --git a/pages/api/stripe/webhook.ts b/pages/api/stripe/webhook.ts
index e2e78e1681..6d9cc551d3 100644
--- a/pages/api/stripe/webhook.ts
+++ b/pages/api/stripe/webhook.ts
@@ -172,6 +172,6 @@ export default async function webhookHandler(
res.status(200).json({ received: true });
} else {
res.setHeader("Allow", ["POST"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
}
diff --git a/pages/api/user/index.ts b/pages/api/user/index.ts
index 10471708f1..8f143f3fc3 100644
--- a/pages/api/user/index.ts
+++ b/pages/api/user/index.ts
@@ -48,6 +48,6 @@ export default withUserAuth(async (req, res, session) => {
}
} else {
res.setHeader("Allow", ["PUT", "DELETE"]);
- return res.status(405).json({ error: `Method ${req.method} Not Allowed` });
+ return res.status(405).end(`Method ${req.method} Not Allowed`);
}
});
diff --git a/pages/app/[slug]/settings/people.tsx b/pages/app/[slug]/settings/people.tsx
index 102d1136c4..99976fd5ea 100644
--- a/pages/app/[slug]/settings/people.tsx
+++ b/pages/app/[slug]/settings/people.tsx
@@ -6,8 +6,14 @@ import useSWR from "swr";
import BlurImage from "#/ui/blur-image";
import { UserProps } from "@/lib/types";
import { fetcher, timeAgo } from "@/lib/utils";
+import Popover from "@/components/shared/popover";
+import IconMenu from "@/components/shared/icon-menu";
+import { UserMinus } from "lucide-react";
+import { ThreeDots } from "@/components/shared/icons";
+import { useRemoveTeammateModal } from "@/components/app/modals/remove-teammate-modal";
+import Badge from "#/ui/badge";
-const tabs = ["Members", "Invitations"];
+const tabs: Array<"Members" | "Invitations"> = ["Members", "Invitations"];
export default function ProjectSettingsPeople() {
const { setShowInviteTeammateModal, InviteTeammateModal } =
@@ -15,13 +21,15 @@ export default function ProjectSettingsPeople() {
const router = useRouter();
const { slug } = router.query as { slug?: string };
- const [currentTab, setCurrentTab] = useState("Members");
+ const [currentTab, setCurrentTab] = useState<"Members" | "Invitations">(
+ "Members",
+ );
const { data: users } = useSWR<UserProps[]>(
slug &&
(currentTab === "Members"
? `/api/projects/${slug}/users`
- : `/api/projects/${slug}/invite`),
+ : `/api/projects/${slug}/invites`),
fetcher,
);
@@ -63,32 +71,12 @@ export default function ProjectSettingsPeople() {
<div className="grid divide-y divide-gray-200">
{users ? (
users.length > 0 ? (
- users.map(({ name, email, image, joinedAt }) => (
- <div
- key={email}
- className="flex items-center justify-between space-x-3 px-4 py-3 sm:px-8"
- >
- <div className="flex items-center space-x-3">
- <BlurImage
- src={
- image ||
- `https://avatars.dicebear.com/api/micah/${email}.svg`
- }
- alt={email}
- width={40}
- height={40}
- className="overflow-hidden rounded-full border border-gray-200"
- />
- <div className="flex flex-col">
- <h3 className="text-sm font-medium">{name || email}</h3>
- <p className="text-xs text-gray-500">{email}</p>
- </div>
- </div>
- <p className="text-xs text-gray-500">
- {currentTab === "Members" ? "Joined " : "Invited "}
- {timeAgo(joinedAt)}
- </p>
- </div>
+ users.map((user) => (
+ <UserCard
+ key={user.email}
+ user={user}
+ currentTab={currentTab}
+ />
))
) : (
<div className="flex flex-col items-center justify-center py-10">
@@ -111,6 +99,96 @@ export default function ProjectSettingsPeople() {
);
}
+const UserCard = ({
+ user,
+ currentTab,
+}: {
+ user: UserProps;
+ currentTab: "Members" | "Invitations";
+}) => {
+ const [openPopover, setOpenPopover] = useState(false);
+ const { RemoveTeammateModal, setShowRemoveTeammateModal } =
+ useRemoveTeammateModal({ user, invite: currentTab === "Invitations" });
+
+ const { name, email, image, joinedAt } = user;
+
+ // invites expire after 14 days of being sent
+ const expiredInvite =
+ currentTab === "Invitations" &&
+ joinedAt &&
+ Date.now() - new Date(joinedAt).getTime() > 14 * 24 * 60 * 60 * 1000;
+
+ return (
+ <>
+ <RemoveTeammateModal />
+ <div
+ key={email}
+ className="flex items-center justify-between space-x-3 px-4 py-3 sm:pl-8"
+ >
+ <div className="flex items-start space-x-3">
+ <div className="flex items-center space-x-3">
+ <BlurImage
+ src={
+ image || `https://avatars.dicebear.com/api/micah/${email}.svg`
+ }
+ alt={email}
+ width={40}
+ height={40}
+ className="overflow-hidden rounded-full border border-gray-200"
+ />
+ <div className="flex flex-col">
+ <h3 className="text-sm font-medium">{name || email}</h3>
+ <p className="text-xs text-gray-500">{email}</p>
+ </div>
+ </div>
+
+ {expiredInvite && <Badge variant="gray" text="Expired" />}
+ </div>
+ <div className="flex items-center space-x-3">
+ <p className="text-xs text-gray-500">
+ {currentTab === "Members" ? "Joined " : "Invited "}
+ {timeAgo(joinedAt)}
+ </p>
+
+ <Popover
+ content={
+ <div className="grid w-full gap-1 p-2 sm:w-48">
+ <button
+ onClick={() => {
+ setOpenPopover(false);
+ setShowRemoveTeammateModal(true);
+ }}
+ className="rounded-md p-2 text-left text-sm font-medium text-red-600 transition-all duration-75 hover:bg-red-600 hover:text-white"
+ >
+ <IconMenu
+ text="Remove"
+ icon={<UserMinus className="h-4 w-4" />}
+ />
+ </button>
+ </div>
+ }
+ align="end"
+ openPopover={openPopover}
+ setOpenPopover={setOpenPopover}
+ >
+ <button
+ type="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ setOpenPopover(!openPopover);
+ }}
+ className="rounded-md px-1 py-2 transition-all duration-75 hover:bg-gray-100 active:bg-gray-200"
+ >
+ <span className="sr-only">Edit</span>
+ <ThreeDots className="h-5 w-5 text-gray-500" />
+ </button>
+ </Popover>
+ </div>
+ </div>
+ </>
+ );
+};
+
const UserPlaceholder = () => (
<div className="flex items-center justify-between space-x-3 px-4 py-3 sm:px-8">
<div className="flex items-center space-x-3">