umami/components/Settings.js

29 lines
910 B
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-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-08-10 00:13:38 +02:00
const [option, setOption] = useState(1);
2020-08-09 11:03:37 +02:00
2020-08-10 00:13:38 +02:00
const menuOptions = [
{ label: 'Websites', value: 1 },
{ label: 'Accounts', value: 2, hidden: !user.is_admin },
{ label: 'Profile', value: 3 },
];
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-08-10 00:13:38 +02:00
{option === 1 && <WebsiteSettings />}
{option === 2 && <AccountSettings />}
{option === 3 && <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
);
}