| 1 | 'use client' |
| 2 | |
| 3 | import { useRouter } from '@bprogress/next/app' |
| 4 | import { Clock, Mail |
| 5 | import { toast } |
| 6 | import { Button } |
| 7 | import { authClient } |
| 8 | import type { PendingInvitation |
| 9 | |
| 10 | export default function PendingInvitationsBlock |
| 11 | invitations, |
| 12 | }: { |
| 13 | invitations: PendingInvitation |
| 14 | }) { |
| 15 | const router = |
| 16 | |
| 17 | if (invitations.length |
| 18 | return null |
| 19 | } |
| 20 | |
| 21 | const handleCancel = |
| 22 | const result = |
| 23 | invitationId, |
| 24 | }) |
| 25 | if (result.error |
| 26 | toast.error(result |
| 27 | } else { |
| 28 | toast.success('Invitation cancelled |
| 29 | router.refresh() |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return ( |
| 34 | <div className='mb-6 |
| 35 | <h3 className='mb-3 flex items-center gap-2 font-medium text-muted-foreground text-sm |
| 36 | <Clock className=' |
| 37 | Pending Invitations |
| 38 | </h3> |
| 39 | <div className='space-y-2 |
| 40 | {invitations.map(( |
| 41 | <div |
| 42 | className='flex items-center justify-between rounded-lg border border-dashed px-4 py-3' |
| 43 | key={inv.id |
| 44 | > |
| 45 | <div className='flex items-center gap-3 |
| 46 | <div className='flex size-8 items-center justify-center rounded-full bg-muted |
| 47 | <Mail className=' |
| 48 | </div> |
| 49 | <div> |
| 50 | <div className='font-medium text-sm |
| 51 | <div className='text-muted-foreground text-xs |
| 52 | Invited as <span className='capitalize |
| 53 | </div> |
| 54 | </div> |
| 55 | </div> |
| 56 | <Button onClick={ |
| 57 | <X className=' |
| 58 | </Button> |
| 59 | </div> |
| 60 | ))} |
| 61 | </div> |
| 62 | </div> |
| 63 | ) |
| 64 | } |