umami/components/ProfileSettings.js

37 lines
1020 B
JavaScript
Raw Normal View History

2020-08-09 08:48:43 +02:00
import React, { useState } from 'react';
import { useSelector } from 'react-redux';
import PageHeader from './layout/PageHeader';
import Button from './common/Button';
import ChangePasswordForm from './forms/ChangePasswordForm';
import Modal from './common/Modal';
export default function ProfileSettings() {
const user = useSelector(state => state.user);
const [changePassword, setChangePassword] = useState(false);
2020-08-09 11:03:37 +02:00
const { user_id } = user;
2020-08-09 08:48:43 +02:00
return (
<>
<PageHeader>
<div>Profile</div>
<Button size="small" onClick={() => setChangePassword(true)}>
Change password
</Button>
</PageHeader>
2020-08-09 11:03:37 +02:00
<dl>
<dt>Username</dt>
<dd>{user.username}</dd>
</dl>
2020-08-09 08:48:43 +02:00
{changePassword && (
<Modal title="Change password">
2020-08-09 11:03:37 +02:00
<ChangePasswordForm
values={{ user_id }}
onSave={() => setChangePassword(false)}
onClose={() => setChangePassword(false)}
/>
2020-08-09 08:48:43 +02:00
</Modal>
)}
</>
);
}