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

Migrate to Redux Toolkit part 7 #2971

Merged
merged 27 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
63e976a
Migrate `evalStory` handler to Stories Saga
RichDom2185 May 1, 2024
1a41c13
Add Redux utils
RichDom2185 May 1, 2024
84bda56
Migrate some stories actions to use helper
RichDom2185 May 1, 2024
745644e
Migrate more stories actions to use helper
RichDom2185 May 1, 2024
b68f224
Fix old reducer/actions helper compatibility issues
RichDom2185 May 1, 2024
130413d
Migrate new stories users handler to BackendSaga
RichDom2185 May 1, 2024
2b3a612
Migrate StoriesSaga to use helper
RichDom2185 May 1, 2024
4411523
Fix tests
RichDom2185 May 1, 2024
323de07
Fix compile errors
RichDom2185 May 1, 2024
6b35854
Remove unnecessary rootReducer creator
RichDom2185 May 1, 2024
75f6e1a
Fix combineSagaHandlers
chownces May 2, 2024
2620156
Merge branch 'master' into rtk-7
RichDom2185 May 3, 2024
39e7707
Migrate SessionActions to use helper
RichDom2185 May 3, 2024
2f46312
Merge branch 'master' into rtk-7
RichDom2185 May 3, 2024
35f4425
Merge branch 'rtk-7' of https://github.com/source-academy/frontend in…
RichDom2185 May 3, 2024
85684c7
Remove old session types
RichDom2185 May 3, 2024
2cc5cd4
Update tests and non-related sagas
RichDom2185 May 3, 2024
8f43026
Fix SessionActions compatibility with ActionsHelper
RichDom2185 May 3, 2024
5a46479
Comment out most of mock backend saga
RichDom2185 May 3, 2024
570eaad
Fix SessionReducer tests
RichDom2185 May 3, 2024
b5e581c
Use action creator in components
RichDom2185 May 3, 2024
4bd9c8b
Merge branch 'master' into rtk-7
RichDom2185 May 3, 2024
38e43e8
Merge branch 'master' into rtk-7
RichDom2185 May 3, 2024
79e1524
Migrate BackendSaga to use new helpers
RichDom2185 May 3, 2024
b6f0771
Update backend saga tests
RichDom2185 May 3, 2024
b6d2f68
Remove duplicate action types
RichDom2185 May 3, 2024
a6eeaf2
Migrate mock backend to RTK action types
RichDom2185 May 3, 2024
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
6 changes: 3 additions & 3 deletions src/commons/achievement/AchievementOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { AchievementUser } from 'src/features/achievement/AchievementTypes';

import { FETCH_TOTAL_XP, FETCH_TOTAL_XP_ADMIN } from '../application/types/SessionTypes';
import { fetchTotalXp, fetchTotalXpAdmin } from '../application/actions/SessionActions';
import { useTypedSelector } from '../utils/Hooks';
import AchievementLevel from './overview/AchievementLevel';

Expand All @@ -20,9 +20,9 @@ const AchievementOverview: React.FC<Props> = ({ name, userState }) => {
useEffect(() => {
// If user is student, fetch assessment details from assessment route instead, as seen below
if (crid && crid !== userCrid) {
dispatch({ type: FETCH_TOTAL_XP_ADMIN, payload: crid });
dispatch(fetchTotalXpAdmin(crid));
} else {
dispatch({ type: FETCH_TOTAL_XP });
dispatch(fetchTotalXp());
}
}, [crid, userCrid, dispatch]);

Expand Down
15 changes: 10 additions & 5 deletions src/commons/achievement/AchievementView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import {
getAbilityGlow
} from '../../features/achievement/AchievementConstants';
import { AchievementStatus, AchievementUser } from '../../features/achievement/AchievementTypes';
import { FETCH_ASSESSMENT, FETCH_ASSESSMENT_ADMIN } from '../application/types/SessionTypes';
import { Assessment, FETCH_ASSESSMENT_OVERVIEWS } from '../assessment/AssessmentTypes';
import {
fetchAssessment,
fetchAssessmentAdmin,
fetchAssessmentOverviews
} from '../application/actions/SessionActions';
import { Assessment } from '../assessment/AssessmentTypes';
import { useTypedSelector } from '../utils/Hooks';
import AchievementCommentCard from './AchievementCommentCard';
import { prettifyDate } from './utils/DateHelper';
Expand All @@ -36,16 +40,17 @@ const AchievementView: React.FC<Props> = ({ focusUuid, userState }) => {

const dispatch = useDispatch();
useEffect(() => {
dispatch({ type: FETCH_ASSESSMENT_OVERVIEWS });
dispatch(fetchAssessmentOverviews());
if (!assessmentId) {
return;
}
if (isAdminView) {
// Fetch selected user's assessment from admin route
dispatch({ type: FETCH_ASSESSMENT_ADMIN, payload: { assessmentId, courseRegId } });
// Safe to use non-null assertion (refer to `isAdminView` declaration above)
dispatch(fetchAssessmentAdmin(assessmentId, courseRegId!));
} else {
// If user is student, fetch assessment details from assessment route instead, as seen below
dispatch({ type: FETCH_ASSESSMENT, payload: { assessmentId } });
dispatch(fetchAssessment(assessmentId));
}
}, [dispatch, assessmentId, courseRegId, isAdminView]);

Expand Down
Loading
Loading