Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket-88 #384

Merged
merged 7 commits into from
Jul 30, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions frontend/src/screens/study-landing.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Navigate, NavLink, useLoaderData } from 'react-router-dom'
import { React } from '@common'
import { React, useState, useEffect } from '@common'
import { colors } from '@theme'
import { LearningPath, ParticipantStudy } from '@api'
import { Page } from '@components'
Expand All @@ -17,16 +17,34 @@ import {
Stack,
Text,
Title,
Notification,
} from '@mantine/core';
import { IconCheck } from '@tabler/icons-react'
import Markdown from 'react-markdown'
import { useLearningPathStudies } from './learner/studies';
import { CompactStudyCard } from '../components/study/compact-study-card';

export default function StudyLanding() {
const env = useEnvironment()

const study = useLoaderData() as ParticipantStudy
const learningPathStudies = useLearningPathStudies(study?.learningPath)
const [showNotification, setShowNotification] = useState(false)

useEffect(() => {
if (study.totalPoints > 0) {
setShowNotification(true)
}
}, [study.totalPoints])

useEffect(() => {
if (showNotification) {
const timer = setTimeout(() => {
setShowNotification(false)
}, 2000)

return () => clearTimeout(timer)
}
}, [showNotification])

if (!study || !study.learningPath) {
return <Navigate to='/studies' />
Expand All @@ -44,6 +62,25 @@ export default function StudyLanding() {
<LearningPathProgress learningPath={study.learningPath} studies={learningPathStudies} />
}
</Card>
{showNotification && (
divitcr7 marked this conversation as resolved.
Show resolved Hide resolved
<Notification
icon={<IconCheck size="1.1rem" />}
color="teal"
onClose={() => setShowNotification(false)}
style={{
position: 'absolute',
top: '1rem',
right: '1rem',
zIndex: 1000,
maxWidth: '400px',
}}
>
<Title order={6} mb={5}>You just earned {study.totalPoints} points!</Title>
<Text size="xs" lineClamp={2} c={colors.gray70}>
The longer the study, the more points you earn. Reach 200 points to unlock additional rewards.
divitcr7 marked this conversation as resolved.
Show resolved Hide resolved
</Text>
</Notification>
)}
</Page>
)
}
Expand Down Expand Up @@ -100,7 +137,7 @@ const CompletedLearningPath: FC<{learningPath: LearningPath}> = ({ learningPath

<Stack gap='0'>
<Title order={5} c='purple'>
You’ve done awesome work so far!
You’ve done awesome work so far!
divitcr7 marked this conversation as resolved.
Show resolved Hide resolved
</Title>
<Text c={colors.gray70}>
{badge.description}
Expand Down