Skip to content

Commit

Permalink
Merge pull request #384 from openstax/Ticket-88
Browse files Browse the repository at this point in the history
Ticket-88
  • Loading branch information
chrisbendel authored Jul 30, 2024
2 parents c4eacd3 + 15d6ab9 commit 4171dde
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
12 changes: 11 additions & 1 deletion frontend/specs/admin/reward.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,20 @@ test('can add/update/delete rewards', async ({ browser }) => {

// Update
const updatedPrize = faker.random.words(2)

await adminPage.waitForSelector('text=Edit', { state: 'visible' });
await adminPage.getByText('Edit').first().click()
await adminPage.waitForLoadState('networkidle');

await adminPage.waitForSelector('input[placeholder="Prize"]', { state: 'visible' });
await adminPage.getByPlaceholder('Prize').fill(updatedPrize)

await adminPage.waitForSelector('text=Update reward', { state: 'visible' });
await adminPage.getByText('Update reward').click()
await adminPage.waitForLoadState('networkidle');

// Delete
await adminPage.waitForSelector('text=Delete', { state: 'visible' });
await adminPage.getByText('Delete').first().click()
})
await adminPage.waitForLoadState('networkidle');
})
29 changes: 27 additions & 2 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, useEffect } from '@common'
import { colors } from '@theme'
import { LearningPath, ParticipantStudy } from '@api'
import { Page } from '@components'
Expand All @@ -18,16 +18,40 @@ import {
Text,
Title,
} 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';
import { notifications } from '@mantine/notifications';

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

const study = useLoaderData() as ParticipantStudy
const learningPathStudies = useLearningPathStudies(study?.learningPath)

const showEarnedPointsNotification = (points: number) => {
notifications.show({
title: `You just earned ${points} points!`,
message: 'The longer the study, the more points you earn. Reach 200 points to unlock additional rewards.',
icon: <IconCheck size="1.1rem" />,
color: 'teal',
autoClose: 5000,
styles: () => ({
description: { fontSize: '12px' },
}),
});
};

useEffect(() => {
if (study.totalPoints > 0) {
const timer = setTimeout(() => {
showEarnedPointsNotification(study.totalPoints);
}, 100);

return () => clearTimeout(timer);
}
}, [study.totalPoints]);

if (!study || !study.learningPath) {
return <Navigate to='/studies' />
}
Expand All @@ -44,6 +68,7 @@ export default function StudyLanding() {
<LearningPathProgress learningPath={study.learningPath} studies={learningPathStudies} />
}
</Card>

</Page>
)
}
Expand Down

0 comments on commit 4171dde

Please sign in to comment.