import { MembersList } from "./components/membersList"; import { getOrgMembers } from "@/actions"; import { isServiceError } from "@/lib/utils"; import { getOrgFromDomain } from "@/data/org"; import { InviteMemberCard } from "./components/inviteMemberCard"; import { Tabs, TabsContent } from "@/components/ui/tabs"; import { TabSwitcher } from "@/components/ui/tab-switcher"; import { InvitesList } from "./components/invitesList"; import { getOrgInvites, getMe, getOrgAccountRequests } from "@/actions"; import { IS_BILLING_ENABLED } from "@/ee/features/billing/stripe"; import { ServiceErrorException } from "@/lib/serviceError"; import { getSeats, SOURCEBOT_UNLIMITED_SEATS } from "@sourcebot/shared"; import { RequestsList } from "./components/requestsList"; import { OrgRole } from "@prisma/client"; interface MembersSettingsPageProps { params: { domain: string }, searchParams: { tab?: string } } export default async function MembersSettingsPage({ params: { domain }, searchParams: { tab } }: MembersSettingsPageProps) { const org = await getOrgFromDomain(domain); if (!org) { throw new Error("Organization not found"); } const me = await getMe(); if (isServiceError(me)) { throw new ServiceErrorException(me); } const userRoleInOrg = me.memberships.find((membership) => membership.id === org.id)?.role; if (!userRoleInOrg) { throw new Error("User role not found"); } const members = await getOrgMembers(domain); if (isServiceError(members)) { throw new ServiceErrorException(members); } const invites = await getOrgInvites(domain); if (isServiceError(invites)) { throw new ServiceErrorException(invites); } const requests = await getOrgAccountRequests(domain); if (isServiceError(requests)) { throw new ServiceErrorException(requests); } const currentTab = tab || "members"; const seats = getSeats(); const usedSeats = members.length const seatsAvailable = seats === SOURCEBOT_UNLIMITED_SEATS || usedSeats < seats; return (

Members

Invite and manage members of your organization.

{seats && seats !== SOURCEBOT_UNLIMITED_SEATS && (
{usedSeats} of {seats} seats used
)}
Pending Requests {requests.length > 0 && ( {requests.length} )}
), value: "requests" }, { label: (
Pending Invites {invites.length > 0 && ( {invites.length} )}
), value: "invites" }, ] : []), ]} currentTab={currentTab} />
{userRoleInOrg === OrgRole.OWNER && ( <> )} ) }