mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import React, { useState } from 'react';
|
|
import { FormattedMessage } from 'react-intl';
|
|
import { useRouter } from 'next/router';
|
|
import Page from 'components/layout/Page';
|
|
import MenuLayout from 'components/layout/MenuLayout';
|
|
import WebsiteSettings from 'components/settings/WebsiteSettings';
|
|
import UserSettings from 'components/settings/UserSettings';
|
|
import ProfileSettings from 'components/settings/ProfileSettings';
|
|
import useUser from 'hooks/useUser';
|
|
|
|
const WEBSITES = '/settings';
|
|
const ACCOUNTS = '/settings/users';
|
|
const PROFILE = '/settings/profile';
|
|
|
|
export default function Settings() {
|
|
const { user } = useUser();
|
|
const [option, setOption] = useState(WEBSITES);
|
|
const router = useRouter();
|
|
const { pathname } = router;
|
|
|
|
if (!user) {
|
|
return null;
|
|
}
|
|
|
|
const menuOptions = [
|
|
{
|
|
label: <FormattedMessage id="label.websites" defaultMessage="Websites" />,
|
|
value: WEBSITES,
|
|
},
|
|
{
|
|
label: <FormattedMessage id="label.users" defaultMessage="Users" />,
|
|
value: ACCOUNTS,
|
|
hidden: !user?.isAdmin,
|
|
},
|
|
{
|
|
label: <FormattedMessage id="label.profile" defaultMessage="Profile" />,
|
|
value: PROFILE,
|
|
},
|
|
];
|
|
|
|
return (
|
|
<Page>
|
|
<MenuLayout menu={menuOptions} selectedOption={option} onMenuSelect={setOption}>
|
|
{pathname === WEBSITES && <WebsiteSettings />}
|
|
{pathname === ACCOUNTS && <UserSettings />}
|
|
{pathname === PROFILE && <ProfileSettings />}
|
|
</MenuLayout>
|
|
</Page>
|
|
);
|
|
}
|