feat: migrate nextjs to rr7

This commit is contained in:
David Nguyen
2025-01-02 15:33:37 +11:00
parent 9183f668d3
commit 383b5f78f0
898 changed files with 31175 additions and 24615 deletions

View File

@ -0,0 +1,29 @@
import { createContext, useContext } from 'react';
import React from 'react';
import type { TGetTeamByUrlResponse } from '@documenso/lib/server-only/team/get-team';
interface TeamProviderProps {
children: React.ReactNode;
team: TGetTeamByUrlResponse;
}
const TeamContext = createContext<TGetTeamByUrlResponse | null>(null);
export const useCurrentTeam = () => {
const context = useContext(TeamContext);
if (!context) {
throw new Error('useCurrentTeam must be used within a TeamProvider');
}
return context;
};
export const useOptionalCurrentTeam = () => {
return useContext(TeamContext);
};
export const TeamProvider = ({ children, team }: TeamProviderProps) => {
return <TeamContext.Provider value={team}>{children}</TeamContext.Provider>;
};