-
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
29 changed files
with
217 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import useAuth from "@/services/useAuth"; | ||
import { getCohort } from "@/utils/cohorts"; | ||
import useCohort from "@/services/useCohort"; | ||
import { YOUNG_SOURCE, YOUNG_STATUS } from "snu-lib"; | ||
|
||
export default function usePermissions() { | ||
const { young } = useAuth(); | ||
const cohort = getCohort(young.cohort); | ||
const { cohort } = useCohort(); | ||
|
||
return { | ||
hasAccessToAVenir: young.source === YOUNG_SOURCE.VOLONTAIRE, | ||
hasAccessToDesistement: young.status !== YOUNG_STATUS.WITHDRAWN && young.status !== YOUNG_STATUS.ABANDONED, | ||
canModifyInscription: new Date() < new Date(cohort.inscriptionModificationEndDate), | ||
hasAccessToNavigation: ![YOUNG_STATUS.IN_PROGRESS, YOUNG_STATUS.REINSCRIPTION].includes(young.status), | ||
canModifyInscription: cohort.inscriptionModificationEndDate ? new Date() < new Date(cohort.inscriptionModificationEndDate) : false, | ||
hasAccessToNavigation: ![YOUNG_STATUS.IN_PROGRESS, YOUNG_STATUS.REINSCRIPTION].includes(young.status as any), | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { CohortType } from "snu-lib"; | ||
|
||
export const authActions = { | ||
SETCOHORT: "SETCOHORT", | ||
}; | ||
|
||
export function setCohort(cohort?: CohortType) { | ||
return { type: authActions.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { CohortType } from "snu-lib"; | ||
|
||
import { authActions } from "./actions"; | ||
|
||
type Action = { | ||
type: string; | ||
cohort?: CohortType; | ||
}; | ||
|
||
export type CohortState = { | ||
// TODO: use API route response | ||
Cohort: { | ||
cohort: CohortType; | ||
}; | ||
}; | ||
|
||
const initState = { | ||
cohort: null, | ||
}; | ||
|
||
export default function reducer(state = initState, action: Action) { | ||
switch (action.type) { | ||
case authActions.SETCOHORT: | ||
return { ...state, cohort: action.cohort }; | ||
default: | ||
return state; | ||
} | ||
} |
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,5 +1,6 @@ | ||
import { reducer as toastr } from "react-redux-toastr"; | ||
|
||
import Auth from "./auth/reducer"; | ||
import Cohort from "./cohort/reducer"; | ||
|
||
export default { Auth, toastr }; | ||
export default { Auth, Cohort, toastr }; |
File renamed without changes.
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.