diff --git a/app/invitations/page.tsx b/app/invitations/page.tsx new file mode 100644 index 0000000..7a60146 --- /dev/null +++ b/app/invitations/page.tsx @@ -0,0 +1,100 @@ +import { auth } from '@/auth' +import { redirect } from 'next/navigation' +import { getInvitations } from '@/lib/sharing-actions' +import InvitationCard from '@/components/InvitationCard' +import { Mail } from 'lucide-react' +import Link from 'next/link' + +type Invitation = { + id: string + email: string + permission: 'editor' | 'viewer' + status: string + createdAt: Date + expiresAt: Date + listId: string + inviterId: string + list: { + id: string + title: string + color: string + } + inviter: { + id: string + name: string | null + email: string + } +} + +export default async function InvitationsPage() { + const session = await auth() + + if (!session?.user) { + redirect('/auth/login') + } + + const invitations = await getInvitations() as Invitation[] + + return ( +
+ {invitations.length === 0 + ? 'No pending invitations' + : `${invitations.length} pending ${invitations.length === 1 ? 'invitation' : 'invitations'}`} +
++ When someone shares a list with you, you'll see the invitation here. +
+ + Go to My Lists + ++ {ownerName || ownerEmail} +
+ {ownerName && ( +{ownerEmail}
+ )} ++ No collaborators yet. Share this list to collaborate! +
+ ) : ( + collaborators.map((collaborator) => ( ++ {collaborator.user.name || collaborator.user.email} +
+ {collaborator.user.name && ( ++ {collaborator.user.email} +
+ )} ++ Invited by {invitation.inviter.name || invitation.inviter.email} +
+