import React from 'react'; import { Container, Row, Col, Card, Button, ProgressBar } from 'react-bootstrap'; import newBie from '../../../../assets/images/illustration/emptyJourney.png'; import reading from '../../../../assets/images/illustration/reading.png'; import listening from '../../../../assets/images/illustration/listening.png'; import { Link, NavLink } from 'react-router-dom'; 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 }; if (error) { return
Error: {error.message}
; } return (

Hi, {validName(username)} !

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

Your Last Journey!

{loading ?( <>
) : ( noData() ?(

Still new?

Begin your journey!

):( journey.map(data => (
{data.NAME_SECTION} {data.DESCRIPTION_SECTION}
{((data.COMPLETED_TOPICS / data.TOTAL_TOPICS)*100).toFixed(0)}%

{data.COMPLETED_TOPICS} / {data.TOTAL_TOPICS} Topics

)) ) )}
); }; export default Dashboard;