mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 19:51:32 +10:00
## Description Add support for teams which will allow users to collaborate on documents. Teams features allows users to: - Create, manage and transfer teams - Manage team members - Manage team emails - Manage a shared team inbox and documents These changes do NOT include the following, which are planned for a future release: - Team templates - Team API - Search menu integration ## Testing Performed - Added E2E tests for general team management - Added E2E tests to validate document counts ## Checklist - [X] I have tested these changes locally and they work as expected. - [X] I have added/updated tests that prove the effectiveness of these changes. - [ ] I have updated the documentation to reflect these changes, if applicable. - [X] I have followed the project's coding style guidelines.
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
import React from 'react';
|
|
|
|
import { RedirectType, redirect } from 'next/navigation';
|
|
|
|
import { LimitsProvider } from '@documenso/ee/server-only/limits/provider/server';
|
|
import { getServerComponentSession } from '@documenso/lib/next-auth/get-server-component-session';
|
|
import { getTeamByUrl } from '@documenso/lib/server-only/team/get-team';
|
|
import { getTeams } from '@documenso/lib/server-only/team/get-teams';
|
|
import { SubscriptionStatus } from '@documenso/prisma/client';
|
|
|
|
import { Header } from '~/components/(dashboard)/layout/header';
|
|
import { RefreshOnFocus } from '~/components/(dashboard)/refresh-on-focus/refresh-on-focus';
|
|
import { NextAuthProvider } from '~/providers/next-auth';
|
|
|
|
import { LayoutBillingBanner } from './layout-billing-banner';
|
|
|
|
export type AuthenticatedTeamsLayoutProps = {
|
|
children: React.ReactNode;
|
|
params: {
|
|
teamUrl: string;
|
|
};
|
|
};
|
|
|
|
export default async function AuthenticatedTeamsLayout({
|
|
children,
|
|
params,
|
|
}: AuthenticatedTeamsLayoutProps) {
|
|
const { session, user } = await getServerComponentSession();
|
|
|
|
if (!session || !user) {
|
|
redirect('/signin');
|
|
}
|
|
|
|
const [getTeamsPromise, getTeamPromise] = await Promise.allSettled([
|
|
getTeams({ userId: user.id }),
|
|
getTeamByUrl({ userId: user.id, teamUrl: params.teamUrl }),
|
|
]);
|
|
|
|
if (getTeamPromise.status === 'rejected') {
|
|
redirect('/documents', RedirectType.replace);
|
|
}
|
|
|
|
const team = getTeamPromise.value;
|
|
const teams = getTeamsPromise.status === 'fulfilled' ? getTeamsPromise.value : [];
|
|
|
|
return (
|
|
<NextAuthProvider session={session}>
|
|
<LimitsProvider teamId={team.id}>
|
|
{team.subscription && team.subscription.status !== SubscriptionStatus.ACTIVE && (
|
|
<LayoutBillingBanner
|
|
subscription={team.subscription}
|
|
teamId={team.id}
|
|
userRole={team.currentTeamMember.role}
|
|
/>
|
|
)}
|
|
|
|
<Header user={user} teams={teams} />
|
|
|
|
<main className="mt-8 pb-8 md:mt-12 md:pb-12">{children}</main>
|
|
|
|
<RefreshOnFocus />
|
|
</LimitsProvider>
|
|
</NextAuthProvider>
|
|
);
|
|
}
|