mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 01:55:36 +01:00
Added settings layout.
This commit is contained in:
parent
d818bf5aaf
commit
6802093d69
22 changed files with 102 additions and 76 deletions
28
src/app/(main)/teams/[teamId]/settings/TeamSettings.tsx
Normal file
28
src/app/(main)/teams/[teamId]/settings/TeamSettings.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'use client';
|
||||
import { ReactNode } from 'react';
|
||||
import SettingsLayout from 'components/layout/SettingsLayout';
|
||||
import { useMessages } from 'components/hooks';
|
||||
|
||||
export default function ({ children, teamId }: { children: ReactNode; teamId: string }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
|
||||
const items = [
|
||||
{
|
||||
key: 'team',
|
||||
label: formatMessage(labels.team),
|
||||
url: `/teams/${teamId}/settings/team`,
|
||||
},
|
||||
{
|
||||
key: 'members',
|
||||
label: formatMessage(labels.members),
|
||||
url: `/teams/${teamId}/settings/members`,
|
||||
},
|
||||
{
|
||||
key: 'websites',
|
||||
label: formatMessage(labels.websites),
|
||||
url: `/teams/${teamId}/settings/websites`,
|
||||
},
|
||||
].filter(n => n);
|
||||
|
||||
return <SettingsLayout items={items}>{children}</SettingsLayout>;
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import Layout from 'app/(main)/settings/layout';
|
||||
import TeamSettings from './TeamSettings';
|
||||
|
||||
export default Layout;
|
||||
export default function ({ children, params: { teamId } }) {
|
||||
return <TeamSettings teamId={teamId}>{children}</TeamSettings>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,23 @@
|
|||
'use client';
|
||||
import TeamEditForm from 'app/(main)/settings/teams/[teamId]/TeamEditForm';
|
||||
import { useLogin, useMessages, useTeam } from 'components/hooks';
|
||||
import { Loading } from 'react-basics';
|
||||
import { useContext } from 'react';
|
||||
import { useLogin, useMessages } from 'components/hooks';
|
||||
import PageHeader from 'components/layout/PageHeader';
|
||||
import { ROLES } from 'lib/constants';
|
||||
import TeamEditForm from 'app/(main)/settings/teams/[teamId]/TeamEditForm';
|
||||
import { TeamContext } from 'app/(main)/teams/[teamId]/TeamProvider';
|
||||
|
||||
export default function Team({ teamId }: { teamId: string }) {
|
||||
const team = useContext(TeamContext);
|
||||
const { user } = useLogin();
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { data: team, isLoading } = useTeam(teamId);
|
||||
const allowEdit = !!team?.teamUser?.find(
|
||||
({ userId, role }) => role === ROLES.teamOwner && userId === user.id,
|
||||
);
|
||||
|
||||
if (isLoading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader title={formatMessage(labels.team)} />
|
||||
<TeamEditForm teamId={teamId} data={team} allowEdit={allowEdit} />
|
||||
<TeamEditForm teamId={teamId} allowEdit={allowEdit} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue