-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
126 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
import { fetchCohort } from "@/utils/cohorts"; | ||
import * as Sentry from "@sentry/react"; | ||
import { Dispatch } from "redux"; | ||
import { YoungType } from "snu-lib"; | ||
import { setCohort } from "../cohort/actions"; | ||
|
||
export const authActions = { | ||
SETYOUNG: "SETYOUNG", | ||
}; | ||
|
||
export function setYoung(young?: YoungType) { | ||
if (young) Sentry.setUser({ id: young._id, email: young.email, username: `${young.firstName} ${young.lastName}` }); | ||
else Sentry.setUser(null); | ||
return { type: authActions.SETYOUNG, young }; | ||
return async (dispatch: Dispatch, getState: () => any) => { | ||
const oldCohortId = getState().Auth.young?.cohortId; | ||
|
||
dispatch({ type: authActions.SETYOUNG, young }); | ||
|
||
// Side effects | ||
if (young) Sentry.setUser({ id: young._id, email: young.email, username: `${young.firstName} ${young.lastName}` }); | ||
else Sentry.setUser(null); | ||
|
||
const newCohortId = young?.cohortId; | ||
if (newCohortId && oldCohortId !== newCohortId) { | ||
const cohort = await fetchCohort(newCohortId); | ||
if (!cohort) return; | ||
console.log(`Updating stored cohort. New cohort name: ${cohort.name}`); | ||
dispatch(setCohort(cohort)); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { createStore, combineReducers } from "redux"; | ||
import { createStore, combineReducers, applyMiddleware, compose } from "redux"; | ||
import reducers from "./reducers"; | ||
import * as Sentry from "@sentry/react"; | ||
import thunk from "redux-thunk"; | ||
|
||
const sentryReduxEnhancer = Sentry.createReduxEnhancer(); | ||
const enhancer = compose(applyMiddleware(thunk), sentryReduxEnhancer); | ||
|
||
export default createStore(combineReducers({ ...reducers }), sentryReduxEnhancer); | ||
export default createStore(combineReducers({ ...reducers }), enhancer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.