Skip to content

Commit 5605718

Browse files
no courses found hint and fixed strict filtering not working
1 parent 0c46a28 commit 5605718

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/client/V2/CourseRecommendations.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Box, Stack } from '@mui/material'
22
import { CourseRecommendation } from '../../common/types'
33
import CourseRecommendationV2 from './CourseRecommendationV2'
44
import { useFilterContext } from './filterContext'
5+
import NoRecommendationsInfo from './components/NoRecommendationsInfo'
56

67
const CourseRecommendations = () => {
78
const { finalRecommendedCourses } = useFilterContext()
@@ -13,6 +14,11 @@ const CourseRecommendations = () => {
1314
if(!recommendations || !points){
1415
return (<></>)
1516
}
17+
18+
if(points.length === 0) {
19+
return <NoRecommendationsInfo />
20+
}
21+
1622
return (
1723
<Box>
1824
<Stack>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Box, Typography, Paper } from '@mui/material'
2+
3+
const NoRecommendationsInfo = () => {
4+
return (
5+
<Paper
6+
elevation={2}
7+
sx={{
8+
padding: 4,
9+
margin: 2,
10+
textAlign: 'center',
11+
backgroundColor: 'background.paper',
12+
}}
13+
>
14+
<Box>
15+
<Typography variant="h6" component="h2" gutterBottom>
16+
Kursseja ei löytynyt
17+
</Typography>
18+
<Typography variant="body1" color="textSecondary">
19+
Yritä muuttaa valintojasi nähdäksesi kursseja.
20+
</Typography>
21+
</Box>
22+
</Paper>
23+
)
24+
}
25+
26+
export default NoRecommendationsInfo

src/server/util/pointRecommendCourses.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ function pointRecommendedCourses(courses: CourseRecommendation[], userCoordinate
172172
}
173173

174174

175-
return {...c, points: points + bonusPoints}
175+
176+
return points >= 0 ? {...c, points: points + bonusPoints} : {...c, points}
176177
})
177178

178179
const filtered = recommendationWithPoints.filter((r) => r.points >= 0)

0 commit comments

Comments
 (0)