Mise en forme basique du loader de module

This commit is contained in:
2020-10-13 13:47:29 +02:00
parent 70fe86a9a5
commit 655ecd1a0f
6 changed files with 24 additions and 80 deletions

View File

@ -2,19 +2,16 @@ import React from 'react';
import { Page } from '../Page';
import { UserForm } from '../UserForm';
import { User } from '../../types/user';
import { useUserProfileQuery } from '../../gql/queries/profile';
import { useUserProfile } from '../../gql/queries/profile';
import { useUpdateUserProfileMutation } from '../../gql/mutations/profile';
import { WithLoader } from '../WithLoader';
export function ProfilePage() {
const userProfileQuery = useUserProfileQuery();
const { user, loading } = useUserProfile();
const [ updateProfile, updateUserProfileMutation ] = useUpdateUserProfileMutation();
const isLoading = updateUserProfileMutation.loading || userProfileQuery.loading;
const { userProfile } = (userProfileQuery.data || {});
const isLoading = updateUserProfileMutation.loading || loading;
const onUserChange = (user: User) => {
if (userProfile.name !== user.name) {
if (user.name !== user.name) {
updateProfile({ variables: {changes: { name: user.name }}});
}
};
@ -27,11 +24,7 @@ export function ProfilePage() {
<div className="column is-6 is-offset-3">
<div className="box">
<h2 className="is-size-2 subtitle">Mon profil</h2>
<WithLoader loading={isLoading || !userProfile}>
{
<UserForm onChange={onUserChange} user={userProfile} />
}
</WithLoader>
<UserForm onChange={onUserChange} user={user} />
</div>
</div>
</div>