From 77d21e90dd145e438ec4c2068d60c1713c76decb Mon Sep 17 00:00:00 2001 From: Wysogota Date: Tue, 23 Aug 2022 12:35:07 +0300 Subject: [PATCH] Update useLoading title --- .../Title/ReadingButtonsBlock/SaveToRecommendation.jsx | 2 +- client/src/hooks/useLoading.jsx | 2 +- client/src/pages/Profile/ProfileLists.jsx | 2 +- client/src/pages/Profile/ProfileTabs.jsx | 2 +- client/src/pages/Profile/index.jsx | 9 ++++++--- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/src/components/Title/ReadingButtonsBlock/SaveToRecommendation.jsx b/client/src/components/Title/ReadingButtonsBlock/SaveToRecommendation.jsx index 3698739..d12e089 100644 --- a/client/src/components/Title/ReadingButtonsBlock/SaveToRecommendation.jsx +++ b/client/src/components/Title/ReadingButtonsBlock/SaveToRecommendation.jsx @@ -28,7 +28,7 @@ const SaveToRecommendation = () => { formikBag.resetForm(); }; - const loading = useLoading({ data: manga, isFetching, title: 'waiting...' }); + const loading = useLoading({ data: manga, isFetching }); if (loading) return loading; return ( diff --git a/client/src/hooks/useLoading.jsx b/client/src/hooks/useLoading.jsx index 7bf5fa6..4e56230 100644 --- a/client/src/hooks/useLoading.jsx +++ b/client/src/hooks/useLoading.jsx @@ -9,7 +9,7 @@ import MinorHeader from '../components/Headers/MinorHeader'; * @returns */ const useLoading = (options) => { - const { data, title = 'Waiting...', isFetching, spinner = true } = options; + const { data, title = '', isFetching, spinner = true } = options; if (!spinner && isFetching) { return <>; diff --git a/client/src/pages/Profile/ProfileLists.jsx b/client/src/pages/Profile/ProfileLists.jsx index 1bdc782..f11b8f3 100644 --- a/client/src/pages/Profile/ProfileLists.jsx +++ b/client/src/pages/Profile/ProfileLists.jsx @@ -27,7 +27,7 @@ const ProfileLists = () => { 'rounded mb-3', ); - const loading = useLoading({ data: listIds, isFethcing, title: 'waiting' }); + const loading = useLoading({ data: listIds, isFethcing }); if (loading) return loading; return ( diff --git a/client/src/pages/Profile/ProfileTabs.jsx b/client/src/pages/Profile/ProfileTabs.jsx index 3976b84..a8316c0 100644 --- a/client/src/pages/Profile/ProfileTabs.jsx +++ b/client/src/pages/Profile/ProfileTabs.jsx @@ -15,7 +15,7 @@ const { const ProfileTabs = () => { const { me, isFetching } = useSelector(({ me }) => me); - const loading = useLoading({ data: me, isFetching, title: 'wait', spinner: false }); + const loading = useLoading({ data: me, isFetching, spinner: false }); if (loading) return loading; return ( diff --git a/client/src/pages/Profile/index.jsx b/client/src/pages/Profile/index.jsx index f3df61b..a2f12f9 100644 --- a/client/src/pages/Profile/index.jsx +++ b/client/src/pages/Profile/index.jsx @@ -1,18 +1,21 @@ import React from 'react'; import { useSelector } from 'react-redux'; import { Container, Row, Button } from 'react-bootstrap'; +import { Link } from 'react-router-dom'; import ColBlock from '../../components/Blocks/ColBlock'; import MainHeader from '../../components/Headers/MainHeader'; import Avatar from '../../components/Avatar'; import ProfileTabs from './ProfileTabs'; -import { Link } from 'react-router-dom'; +import { useLoading } from '../../hooks'; import CONSTANTS from '../../constants'; const { PAGES: { SETTINGS: { path: SETTINGS_PATH } } } = CONSTANTS; - const Profile = () => { const { theme: { invertedColor } } = useSelector(({ themes }) => themes); - const { me } = useSelector(({ me }) => me); + const { me, isFetching } = useSelector(({ me }) => me); + + const loading = useLoading({ data: me, isFetching }); + if (loading) return loading; return (