diff --git a/src/app/newsletter/page.tsx b/src/app/newsletter/page.tsx index cd35b74..5cf44bb 100644 --- a/src/app/newsletter/page.tsx +++ b/src/app/newsletter/page.tsx @@ -10,20 +10,20 @@ import NewsCardHorizontal from '@/components/NewsCardHorizontal'; import Suggestions from '@/components/Suggestion'; import { articleCategory } from '@/constants/category'; import color from '@/constants/color'; -import useGetUser from '@/hooks/useGetUser'; +import { useGetUserProfile } from '@/hooks/useGetUser'; +import useUpdateUserProfile from '@/hooks/useUpdateUser'; import suggestionData from '@/mocks/suggestion'; import { Article } from '@/types'; import { getArticleAll, getPopularArticle } from '../api/newsletter'; -import { getUser } from '../api/user'; const Page = () => { const [selectedTab, setSelectedTab] = useState(articleCategory[0]); const [articles, setArticles] = useState([]); const [popularArticles, setPopularArticles] = useState([]); - const user = useGetUser(); - const [userName, setUserName] = useState(null); + const userProfile = useGetUserProfile(); + useUpdateUserProfile(); useEffect(() => { getArticleAll().then((res) => { @@ -42,18 +42,6 @@ const Page = () => { }); }, []); - useEffect(() => { - if (user.isLogin) { - getUser(user.token).then((res) => { - if (res.status) { - setUserName(res.data.name); - } else { - throw res.message; - } - }); - } - }, [user]); - return ( @@ -93,10 +81,10 @@ const Page = () => { - {userName && ( + {userProfile && ( <> - - + + )}