diff --git a/src/roles/user/dashboard/views/Dashboard.jsx b/src/roles/user/dashboard/views/Dashboard.jsx index 2b020ce..93b8e05 100644 --- a/src/roles/user/dashboard/views/Dashboard.jsx +++ b/src/roles/user/dashboard/views/Dashboard.jsx @@ -8,7 +8,15 @@ import useDashboards from '../hooks/useDashboards'; import { slugify } from '../../../../utils/Constant'; import Skeleton from 'react-loading-skeleton'; +function validName(fullName) { + const nameArray = fullName.split(" "); + const firstTwoWords = nameArray.slice(0, 2).join(" "); + + return firstTwoWords; +} + const Dashboard = () => { + const { username } = JSON.parse(localStorage.getItem('userData')); const { journey, loading, error, thumbPath} = useDashboards(); const noData = () =>{ return journey.lenght > 0 ? false : true }; @@ -19,7 +27,7 @@ const Dashboard = () => { return (
-

Hi, Dimas Anhar !

+

Hi, {validName(username)} !

Let’s evolve together with adaptive learning tailored just for you.

Your Last Journey!

diff --git a/src/roles/user/history/hooks/useHirtories.jsx b/src/roles/user/history/hooks/useHirtories.jsx index fcd050c..c6072c3 100644 --- a/src/roles/user/history/hooks/useHirtories.jsx +++ b/src/roles/user/history/hooks/useHirtories.jsx @@ -60,8 +60,12 @@ const useHistories = () => { } setHistoryData(data.payload); } catch (error) { - console.log(error); - setError('Failed to fetch data'); + if (error.status == 404) { + setHistoryData([]); + }else{ + console.log(error); + setError(error.message); + } } finally { setLoading(false); }