umami/components/settings/Settings.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-08-09 12:04:48 +02:00
import React, { useState } from 'react';
2020-08-09 08:48:43 +02:00
import Page from 'components/layout/Page';
import MenuLayout from 'components/layout/MenuLayout';
import WebsiteSettings from './WebsiteSettings';
import AccountSettings from './AccountSettings';
import ProfileSettings from './ProfileSettings';
2020-08-09 11:03:37 +02:00
import { useSelector } from 'react-redux';
2020-09-06 02:27:01 +02:00
import { FormattedMessage } from 'react-intl';
const WEBSITES = 1;
const ACCOUNTS = 2;
const PROFILE = 3;
2020-08-09 08:48:43 +02:00
export default function Settings() {
2020-08-09 11:03:37 +02:00
const user = useSelector(state => state.user);
2020-09-06 02:27:01 +02:00
const [option, setOption] = useState(WEBSITES);
2020-08-09 11:03:37 +02:00
2020-08-10 00:13:38 +02:00
const menuOptions = [
2020-09-06 02:27:01 +02:00
{
label: <FormattedMessage id="settings.websites" defaultMessage="Websites" />,
value: WEBSITES,
},
{
label: <FormattedMessage id="settings.accounts" defaultMessage="Accounts" />,
value: ACCOUNTS,
hidden: !user.is_admin,
},
{ label: <FormattedMessage id="settings.profile" defaultMessage="Profile" />, value: PROFILE },
2020-08-10 00:13:38 +02:00
];
2020-08-09 11:03:37 +02:00
2020-08-05 07:45:05 +02:00
return (
2020-08-06 04:04:02 +02:00
<Page>
2020-08-09 12:04:48 +02:00
<MenuLayout menu={menuOptions} selectedOption={option} onMenuSelect={setOption}>
2020-09-06 02:27:01 +02:00
{option === WEBSITES && <WebsiteSettings />}
{option === ACCOUNTS && <AccountSettings />}
{option === PROFILE && <ProfileSettings />}
2020-08-09 08:48:43 +02:00
</MenuLayout>
2020-08-06 04:04:02 +02:00
</Page>
2020-08-05 07:45:05 +02:00
);
}