diff --git a/src/roles/user/dashboard/services/dashboardService.jsx b/src/roles/user/dashboard/services/dashboardService.jsx index 89bac0d..379c7ae 100644 --- a/src/roles/user/dashboard/services/dashboardService.jsx +++ b/src/roles/user/dashboard/services/dashboardService.jsx @@ -1,14 +1,10 @@ -import axiosInstance from '../../../../utils/axiosInstance'; +import axiosInstance from '../../../../utils/axiosInstance' const fetchJourney = async () => { - try { - const response = await axiosInstance.get(`/topic/complete`); - return response.data; - } catch (error) { - throw error; - } -}; + const response = await axiosInstance.get(`/topic/complete`) + return response.data +} export default { - fetchJourney, -}; + fetchJourney, +} diff --git a/src/roles/user/dashboard/views/Dashboard.jsx b/src/roles/user/dashboard/views/Dashboard.jsx index 93b8e05..478883c 100644 --- a/src/roles/user/dashboard/views/Dashboard.jsx +++ b/src/roles/user/dashboard/views/Dashboard.jsx @@ -1,100 +1,170 @@ -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'; +import { Container, Row, Col, Card, Button, ProgressBar } from 'react-bootstrap' +import newBie from '../../../../assets/images/illustration/emptyJourney.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 nameArray = fullName.split(' ') + const firstTwoWords = nameArray.slice(0, 2).join(' ') + + return firstTwoWords } const Dashboard = () => { - const { username } = JSON.parse(localStorage.getItem('userData')); + const { username } = JSON.parse(localStorage.getItem('userData')) - const { journey, loading, error, thumbPath} = useDashboards(); - const noData = () =>{ return journey.lenght > 0 ? false : true }; + const { journey, loading, error, thumbPath } = useDashboards() + const noData = () => { + return journey.lenght == 0 + } - if (error) { - return
Error: {error.message}
; - } + 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

-
- -
-
-
- )) - ) - )} - -
-
-
- ); -}; + 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; +export default Dashboard diff --git a/src/utils/Constant.jsx b/src/utils/Constant.jsx index a886da4..3b228bd 100644 --- a/src/utils/Constant.jsx +++ b/src/utils/Constant.jsx @@ -1,38 +1,38 @@ -export const API_URL = 'http://54.173.167.62/api'; -export const MEDIA_URL = 'http://54.173.167.62/api/uploads'; +export const API_URL = 'https://z30xrgl5-3001.asse.devtunnels.ms/api' +export const MEDIA_URL = 'https://z30xrgl5-3001.asse.devtunnels.ms/api/uploads' -export let headerSection = 'section'; -export let headerTopic = 'topic'; -export let headerLevel = 'level'; +export let headerSection = 'section' +export let headerTopic = 'topic' +export let headerLevel = 'level' -export const slugify = (text) => { - if (!text) { - return ''; - } - - return text - .toString() - .toLowerCase() - .trim() - .replace(/\s+/g, '-') - .replace(/[^\w\-]+/g, '') - .replace(/\-\-+/g, '-'); -}; +export const slugify = text => { + if (!text) { + return '' + } -export const unSlugify = (text) => { - if (!text) { - return ''; - } - - return text - .toString() - .toLowerCase() - .replace(/-/g, ' ') - .replace(/\b\w/g, (char) => char.toUpperCase()); -}; + return text + .toString() + .toLowerCase() + .trim() + .replace(/\s+/g, '-') + .replace(/[^\w-]+/g, '') + .replace(/--+/g, '-') +} + +export const unSlugify = text => { + if (!text) { + return '' + } + + return text + .toString() + .toLowerCase() + .replace(/-/g, ' ') + .replace(/\b\w/g, char => char.toUpperCase()) +} export const setReviewHeader = (section, topic, level) => { - headerSection = section; - headerTopic = topic; - headerLevel = level; -} \ No newline at end of file + headerSection = section + headerTopic = topic + headerLevel = level +}