Simple page de modification de profil

This commit is contained in:
2020-07-16 20:21:58 +02:00
parent 05dd505d6b
commit 758c166f27
14 changed files with 284 additions and 29 deletions

View File

@ -0,0 +1,38 @@
import React, { useEffect } from 'react';
import { Page } from '../Page';
import { useSelector, useDispatch } from 'react-redux';
import { RootState } from '../../store/reducers/root';
import { UserForm } from '../UserForm';
import { Loader } from '../Loader';
import { User } from '../../types/user';
import { updateProfile } from '../../store/actions/profile';
export function ProfilePage() {
const currentUser = useSelector((state: RootState) => state.auth.currentUser);
const dispatch = useDispatch();
const onUserChange = (user: User) => {
if (currentUser.name !== user.name) {
dispatch(updateProfile({ name: user.name }))
}
};
return (
<Page title="Mon profil">
<div className="container is-fluid">
<section className="section">
<div className="columns">
<div className="column is-6 is-offset-3">
<h2 className="is-size-2 subtitle">Mon profil</h2>
{
currentUser ?
<UserForm onChange={onUserChange} user={currentUser} /> :
<Loader />
}
</div>
</div>
</section>
</div>
</Page>
);
}