Merge branch 'fix/dashboard' into 'master'
Fixed code formatting and removed unused imports in Dashboard component (fix completed topics bug). See merge request profile-image/kedaireka/polinema-adapative-learning/frontend-adaptive-learning!1
This commit is contained in:
commit
9a3c1f678d
|
|
@ -1,14 +1,10 @@
|
||||||
import axiosInstance from '../../../../utils/axiosInstance';
|
import axiosInstance from '../../../../utils/axiosInstance'
|
||||||
|
|
||||||
const fetchJourney = async () => {
|
const fetchJourney = async () => {
|
||||||
try {
|
const response = await axiosInstance.get(`/topic/complete`)
|
||||||
const response = await axiosInstance.get(`/topic/complete`);
|
return response.data
|
||||||
return response.data;
|
}
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
fetchJourney,
|
fetchJourney,
|
||||||
};
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,100 +1,170 @@
|
||||||
import React from 'react';
|
import { Container, Row, Col, Card, Button, ProgressBar } from 'react-bootstrap'
|
||||||
import { Container, Row, Col, Card, Button, ProgressBar } from 'react-bootstrap';
|
import newBie from '../../../../assets/images/illustration/emptyJourney.png'
|
||||||
import newBie from '../../../../assets/images/illustration/emptyJourney.png';
|
import { Link, NavLink } from 'react-router-dom'
|
||||||
import reading from '../../../../assets/images/illustration/reading.png';
|
import useDashboards from '../hooks/useDashboards'
|
||||||
import listening from '../../../../assets/images/illustration/listening.png';
|
import { slugify } from '../../../../utils/Constant'
|
||||||
import { Link, NavLink } from 'react-router-dom';
|
import Skeleton from 'react-loading-skeleton'
|
||||||
import useDashboards from '../hooks/useDashboards';
|
|
||||||
import { slugify } from '../../../../utils/Constant';
|
|
||||||
import Skeleton from 'react-loading-skeleton';
|
|
||||||
|
|
||||||
function validName(fullName) {
|
function validName(fullName) {
|
||||||
const nameArray = fullName.split(" ");
|
const nameArray = fullName.split(' ')
|
||||||
const firstTwoWords = nameArray.slice(0, 2).join(" ");
|
const firstTwoWords = nameArray.slice(0, 2).join(' ')
|
||||||
|
|
||||||
return firstTwoWords;
|
return firstTwoWords
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
const { username } = JSON.parse(localStorage.getItem('userData'));
|
const { username } = JSON.parse(localStorage.getItem('userData'))
|
||||||
|
|
||||||
const { journey, loading, error, thumbPath} = useDashboards();
|
const { journey, loading, error, thumbPath } = useDashboards()
|
||||||
const noData = () =>{ return journey.lenght > 0 ? false : true };
|
const noData = () => {
|
||||||
|
return journey.lenght == 0
|
||||||
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <div>Error: {error.message}</div>;
|
return <div>Error: {error.message}</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='home-page'>
|
<div className="home-page">
|
||||||
<h1 className='text-blue text-capitalize fw-bold mb-1'>Hi, {validName(username)} !</h1>
|
<h1 className="text-blue text-capitalize fw-bold mb-1">
|
||||||
<p className='text-secondary'>Let’s evolve together with adaptive learning tailored just for you.</p>
|
Hi, {validName(username)} !
|
||||||
<h4 className='text-blue mt-4 fw-bold'>Your Last Journey!</h4>
|
</h1>
|
||||||
<Container fluid className='bg-white rounded rounded-4 p-4'>
|
<p className="text-secondary">
|
||||||
<Row xs={1} className='filled-journey'>
|
Let’s evolve together with adaptive learning tailored just for you.
|
||||||
<Col className='mb-3'>
|
</p>
|
||||||
{loading ?(
|
<h4 className="text-blue mt-4 fw-bold">Your Last Journey!</h4>
|
||||||
<>
|
<Container fluid className="bg-white rounded rounded-4 p-4">
|
||||||
<Card className='flex-row p-3 mb-3 border-0 shadow shadow-sm rounded-4'>
|
<Row xs={1} className="filled-journey">
|
||||||
<div className="w-100 d-flex">
|
<Col className="mb-3">
|
||||||
<Skeleton containerClassName="mb-2" className='mb-2 rounded-4' style={{width:"10vw", height:"10vw"}} />
|
{loading ? (
|
||||||
<div className='ps-2 d-flex flex-column justify-content-between'>
|
<>
|
||||||
<Skeleton containerClassName="mb-2" className='mb-2 rounded-4' style={{width:"20vw", height:"3vw"}} />
|
<Card className="flex-row p-3 mb-3 border-0 shadow shadow-sm rounded-4">
|
||||||
<Skeleton containerClassName="mb-2" className='mb-2 rounded-4' style={{width:"30vw", height:"2vw"}} />
|
<div className="w-100 d-flex">
|
||||||
</div>
|
<Skeleton
|
||||||
<Skeleton containerClassName="mb-2 mt-auto ms-auto" className='mb-2 rounded-4' style={{width:"17vw", height:"4vw"}} />
|
containerClassName="mb-2"
|
||||||
</div>
|
className="mb-2 rounded-4"
|
||||||
</Card>
|
style={{ width: '10vw', height: '10vw' }}
|
||||||
<Card className='flex-row p-3 mb-3 border-0 shadow shadow-sm rounded-4'>
|
/>
|
||||||
<div className="w-100 d-flex">
|
<div className="ps-2 d-flex flex-column justify-content-between">
|
||||||
<Skeleton containerClassName="mb-2" className='mb-2 rounded-4' style={{width:"10vw", height:"10vw"}} />
|
<Skeleton
|
||||||
<div className='ps-2 d-flex flex-column justify-content-between'>
|
containerClassName="mb-2"
|
||||||
<Skeleton containerClassName="mb-2" className='mb-2 rounded-4' style={{width:"20vw", height:"3vw"}} />
|
className="mb-2 rounded-4"
|
||||||
<Skeleton containerClassName="mb-2" className='mb-2 rounded-4' style={{width:"30vw", height:"2vw"}} />
|
style={{ width: '20vw', height: '3vw' }}
|
||||||
</div>
|
/>
|
||||||
<Skeleton containerClassName="mb-2 mt-auto ms-auto" className='mb-2 rounded-4' style={{width:"17vw", height:"4vw"}} />
|
<Skeleton
|
||||||
</div>
|
containerClassName="mb-2"
|
||||||
</Card>
|
className="mb-2 rounded-4"
|
||||||
</>
|
style={{ width: '30vw', height: '2vw' }}
|
||||||
) : (
|
/>
|
||||||
noData() ?(
|
</div>
|
||||||
<Col className='d-flex flex-column items-center'>
|
<Skeleton
|
||||||
<h4 className='mb-0'>Still new?</h4>
|
containerClassName="mb-2 mt-auto ms-auto"
|
||||||
<p className='fs-5 text-muted fw-light'>Begin your journey!</p>
|
className="mb-2 rounded-4"
|
||||||
<img src={newBie} alt="" />
|
style={{ width: '17vw', height: '4vw' }}
|
||||||
<Button as={Link} to={'/learning/module'} variant='warning' className='mt-4 py-2 px-5 rounded-35'>Explore</Button>
|
/>
|
||||||
</Col>
|
</div>
|
||||||
):(
|
</Card>
|
||||||
journey.map(data => (
|
<Card className="flex-row p-3 mb-3 border-0 shadow shadow-sm rounded-4">
|
||||||
<Card className='flex-row p-3 mb-3 border-0 shadow shadow-sm rounded-4'>
|
<div className="w-100 d-flex">
|
||||||
<Card.Img variant="top" src={`${thumbPath}${data.THUMBNAIL}`} className='ratio ratio-1x1 rounded rounded-3 me-3' />
|
<Skeleton
|
||||||
<Card.Body className='p-0 d-flex flex-column justify-content-between'>
|
containerClassName="mb-2"
|
||||||
<div className='w-75'>
|
className="mb-2 rounded-4"
|
||||||
<Card.Title>{data.NAME_SECTION}</Card.Title>
|
style={{ width: '10vw', height: '10vw' }}
|
||||||
<Card.Text className='text-muted'>
|
/>
|
||||||
{data.DESCRIPTION_SECTION}
|
<div className="ps-2 d-flex flex-column justify-content-between">
|
||||||
</Card.Text>
|
<Skeleton
|
||||||
</div>
|
containerClassName="mb-2"
|
||||||
<div className="w-100 d-flex align-items-end">
|
className="mb-2 rounded-4"
|
||||||
<div className="w-75">
|
style={{ width: '20vw', height: '3vw' }}
|
||||||
<div className='d-flex align-items-center'>
|
/>
|
||||||
<ProgressBar now={((data.COMPLETED_TOPICS / data.TOTAL_TOPICS)*100).toFixed(0)} className='w-75' />
|
<Skeleton
|
||||||
<span className='text-blue ms-2'>{((data.COMPLETED_TOPICS / data.TOTAL_TOPICS)*100).toFixed(0)}%</span>
|
containerClassName="mb-2"
|
||||||
</div>
|
className="mb-2 rounded-4"
|
||||||
<p className='text-muted m-0'>{data.COMPLETED_TOPICS} / {data.TOTAL_TOPICS} Topics</p>
|
style={{ width: '30vw', height: '2vw' }}
|
||||||
</div>
|
/>
|
||||||
<Button as={NavLink} to={`/learning/module/${slugify(data.NAME_SECTION)}`} variant="warning" className='ms-auto py-2 px-5 rounded-35'>Continue</Button>
|
</div>
|
||||||
</div>
|
<Skeleton
|
||||||
</Card.Body>
|
containerClassName="mb-2 mt-auto ms-auto"
|
||||||
</Card>
|
className="mb-2 rounded-4"
|
||||||
))
|
style={{ width: '17vw', height: '4vw' }}
|
||||||
)
|
/>
|
||||||
)}
|
</div>
|
||||||
</Col>
|
</Card>
|
||||||
</Row>
|
</>
|
||||||
</Container>
|
) : noData() ? (
|
||||||
</div>
|
<Col className="d-flex flex-column items-center">
|
||||||
);
|
<h4 className="mb-0">Still new?</h4>
|
||||||
};
|
<p className="fs-5 text-muted fw-light">Begin your journey!</p>
|
||||||
|
<img src={newBie} alt="" />
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
to={'/learning/module'}
|
||||||
|
variant="warning"
|
||||||
|
className="mt-4 py-2 px-5 rounded-35"
|
||||||
|
>
|
||||||
|
Explore
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
|
) : (
|
||||||
|
journey.map(data => (
|
||||||
|
<Card
|
||||||
|
key={data.ID}
|
||||||
|
className="flex-row p-3 mb-3 border-0 shadow shadow-sm rounded-4"
|
||||||
|
>
|
||||||
|
<Card.Img
|
||||||
|
variant="top"
|
||||||
|
src={
|
||||||
|
data.THUMBNAIL ? `${thumbPath}${data.THUMBNAIL}` : newBie
|
||||||
|
}
|
||||||
|
className="ratio ratio-1x1 rounded rounded-3 me-3"
|
||||||
|
/>
|
||||||
|
<Card.Body className="p-0 d-flex flex-column justify-content-between">
|
||||||
|
<div className="w-75">
|
||||||
|
<Card.Title>{data.NAME_SECTION}</Card.Title>
|
||||||
|
<Card.Text className="text-muted">
|
||||||
|
{data.DESCRIPTION_SECTION}
|
||||||
|
</Card.Text>
|
||||||
|
</div>
|
||||||
|
<div className="w-100 d-flex align-items-end">
|
||||||
|
<div className="w-75">
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
<ProgressBar
|
||||||
|
now={(
|
||||||
|
(data.COMPLETED_TOPICS / data.TOTAL_TOPICS) *
|
||||||
|
100
|
||||||
|
).toFixed(0)}
|
||||||
|
className="w-75"
|
||||||
|
/>
|
||||||
|
<span className="text-blue ms-2">
|
||||||
|
{(
|
||||||
|
(data.COMPLETED_TOPICS / data.TOTAL_TOPICS) *
|
||||||
|
100
|
||||||
|
).toFixed(0)}
|
||||||
|
%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-muted m-0">
|
||||||
|
{data.COMPLETED_TOPICS} / {data.TOTAL_TOPICS} Topics
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
as={NavLink}
|
||||||
|
to={`/learning/module/${slugify(data.NAME_SECTION)}`}
|
||||||
|
variant="warning"
|
||||||
|
className="ms-auto py-2 px-5 rounded-35"
|
||||||
|
>
|
||||||
|
Continue
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Card.Body>
|
||||||
|
</Card>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Container>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default Dashboard;
|
export default Dashboard
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
export const API_URL = 'http://54.173.167.62/api';
|
export const API_URL = 'https://z30xrgl5-3001.asse.devtunnels.ms/api'
|
||||||
export const MEDIA_URL = 'http://54.173.167.62/api/uploads';
|
export const MEDIA_URL = 'https://z30xrgl5-3001.asse.devtunnels.ms/api/uploads'
|
||||||
|
|
||||||
export let headerSection = 'section';
|
export let headerSection = 'section'
|
||||||
export let headerTopic = 'topic';
|
export let headerTopic = 'topic'
|
||||||
export let headerLevel = 'level';
|
export let headerLevel = 'level'
|
||||||
|
|
||||||
export const slugify = (text) => {
|
export const slugify = text => {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return '';
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return text
|
return text
|
||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/\s+/g, '-')
|
.replace(/\s+/g, '-')
|
||||||
.replace(/[^\w\-]+/g, '')
|
.replace(/[^\w-]+/g, '')
|
||||||
.replace(/\-\-+/g, '-');
|
.replace(/--+/g, '-')
|
||||||
};
|
}
|
||||||
|
|
||||||
export const unSlugify = (text) => {
|
export const unSlugify = text => {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
return '';
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return text
|
return text
|
||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/-/g, ' ')
|
.replace(/-/g, ' ')
|
||||||
.replace(/\b\w/g, (char) => char.toUpperCase());
|
.replace(/\b\w/g, char => char.toUpperCase())
|
||||||
};
|
}
|
||||||
|
|
||||||
export const setReviewHeader = (section, topic, level) => {
|
export const setReviewHeader = (section, topic, level) => {
|
||||||
headerSection = section;
|
headerSection = section
|
||||||
headerTopic = topic;
|
headerTopic = topic
|
||||||
headerLevel = level;
|
headerLevel = level
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user