mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 00:55:37 +01:00
Added teams pages. Refactored hooks.
This commit is contained in:
parent
a2c202fa36
commit
9448aa3ab5
136 changed files with 387 additions and 287 deletions
5
src/app/(main)/teams/TeamsContext.tsx
Normal file
5
src/app/(main)/teams/TeamsContext.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { createContext } from 'react';
|
||||
|
||||
export const TeamsContext = createContext(null);
|
||||
|
||||
export default TeamsContext;
|
||||
20
src/app/(main)/teams/[id]/Team.tsx
Normal file
20
src/app/(main)/teams/[id]/Team.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
'use client';
|
||||
import TeamsContext from '../TeamsContext';
|
||||
import { Loading } from 'react-basics';
|
||||
import { useTeam } from 'components/hooks';
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
export default function Team({ children }) {
|
||||
const { id: teamId } = useParams();
|
||||
const { data: team, isLoading, error } = useTeam(teamId as string);
|
||||
|
||||
if (error) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return <Loading position="page" />;
|
||||
}
|
||||
|
||||
return <TeamsContext.Provider value={team}>{children}</TeamsContext.Provider>;
|
||||
}
|
||||
5
src/app/(main)/teams/[id]/layout.tsx
Normal file
5
src/app/(main)/teams/[id]/layout.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import Team from './Team';
|
||||
|
||||
export default function ({ children }) {
|
||||
return <Team>{children}</Team>;
|
||||
}
|
||||
14
src/app/(main)/teams/[id]/websites/TeamWebsites.tsx
Normal file
14
src/app/(main)/teams/[id]/websites/TeamWebsites.tsx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
'use client';
|
||||
import { useContext } from 'react';
|
||||
import TeamsContext from 'app/(main)/teams/TeamsContext';
|
||||
import WebsitesDataTable from 'app/(main)/settings/websites/WebsitesDataTable';
|
||||
|
||||
export default function TeamWebsites() {
|
||||
const team = useContext(TeamsContext);
|
||||
|
||||
if (!team) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <WebsitesDataTable teamId={team.id} />;
|
||||
}
|
||||
11
src/app/(main)/teams/[id]/websites/page.tsx
Normal file
11
src/app/(main)/teams/[id]/websites/page.tsx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import TeamWebsites from './TeamWebsites';
|
||||
import WebsitesHeader from 'app/(main)/settings/websites/WebsitesHeader';
|
||||
|
||||
export default function TeamWebsitesPage({ params: { id } }: { params: { id: string } }) {
|
||||
return (
|
||||
<>
|
||||
<WebsitesHeader teamId={id} />
|
||||
<TeamWebsites />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue