diff --git a/src/components/Action/ActionDone.tsx b/src/components/Action/ActionDone.tsx index 63355806a52321b3166855e3ac35da05f17d8876..749803180eddfc5b2598c143ebc21ead5d67c78a 100644 --- a/src/components/Action/ActionDone.tsx +++ b/src/components/Action/ActionDone.tsx @@ -11,6 +11,7 @@ import { useHistory } from 'react-router-dom' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import starFilled from 'assets/icons/visu/challenge/starFilled.svg' import './actionDone.scss' +import { toogleChallengeActionNotification } from 'store/global/global.actions' interface ActionDoneProps { currentChallenge: UserChallenge } @@ -28,6 +29,7 @@ const ActionDone: React.FC<ActionDoneProps> = ({ currentChallenge, UserChallengeUpdateFlag.ACTION_DONE ) + dispatch(toogleChallengeActionNotification(false)) dispatch(updateUserChallengeList(updatedChallenge)) history.goBack() }, [currentChallenge, dispatch, client, history]) diff --git a/src/components/Action/ActionList.tsx b/src/components/Action/ActionList.tsx index c3f2cf6ef1713895ba47c4a055568550d8f70233..8e1dd62322162d56377207995842acffa2895eaa 100644 --- a/src/components/Action/ActionList.tsx +++ b/src/components/Action/ActionList.tsx @@ -41,7 +41,7 @@ const ActionList: React.FC<ActionListProps> = ({ return () => { subscribed = false } - }, [client, isProfileTypeCompleted, fluidTypes, actions]) + }, [client, isProfileTypeCompleted, fluidTypes]) return ( <> diff --git a/src/components/Challenge/ChallengeCardOnGoing.tsx b/src/components/Challenge/ChallengeCardOnGoing.tsx index 93979bf0a6e0eefa23d85d713d39ec82c08fa2c3..70538bfe1374bfc3a7a177e91c648cf5f2fce50d 100644 --- a/src/components/Challenge/ChallengeCardOnGoing.tsx +++ b/src/components/Challenge/ChallengeCardOnGoing.tsx @@ -114,11 +114,33 @@ const ChallengeCardOnGoing: React.FC<ChallengeCardOnGoingProps> = ({ setisDone(isDone) } } + const unlockDuel = async () => { + if ( + userChallenge.duel.state === UserDuelState.LOCKED && + userChallenge.progress.actionProgress === 5 && + userChallenge.progress.quizProgress === 5 && + userChallenge.progress.explorationProgress === 5 + ) { + const updatedChallenge = await challengeService.updateUserChallenge( + { + ...userChallenge, + progress: { + ...userChallenge.progress, + explorationProgress: 5, + actionProgress: 5, + }, + }, + UserChallengeUpdateFlag.DUEL_UNLOCK + ) + dispatch(updateUserChallengeList(updatedChallenge)) + } + } + unlockDuel() setChallengeResult() return () => { subscribed = false } - }, [client, currentDataload, userChallenge]) + }, [client, currentDataload, userChallenge, dispatch]) return ( <div className="cardContent onGoing"> diff --git a/src/components/Exploration/ExplorationFinished.tsx b/src/components/Exploration/ExplorationFinished.tsx index 0b6f2aea89874d91c3160e79fe258feb7d1a8bab..5ca43d11b9eb6c3e0787eca72cf2590a7674da65 100644 --- a/src/components/Exploration/ExplorationFinished.tsx +++ b/src/components/Exploration/ExplorationFinished.tsx @@ -12,7 +12,7 @@ import { updateUserChallengeList } from 'store/challenge/challenge.actions' import ChallengeService from 'services/challenge.service' import { Client, useClient } from 'cozy-client' import { useDispatch } from 'react-redux' -import { toogleChallengeNotification } from 'store/global/global.actions' +import { toogleChallengeExplorationNotification } from 'store/global/global.actions' interface ExplorationFinishedProps { userChallenge: UserChallenge @@ -33,7 +33,7 @@ const ExplorationFinished: React.FC<ExplorationFinishedProps> = ({ userChallenge, UserChallengeUpdateFlag.EXPLORATION_DONE ) - dispatch(toogleChallengeNotification(false)) + dispatch(toogleChallengeExplorationNotification(false)) dispatch(updateUserChallengeList(updatedChallenge)) } }, [client, dispatch, userChallenge]) diff --git a/src/components/Hooks/useExploration.tsx b/src/components/Hooks/useExploration.tsx index 645075018a729533167f260dbeb195deca28c00b..3b88c07629296d89a2c33767bf8fcca44525196c 100644 --- a/src/components/Hooks/useExploration.tsx +++ b/src/components/Hooks/useExploration.tsx @@ -7,7 +7,7 @@ import { AppStore } from 'store' import ExplorationService from 'services/exploration.service' import { updateUserChallengeList } from 'store/challenge/challenge.actions' import { UserExplorationState } from 'enum/userExploration.enum' -import { toogleChallengeNotification } from 'store/global/global.actions' +import { toogleChallengeExplorationNotification } from 'store/global/global.actions' const useExploration = (): [string, Dispatch<SetStateAction<string>>] => { const client: Client = useClient() @@ -41,7 +41,7 @@ const useExploration = (): [string, Dispatch<SetStateAction<string>>] => { updatedChallenge.exploration.state === UserExplorationState.NOTIFICATION ) { - dispatch(toogleChallengeNotification(true)) + dispatch(toogleChallengeExplorationNotification(true)) } }) if (subscribed) setExplorationID('') diff --git a/src/components/Konnector/KonnectorViewerCard.tsx b/src/components/Konnector/KonnectorViewerCard.tsx index 246f901c4c527051e43ca6790d96ec4e0869af5c..f44a93d38bd922d4dbb245b684b6d8562f963da0 100644 --- a/src/components/Konnector/KonnectorViewerCard.tsx +++ b/src/components/Konnector/KonnectorViewerCard.tsx @@ -21,7 +21,7 @@ import { updateProfile } from 'store/profile/profile.actions' import { setChallengeConsumption } from 'store/challenge/challenge.actions' import { setFluidStatus, - toogleChallengeNotification, + toogleChallengeDuelNotification, updatedFluidConnection, } from 'store/global/global.actions' import FluidService from 'services/fluid.service' @@ -124,7 +124,7 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ updatedUserChallenge, dataloads ) - dispatch(toogleChallengeNotification(isDone)) + dispatch(toogleChallengeDuelNotification(isDone)) } }, [client, dispatch, currentChallenge]) diff --git a/src/components/Navbar/Navbar.spec.tsx b/src/components/Navbar/Navbar.spec.tsx index ce1cf6c10e77811c0315ca0330c26ada5d90fe3a..62bd7a354398745acdc9a8c3ea94b723d8495bea 100644 --- a/src/components/Navbar/Navbar.spec.tsx +++ b/src/components/Navbar/Navbar.spec.tsx @@ -40,7 +40,9 @@ describe('Navbar component', () => { ecolyo: { global: { ...globalStateData, - challengeNotification: true, + challengeExplorationNotification: true, + challengeActionNotification: false, + challengeDuelNotification: false, analysisNotification: true, }, }, @@ -71,7 +73,9 @@ describe('Navbar component', () => { ecolyo: { global: { ...globalStateData, - challengeNotification: false, + challengeExplorationNotification: false, + challengeActionNotification: false, + challengeDuelNotification: false, analysisNotification: false, }, }, diff --git a/src/components/Navbar/Navbar.tsx b/src/components/Navbar/Navbar.tsx index f6e0989777f7ea87905b3afe1b13ee4061dbb19d..0105eaec112dd27a4a6315725fa9a6c74fb0ff3b 100644 --- a/src/components/Navbar/Navbar.tsx +++ b/src/components/Navbar/Navbar.tsx @@ -23,9 +23,12 @@ import './navBar.scss' export const Navbar: React.FC = () => { const { t } = useI18n() - const { challengeNotification, analysisNotification } = useSelector( - (state: AppStore) => state.ecolyo.global - ) + const { + challengeExplorationNotification, + challengeActionNotification, + challengeDuelNotification, + analysisNotification, + } = useSelector((state: AppStore) => state.ecolyo.global) return ( <aside className="o-sidebar"> @@ -48,7 +51,9 @@ export const Navbar: React.FC = () => { className="c-nav-link" activeClassName="is-active" > - {challengeNotification && <div className="nb-notif">1</div>} + {(challengeExplorationNotification || + challengeActionNotification || + challengeDuelNotification) && <div className="nb-notif">1</div>} <StyledIcon className="c-nav-icon off" icon={ChallengeIconOff} /> <StyledIcon className="c-nav-icon on" icon={ChallengeIconOn} /> {t('Nav.challenges')} diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index 7007fba8b5cdd528ad29f1f1f23b610c3360c53f..350e8b85f3a4c1b2e3c1da20420b140c6cd53d3b 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -4,13 +4,16 @@ import classNames from 'classnames' import { useDispatch } from 'react-redux' import { toogleAnalysisNotification, - toogleChallengeNotification, + toogleChallengeExplorationNotification, + toogleChallengeActionNotification, + toogleChallengeDuelNotification, setFluidStatus, } from 'store/global/global.actions' import { updateProfile } from 'store/profile/profile.actions' import { setUserChallengeList, setChallengeConsumption, + updateUserChallengeList, } from 'store/challenge/challenge.actions' import { setSelectedDate } from 'store/chart/chart.actions' import InitializationService from 'services/initialization.service' @@ -26,6 +29,7 @@ import { import { DateTime } from 'luxon' import { UserActionState } from 'enum/userAction.enum' import ActionService from 'services/action.service' +import { UserChallenge } from 'models' interface SplashRootProps { fadeTimer?: number @@ -157,7 +161,7 @@ const SplashRoot = ({ filteredCurrentOngoingChallenge[0].exploration.state === UserExplorationState.NOTIFICATION ) { - dispatch(toogleChallengeNotification(true)) + dispatch(toogleChallengeExplorationNotification(true)) } // Set Notification if action state is notification if ( @@ -166,10 +170,13 @@ const SplashRoot = ({ UserActionState.ONGOING ) { const actionService = new ActionService(client) - const isActionDone: boolean = await actionService.isActionDone( + const updatedUserChallenge: UserChallenge | null = await actionService.isActionDone( filteredCurrentOngoingChallenge[0] ) - dispatch(toogleChallengeNotification(isActionDone)) + if (updatedUserChallenge) { + dispatch(updateUserChallengeList(updatedUserChallenge)) + dispatch(toogleChallengeActionNotification(true)) + } } const filteredCurrentDuelChallenge = userChallengeList.filter( challenge => challenge.state === UserChallengeState.DUEL @@ -192,7 +199,7 @@ const SplashRoot = ({ updatedUserChallenge, dataloads ) - dispatch(toogleChallengeNotification(isDone)) + dispatch(toogleChallengeDuelNotification(isDone)) } } } diff --git a/src/enum/ecogesture.enum.ts b/src/enum/ecogesture.enum.ts index 20f16f7383ba08ed5e7ffa792e2b51c5555d4762..7cb2f7c697701f193fde6e3c1bf170819448f85a 100644 --- a/src/enum/ecogesture.enum.ts +++ b/src/enum/ecogesture.enum.ts @@ -17,9 +17,9 @@ export enum Room { } export enum Season { - NONE = 0, - WINTER = 1, - SUMMER = 2, + NONE = 'Sans saison', + WINTER = 'Hiver', + SUMMER = 'Eté', } export enum EquipmentType { diff --git a/src/models/global.model.ts b/src/models/global.model.ts index c484c173016792d8a7a2caf8bdf5794b308b91d8..61ea639d01c91956e4a4913b7013c3cf1c27a47c 100644 --- a/src/models/global.model.ts +++ b/src/models/global.model.ts @@ -4,7 +4,9 @@ import { FluidStatus } from './fluid.model' export interface GlobalState { screenType: ScreenType - challengeNotification: boolean + challengeExplorationNotification: boolean + challengeActionNotification: boolean + challengeDuelNotification: boolean analysisNotification: boolean fluidStatus: FluidStatus[] fluidTypes: FluidType[] diff --git a/src/services/action.service.ts b/src/services/action.service.ts index 31371b6ad14c2c701338dfef6305a898ceabbcc4..9257c982f630cb6b699c00027cab6e6ade2cfca0 100644 --- a/src/services/action.service.ts +++ b/src/services/action.service.ts @@ -154,7 +154,10 @@ export default class ActionService { filteredList = actionList.filter( action => action.season === Season.SUMMER ) - filteredList = this.completeWithNoSeason(filteredList, actionList) + filteredList = this.completeWithNoSeason(filteredList, actionList).slice( + 0, + 3 + ) } else if ( winterStartOfYear.contains(currentDate) || winterEndofYear.contains(currentDate) @@ -166,7 +169,6 @@ export default class ActionService { } else { filteredList = actionList.filter(action => action.season === Season.NONE) } - return filteredList } @@ -183,7 +185,10 @@ export default class ActionService { action.fluidTypes.some(fluid => connectedFluids.includes(fluid)) ) let filteredBySeason: Ecogesture[] = this.filterBySeason(filteredByFluid) - if (filteredBySeason.length < 3) { + + if (filteredBySeason.length > 3) { + filteredBySeason = filteredBySeason.slice(0, 3) + } else if (filteredBySeason.length < 3) { filteredBySeason = await this.keepListComplete(filteredBySeason) } @@ -244,9 +249,11 @@ export default class ActionService { /** * isActionDone - Set Action state to notification if progress > actionDuration * @param {UserChallenge} currentChallenge - * @returns {Promise<boolean>} + * @returns {Promise<UserChallenge | null>} */ - public async isActionDone(currentChallenge: UserChallenge): Promise<boolean> { + public async isActionDone( + currentChallenge: UserChallenge + ): Promise<UserChallenge | null> { if ( currentChallenge.action.startDate && currentChallenge.action.ecogesture @@ -257,12 +264,12 @@ export default class ActionService { const progressInHours = -startDate.diffNow('hours').hours if (progressInHours > durationInHours) { const challengeService = new ChallengeService(this._client) - await challengeService.updateUserChallenge( + const userChallenge: UserChallenge = await challengeService.updateUserChallenge( currentChallenge, UserChallengeUpdateFlag.ACTION_NOTIFICATION ) - return true - } else return false - } else return false + return userChallenge + } else return null + } else return null } } diff --git a/src/store/challenge/challenge.actions.ts b/src/store/challenge/challenge.actions.ts index 6ed42b01f95085f03bf93bf78e6657b48de52a4b..a685f415500e36444281374b20cffb3ffefaf819 100644 --- a/src/store/challenge/challenge.actions.ts +++ b/src/store/challenge/challenge.actions.ts @@ -10,7 +10,7 @@ interface SetUserChallengeList { payload?: UserChallenge[] } -interface UserChallengeUpdateFlag { +interface UpdateUserChallengeList { type: typeof UPDATE_USER_CHALLENGE_LIST payload?: UserChallenge } @@ -27,7 +27,7 @@ interface SetChallengeConsumption { export type ChallengeActionTypes = | SetUserChallengeList - | UserChallengeUpdateFlag + | UpdateUserChallengeList | UnlockNextUserChallenge | SetChallengeConsumption diff --git a/src/store/global/global.action.spec.ts b/src/store/global/global.action.spec.ts index de12d00127d74fb1d01fdfd4aa838198c0e436cc..5a7db613eec2681ef619976b5e3eb2f3bbf3179b 100644 --- a/src/store/global/global.action.spec.ts +++ b/src/store/global/global.action.spec.ts @@ -1,11 +1,16 @@ import { ScreenType } from 'enum/screen.enum' +import { mockInitialGlobalState } from '../../../test/__mocks__/store' import { CHANGE_SCREEN_TYPE, - TOOGLE_CHALLENGE_NOTIFICATION, + TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION, + TOOGLE_CHALLENGE_ACTION_NOTIFICATION, + TOOGLE_CHALLENGE_DUEL_NOTIFICATION, TOOGLE_ANALYSIS_NOTIFICATION, SET_FLUID_STATUS, changeScreenType, - toogleChallengeNotification, + toogleChallengeExplorationNotification, + toogleChallengeActionNotification, + toogleChallengeDuelNotification, toogleAnalysisNotification, setFluidStatus, } from './global.actions' @@ -20,13 +25,37 @@ describe('global actions', () => { expect(changeScreenType(screenType)).toEqual(expectedAction) }) - it('should create an action to toogle challenge notification', () => { + it('should create an action to toogle challenge exploration notification', () => { const notification = true const expectedAction = { - type: TOOGLE_CHALLENGE_NOTIFICATION, + type: TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION, payload: notification, } - expect(toogleChallengeNotification(notification)).toEqual(expectedAction) + expect(toogleChallengeExplorationNotification(notification)).toEqual( + expectedAction + ) + }) + + it('should create an action to toogle challenge action notification', () => { + const notification = true + const expectedAction = { + type: TOOGLE_CHALLENGE_ACTION_NOTIFICATION, + payload: notification, + } + expect(toogleChallengeActionNotification(notification)).toEqual( + expectedAction + ) + }) + + it('should create an action to toogle challenge duel notification', () => { + const notification = true + const expectedAction = { + type: TOOGLE_CHALLENGE_DUEL_NOTIFICATION, + payload: notification, + } + expect(toogleChallengeDuelNotification(notification)).toEqual( + expectedAction + ) }) it('should create an action to toogle analysis notification', () => { @@ -39,23 +68,7 @@ describe('global actions', () => { }) it('should create an action to set fluid status', () => { - const fluidStatus = [ - { - fluidType: 0, - status: null, - lastDataDate: null, - }, - { - fluidType: 1, - status: null, - lastDataDate: null, - }, - { - fluidType: 2, - status: null, - lastDataDate: null, - }, - ] + const fluidStatus = mockInitialGlobalState.fluidStatus const expectedAction = { type: SET_FLUID_STATUS, payload: fluidStatus, diff --git a/src/store/global/global.actions.ts b/src/store/global/global.actions.ts index 0318af22974eb29c1956f4144b188e7e33deb2eb..2e3d82c40657a68321d231c6d77b0d8bcb5721dd 100644 --- a/src/store/global/global.actions.ts +++ b/src/store/global/global.actions.ts @@ -3,7 +3,12 @@ import { ScreenType } from 'enum/screen.enum' import { FluidConnection, FluidStatus } from 'models' export const CHANGE_SCREEN_TYPE = 'CHANGE_SCREEN_TYPE' -export const TOOGLE_CHALLENGE_NOTIFICATION = 'TOOGLE_CHALLENGE_NOTIFICATION' +export const TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION = + 'TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION' +export const TOOGLE_CHALLENGE_ACTION_NOTIFICATION = + 'TOOGLE_CHALLENGE_ACTION_NOTIFICATION' +export const TOOGLE_CHALLENGE_DUEL_NOTIFICATION = + 'TOOGLE_CHALLENGE_DUEL_NOTIFICATION' export const TOOGLE_ANALYSIS_NOTIFICATION = 'TOOGLE_ANALYSIS_NOTIFICATION' export const SET_FLUID_STATUS = 'SET_FLUID_STATUS' export const UPDATE_FLUID_CONNECTION = 'UPDATE_FLUID_CONNECTION' @@ -13,8 +18,18 @@ interface ChangeScreenType { payload?: ScreenType } -interface ToogleChallengeNotification { - type: typeof TOOGLE_CHALLENGE_NOTIFICATION +interface ToogleChallengeExplorationNotification { + type: typeof TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION + payload?: boolean +} + +interface ToogleChallengeActionNotification { + type: typeof TOOGLE_CHALLENGE_ACTION_NOTIFICATION + payload?: boolean +} + +interface ToogleChallengeDuelNotification { + type: typeof TOOGLE_CHALLENGE_DUEL_NOTIFICATION payload?: boolean } @@ -35,7 +50,9 @@ interface UpdatedFluidConnection { export type GlobalActionTypes = | ChangeScreenType - | ToogleChallengeNotification + | ToogleChallengeExplorationNotification + | ToogleChallengeActionNotification + | ToogleChallengeDuelNotification | ToogleAnalysisNotification | SetFluidStatus | UpdatedFluidConnection @@ -47,9 +64,29 @@ export function changeScreenType(screenType: ScreenType): GlobalActionTypes { } } -export function toogleChallengeNotification(notif: boolean): GlobalActionTypes { +export function toogleChallengeExplorationNotification( + notif: boolean +): GlobalActionTypes { + return { + type: TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION, + payload: notif, + } +} + +export function toogleChallengeActionNotification( + notif: boolean +): GlobalActionTypes { + return { + type: TOOGLE_CHALLENGE_ACTION_NOTIFICATION, + payload: notif, + } +} + +export function toogleChallengeDuelNotification( + notif: boolean +): GlobalActionTypes { return { - type: TOOGLE_CHALLENGE_NOTIFICATION, + type: TOOGLE_CHALLENGE_DUEL_NOTIFICATION, payload: notif, } } diff --git a/src/store/global/global.reducer.spec.ts b/src/store/global/global.reducer.spec.ts index 4c11a3dbbe89a487921f0f3295198b2a95341f71..88790f01fc37b076a26ccc885cb41a6879ce3339 100644 --- a/src/store/global/global.reducer.spec.ts +++ b/src/store/global/global.reducer.spec.ts @@ -1,7 +1,9 @@ import { globalReducer } from './global.reducer' import { CHANGE_SCREEN_TYPE, - TOOGLE_CHALLENGE_NOTIFICATION, + TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION, + TOOGLE_CHALLENGE_ACTION_NOTIFICATION, + TOOGLE_CHALLENGE_DUEL_NOTIFICATION, TOOGLE_ANALYSIS_NOTIFICATION, SET_FLUID_STATUS, } from './global.actions' @@ -51,20 +53,56 @@ describe('global reducer', () => { expect(result).toEqual(mockInitialGlobalState) }) - it('should handle TOOGLE_CHALLENGE_NOTIFICATION with payload', () => { + it('should handle TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION with payload', () => { const result = globalReducer(mockInitialGlobalState, { - type: TOOGLE_CHALLENGE_NOTIFICATION, + type: TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION, payload: true, }) expect(result).toEqual({ ...mockInitialGlobalState, - challengeNotification: true, + challengeExplorationNotification: true, }) }) - it('should handle TOOGLE_CHALLENGE_NOTIFICATION without payload', () => { + it('should handle TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION without payload', () => { const result = globalReducer(mockInitialGlobalState, { - type: TOOGLE_CHALLENGE_NOTIFICATION, + type: TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION, + }) + expect(result).toEqual(mockInitialGlobalState) + }) + + it('should handle TOOGLE_CHALLENGE_ACTION_NOTIFICATION with payload', () => { + const result = globalReducer(mockInitialGlobalState, { + type: TOOGLE_CHALLENGE_ACTION_NOTIFICATION, + payload: true, + }) + expect(result).toEqual({ + ...mockInitialGlobalState, + challengeActionNotification: true, + }) + }) + + it('should handle TOOGLE_CHALLENGE_ACTION_NOTIFICATION without payload', () => { + const result = globalReducer(mockInitialGlobalState, { + type: TOOGLE_CHALLENGE_ACTION_NOTIFICATION, + }) + expect(result).toEqual(mockInitialGlobalState) + }) + + it('should handle TOOGLE_CHALLENGE_DUEL_NOTIFICATION with payload', () => { + const result = globalReducer(mockInitialGlobalState, { + type: TOOGLE_CHALLENGE_DUEL_NOTIFICATION, + payload: true, + }) + expect(result).toEqual({ + ...mockInitialGlobalState, + challengeDuelNotification: true, + }) + }) + + it('should handle TOOGLE_CHALLENGE_DUEL_NOTIFICATION without payload', () => { + const result = globalReducer(mockInitialGlobalState, { + type: TOOGLE_CHALLENGE_DUEL_NOTIFICATION, }) expect(result).toEqual(mockInitialGlobalState) }) @@ -105,6 +143,7 @@ describe('global reducer', () => { oauth: true, slug: 'enedisgrandlyon', siteLink: 'https://mon-compte-particulier.enedis.fr/donnees/', + activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, }, }, @@ -124,6 +163,7 @@ describe('global reducer', () => { oauth: false, slug: 'eglgrandlyon', siteLink: 'https://agence.eaudugrandlyon.com/inscription.aspx', + activation: '', }, }, }, @@ -143,6 +183,7 @@ describe('global reducer', () => { oauth: true, slug: 'grdfgrandlyon', siteLink: 'https://monespace.grdf.fr/monespace/connexion', + activation: '', }, }, }, diff --git a/src/store/global/global.reducer.ts b/src/store/global/global.reducer.ts index 43d5807191ce2cce65368431cbac74dddb78a076..ce4c3f740322c93f59a9e77eec98e1a2cd80f0fb 100644 --- a/src/store/global/global.reducer.ts +++ b/src/store/global/global.reducer.ts @@ -1,7 +1,9 @@ import { Reducer } from 'redux' import { CHANGE_SCREEN_TYPE, - TOOGLE_CHALLENGE_NOTIFICATION, + TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION, + TOOGLE_CHALLENGE_ACTION_NOTIFICATION, + TOOGLE_CHALLENGE_DUEL_NOTIFICATION, TOOGLE_ANALYSIS_NOTIFICATION, SET_FLUID_STATUS, GlobalActionTypes, @@ -13,7 +15,9 @@ import { FluidState, FluidType } from 'enum/fluid.enum' const initialState: GlobalState = { screenType: ScreenType.MOBILE, - challengeNotification: false, + challengeExplorationNotification: false, + challengeActionNotification: false, + challengeDuelNotification: false, analysisNotification: false, fluidStatus: [ { @@ -105,11 +109,25 @@ export const globalReducer: Reducer<GlobalState> = ( screenType: action.payload, } : state - case TOOGLE_CHALLENGE_NOTIFICATION: + case TOOGLE_CHALLENGE_EXPLORATION_NOTIFICATION: return action.payload != undefined ? { ...state, - challengeNotification: action.payload, + challengeExplorationNotification: action.payload, + } + : state + case TOOGLE_CHALLENGE_ACTION_NOTIFICATION: + return action.payload != undefined + ? { + ...state, + challengeActionNotification: action.payload, + } + : state + case TOOGLE_CHALLENGE_DUEL_NOTIFICATION: + return action.payload != undefined + ? { + ...state, + challengeDuelNotification: action.payload, } : state case TOOGLE_ANALYSIS_NOTIFICATION: diff --git a/src/utils/hash.spec.ts b/src/utils/hash.spec.ts index d830bccd1f2411c5312f97fad9197e8f3598d466..0ecb357dad24df313b8dae884696998365037d43 100644 --- a/src/utils/hash.spec.ts +++ b/src/utils/hash.spec.ts @@ -5,7 +5,7 @@ describe('hash utilis test', () => { describe('hashFile test', () => { it('should return the correct hash of the file', () => { const result = hashFile(ecogesturesData) - expect(result).toBe('57e829c5cab3187b1bc6c1aaefb9db03d364290c') + expect(result).toBe('8360d4805f19a732e6b43a41f972c324c8e06488') }) }) }) diff --git a/test/__mocks__/store.ts b/test/__mocks__/store.ts index 7b68309ca77be645ad37d5d10244eb096481e53f..e43fab87dd2edd657449e4477d2faa6e7001f2fe 100644 --- a/test/__mocks__/store.ts +++ b/test/__mocks__/store.ts @@ -25,7 +25,9 @@ import mockClient from './client' export const mockInitialGlobalState: GlobalState = { screenType: ScreenType.MOBILE, - challengeNotification: false, + challengeExplorationNotification: false, + challengeActionNotification: false, + challengeDuelNotification: false, analysisNotification: false, fluidStatus: [ {