| 1 | import type { Metadata } from 'next' |
| 2 | import { headers } |
| 3 | import { redirect } |
| 4 | import { projectsService } |
| 5 | import { teamService } |
| 6 | import { createMetadata } |
| 7 | import { auth } |
| 8 | import { resolveOrgContext } |
| 9 | import { TeamsPageClient } |
| 10 | import type { PendingInvitation |
| 11 | |
| 12 | export const metadata: |
| 13 | title: 'Teams', |
| 14 | description: 'Manage workspace members, roles, and team groups.', |
| 15 | openGraph: { |
| 16 | images: ['/api/og?page=Team'], |
| 17 | }, |
| 18 | twitter: { |
| 19 | images: ['/api/og?page=Team'], |
| 20 | }, |
| 21 | }) |
| 22 | |
| 23 | export default async function |
| 24 | const { org |
| 25 | const { organization, |
| 26 | |
| 27 | if ( |
| 28 | !( |
| 29 | role.authorize({ |
| 30 | role.authorize({ |
| 31 | ) |
| 32 | ) { |
| 33 | redirect( |
| 34 | `/error/403?message=${encodeURIComponent('You do not have permission to view teams |
| 35 | ) |
| 36 | } |
| 37 | |
| 38 | const canManage = |
| 39 | |
| 40 | const [orgMembers, |
| 41 | await Promise.all |
| 42 | teamService.getOrgMembers(organization |
| 43 | teamService.getOrgTeamsWithMembers(organization |
| 44 | canManage |
| 45 | ? auth.api. |
| 46 | headers: await headers |
| 47 | query: { organizationId: organization |
| 48 | }) |
| 49 | : Promise.resolve([]) |
| 50 | projectsService.getSettings(organization |
| 51 | ]) |
| 52 | |
| 53 | const pendingInvitations: |
| 54 | .filter((i) |
| 55 | .map((i) |
| 56 | id: i.id |
| 57 | email: i.email |
| 58 | role: i.role |
| 59 | status: i.status |
| 60 | expiresAt: i.expiresAt |
| 61 | })) |
| 62 | |
| 63 | return ( |
| 64 | <TeamsPageClient |
| 65 | canManage={canManage} |
| 66 | currentMemberId={orgMember.id |
| 67 | defaultCurrency={orgSettings.currency |
| 68 | defaultMemberRate={orgSettings.memberRate |
| 69 | invitations={pendingInvitations} |
| 70 | members={orgMembers} |
| 71 | organizationId={organization.id |
| 72 | orgSlug={org} |
| 73 | teams={orgTeams} |
| 74 | /> |
| 75 | ) |
| 76 | } |