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