From 697ab639cdda23cfd2e56692f98438d0960c7f79 Mon Sep 17 00:00:00 2001 From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com> Date: Tue, 15 Dec 2020 19:24:20 +0100 Subject: [PATCH] feat: change store & service season to challenge --- .../{Season => Challenge}/SeasonCard.spec.tsx | 24 ++--- .../{Season => Challenge}/SeasonCard.tsx | 28 ++--- .../SeasonCardDone.spec.tsx | 6 +- .../{Season => Challenge}/SeasonCardDone.tsx | 40 +++---- .../SeasonCardLocked.spec.tsx | 6 +- src/components/Challenge/SeasonCardLocked.tsx | 28 +++++ .../SeasonCardOnGoing.tsx | 68 ++++++------ .../SeasonCardUnlocked.spec.tsx | 22 ++-- .../SeasonCardUnlocked.tsx | 46 ++++---- .../SeasonNoFluidModal.spec.tsx | 8 +- .../SeasonNoFluidModal.tsx | 16 +-- .../{Season => Challenge}/SeasonView.spec.tsx | 6 +- .../{Season => Challenge}/SeasonView.tsx | 34 +++--- .../{Season => Challenge}/StarsContainer.tsx | 6 +- .../__snapshots__/SeasonCard.spec.tsx.snap | 8 +- .../SeasonCardDone.spec.tsx.snap | 16 +-- .../SeasonCardLocked.spec.tsx.snap | 12 +-- .../SeasonNoFluidModal.spec.tsx.snap | 12 +-- .../__snapshots__/SeasonView.spec.tsx.snap | 34 +++--- .../{Season => Challenge}/seasonCard.scss | 0 .../{Season => Challenge}/seasonCardDone.scss | 2 +- .../seasonCardLocked.scss | 2 +- .../seasonCardOnGoing.scss | 2 +- .../seasonCardUnlocked.scss | 2 +- .../seasonNoFluidModal.scss | 0 .../{Season => Challenge}/seasonView.scss | 6 +- .../Connection/ConnectionResult.tsx | 28 ++--- src/components/Duel/DuelOngoing.spec.tsx | 24 ++--- src/components/Duel/DuelOngoing.tsx | 38 +++---- src/components/Duel/DuelUnlocked.spec.tsx | 18 ++-- src/components/Duel/DuelUnlocked.tsx | 26 ++--- src/components/Duel/DuelView.spec.tsx | 10 +- src/components/Duel/DuelView.tsx | 17 +-- src/components/Navbar/Navbar.spec.tsx | 4 +- src/components/Navbar/Navbar.tsx | 4 +- src/components/Routes/Routes.tsx | 4 +- src/components/Season/SeasonCardLocked.tsx | 28 ----- src/components/Splash/SplashRoot.tsx | 32 +++--- src/db/profileData.json | 2 +- src/doctypes/index.ts | 4 +- src/enum/userChallenge.enum.ts | 2 +- src/enum/userSeason.enum.ts | 14 --- src/locales/fr.json | 2 +- src/models/challenge.model.ts | 2 +- src/models/global.model.ts | 2 +- src/models/profile.model.ts | 2 +- ...vice.spec.ts => challenge.service.spec.ts} | 88 ++++++++------- ...season.service.ts => challenge.service.ts} | 100 +++++++++--------- src/services/initialization.service.spec.ts | 8 +- src/services/initialization.service.ts | 44 ++++---- .../challenge.action.spec.ts} | 30 +++--- src/store/challenge/challenge.actions.ts | 69 ++++++++++++ .../challenge.reducer.spec.ts} | 72 ++++++------- .../challenge.reducer.ts} | 68 ++++++------ src/store/global/global.action.spec.ts | 10 +- src/store/global/global.actions.ts | 12 +-- src/store/global/global.reducer.spec.ts | 14 +-- src/store/global/global.reducer.ts | 8 +- src/store/index.ts | 6 +- src/store/profile/profile.reducer.spec.ts | 2 +- src/store/profile/profile.reducer.ts | 2 +- src/store/season/season.actions.ts | 69 ------------ src/utils/utils.ts | 8 +- test/__mocks__/challengeEntity.mock.ts | 24 ++--- test/__mocks__/challengeStateData.mock.ts | 4 +- test/__mocks__/globalStateData.mock.ts | 2 +- test/__mocks__/profile.mock.ts | 2 +- test/__mocks__/userChallengeData.mock.ts | 40 +++---- 68 files changed, 696 insertions(+), 683 deletions(-) rename src/components/{Season => Challenge}/SeasonCard.spec.tsx (69%) rename src/components/{Season => Challenge}/SeasonCard.tsx (54%) rename src/components/{Season => Challenge}/SeasonCardDone.spec.tsx (70%) rename src/components/{Season => Challenge}/SeasonCardDone.tsx (73%) rename src/components/{Season => Challenge}/SeasonCardLocked.spec.tsx (73%) create mode 100644 src/components/Challenge/SeasonCardLocked.tsx rename src/components/{Season => Challenge}/SeasonCardOnGoing.tsx (68%) rename src/components/{Season => Challenge}/SeasonCardUnlocked.spec.tsx (70%) rename src/components/{Season => Challenge}/SeasonCardUnlocked.tsx (53%) rename src/components/{Season => Challenge}/SeasonNoFluidModal.spec.tsx (69%) rename src/components/{Season => Challenge}/SeasonNoFluidModal.tsx (66%) rename src/components/{Season => Challenge}/SeasonView.spec.tsx (70%) rename src/components/{Season => Challenge}/SeasonView.tsx (85%) rename src/components/{Season => Challenge}/StarsContainer.tsx (81%) rename src/components/{Season => Challenge}/__snapshots__/SeasonCard.spec.tsx.snap (83%) rename src/components/{Season => Challenge}/__snapshots__/SeasonCardDone.spec.tsx.snap (67%) rename src/components/{Season => Challenge}/__snapshots__/SeasonCardLocked.spec.tsx.snap (55%) rename src/components/{Season => Challenge}/__snapshots__/SeasonNoFluidModal.spec.tsx.snap (75%) rename src/components/{Season => Challenge}/__snapshots__/SeasonView.spec.tsx.snap (88%) rename src/components/{Season => Challenge}/seasonCard.scss (100%) rename src/components/{Season => Challenge}/seasonCardDone.scss (97%) rename src/components/{Season => Challenge}/seasonCardLocked.scss (93%) rename src/components/{Season => Challenge}/seasonCardOnGoing.scss (99%) rename src/components/{Season => Challenge}/seasonCardUnlocked.scss (95%) rename src/components/{Season => Challenge}/seasonNoFluidModal.scss (100%) rename src/components/{Season => Challenge}/seasonView.scss (94%) delete mode 100644 src/components/Season/SeasonCardLocked.tsx delete mode 100644 src/enum/userSeason.enum.ts rename src/services/{season.service.spec.ts => challenge.service.spec.ts} (76%) rename src/services/{season.service.ts => challenge.service.ts} (82%) rename src/store/{season/season.action.spec.ts => challenge/challenge.action.spec.ts} (59%) create mode 100644 src/store/challenge/challenge.actions.ts rename src/store/{season/season.reducer.spec.ts => challenge/challenge.reducer.spec.ts} (62%) rename src/store/{season/season.reducer.ts => challenge/challenge.reducer.ts} (58%) delete mode 100644 src/store/season/season.actions.ts diff --git a/src/components/Season/SeasonCard.spec.tsx b/src/components/Challenge/SeasonCard.spec.tsx similarity index 69% rename from src/components/Season/SeasonCard.spec.tsx rename to src/components/Challenge/SeasonCard.spec.tsx index 387a6aff2..dcfdef0cf 100644 --- a/src/components/Season/SeasonCard.spec.tsx +++ b/src/components/Challenge/SeasonCard.spec.tsx @@ -1,9 +1,9 @@ import React from 'react' import { shallow } from 'enzyme' -import SeasonCard from './SeasonCard' -import SeasonCardLocked from './SeasonCardLocked' -import SeasonCardUnlocked from './SeasonCardUnlocked' -import SeasonCardOnGoing from './SeasonCardOnGoing' +import ChallengeCard from './ChallengeCard' +import ChallengeCardLocked from './ChallengeCardLocked' +import ChallengeCardUnlocked from './ChallengeCardUnlocked' +import ChallengeCardOnGoing from './ChallengeCardOnGoing' import { userChallengeData } from '../../../test/__mocks__/userChallengeData.mock' jest.mock('cozy-ui/transpiled/react/I18n', () => { @@ -16,10 +16,10 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { } }) -describe('SeasonCard component', () => { +describe('ChallengeCard component', () => { it('should be rendered correctly', () => { const component = shallow( - <SeasonCard + <ChallengeCard userChallenge={userChallengeData[1]} indexSlider={0} index={0} @@ -31,7 +31,7 @@ describe('SeasonCard component', () => { }) it('should render locked Card', () => { const wrapper = shallow( - <SeasonCard + <ChallengeCard userChallenge={userChallengeData[4]} indexSlider={0} index={0} @@ -39,11 +39,11 @@ describe('SeasonCard component', () => { cardHeight={400} /> ) - expect(wrapper.find(SeasonCardLocked).exists()).toBeTruthy() + expect(wrapper.find(ChallengeCardLocked).exists()).toBeTruthy() }) it('should render unlocked Card', () => { const wrapper = shallow( - <SeasonCard + <ChallengeCard userChallenge={userChallengeData[3]} indexSlider={0} index={0} @@ -51,11 +51,11 @@ describe('SeasonCard component', () => { cardHeight={400} /> ) - expect(wrapper.find(SeasonCardUnlocked).exists()).toBeTruthy() + expect(wrapper.find(ChallengeCardUnlocked).exists()).toBeTruthy() }) it('should render ongoing Card', () => { const wrapper = shallow( - <SeasonCard + <ChallengeCard userChallenge={userChallengeData[2]} indexSlider={0} index={0} @@ -63,6 +63,6 @@ describe('SeasonCard component', () => { cardHeight={400} /> ) - expect(wrapper.find(SeasonCardOnGoing).exists()).toBeTruthy() + expect(wrapper.find(ChallengeCardOnGoing).exists()).toBeTruthy() }) }) diff --git a/src/components/Season/SeasonCard.tsx b/src/components/Challenge/SeasonCard.tsx similarity index 54% rename from src/components/Season/SeasonCard.tsx rename to src/components/Challenge/SeasonCard.tsx index d2ad423c1..37066948c 100644 --- a/src/components/Season/SeasonCard.tsx +++ b/src/components/Challenge/SeasonCard.tsx @@ -1,39 +1,39 @@ import { UserChallengeState } from 'enum/userChallenge.enum' import { UserChallenge } from 'models' import React from 'react' -import SeasonCardDone from './SeasonCardDone' -import SeasonCardLocked from './SeasonCardLocked' -import SeasonCardOnGoing from './SeasonCardOnGoing' -import SeasonCardUnlocked from './SeasonCardUnlocked' -import './seasonCard.scss' +import ChallengeCardDone from './ChallengeCardDone' +import ChallengeCardLocked from './ChallengeCardLocked' +import ChallengeCardOnGoing from './ChallengeCardOnGoing' +import ChallengeCardUnlocked from './ChallengeCardUnlocked' +import './challengeCard.scss' -interface SeasonCardProps { +interface ChallengeCardProps { userChallenge: UserChallenge indexSlider: number index: number cardWidth: number cardHeight: number } -const SeasonCard: React.FC<SeasonCardProps> = ({ +const ChallengeCard: React.FC<ChallengeCardProps> = ({ userChallenge, indexSlider, index, cardWidth, cardHeight, -}: SeasonCardProps) => { +}: ChallengeCardProps) => { const renderCard = (state: UserChallengeState) => { switch (state) { case UserChallengeState.LOCKED: - return <SeasonCardLocked userChallenge={userChallenge} /> + return <ChallengeCardLocked userChallenge={userChallenge} /> case UserChallengeState.UNLOCKED: - return <SeasonCardUnlocked userChallenge={userChallenge} /> + return <ChallengeCardUnlocked userChallenge={userChallenge} /> case UserChallengeState.DONE: - return <SeasonCardDone userChallenge={userChallenge} /> + return <ChallengeCardDone userChallenge={userChallenge} /> case UserChallengeState.ONGOING: case UserChallengeState.BOSS: - return <SeasonCardOnGoing userChallenge={userChallenge} /> + return <ChallengeCardOnGoing userChallenge={userChallenge} /> default: - return <SeasonCardLocked userChallenge={userChallenge} /> + return <ChallengeCardLocked userChallenge={userChallenge} /> } } return ( @@ -50,4 +50,4 @@ const SeasonCard: React.FC<SeasonCardProps> = ({ ) } -export default SeasonCard +export default ChallengeCard diff --git a/src/components/Season/SeasonCardDone.spec.tsx b/src/components/Challenge/SeasonCardDone.spec.tsx similarity index 70% rename from src/components/Season/SeasonCardDone.spec.tsx rename to src/components/Challenge/SeasonCardDone.spec.tsx index b92b79333..140be575d 100644 --- a/src/components/Season/SeasonCardDone.spec.tsx +++ b/src/components/Challenge/SeasonCardDone.spec.tsx @@ -1,6 +1,6 @@ import React from 'react' import { shallow } from 'enzyme' -import SeasonCardDone from 'components/Season/SeasonCardDone' +import ChallengeCardDone from 'components/Challenge/ChallengeCardDone' import { userChallengeData } from '../../../test/__mocks__/userChallengeData.mock' jest.mock('cozy-ui/transpiled/react/I18n', () => { @@ -13,10 +13,10 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { } }) -describe('SeasonCardDone component', () => { +describe('ChallengeCardDone component', () => { it('should be rendered correctly', () => { const component = shallow( - <SeasonCardDone userChallenge={userChallengeData[0]} /> + <ChallengeCardDone userChallenge={userChallengeData[0]} /> ).getElement() expect(component).toMatchSnapshot() }) diff --git a/src/components/Season/SeasonCardDone.tsx b/src/components/Challenge/SeasonCardDone.tsx similarity index 73% rename from src/components/Season/SeasonCardDone.tsx rename to src/components/Challenge/SeasonCardDone.tsx index b6c31dc2e..f37c2b401 100644 --- a/src/components/Season/SeasonCardDone.tsx +++ b/src/components/Challenge/SeasonCardDone.tsx @@ -1,21 +1,21 @@ import React from 'react' -import './seasonCardDone.scss' +import './challengeCardDone.scss' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import classNames from 'classnames' import { formatNumberValues } from 'utils/utils' import { UserChallenge } from 'models' -import iconSuccess from 'assets/png/seasons/beariconSuccess.png' -import iconAlmost from 'assets/png/seasons/bearx.png' +import iconSuccess from 'assets/png/challenges/beariconSuccess.png' +import iconAlmost from 'assets/png/challenges/bearx.png' import { UserChallengeSuccess } from 'enum/userChallenge.enum' import { DateTime } from 'luxon' -interface SeasonCardDoneProps { +interface ChallengeCardDoneProps { userChallenge: UserChallenge } -const SeasonCardDone: React.FC<SeasonCardDoneProps> = ({ +const ChallengeCardDone: React.FC<ChallengeCardDoneProps> = ({ userChallenge, -}: SeasonCardDoneProps) => { +}: ChallengeCardDoneProps) => { const { t } = useI18n() // TODO Use pluarality of I18n @@ -32,8 +32,8 @@ const SeasonCardDone: React.FC<SeasonCardDoneProps> = ({ delta.days = Math.round(delta.days + 1) const label = delta.days == 1 - ? t('season.card_done.day') - : t('season.card_done.days') + ? t('challenge.card_done.day') + : t('challenge.card_done.days') return ' ' + delta.days + ' ' + label } } else return '' @@ -42,8 +42,8 @@ const SeasonCardDone: React.FC<SeasonCardDoneProps> = ({ const getUserSaving = (_userChallenge: UserChallenge) => { let label if (_userChallenge.success === UserChallengeSuccess.WIN) - label = t('season.card_done.saving') - else label = t('season.card_done.depense') + label = t('challenge.card_done.saving') + else label = t('challenge.card_done.depense') return ( label + @@ -60,11 +60,11 @@ const SeasonCardDone: React.FC<SeasonCardDoneProps> = ({ const getResultLabel = (_userChallenge: UserChallenge) => { switch (_userChallenge.success) { case UserChallengeSuccess.WIN: - return t('season.card_done.win') + return t('challenge.card_done.win') case UserChallengeSuccess.ALMOST_WIN: - return t('season.card_done.almostWin') + return t('challenge.card_done.almostWin') case UserChallengeSuccess.LOST: - return t('season.card_done.lost') + return t('challenge.card_done.lost') } } @@ -77,8 +77,10 @@ const SeasonCardDone: React.FC<SeasonCardDoneProps> = ({ return ( <div className="cardContent cardDone"> - <div className="headerCard">{t('season.card.title')}</div> - <div className="seasonName text-20-bold">{userChallenge.boss.title}</div> + <div className="headerCard">{t('challenge.card.title')}</div> + <div className="challengeName text-20-bold"> + {userChallenge.boss.title} + </div> <div className="iconResult"> <img src={getIcon(userChallenge)} className="imgResult" /> </div> @@ -94,10 +96,10 @@ const SeasonCardDone: React.FC<SeasonCardDoneProps> = ({ </div> <div className="statsResult"> <span className="text-18-bold"> - {userChallenge.progress} {t('season.card_done.stars')} + {userChallenge.progress} {t('challenge.card_done.stars')} </span> <br /> - {t('season.card_done.get_in')} + {t('challenge.card_done.get_in')} <span className="text-18-bold"> {getNumberDayProgress(userChallenge)} </span> @@ -105,10 +107,10 @@ const SeasonCardDone: React.FC<SeasonCardDoneProps> = ({ <br /> <span className="text-18-bold">{getUserSaving(userChallenge)}</span> <br /> - {t('season.card_done.final_defi')} + {t('challenge.card_done.final_defi')} </div> </div> ) } -export default SeasonCardDone +export default ChallengeCardDone diff --git a/src/components/Season/SeasonCardLocked.spec.tsx b/src/components/Challenge/SeasonCardLocked.spec.tsx similarity index 73% rename from src/components/Season/SeasonCardLocked.spec.tsx rename to src/components/Challenge/SeasonCardLocked.spec.tsx index ef6f42414..76c52d839 100644 --- a/src/components/Season/SeasonCardLocked.spec.tsx +++ b/src/components/Challenge/SeasonCardLocked.spec.tsx @@ -1,6 +1,6 @@ import React from 'react' import { shallow } from 'enzyme' -import SeasonCardLocked from './SeasonCardLocked' +import ChallengeCardLocked from './ChallengeCardLocked' import { userChallengeData } from '../../../test/__mocks__/userChallengeData.mock' jest.mock('cozy-ui/transpiled/react/I18n', () => { @@ -13,10 +13,10 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { } }) //TODO fis MUI theme error -describe('SeasonCardLocked component', () => { +describe('ChallengeCardLocked component', () => { it('should be rendered correctly', () => { const component = shallow( - <SeasonCardLocked userChallenge={userChallengeData[3]} /> + <ChallengeCardLocked userChallenge={userChallengeData[3]} /> ).getElement() expect(component).toMatchSnapshot() }) diff --git a/src/components/Challenge/SeasonCardLocked.tsx b/src/components/Challenge/SeasonCardLocked.tsx new file mode 100644 index 000000000..3003e00c6 --- /dev/null +++ b/src/components/Challenge/SeasonCardLocked.tsx @@ -0,0 +1,28 @@ +import React from 'react' +import './challengeCardLocked.scss' +import { UserChallenge } from 'models' +import StyledIcon from 'components/CommonKit/Icon/StyledIcon' +import challengeLockedIcon from 'assets/icons/visu/challenge/challengeLocked.svg' +import { useI18n } from 'cozy-ui/transpiled/react/I18n' + +interface ChallengeCardLockedProps { + userChallenge: UserChallenge +} +const ChallengeCardLocked: React.FC<ChallengeCardLockedProps> = ({ + userChallenge, +}: ChallengeCardLockedProps) => { + const { t } = useI18n() + + return ( + <div className="cardContent cardLocked"> + <p className="title">{t('challenge.card.title')}</p> + <span className="challengeTitle">{userChallenge.title}</span> + <StyledIcon className="challengeIcon" icon={challengeLockedIcon} /> + <p className="toUnlock text-16-normal-150"> + {t('challenge.card.locked.desc')} + </p> + </div> + ) +} + +export default ChallengeCardLocked diff --git a/src/components/Season/SeasonCardOnGoing.tsx b/src/components/Challenge/SeasonCardOnGoing.tsx similarity index 68% rename from src/components/Season/SeasonCardOnGoing.tsx rename to src/components/Challenge/SeasonCardOnGoing.tsx index b51f1c61a..fd709deb7 100644 --- a/src/components/Season/SeasonCardOnGoing.tsx +++ b/src/components/Challenge/SeasonCardOnGoing.tsx @@ -3,78 +3,78 @@ import { Client, useClient } from 'cozy-client' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import { useDispatch } from 'react-redux' import { useHistory } from 'react-router-dom' -import { updateUserChallengeList } from 'store/season/season.actions' -import './seasonCardOnGoing.scss' -import SeasonService from 'services/season.service' +import { updateUserChallengeList } from 'store/challenge/challenge.actions' +import './challengeCardOnGoing.scss' +import ChallengeService from 'services/challenge.service' import { UserChallenge } from 'models' -import { UpdateUserChallenge } from 'enum/userChallenge.enum' +import { UserChallengeUpdateFlag } from 'enum/userChallenge.enum' -import circleUnchecked from 'assets/icons/visu/season/circleUnchecked.svg' -import circleChecked from 'assets/icons/visu/season/circleChecked.svg' +import circleUnchecked from 'assets/icons/visu/challenge/circleUnchecked.svg' +import circleChecked from 'assets/icons/visu/challenge/circleChecked.svg' import StarsContainer from './StarsContainer' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import { importIconbyId } from 'utils/utils' import defaultIcon from 'assets/icons/visu/boss/default.svg' -import defaultSeasonIcon from 'assets/icons/visu/season/CHALLENGE0001.svg' +import defaultChallengeIcon from 'assets/icons/visu/challenge/CHALLENGE0001.svg' import circleStar from 'assets/icons/visu/duel/circleStar.svg' import duelLocked from 'assets/icons/visu/duel/locked.svg' import { UserBossState } from 'enum/userBoss.enum' import classNames from 'classnames' -interface SeasonCardOnGoingProps { +interface ChallengeCardOnGoingProps { userChallenge: UserChallenge } -const SeasonCardOnGoing: React.FC<SeasonCardOnGoingProps> = ({ +const ChallengeCardOnGoing: React.FC<ChallengeCardOnGoingProps> = ({ userChallenge, -}: SeasonCardOnGoingProps) => { +}: ChallengeCardOnGoingProps) => { const client: Client = useClient() const { t } = useI18n() const dispatch = useDispatch() const history = useHistory() - const [seasonIcon, setSeasonIcon] = useState(defaultIcon) + const [challengeIcon, setChallengeIcon] = useState(defaultIcon) const winStarts = async () => { - const seasonService = new SeasonService(client) + const challengeService = new ChallengeService(client) let progress = 0 - let updateType: UpdateUserChallenge + let updateType: UserChallengeUpdateFlag if (userChallenge.progress + 5 >= userChallenge.target) { progress = userChallenge.target updateType = UserChallengeUpdateFlag.BOSS_UNLOCK } else { progress = userChallenge.progress + 5 - updateType = UserChallengeUpdateFlag.SEASON + updateType = UserChallengeUpdateFlag.CHALLENGE } - const updatedSeason = await seasonService.updateUserChallenge( + const updatedChallenge = await challengeService.updateUserChallenge( { ...userChallenge, progress: progress }, updateType ) - dispatch(updateUserChallengeList(updatedSeason)) + dispatch(updateUserChallengeList(updatedChallenge)) } const goDuel = async () => { if (userChallenge.boss.state !== UserBossState.ONGOING) { - const seasonService = new SeasonService(client) - const updatedSeason = await seasonService.updateUserChallenge( + const challengeService = new ChallengeService(client) + const updatedChallenge = await challengeService.updateUserChallenge( userChallenge, UserChallengeUpdateFlag.BOSS_UPDATE_THRESHOLD ) - dispatch(updateUserChallengeList(updatedSeason)) + dispatch(updateUserChallengeList(updatedChallenge)) } history.push('/challenges/duel') } useEffect(() => { - importIconbyId(userChallenge.id, 'season').then(icon => { - icon ? setSeasonIcon(icon) : setSeasonIcon(defaultSeasonIcon) + importIconbyId(userChallenge.id, 'challenge').then(icon => { + icon ? setChallengeIcon(icon) : setChallengeIcon(defaultChallengeIcon) }) }, [userChallenge]) return ( <div className="cardContent onGoing"> <div className="titleBlock"> - <p className="title">{t('season.card.title')}</p> - <span className="seasonTitle">{userChallenge.title}</span> + <p className="title">{t('challenge.card.title')}</p> + <span className="challengeTitle">{userChallenge.title}</span> </div> <div className={classNames('smallCard', { @@ -88,7 +88,7 @@ const SeasonCardOnGoing: React.FC<SeasonCardOnGoingProps> = ({ size={25} /> <div className="content"> - <span>{t('season.card.ongoing.quiz')}</span> + <span>{t('challenge.card.ongoing.quiz')}</span> <StarsContainer starNumber={userChallenge.progress >= 5 ? 5 : 2} /> </div> </div> @@ -104,7 +104,7 @@ const SeasonCardOnGoing: React.FC<SeasonCardOnGoingProps> = ({ size={25} /> <div className="content"> - <span>{t('season.card.ongoing.mission')}</span> + <span>{t('challenge.card.ongoing.mission')}</span> <StarsContainer starNumber={userChallenge.progress >= 10 ? 5 : 3} /> </div> </div> @@ -120,30 +120,34 @@ const SeasonCardOnGoing: React.FC<SeasonCardOnGoingProps> = ({ size={25} /> <div className="content"> - <span>{t('season.card.ongoing.action')}</span> + <span>{t('challenge.card.ongoing.action')}</span> <StarsContainer starNumber={userChallenge.progress >= 15 ? 5 : 4} /> </div> </div> {userChallenge.progress >= userChallenge.target && userChallenge.boss.state === UserBossState.UNLOCKED ? ( <button className="smallCard goDuel" onClick={goDuel}> - {t('season.card.ongoing.duel')} - <StyledIcon className="seasonminIcon" icon={seasonIcon} size={60} /> + {t('challenge.card.ongoing.duel')} + <StyledIcon + className="challengeminIcon" + icon={challengeIcon} + size={60} + /> </button> ) : userChallenge.boss.state === UserBossState.ONGOING ? ( <div className={'smallCard bossCard active'} onClick={goDuel}> <div className="finalDuel"> - <span>{t('season.card.ongoing.duel')}</span> + <span>{t('challenge.card.ongoing.duel')}</span> <p className="starCount"> <span className="blueNumber">{`${userChallenge.boss.userConsumption} € `}</span> <span>{` / ${userChallenge.boss.threshold} €`}</span> </p> </div> - <StyledIcon className="circleStar" icon={seasonIcon} size={60} /> + <StyledIcon className="circleStar" icon={challengeIcon} size={60} /> </div> ) : userChallenge.boss.state === UserBossState.DONE ? ( <div className={'smallCard bossCard'} onClick={goDuel}> - <span>{t('season.card.ongoing.duelDone')}</span> + <span>{t('challenge.card.ongoing.duelDone')}</span> <StyledIcon className="duelLocked" icon={duelLocked} size={60} /> </div> ) : ( @@ -160,4 +164,4 @@ const SeasonCardOnGoing: React.FC<SeasonCardOnGoingProps> = ({ ) } -export default SeasonCardOnGoing +export default ChallengeCardOnGoing diff --git a/src/components/Season/SeasonCardUnlocked.spec.tsx b/src/components/Challenge/SeasonCardUnlocked.spec.tsx similarity index 70% rename from src/components/Season/SeasonCardUnlocked.spec.tsx rename to src/components/Challenge/SeasonCardUnlocked.spec.tsx index 85d7c73ae..7712fa67c 100644 --- a/src/components/Season/SeasonCardUnlocked.spec.tsx +++ b/src/components/Challenge/SeasonCardUnlocked.spec.tsx @@ -2,10 +2,10 @@ import React from 'react' import { mount } from 'enzyme' import { Provider } from 'react-redux' import configureStore from 'redux-mock-store' -import SeasonCardUnlocked from './SeasonCardUnlocked' +import ChallengeCardUnlocked from './ChallengeCardUnlocked' import { userChallengeData } from '../../../test/__mocks__/userChallengeData.mock' import { globalStateData } from '../../../test/__mocks__/globalStateData.mock' -import SeasonNoFluidModal from './SeasonNoFluidModal' +import ChallengeNoFluidModal from './ChallengeNoFluidModal' import { FluidType } from 'enum/fluid.enum' jest.mock('cozy-ui/transpiled/react/I18n', () => { @@ -19,7 +19,7 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { }) const mockStartUserChallenge = jest.fn() -jest.mock('services/season.service', () => { +jest.mock('services/challenge.service', () => { return jest.fn(() => { return { startUserChallenge: mockStartUserChallenge, @@ -30,31 +30,31 @@ jest.mock('services/season.service', () => { const mockStore = configureStore([]) //TODO fix click test -describe('SeasonCardUnlocked component', () => { +describe('ChallengeCardUnlocked component', () => { it('should be rendered correctly', () => { const store = mockStore({ global: globalStateData, }) const wrapper = mount( <Provider store={store}> - <SeasonCardUnlocked userChallenge={userChallengeData[0]} /> + <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) expect(wrapper.find('.title').exists()).toBeTruthy() - expect(wrapper.find('.seasonTitle').text()).toEqual( + expect(wrapper.find('.challengeTitle').text()).toEqual( userChallengeData[0].title ) expect(wrapper.find('.launchButton').exists()).toBeTruthy() - expect(wrapper.find(SeasonNoFluidModal).exists()).toBeTruthy() + expect(wrapper.find(ChallengeNoFluidModal).exists()).toBeTruthy() }) - it('should display SeasonNoFluidModal when launching season without configured fluid', () => { + it('should display ChallengeNoFluidModal when launching challenge without configured fluid', () => { const store = mockStore({ global: globalStateData, }) const wrapper = mount( <Provider store={store}> - <SeasonCardUnlocked userChallenge={userChallengeData[0]} /> + <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) wrapper @@ -64,7 +64,7 @@ describe('SeasonCardUnlocked component', () => { expect(wrapper.find('.modal-opened').exists()).toBeTruthy() }) - it('should not display SeasonNoFluidModal and update userChallenge when launching season with configured fluid', () => { + it('should not display ChallengeNoFluidModal and update userChallenge when launching challenge with configured fluid', () => { const updateGlobalStoreData = { ...globalStateData, fluidTypes: [FluidType.ELECTRICITY], @@ -74,7 +74,7 @@ describe('SeasonCardUnlocked component', () => { }) const wrapper = mount( <Provider store={store}> - <SeasonCardUnlocked userChallenge={userChallengeData[0]} /> + <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) wrapper diff --git a/src/components/Season/SeasonCardUnlocked.tsx b/src/components/Challenge/SeasonCardUnlocked.tsx similarity index 53% rename from src/components/Season/SeasonCardUnlocked.tsx rename to src/components/Challenge/SeasonCardUnlocked.tsx index fa581bd06..bdb16af73 100644 --- a/src/components/Season/SeasonCardUnlocked.tsx +++ b/src/components/Challenge/SeasonCardUnlocked.tsx @@ -2,23 +2,23 @@ import React, { useCallback, useEffect, useState } from 'react' import { Client, useClient } from 'cozy-client' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import { useDispatch, useSelector } from 'react-redux' -import { updateUserChallengeList } from 'store/season/season.actions' -import './seasonCardUnlocked.scss' +import { updateUserChallengeList } from 'store/challenge/challenge.actions' +import './challengeCardUnlocked.scss' import { UserChallenge } from 'models' -import SeasonService from 'services/season.service' +import ChallengeService from 'services/challenge.service' import StyledButtonValid from 'components/CommonKit/Button/StyledButtonValid' -import SeasonNoFluidModal from './SeasonNoFluidModal' +import ChallengeNoFluidModal from './ChallengeNoFluidModal' import { AppStore } from 'store' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' -import defaultIcon from 'assets/icons/visu/season/seasonLocked.svg' +import defaultIcon from 'assets/icons/visu/challenge/challengeLocked.svg' import { importIconbyId } from 'utils/utils' -interface SeasonCardUnlockedProps { +interface ChallengeCardUnlockedProps { userChallenge: UserChallenge } -const SeasonCardUnlocked: React.FC<SeasonCardUnlockedProps> = ({ +const ChallengeCardUnlocked: React.FC<ChallengeCardUnlockedProps> = ({ userChallenge, -}: SeasonCardUnlockedProps) => { +}: ChallengeCardUnlockedProps) => { const client: Client = useClient() const dispatch = useDispatch() const { t } = useI18n() @@ -26,19 +26,19 @@ const SeasonCardUnlocked: React.FC<SeasonCardUnlockedProps> = ({ const [openNoFluidModal, setopenNoFluidModal] = useState(false) const { fluidTypes } = useSelector((state: AppStore) => state.ecolyo.global) - const [seasonIcon, setSeasonIcon] = useState(defaultIcon) + const [challengeIcon, setChallengeIcon] = useState(defaultIcon) const toggleNoFluidModal = useCallback(() => { setopenNoFluidModal(prev => !prev) }, []) - const launchSeason = useCallback(async () => { + const launchChallenge = useCallback(async () => { if (fluidTypes.length > 0) { - const seasonService = new SeasonService(client) - const updatedSeason = await seasonService.startUserChallenge( + const challengeService = new ChallengeService(client) + const updatedChallenge = await challengeService.startUserChallenge( userChallenge ) - dispatch(updateUserChallengeList(updatedSeason)) + dispatch(updateUserChallengeList(updatedChallenge)) } else { return toggleNoFluidModal() } @@ -46,8 +46,8 @@ const SeasonCardUnlocked: React.FC<SeasonCardUnlockedProps> = ({ useEffect(() => { if (userChallenge) { - importIconbyId(userChallenge.id, 'season').then(icon => { - icon && setSeasonIcon(icon) + importIconbyId(userChallenge.id, 'challenge').then(icon => { + icon && setChallengeIcon(icon) }) } }, [userChallenge]) @@ -55,20 +55,20 @@ const SeasonCardUnlocked: React.FC<SeasonCardUnlockedProps> = ({ return ( <> <div className="cardContent cardUnlocked"> - <p className="title">{t('season.card.title')}</p> - <span className="seasonTitle">{userChallenge.title}</span> - <StyledIcon className="seasonIcon" icon={seasonIcon} /> - <StyledButtonValid className="launchButton" onClick={launchSeason}> - {t('season.card.unlocked.launch')} + <p className="title">{t('challenge.card.title')}</p> + <span className="challengeTitle">{userChallenge.title}</span> + <StyledIcon className="challengeIcon" icon={challengeIcon} /> + <StyledButtonValid className="launchButton" onClick={launchChallenge}> + {t('challenge.card.unlocked.launch')} </StyledButtonValid> </div> - <SeasonNoFluidModal + <ChallengeNoFluidModal open={openNoFluidModal} handleCloseClick={toggleNoFluidModal} - ></SeasonNoFluidModal> + ></ChallengeNoFluidModal> </> ) } -export default SeasonCardUnlocked +export default ChallengeCardUnlocked diff --git a/src/components/Season/SeasonNoFluidModal.spec.tsx b/src/components/Challenge/SeasonNoFluidModal.spec.tsx similarity index 69% rename from src/components/Season/SeasonNoFluidModal.spec.tsx rename to src/components/Challenge/SeasonNoFluidModal.spec.tsx index c9c1d1785..6fb0e7b94 100644 --- a/src/components/Season/SeasonNoFluidModal.spec.tsx +++ b/src/components/Challenge/SeasonNoFluidModal.spec.tsx @@ -1,6 +1,6 @@ import React from 'react' import { shallow } from 'enzyme' -import SeasonNoFluidModal from './SeasonNoFluidModal' +import ChallengeNoFluidModal from './ChallengeNoFluidModal' jest.mock('cozy-ui/transpiled/react/I18n', () => { return { @@ -12,11 +12,11 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { } }) -describe('SeasonNoFluidModal component', () => { +describe('ChallengeNoFluidModal component', () => { it('should be rendered correctly opened', () => { const handleClose = jest.fn() const component = shallow( - <SeasonNoFluidModal open={true} handleCloseClick={handleClose} /> + <ChallengeNoFluidModal open={true} handleCloseClick={handleClose} /> ).getElement() expect(component).toMatchSnapshot() }) @@ -24,7 +24,7 @@ describe('SeasonNoFluidModal component', () => { it('should be rendered correctly closed', () => { const handleClose = jest.fn() const component = shallow( - <SeasonNoFluidModal open={false} handleCloseClick={handleClose} /> + <ChallengeNoFluidModal open={false} handleCloseClick={handleClose} /> ).getElement() expect(component).toMatchSnapshot() }) diff --git a/src/components/Season/SeasonNoFluidModal.tsx b/src/components/Challenge/SeasonNoFluidModal.tsx similarity index 66% rename from src/components/Season/SeasonNoFluidModal.tsx rename to src/components/Challenge/SeasonNoFluidModal.tsx index bb1b4c70c..6dc422d57 100644 --- a/src/components/Season/SeasonNoFluidModal.tsx +++ b/src/components/Challenge/SeasonNoFluidModal.tsx @@ -2,26 +2,28 @@ import React from 'react' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import Modal from 'components/CommonKit/Modal/Modal' import StyledStopButton from 'components/CommonKit/Button/StyledStopButton' -import './seasonNoFluidModal.scss' +import './challengeNoFluidModal.scss' -interface SeasonNoFluidModalProps { +interface ChallengeNoFluidModalProps { open: boolean handleCloseClick: () => void } -const SeasonNoFluidModal: React.FC<SeasonNoFluidModalProps> = ({ +const ChallengeNoFluidModal: React.FC<ChallengeNoFluidModalProps> = ({ open, handleCloseClick, -}: SeasonNoFluidModalProps) => { +}: ChallengeNoFluidModalProps) => { const { t } = useI18n() return ( <> <Modal open={open} handleCloseClick={handleCloseClick}> <div className="noFluidModal"> - <div className="no-fluid-title">{t('season.noFluidModal.title')}</div> + <div className="no-fluid-title"> + {t('challenge.noFluidModal.title')} + </div> <div className="no-fluid-content"> - {t('season.noFluidModal.content')} + {t('challenge.noFluidModal.content')} </div> <StyledStopButton color="secondary" @@ -36,4 +38,4 @@ const SeasonNoFluidModal: React.FC<SeasonNoFluidModalProps> = ({ ) } -export default SeasonNoFluidModal +export default ChallengeNoFluidModal diff --git a/src/components/Season/SeasonView.spec.tsx b/src/components/Challenge/SeasonView.spec.tsx similarity index 70% rename from src/components/Season/SeasonView.spec.tsx rename to src/components/Challenge/SeasonView.spec.tsx index acf49d6ff..7f4d141ba 100644 --- a/src/components/Season/SeasonView.spec.tsx +++ b/src/components/Challenge/SeasonView.spec.tsx @@ -1,15 +1,15 @@ import React from 'react' import { shallow } from 'enzyme' -import SeasonView from 'components/Season/SeasonView' +import ChallengeView from 'components/Challenge/ChallengeView' import * as reactRedux from 'react-redux' import { challengeStateDataFull } from '../../../test/__mocks__/challengeStateData.mock' const mockUseSelector = jest.spyOn(reactRedux, 'useSelector') -describe('SeasonView component', () => { +describe('ChallengeView component', () => { it('should be rendered correctly', () => { mockUseSelector.mockReturnValue(challengeStateDataFull) - const component = shallow(<SeasonView />).getElement() + const component = shallow(<ChallengeView />).getElement() expect(component).toMatchSnapshot() }) }) diff --git a/src/components/Season/SeasonView.tsx b/src/components/Challenge/SeasonView.tsx similarity index 85% rename from src/components/Season/SeasonView.tsx rename to src/components/Challenge/SeasonView.tsx index a21339ef6..8740eb84f 100644 --- a/src/components/Season/SeasonView.tsx +++ b/src/components/Challenge/SeasonView.tsx @@ -1,20 +1,20 @@ import React, { useCallback, useEffect, useState } from 'react' -import './seasonView.scss' +import './challengeView.scss' import { useSelector } from 'react-redux' import { AppStore } from 'store' import CozyBar from 'components/Header/CozyBar' import Content from 'components/Content/Content' import Header from 'components/Header/Header' -import SeasonCard from './SeasonCard' +import ChallengeCard from './ChallengeCard' import StyledIconbutton from 'components/CommonKit/IconButton/StyledIconButton' import LeftArrowIcon from 'assets/icons/ico/left-arrow.svg' import RightArrowIcon from 'assets/icons/ico/right-arrow.svg' import { UserChallengeState } from 'enum/userChallenge.enum' import { UserChallenge } from 'models' -const SeasonView: React.FC = () => { +const ChallengeView: React.FC = () => { const { userChallengeList } = useSelector( - (state: AppStore) => state.ecolyo.season + (state: AppStore) => state.ecolyo.challenge ) const marginPx = 16 @@ -28,7 +28,7 @@ const SeasonView: React.FC = () => { const [touchStart, setTouchStart] = useState<number>() const [touchEnd, setTouchEnd] = useState<number>() const [index, setindex] = useState<number>(0) - const [lastSeasonIndex, setlastSeasonIndex] = useState<number>(0) + const [lastChallengeIndex, setlastChallengeIndex] = useState<number>(0) const [containerTranslation, setcontainerTranslation] = useState<number>( marginPx ) @@ -99,24 +99,24 @@ const SeasonView: React.FC = () => { } useEffect(() => { - userChallengeList.forEach((season: UserChallenge, i: number) => { + userChallengeList.forEach((challenge: UserChallenge, i: number) => { if ( - season.state === UserChallengeState.UNLOCKED || - season.state === UserChallengeState.ONGOING + challenge.state === UserChallengeState.UNLOCKED || + challenge.state === UserChallengeState.ONGOING ) { - setlastSeasonIndex(i) - if (lastSeasonIndex === 0) return - else if (lastSeasonIndex === 1) { - setcontainerTranslation(0 - cardWitdh * lastSeasonIndex) + setlastChallengeIndex(i) + if (lastChallengeIndex === 0) return + else if (lastChallengeIndex === 1) { + setcontainerTranslation(0 - cardWitdh * lastChallengeIndex) } else { setcontainerTranslation( - 0 - cardWitdh * lastSeasonIndex - marginPx * 1.2 + 0 - cardWitdh * lastChallengeIndex - marginPx * 1.2 ) } setindex(i) } }) - }, [userChallengeList, lastSeasonIndex, cardWitdh]) + }, [userChallengeList, lastChallengeIndex, cardWitdh]) return ( <> @@ -127,7 +127,7 @@ const SeasonView: React.FC = () => { ></Header> <Content height={headerHeight}> <div - className="seasonSlider" + className="challengeSlider" onClick={resetValues} onTouchStart={handleClickOrTouchStart} onTouchMove={handleClickOrTouchMove} @@ -143,7 +143,7 @@ const SeasonView: React.FC = () => { }} > {userChallengeList.map((userChallenge, i) => ( - <SeasonCard + <ChallengeCard key={i} userChallenge={userChallenge} indexSlider={index} @@ -171,4 +171,4 @@ const SeasonView: React.FC = () => { ) } -export default SeasonView +export default ChallengeView diff --git a/src/components/Season/StarsContainer.tsx b/src/components/Challenge/StarsContainer.tsx similarity index 81% rename from src/components/Season/StarsContainer.tsx rename to src/components/Challenge/StarsContainer.tsx index f1caab739..87cf8e6c4 100644 --- a/src/components/Season/StarsContainer.tsx +++ b/src/components/Challenge/StarsContainer.tsx @@ -1,8 +1,8 @@ import React from 'react' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' -import starIcon from 'assets/icons/visu/season/star.svg' -import starFilled from 'assets/icons/visu/season/starFilled.svg' -import starFinished from 'assets/icons/visu/season/starFinished.svg' +import starIcon from 'assets/icons/visu/challenge/star.svg' +import starFilled from 'assets/icons/visu/challenge/starFilled.svg' +import starFinished from 'assets/icons/visu/challenge/starFinished.svg' interface StarsContainerProps { starNumber?: number diff --git a/src/components/Season/__snapshots__/SeasonCard.spec.tsx.snap b/src/components/Challenge/__snapshots__/SeasonCard.spec.tsx.snap similarity index 83% rename from src/components/Season/__snapshots__/SeasonCard.spec.tsx.snap rename to src/components/Challenge/__snapshots__/SeasonCard.spec.tsx.snap index d0dc1dedb..6f1383829 100644 --- a/src/components/Season/__snapshots__/SeasonCard.spec.tsx.snap +++ b/src/components/Challenge/__snapshots__/SeasonCard.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SeasonCard component should be rendered correctly 1`] = ` +exports[`ChallengeCard component should be rendered correctly 1`] = ` <div className="slide active" style={ @@ -11,7 +11,7 @@ exports[`SeasonCard component should be rendered correctly 1`] = ` } } > - <SeasonCardDone + <ChallengeCardDone userChallenge={ Object { "boss": Object { @@ -25,7 +25,7 @@ exports[`SeasonCard component should be rendered correctly 1`] = ` "title": "Title BOSS001", "userConsumption": 0, }, - "description": "Description season 2", + "description": "Description challenge 2", "endingDate": null, "id": "CHALLENGE0002", "progress": 0, @@ -34,7 +34,7 @@ exports[`SeasonCard component should be rendered correctly 1`] = ` "state": 4, "success": 1, "target": 15, - "title": "Season 2", + "title": "Challenge 2", } } /> diff --git a/src/components/Season/__snapshots__/SeasonCardDone.spec.tsx.snap b/src/components/Challenge/__snapshots__/SeasonCardDone.spec.tsx.snap similarity index 67% rename from src/components/Season/__snapshots__/SeasonCardDone.spec.tsx.snap rename to src/components/Challenge/__snapshots__/SeasonCardDone.spec.tsx.snap index e7452eaf7..2c2af6f30 100644 --- a/src/components/Season/__snapshots__/SeasonCardDone.spec.tsx.snap +++ b/src/components/Challenge/__snapshots__/SeasonCardDone.spec.tsx.snap @@ -1,16 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SeasonCardDone component should be rendered correctly 1`] = ` +exports[`ChallengeCardDone component should be rendered correctly 1`] = ` <div className="cardContent cardDone" > <div className="headerCard" > - season.card.title + challenge.card.title </div> <div - className="seasonName text-20-bold" + className="challengeName text-20-bold" > Title BOSS001 </div> @@ -25,7 +25,7 @@ exports[`SeasonCardDone component should be rendered correctly 1`] = ` <div className="labelResult win" > - season.card_done.win + challenge.card_done.win </div> <div className="statsResult" @@ -35,10 +35,10 @@ exports[`SeasonCardDone component should be rendered correctly 1`] = ` > 0 - season.card_done.stars + challenge.card_done.stars </span> <br /> - season.card_done.get_in + challenge.card_done.get_in <span className="text-18-bold" > @@ -49,10 +49,10 @@ exports[`SeasonCardDone component should be rendered correctly 1`] = ` <span className="text-18-bold" > - season.card_done.saving 0.00€ + challenge.card_done.saving 0.00€ </span> <br /> - season.card_done.final_defi + challenge.card_done.final_defi </div> </div> `; diff --git a/src/components/Season/__snapshots__/SeasonCardLocked.spec.tsx.snap b/src/components/Challenge/__snapshots__/SeasonCardLocked.spec.tsx.snap similarity index 55% rename from src/components/Season/__snapshots__/SeasonCardLocked.spec.tsx.snap rename to src/components/Challenge/__snapshots__/SeasonCardLocked.spec.tsx.snap index 49b4ebd69..e66e19462 100644 --- a/src/components/Season/__snapshots__/SeasonCardLocked.spec.tsx.snap +++ b/src/components/Challenge/__snapshots__/SeasonCardLocked.spec.tsx.snap @@ -1,27 +1,27 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SeasonCardLocked component should be rendered correctly 1`] = ` +exports[`ChallengeCardLocked component should be rendered correctly 1`] = ` <div className="cardContent cardLocked" > <p className="title" > - season.card.title + challenge.card.title </p> <span - className="seasonTitle" + className="challengeTitle" > - Season 4 + Challenge 4 </span> <StyledIcon - className="seasonIcon" + className="challengeIcon" icon="test-file-stub" /> <p className="toUnlock text-16-normal-150" > - season.card.locked.desc + challenge.card.locked.desc </p> </div> `; diff --git a/src/components/Season/__snapshots__/SeasonNoFluidModal.spec.tsx.snap b/src/components/Challenge/__snapshots__/SeasonNoFluidModal.spec.tsx.snap similarity index 75% rename from src/components/Season/__snapshots__/SeasonNoFluidModal.spec.tsx.snap rename to src/components/Challenge/__snapshots__/SeasonNoFluidModal.spec.tsx.snap index e37e4eaa3..90c5487fa 100644 --- a/src/components/Season/__snapshots__/SeasonNoFluidModal.spec.tsx.snap +++ b/src/components/Challenge/__snapshots__/SeasonNoFluidModal.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SeasonNoFluidModal component should be rendered correctly closed 1`] = ` +exports[`ChallengeNoFluidModal component should be rendered correctly closed 1`] = ` <React.Fragment> <Modal handleCloseClick={[MockFunction]} @@ -12,12 +12,12 @@ exports[`SeasonNoFluidModal component should be rendered correctly closed 1`] = <div className="no-fluid-title" > - season.noFluidModal.title + challenge.noFluidModal.title </div> <div className="no-fluid-content" > - season.noFluidModal.content + challenge.noFluidModal.content </div> <StyledStopButton className="button-ok" @@ -31,7 +31,7 @@ exports[`SeasonNoFluidModal component should be rendered correctly closed 1`] = </React.Fragment> `; -exports[`SeasonNoFluidModal component should be rendered correctly opened 1`] = ` +exports[`ChallengeNoFluidModal component should be rendered correctly opened 1`] = ` <React.Fragment> <Modal handleCloseClick={[MockFunction]} @@ -43,12 +43,12 @@ exports[`SeasonNoFluidModal component should be rendered correctly opened 1`] = <div className="no-fluid-title" > - season.noFluidModal.title + challenge.noFluidModal.title </div> <div className="no-fluid-content" > - season.noFluidModal.content + challenge.noFluidModal.content </div> <StyledStopButton className="button-ok" diff --git a/src/components/Season/__snapshots__/SeasonView.spec.tsx.snap b/src/components/Challenge/__snapshots__/SeasonView.spec.tsx.snap similarity index 88% rename from src/components/Season/__snapshots__/SeasonView.spec.tsx.snap rename to src/components/Challenge/__snapshots__/SeasonView.spec.tsx.snap index 9939bc10a..162cf2eff 100644 --- a/src/components/Season/__snapshots__/SeasonView.spec.tsx.snap +++ b/src/components/Challenge/__snapshots__/SeasonView.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SeasonView component should be rendered correctly 1`] = ` +exports[`ChallengeView component should be rendered correctly 1`] = ` <React.Fragment> <CozyBar titleKey="COMMON.APP_CHALLENGE_TITLE" @@ -13,7 +13,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` height={0} > <div - className="seasonSlider" + className="challengeSlider" onClick={[Function]} onMouseDown={[Function]} onMouseMove={[Function]} @@ -30,7 +30,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` } } > - <SeasonCard + <ChallengeCard cardHeight={384} cardWidth={285} index={0} @@ -48,7 +48,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "title": "Title BOSS001", "userConsumption": 0, }, - "description": "Description season 1", + "description": "Description challenge 1", "endingDate": null, "id": "CHALLENGE0001", "progress": 0, @@ -57,11 +57,11 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "state": 4, "success": 3, "target": 15, - "title": "Season 1", + "title": "Challenge 1", } } /> - <SeasonCard + <ChallengeCard cardHeight={384} cardWidth={285} index={1} @@ -79,7 +79,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "title": "Title BOSS001", "userConsumption": 0, }, - "description": "Description season 2", + "description": "Description challenge 2", "endingDate": null, "id": "CHALLENGE0002", "progress": 0, @@ -88,11 +88,11 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "state": 4, "success": 1, "target": 15, - "title": "Season 2", + "title": "Challenge 2", } } /> - <SeasonCard + <ChallengeCard cardHeight={384} cardWidth={285} index={2} @@ -110,7 +110,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "title": "Title BOSS001", "userConsumption": 0, }, - "description": "Description season 3", + "description": "Description challenge 3", "endingDate": null, "id": "CHALLENGE0003", "progress": 0, @@ -119,11 +119,11 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "state": 2, "success": 0, "target": 15, - "title": "Season 3", + "title": "Challenge 3", } } /> - <SeasonCard + <ChallengeCard cardHeight={384} cardWidth={285} index={3} @@ -141,7 +141,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "title": "Title BOSS001", "userConsumption": 0, }, - "description": "Description season 4", + "description": "Description challenge 4", "endingDate": null, "id": "CHALLENGE0004", "progress": 0, @@ -150,11 +150,11 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "state": 1, "success": 0, "target": 15, - "title": "Season 4", + "title": "Challenge 4", } } /> - <SeasonCard + <ChallengeCard cardHeight={384} cardWidth={285} index={4} @@ -172,7 +172,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "title": "Title BOSS001", "userConsumption": 0, }, - "description": "Description season 5", + "description": "Description challenge 5", "endingDate": null, "id": "CHALLENGE0005", "progress": 0, @@ -181,7 +181,7 @@ exports[`SeasonView component should be rendered correctly 1`] = ` "state": 0, "success": 0, "target": 15, - "title": "Season 5", + "title": "Challenge 5", } } /> diff --git a/src/components/Season/seasonCard.scss b/src/components/Challenge/seasonCard.scss similarity index 100% rename from src/components/Season/seasonCard.scss rename to src/components/Challenge/seasonCard.scss diff --git a/src/components/Season/seasonCardDone.scss b/src/components/Challenge/seasonCardDone.scss similarity index 97% rename from src/components/Season/seasonCardDone.scss rename to src/components/Challenge/seasonCardDone.scss index 3215a4e1f..f17d305dc 100644 --- a/src/components/Season/seasonCardDone.scss +++ b/src/components/Challenge/seasonCardDone.scss @@ -8,7 +8,7 @@ flex-direction: column; justify-content: space-around; align-items: center; - .seasonName, + .challengeName, .labelResult { margin-bottom: 1rem; } diff --git a/src/components/Season/seasonCardLocked.scss b/src/components/Challenge/seasonCardLocked.scss similarity index 93% rename from src/components/Season/seasonCardLocked.scss rename to src/components/Challenge/seasonCardLocked.scss index c08f7b2b2..1207be3ae 100644 --- a/src/components/Season/seasonCardLocked.scss +++ b/src/components/Challenge/seasonCardLocked.scss @@ -3,7 +3,7 @@ .cardLocked { filter: drop-shadow(0px 4px 16px rgba(0, 0, 0, 0.55)); - .seasonIcon { + .challengeIcon { @media all and(max-height: 700px) { width: 70%; margin: auto; diff --git a/src/components/Season/seasonCardOnGoing.scss b/src/components/Challenge/seasonCardOnGoing.scss similarity index 99% rename from src/components/Season/seasonCardOnGoing.scss rename to src/components/Challenge/seasonCardOnGoing.scss index 21db16690..f509e9994 100644 --- a/src/components/Season/seasonCardOnGoing.scss +++ b/src/components/Challenge/seasonCardOnGoing.scss @@ -66,7 +66,7 @@ font-size: 1rem; } } - .seasonminIcon { + .challengeminIcon { filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.55)); } .duelLocked { diff --git a/src/components/Season/seasonCardUnlocked.scss b/src/components/Challenge/seasonCardUnlocked.scss similarity index 95% rename from src/components/Season/seasonCardUnlocked.scss rename to src/components/Challenge/seasonCardUnlocked.scss index 82c912577..3f1bdc542 100644 --- a/src/components/Season/seasonCardUnlocked.scss +++ b/src/components/Challenge/seasonCardUnlocked.scss @@ -15,7 +15,7 @@ display: block !important; padding: 1rem 1.5rem !important; } - .seasonIcon { + .challengeIcon { @media all and(max-height: 700px) { width: 80%; margin: auto; diff --git a/src/components/Season/seasonNoFluidModal.scss b/src/components/Challenge/seasonNoFluidModal.scss similarity index 100% rename from src/components/Season/seasonNoFluidModal.scss rename to src/components/Challenge/seasonNoFluidModal.scss diff --git a/src/components/Season/seasonView.scss b/src/components/Challenge/seasonView.scss similarity index 94% rename from src/components/Season/seasonView.scss rename to src/components/Challenge/seasonView.scss index e26697bcb..56e68b048 100644 --- a/src/components/Season/seasonView.scss +++ b/src/components/Challenge/seasonView.scss @@ -1,6 +1,6 @@ @import '../../styles/base/typography'; -.seasonSlider { +.challengeSlider { min-height: inherit; margin-top: -2rem; overflow-x: hidden; @@ -31,7 +31,7 @@ font-size: 1.2rem; margin-bottom: 0; } - .seasonTitle { + .challengeTitle { display: block; font-weight: 700; text-align: center; @@ -39,7 +39,7 @@ color: $grey-bright; font-size: 1.3rem; } - .seasonIcon { + .challengeIcon { margin-top: 8%; width: 100%; max-width: 180px; diff --git a/src/components/Connection/ConnectionResult.tsx b/src/components/Connection/ConnectionResult.tsx index 9144de1cc..8356b6614 100644 --- a/src/components/Connection/ConnectionResult.tsx +++ b/src/components/Connection/ConnectionResult.tsx @@ -5,8 +5,8 @@ import { useDispatch, useSelector } from 'react-redux' import { EcolyoState } from 'store' import { setFluidStatus } from 'store/global/global.actions' import { updateProfile } from 'store/profile/profile.actions' -import { toogleSeasonNotification } from 'store/global/global.actions' -import { setSeasonConsumption } from 'store/season/season.actions' +import { toogleChallengeNotification } from 'store/global/global.actions' +import { setChallengeConsumption } from 'store/challenge/challenge.actions' import { isKonnectorRunning } from 'cozy-harvest-lib/dist/helpers/triggers' import { getKonnectorUpdateError } from 'utils/utils' @@ -26,7 +26,7 @@ import warningWhite from 'assets/icons/ico/warning-white.svg' import StyledButton from 'components/CommonKit/Button/StyledButton' import StyledBlackSpinner from 'components/CommonKit/Spinner/StyledBlackSpinner' import InitializationService from 'services/initialization.service' -import SeasonService from 'services/season.service' +import ChallengeService from 'components/Challenge/node_modules/services/challenge.service' import { UserChallengeState } from 'enum/userChallenge.enum' import { UserBossState } from 'enum/userBoss.enum' @@ -45,7 +45,9 @@ const ConnectionResult: React.FC<ConnectionResultProps> = ({ }: ConnectionResultProps) => { const { t } = useI18n() const client = useClient() - const { currentSeason } = useSelector((state: EcolyoState) => state.season) + const { currentChallenge } = useSelector( + (state: EcolyoState) => state.challenge + ) const dispatch = useDispatch() const [trigger, setTrigger] = useState<Trigger | null>(null) @@ -63,25 +65,25 @@ const ConnectionResult: React.FC<ConnectionResultProps> = ({ const refreshChallengeState = useCallback(async () => { if ( - currentSeason && - currentSeason.state === UserChallengeState.BOSS && - currentSeason.boss.state === UserBossState.ONGOING + currentChallenge && + currentChallenge.state === UserChallengeState.BOSS && + currentChallenge.boss.state === UserBossState.ONGOING ) { const initializationService = new InitializationService(client) const { updatedUserChallenge, dataloads, - } = await initializationService.initBossProgress(currentSeason) - dispatch(setSeasonConsumption(updatedUserChallenge, dataloads)) + } = await initializationService.initBossProgress(currentChallenge) + dispatch(setChallengeConsumption(updatedUserChallenge, dataloads)) // Check is boss is done and display notification - const seasonService = new SeasonService(client) - const { isDone } = await seasonService.isSeasonDone( + const challengeService = new ChallengeService(client) + const { isDone } = await challengeService.isChallengeDone( updatedUserChallenge, dataloads ) - dispatch(toogleSeasonNotification(isDone)) + dispatch(toogleChallengeNotification(isDone)) } - }, [client, dispatch, currentSeason]) + }, [client, dispatch, currentChallenge]) const updateProfileHaveSeenOldFluidModal = useCallback(async () => { const profileService = new ProfileService(client) diff --git a/src/components/Duel/DuelOngoing.spec.tsx b/src/components/Duel/DuelOngoing.spec.tsx index 3b96f360f..63d04e20e 100644 --- a/src/components/Duel/DuelOngoing.spec.tsx +++ b/src/components/Duel/DuelOngoing.spec.tsx @@ -21,13 +21,13 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { } }) -const mockUpdateUserChallenge = jest.fn() -const mockIsSeasonDone = jest.fn() -jest.mock('services/season.service', () => { +const mockUserChallengeUpdateFlag = jest.fn() +const mockIsChallengeDone = jest.fn() +jest.mock('services/challenge.service', () => { return jest.fn(() => { return { - updateUserChallenge: mockUpdateUserChallenge, - isSeasonDone: mockIsSeasonDone, + updateUserChallenge: mockUserChallengeUpdateFlag, + isChallengeDone: mockIsChallengeDone, } }) }) @@ -48,9 +48,9 @@ describe('DuelOngoing component', () => { it('should be rendered correctly', () => { const store = mockStore({ global: globalStateData, - season: challengeStateData, + challenge: challengeStateData, }) - mockIsSeasonDone.mockResolvedValueOnce({ isDone: false, isWin: false }) + mockIsChallengeDone.mockResolvedValueOnce({ isDone: false, isWin: false }) const wrapper = mount( <Provider store={store}> <DuelOngoing userChallenge={userChallengeData[0]} /> @@ -68,14 +68,14 @@ describe('DuelOngoing component', () => { it('should display the result modal', async () => { const store = mockStore({ global: globalStateData, - season: challengeStateData, + challenge: challengeStateData, }) const updatedUserChallenge: UserChallenge = { ...userChallengeData[0], state: UserChallengeState.BOSS, startDate: DateTime.local().setZone('utc', { keepLocalTime: true }), } - mockIsSeasonDone.mockResolvedValue({ isDone: true, isWin: true }) + mockIsChallengeDone.mockResolvedValue({ isDone: true, isWin: true }) const wrapper = mount( <Provider store={store}> <DuelOngoing userChallenge={updatedUserChallenge} /> @@ -91,15 +91,15 @@ describe('DuelOngoing component', () => { it('should be redirected to challenges when modal button is clicked', async () => { const store = mockStore({ global: globalStateData, - season: challengeStateData, + challenge: challengeStateData, }) const updatedUserChallenge: UserChallenge = { ...userChallengeData[0], state: UserChallengeState.BOSS, startDate: DateTime.local().setZone('utc', { keepLocalTime: true }), } - mockIsSeasonDone.mockResolvedValue({ isDone: true, isWin: true }) - mockUpdateUserChallenge.mockResolvedValue(updatedUserChallenge) + mockIsChallengeDone.mockResolvedValue({ isDone: true, isWin: true }) + mockUserChallengeUpdateFlag.mockResolvedValue(updatedUserChallenge) const wrapper = mount( <Provider store={store}> <DuelOngoing userChallenge={updatedUserChallenge} /> diff --git a/src/components/Duel/DuelOngoing.tsx b/src/components/Duel/DuelOngoing.tsx index c8013d7aa..e0b2b6e8b 100644 --- a/src/components/Duel/DuelOngoing.tsx +++ b/src/components/Duel/DuelOngoing.tsx @@ -8,17 +8,17 @@ import { AppStore } from 'store' import { unlockNextUserChallenge, updateUserChallengeList, -} from 'store/season/season.actions' -import { toogleSeasonNotification } from 'store/global/global.actions' +} from 'store/challenge/challenge.actions' +import { toogleChallengeNotification } from 'store/global/global.actions' import { formatNumberValues } from 'utils/utils' import { UserBoss, UserChallenge } from 'models' -import { UpdateUserChallenge } from 'enum/userChallenge.enum' +import { UserChallengeUpdateFlag } from 'enum/userChallenge.enum' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import CaptionAverageIcon from 'assets/icons/visu/duel/captionAverage.svg' import CaptionConsumptionIcon from 'assets/icons/visu/duel/captionConsumption.svg' import CaptionIncomingIcon from 'assets/icons/visu/duel/captionIncoming.svg' -import SeasonService from 'services/season.service' +import ChallengeService from 'components/Challenge/node_modules/services/challenge.service' import ChartDuel from 'components/Duel/ChartDuel' import DuelResultModal from 'components/Duel/DuelResultModal' @@ -32,12 +32,12 @@ const DuelOngoing: React.FC<DuelOngoingProps> = ({ const client: Client = useClient() const { t } = useI18n() const { currentDataload } = useSelector( - (state: AppStore) => state.ecolyo.season + (state: AppStore) => state.ecolyo.challenge ) const dispatch = useDispatch() const history = useHistory() const [resultModal, setResultModal] = useState<boolean>(false) - const [winSeason, setWinSeason] = useState<boolean>(false) + const [winChallenge, setWinChallenge] = useState<boolean>(false) const boss: UserBoss = userChallenge.boss const title: string = boss.title @@ -49,33 +49,33 @@ const DuelOngoing: React.FC<DuelOngoingProps> = ({ ).toString() const setResult = useCallback(async () => { - const seasonService = new SeasonService(client) - const updatedSeason = await seasonService.updateUserChallenge( + const challengeService = new ChallengeService(client) + const updatedChallenge = await challengeService.updateUserChallenge( userChallenge, - winSeason + winChallenge ? UserChallengeUpdateFlag.BOSS_WIN : UserChallengeUpdateFlag.BOSS_LOSS ) - dispatch(updateUserChallengeList(updatedSeason)) - dispatch(unlockNextUserChallenge(updatedSeason)) - dispatch(toogleSeasonNotification(false)) + dispatch(updateUserChallengeList(updatedChallenge)) + dispatch(unlockNextUserChallenge(updatedChallenge)) + dispatch(toogleChallengeNotification(false)) history.push('/challenges') - }, [client, dispatch, userChallenge, history, winSeason]) + }, [client, dispatch, userChallenge, history, winChallenge]) useEffect(() => { - const seasonService = new SeasonService(client) + const challengeService = new ChallengeService(client) let subscribed = true - async function setSeasonResult() { - const { isDone, isWin } = await seasonService.isSeasonDone( + async function setChallengeResult() { + const { isDone, isWin } = await challengeService.isChallengeDone( userChallenge, currentDataload ) if (subscribed) { setResultModal(isDone) - setWinSeason(isWin) + setWinChallenge(isWin) } } - setSeasonResult() + setChallengeResult() return () => { subscribed = false } @@ -129,7 +129,7 @@ const DuelOngoing: React.FC<DuelOngoingProps> = ({ <DuelResultModal open={resultModal} userChallenge={userChallenge} - win={winSeason} + win={winChallenge} handleCloseClick={setResult} /> </> diff --git a/src/components/Duel/DuelUnlocked.spec.tsx b/src/components/Duel/DuelUnlocked.spec.tsx index 9c77142de..8777fb9cc 100644 --- a/src/components/Duel/DuelUnlocked.spec.tsx +++ b/src/components/Duel/DuelUnlocked.spec.tsx @@ -7,10 +7,10 @@ import { globalStateData } from '../../../test/__mocks__/globalStateData.mock' import { userChallengeData } from '../../../test/__mocks__/userChallengeData.mock' import { formatNumberValues } from 'utils/utils' import StyledStopButton from 'components/CommonKit/Button/StyledStopButton' -import SeasonNoFluidModal from 'components/Season/SeasonNoFluidModal' +import ChallengeNoFluidModal from 'components/Challenge/ChallengeNoFluidModal' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import { FluidType } from 'enum/fluid.enum' -import { UpdateUserChallenge } from 'enum/userChallenge.enum' +import { UserChallengeUpdateFlag } from 'enum/userChallenge.enum' jest.mock('cozy-ui/transpiled/react/I18n', () => { return { @@ -22,11 +22,11 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { } }) -const mockUpdateUserChallenge = jest.fn() -jest.mock('services/season.service', () => { +const mockUserChallengeUpdateFlag = jest.fn() +jest.mock('services/challenge.service', () => { return jest.fn(() => { return { - updateUserChallenge: mockUpdateUserChallenge, + updateUserChallenge: mockUserChallengeUpdateFlag, } }) }) @@ -57,10 +57,10 @@ describe('DuelUnlocked component', () => { expect(wrapper.find('.boss-description').text()).toEqual(description) expect(wrapper.find('.boss-average-info').exists()).toBeTruthy() expect(wrapper.find('.button-start').exists()).toBeTruthy() - expect(wrapper.find(SeasonNoFluidModal).exists()).toBeTruthy() + expect(wrapper.find(ChallengeNoFluidModal).exists()).toBeTruthy() }) - it('should display SeasonNoFluidModal when launching duel without configured fluid', () => { + it('should display ChallengeNoFluidModal when launching duel without configured fluid', () => { const store = mockStore({ global: globalStateData, }) @@ -76,7 +76,7 @@ describe('DuelUnlocked component', () => { expect(wrapper.find('.modal-opened').exists()).toBeTruthy() }) - it('should not display SeasonNoFluidModal and update userChallenge when launching duel with configured fluid', () => { + it('should not display ChallengeNoFluidModal and update userChallenge when launching duel with configured fluid', () => { const updateGlobalStoreData = { ...globalStateData, fluidTypes: [FluidType.ELECTRICITY], @@ -94,7 +94,7 @@ describe('DuelUnlocked component', () => { .find(StyledStopButton) .simulate('click') expect(wrapper.find('.modal-opened').exists()).toBeFalsy() - expect(mockUpdateUserChallenge).toHaveBeenCalledWith( + expect(mockUserChallengeUpdateFlag).toHaveBeenCalledWith( userChallengeData[0], UserChallengeUpdateFlag.BOSS_START ) diff --git a/src/components/Duel/DuelUnlocked.tsx b/src/components/Duel/DuelUnlocked.tsx index b8cce90a6..3bc94d02d 100644 --- a/src/components/Duel/DuelUnlocked.tsx +++ b/src/components/Duel/DuelUnlocked.tsx @@ -5,16 +5,16 @@ import { useI18n } from 'cozy-ui/transpiled/react/I18n' import { useDispatch, useSelector } from 'react-redux' import { AppStore } from 'store' import { UserChallenge } from 'models' -import { setSeasonConsumption } from 'store/season/season.actions' -import SeasonService from 'services/season.service' +import { setChallengeConsumption } from 'store/challenge/challenge.actions' +import ChallengeService from 'services/challenge.service' import { formatNumberValues, importIconbyId } from 'utils/utils' -import defaultBossIcon from 'assets/icons/visu/season/CHALLENGE0001.svg' +import defaultBossIcon from 'assets/icons/visu/challenge/CHALLENGE0001.svg' import defaultIcon from 'assets/icons/visu/boss/default.svg' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import StyledStopButton from 'components/CommonKit/Button/StyledStopButton' -import SeasonNoFluidModal from 'components/Season/SeasonNoFluidModal' -import { UpdateUserChallenge } from 'enum/userChallenge.enum' +import ChallengeNoFluidModal from 'components/Challenge/ChallengeNoFluidModal' +import { UserChallengeUpdateFlag } from 'enum/userChallenge.enum' interface DuelUnlockedProps { userChallenge: UserChallenge @@ -44,22 +44,22 @@ const DuelUnlocked: React.FC<DuelUnlockedProps> = ({ const launchBoss = useCallback(async () => { if (fluidTypes.length > 0) { - const seasonService = new SeasonService(client) - const updatedSeason = await seasonService.updateUserChallenge( + const challengeService = new ChallengeService(client) + const updatedChallenge = await challengeService.updateUserChallenge( userChallenge, UserChallengeUpdateFlag.BOSS_START ) - const dataloads = await seasonService.getUserChallengeDataload( - updatedSeason + const dataloads = await challengeService.getUserChallengeDataload( + updatedChallenge ) - dispatch(setSeasonConsumption(updatedSeason, dataloads)) + dispatch(setChallengeConsumption(updatedChallenge, dataloads)) } else { return toggleNoFluidModal() } }, [client, dispatch, userChallenge, fluidTypes, toggleNoFluidModal]) useEffect(() => { - importIconbyId(userChallenge.id, 'season').then(icon => { + importIconbyId(userChallenge.id, 'challenge').then(icon => { icon ? setBossIcon(icon) : setBossIcon(defaultBossIcon) }) }, [userChallenge]) @@ -84,10 +84,10 @@ const DuelUnlocked: React.FC<DuelUnlockedProps> = ({ </StyledStopButton> </div> - <SeasonNoFluidModal + <ChallengeNoFluidModal open={openNoFluidModal} handleCloseClick={toggleNoFluidModal} - ></SeasonNoFluidModal> + ></ChallengeNoFluidModal> </div> ) } diff --git a/src/components/Duel/DuelView.spec.tsx b/src/components/Duel/DuelView.spec.tsx index 4dd270fd3..00bd93cac 100644 --- a/src/components/Duel/DuelView.spec.tsx +++ b/src/components/Duel/DuelView.spec.tsx @@ -27,7 +27,7 @@ describe('DuelView component', () => { } const updatedChallengeState = { ...challengeStateData, - currentSeason: updatedUserChallenge, + currentChallenge: updatedUserChallenge, } mockUseSelector.mockReturnValue(updatedChallengeState) const wrapper = shallow(<DuelView />) @@ -42,7 +42,7 @@ describe('DuelView component', () => { } const updatedChallengeState = { ...challengeStateData, - currentSeason: updatedUserChallenge, + currentChallenge: updatedUserChallenge, } mockUseSelector.mockReturnValue(updatedChallengeState) const wrapper = shallow(<DuelView />) @@ -56,7 +56,7 @@ describe('DuelView component', () => { } const updatedChallengeState = { ...challengeStateData, - currentSeason: updatedUserChallenge, + currentChallenge: updatedUserChallenge, } mockUseSelector.mockReturnValue(updatedChallengeState) const wrapper = shallow(<DuelView />) @@ -71,7 +71,7 @@ describe('DuelView component', () => { } const updatedChallengeState = { ...challengeStateData, - currentSeason: updatedUserChallenge, + currentChallenge: updatedUserChallenge, } mockUseSelector.mockReturnValue(updatedChallengeState) const wrapper = shallow(<DuelView />) @@ -86,7 +86,7 @@ describe('DuelView component', () => { } const updatedChallengeState = { ...challengeStateData, - currentSeason: updatedUserChallenge, + currentChallenge: updatedUserChallenge, } mockUseSelector.mockReturnValue(updatedChallengeState) const wrapper = shallow(<DuelView />) diff --git a/src/components/Duel/DuelView.tsx b/src/components/Duel/DuelView.tsx index 0d228b8e7..64aaa59f2 100644 --- a/src/components/Duel/DuelView.tsx +++ b/src/components/Duel/DuelView.tsx @@ -14,20 +14,20 @@ import DuelOngoing from './DuelOngoing' const DuelView: React.FC = () => { const [headerHeight, setHeaderHeight] = useState<number>(0) - const { currentSeason } = useSelector( - (state: AppStore) => state.ecolyo.season + const { currentChallenge } = useSelector( + (state: AppStore) => state.ecolyo.challenge ) const defineHeaderHeight = useCallback((height: number) => { setHeaderHeight(height) }, []) - const renderDuel = (season: UserChallenge) => { - switch (season.boss.state) { + const renderDuel = (challenge: UserChallenge) => { + switch (challenge.boss.state) { case UserBossState.UNLOCKED: - return <DuelUnlocked userChallenge={season} /> + return <DuelUnlocked userChallenge={challenge} /> case UserBossState.ONGOING: - return <DuelOngoing userChallenge={season} /> + return <DuelOngoing userChallenge={challenge} /> default: return <DuelError /> } @@ -43,8 +43,9 @@ const DuelView: React.FC = () => { ></Header> <Content height={headerHeight}> <div> - {currentSeason && currentSeason.state === UserChallengeState.BOSS ? ( - renderDuel(currentSeason) + {currentChallenge && + currentChallenge.state === UserChallengeState.BOSS ? ( + renderDuel(currentChallenge) ) : ( <DuelError /> )} diff --git a/src/components/Navbar/Navbar.spec.tsx b/src/components/Navbar/Navbar.spec.tsx index 30bd1acaf..2a35d44e8 100644 --- a/src/components/Navbar/Navbar.spec.tsx +++ b/src/components/Navbar/Navbar.spec.tsx @@ -37,7 +37,7 @@ describe('Navbar component', () => { const store = mockStore({ global: { ...globalStateData, - seasonNotification: true, + challengeNotification: true, reportNotification: true, }, }) @@ -66,7 +66,7 @@ describe('Navbar component', () => { const store = mockStore({ global: { ...globalStateData, - seasonNotification: false, + challengeNotification: false, reportNotification: false, }, }) diff --git a/src/components/Navbar/Navbar.tsx b/src/components/Navbar/Navbar.tsx index b24c48d7f..901d5e873 100644 --- a/src/components/Navbar/Navbar.tsx +++ b/src/components/Navbar/Navbar.tsx @@ -21,7 +21,7 @@ import './navBar.scss' export const Navbar: React.FC = () => { const { t } = useI18n() - const { seasonNotification, reportNotification } = useSelector( + const { challengeNotification, reportNotification } = useSelector( (state: AppStore) => state.ecolyo.global ) @@ -46,7 +46,7 @@ export const Navbar: React.FC = () => { className="c-nav-link" activeClassName="is-active" > - {seasonNotification && <div className="nb-notif">1</div>} + {challengeNotification && <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/Routes/Routes.tsx b/src/components/Routes/Routes.tsx index 1b52f62bc..9b00310a2 100644 --- a/src/components/Routes/Routes.tsx +++ b/src/components/Routes/Routes.tsx @@ -1,7 +1,7 @@ import React, { Suspense, lazy } from 'react' import { Route, Switch, Redirect } from 'react-router-dom' import { FluidType } from 'enum/fluid.enum' -import SeasonView from 'components/Season/SeasonView' +import ChallengeView from 'components/Challenge/node_modules/components/Challenge/ChallengeView' import DuelView from 'components/Duel/DuelView' const HomeView = lazy(() => import('components/Home/HomeView')) @@ -54,7 +54,7 @@ const Routes = () => { render={({ match: { url } }) => ( <> <Route path={`${url}/duel`} component={DuelView} /> - <Route path={`${url}/`} component={SeasonView} exact /> + <Route path={`${url}/`} component={ChallengeView} exact /> </> )} /> diff --git a/src/components/Season/SeasonCardLocked.tsx b/src/components/Season/SeasonCardLocked.tsx deleted file mode 100644 index 5e6a80939..000000000 --- a/src/components/Season/SeasonCardLocked.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react' -import './seasonCardLocked.scss' -import { UserChallenge } from 'models' -import StyledIcon from 'components/CommonKit/Icon/StyledIcon' -import seasonLockedIcon from 'assets/icons/visu/season/seasonLocked.svg' -import { useI18n } from 'cozy-ui/transpiled/react/I18n' - -interface SeasonCardLockedProps { - userChallenge: UserChallenge -} -const SeasonCardLocked: React.FC<SeasonCardLockedProps> = ({ - userChallenge, -}: SeasonCardLockedProps) => { - const { t } = useI18n() - - return ( - <div className="cardContent cardLocked"> - <p className="title">{t('season.card.title')}</p> - <span className="seasonTitle">{userChallenge.title}</span> - <StyledIcon className="seasonIcon" icon={seasonLockedIcon} /> - <p className="toUnlock text-16-normal-150"> - {t('season.card.locked.desc')} - </p> - </div> - ) -} - -export default SeasonCardLocked diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index 3890d2d2a..90d28914e 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -4,19 +4,19 @@ import classNames from 'classnames' import { useDispatch } from 'react-redux' import { toogleReportNotification, - toogleSeasonNotification, + toogleChallengeNotification, setFluidStatus, } from 'store/global/global.actions' import { updateProfile } from 'store/profile/profile.actions' import { setUserChallengeList, - setSeasonConsumption, -} from 'store/season/season.actions' + setChallengeConsumption, +} from 'store/challenge/challenge.actions' import InitializationService from 'services/initialization.service' import './splashRoot.scss' import { UserChallengeState } from 'enum/userChallenge.enum' import { UserBossState } from 'enum/userBoss.enum' -import SeasonService from 'services/season.service' +import ChallengeService from 'components/Challenge/node_modules/services/challenge.service' interface SplashRootProps { fadeTimer?: number @@ -60,7 +60,7 @@ const SplashRoot = ({ try { // Init index await initializationService.initIndex() - // Init profile and update ecogestures, seasons, report + // Init profile and update ecogestures, challenges, report let profile = await initializationService.initProfile() if (subscribed && profile) { const resultEcogesture = await initializationService.initEcogesture( @@ -80,7 +80,7 @@ const SplashRoot = ({ profile = resultBoss.profile } const resultChallengeEntity = await initializationService.initChallengeEntity( - profile.seasonHash + profile.challengeHash ) if ( subscribed && @@ -101,31 +101,31 @@ const SplashRoot = ({ if (subscribed) { dispatch(setFluidStatus(fluidStatus)) } - // Init Season + // Init Challenge const userChallengeList = await initializationService.initUserChallenges() if (subscribed) { dispatch(setUserChallengeList(userChallengeList)) - const filteredCurrentBossSeason = userChallengeList.filter( - season => season.state === UserChallengeState.BOSS + const filteredCurrentBossChallenge = userChallengeList.filter( + challenge => challenge.state === UserChallengeState.BOSS ) if ( - filteredCurrentBossSeason[0] && - filteredCurrentBossSeason[0].boss.state === UserBossState.ONGOING + filteredCurrentBossChallenge[0] && + filteredCurrentBossChallenge[0].boss.state === UserBossState.ONGOING ) { const { updatedUserChallenge, dataloads, } = await initializationService.initBossProgress( - filteredCurrentBossSeason[0] + filteredCurrentBossChallenge[0] ) - dispatch(setSeasonConsumption(updatedUserChallenge, dataloads)) + dispatch(setChallengeConsumption(updatedUserChallenge, dataloads)) // Check is boss is done and siplay notification - const seasonService = new SeasonService(client) - const { isDone } = await seasonService.isSeasonDone( + const challengeService = new ChallengeService(client) + const { isDone } = await challengeService.isChallengeDone( updatedUserChallenge, dataloads ) - dispatch(toogleSeasonNotification(isDone)) + dispatch(toogleChallengeNotification(isDone)) } } // Update state diff --git a/src/db/profileData.json b/src/db/profileData.json index 0fe543dd2..e9266df9d 100644 --- a/src/db/profileData.json +++ b/src/db/profileData.json @@ -1,7 +1,7 @@ [ { "ecogestureHash": "", - "seasonHash": "", + "challengeHash": "", "bossHash": "", "isFirstConnection": true, "haveSeenFavoriteModal": false, diff --git a/src/doctypes/index.ts b/src/doctypes/index.ts index a25a53001..5ef475cc7 100644 --- a/src/doctypes/index.ts +++ b/src/doctypes/index.ts @@ -55,7 +55,7 @@ const doctypes = { attributes: {}, relationships: {}, }, - season: { + challenge: { doctype: CHALLENGE_DOCTYPE, attributes: {}, relationships: { @@ -65,7 +65,7 @@ const doctypes = { }, }, }, - userseason: { + userchallenge: { doctype: USERCHALLENGE_DOCTYPE, attributes: {}, relationships: {}, diff --git a/src/enum/userChallenge.enum.ts b/src/enum/userChallenge.enum.ts index 8872acaaf..7cdbc1166 100644 --- a/src/enum/userChallenge.enum.ts +++ b/src/enum/userChallenge.enum.ts @@ -1,5 +1,5 @@ export enum UserChallengeUpdateFlag { - SEASON = 0, + CHALLENGE = 0, BOSS_UNLOCK = 10, BOSS_UPDATE_THRESHOLD = 11, BOSS_START = 12, diff --git a/src/enum/userSeason.enum.ts b/src/enum/userSeason.enum.ts deleted file mode 100644 index 0ad2e652d..000000000 --- a/src/enum/userSeason.enum.ts +++ /dev/null @@ -1,14 +0,0 @@ -export enum UserChallengeState { - LOCKED = 0, - UNLOCKED = 1, - ONGOING = 2, - BOSS = 3, - DONE = 4, -} - -export enum UserChallengeSuccess { - ONGOING = 0, - LOST = 1, - ALMOST_WIN = 2, - WIN = 3, -} diff --git a/src/locales/fr.json b/src/locales/fr.json index 9ad3455ad..bc244ad9e 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -336,7 +336,7 @@ "detail": "Détail du mois", "challenge": "Défis terminés en" }, - "season": { + "challenge": { "noFluidModal": { "title": "Oups !", "content": "Connectez au moins 1 fluide pour pouvoir jouer" diff --git a/src/models/challenge.model.ts b/src/models/challenge.model.ts index 8de86f6c7..7711c0cb0 100644 --- a/src/models/challenge.model.ts +++ b/src/models/challenge.model.ts @@ -8,7 +8,7 @@ import { Dataload } from 'models' export interface ChallengeState { userChallengeList: UserChallenge[] - currentSeason: UserChallenge | null + currentChallenge: UserChallenge | null currentDataload: Dataload[] } export interface ChallengeEntity { diff --git a/src/models/global.model.ts b/src/models/global.model.ts index 673b18a89..2d016b382 100644 --- a/src/models/global.model.ts +++ b/src/models/global.model.ts @@ -4,7 +4,7 @@ import { FluidStatus } from './fluid.model' export interface GlobalState { screenType: ScreenType - seasonNotification: boolean + challengeNotification: boolean reportNotification: boolean fluidStatus: FluidStatus[] fluidTypes: FluidType[] diff --git a/src/models/profile.model.ts b/src/models/profile.model.ts index ba69070ca..f47dd96ca 100644 --- a/src/models/profile.model.ts +++ b/src/models/profile.model.ts @@ -3,7 +3,7 @@ import { DateTime } from 'luxon' export interface Profile { id: string ecogestureHash: string - seasonHash: string + challengeHash: string bossHash: string isFirstConnection: boolean haveSeenFavoriteModal: boolean diff --git a/src/services/season.service.spec.ts b/src/services/challenge.service.spec.ts similarity index 76% rename from src/services/season.service.spec.ts rename to src/services/challenge.service.spec.ts index 515d35288..755fa5558 100644 --- a/src/services/season.service.spec.ts +++ b/src/services/challenge.service.spec.ts @@ -4,8 +4,8 @@ import { UserChallengeState, UserChallengeSuccess, } from 'enum/userChallenge.enum' -import { UpdateUserChallenge } from 'enum/userChallenge.enum' -import SeasonService from './season.service' +import { UserChallengeUpdateFlag } from 'enum/userChallenge.enum' +import ChallengeService from './challenge.service' import { userChallengeData, userChallengeDefault, @@ -34,23 +34,27 @@ jest.mock('./consumption.service', () => { }) describe('Boss service', () => { - const seasonService = new SeasonService(mockClient) + const challengeService = new ChallengeService(mockClient) - describe('isAllSeasonLocked method', () => { - it('should return all user season', () => { - const result = seasonService.isAllSeasonLocked(userChallengeData) + describe('unLockCurrentUserChallenge method', () => { + it('should return all user challenge', () => { + const result = challengeService.unLockCurrentUserChallenge( + userChallengeData + ) expect(result).toEqual(userChallengeData) }) - it('should return the season unlocked', () => { + it('should return the challenge unlocked', () => { const expectedResult = userChallengeData[1] expectedResult.state = UserChallengeState.UNLOCKED - const result = seasonService.isAllSeasonLocked([userChallengeData[1]]) + const result = challengeService.unLockCurrentUserChallenge([ + userChallengeData[1], + ]) expect(result).toEqual([expectedResult]) }) }) describe('parseChallengeEntityToUserChallenge method', () => { - it('should return a user season', () => { + it('should return a user challenge', () => { const expectedResult = { id: challengeEntityData.id, title: challengeEntityData.title, @@ -64,7 +68,7 @@ describe('Boss service', () => { endingDate: null, quiz: null, } - const result = seasonService.parseChallengeEntityToUserChallenge( + const result = challengeService.parseChallengeEntityToUserChallenge( challengeEntityData, bossData ) @@ -73,7 +77,7 @@ describe('Boss service', () => { }) describe('buildUserChallengeList method', () => { - it('should return all user season', async () => { + it('should return all user challenge', async () => { const mockQueryResult: QueryResult<ChallengeEntity[], BossEntity[]> = { data: allChallengeEntityData, included: [bossEntity], @@ -90,10 +94,10 @@ describe('Boss service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResultUser) - const result = await seasonService.buildUserChallengeList() + const result = await challengeService.buildUserChallengeList() expect(result).toEqual(userChallengeData) }) - it('should return all user season plus create one missing', async () => { + it('should return all user challenge plus create one missing', async () => { const mockQueryResult: QueryResult<ChallengeEntity[], BossEntity[]> = { data: allChallengeEntityData, included: allBossEntity, @@ -110,10 +114,10 @@ describe('Boss service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResultUser) - const result = await seasonService.buildUserChallengeList() + const result = await challengeService.buildUserChallengeList() expect(result).toEqual(userChallengeData) }) - it('should create all user season', async () => { + it('should create all user challenge', async () => { const mockQueryResult: QueryResult<ChallengeEntity[], BossEntity[]> = { data: allChallengeEntityData, included: [bossEntity], @@ -130,13 +134,13 @@ describe('Boss service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResultUser) - const result = await seasonService.buildUserChallengeList() + const result = await challengeService.buildUserChallengeList() expect(result).toEqual(userChallengeDefault) }) }) - describe('getAllSeasonEntities method', () => { - it('should return all Seasons Entities', async () => { + describe('getAllChallengeEntities method', () => { + it('should return all Challenges Entities', async () => { const mockQueryResult: QueryResult<ChallengeEntity[]> = { data: allChallengeEntityData, bookmark: '', @@ -144,13 +148,13 @@ describe('Boss service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResult) - const result = await seasonService.getAllSeasonEntities() + const result = await challengeService.getAllChallengeEntities() expect(result).toEqual(allChallengeEntityData) }) }) - describe('deleteAllSeasonEntities method', () => { - it('should return delete all Seasons Entities', async () => { + describe('deleteAllChallengeEntities method', () => { + it('should return delete all Challenges Entities', async () => { const mockQueryResult: QueryResult<ChallengeEntity[]> = { data: allChallengeEntityData, bookmark: '', @@ -158,7 +162,7 @@ describe('Boss service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResult) - const result = await seasonService.deleteAllSeasonEntities() + const result = await challengeService.deleteAllChallengeEntities() expect(result).toBeTruthy() }) it('should throw an error because destroy failed', async () => { @@ -171,7 +175,7 @@ describe('Boss service', () => { mockClient.query.mockResolvedValueOnce(mockQueryResult) mockClient.destroy.mockRejectedValue(new Error()) try { - await seasonService.deleteAllSeasonEntities() + await challengeService.deleteAllChallengeEntities() } catch (error) { expect(error).toEqual(new Error()) } @@ -187,7 +191,7 @@ describe('Boss service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResult) - const result = await seasonService.getAllUserChallengeEntities() + const result = await challengeService.getAllUserChallengeEntities() expect(result).toEqual(userChallengeData) }) }) @@ -201,7 +205,7 @@ describe('Boss service', () => { skip: 0, } mockClient.create.mockResolvedValueOnce(mockQueryResult) - const result = await seasonService.startUserChallenge( + const result = await challengeService.startUserChallenge( userChallengeData[0] ) expect(result).toEqual(userChallengeData[2]) @@ -209,7 +213,7 @@ describe('Boss service', () => { it('should throw an error because create failed', async () => { mockClient.create.mockRejectedValue(new Error()) try { - await seasonService.startUserChallenge(userChallengeData[0]) + await challengeService.startUserChallenge(userChallengeData[0]) } catch (error) { expect(error).toEqual(new Error()) } @@ -225,12 +229,12 @@ describe('Boss service', () => { skip: 0, } mockClient.save.mockResolvedValue(mockQueryResult) - const result = await seasonService.updateUserChallenge( + const result = await challengeService.updateUserChallenge( userChallengeData[0], - UserChallengeUpdateFlag.SEASON + UserChallengeUpdateFlag.CHALLENGE ) expect(result).toEqual(userChallengeData[0]) - const resultDefault = await seasonService.updateUserChallenge( + const resultDefault = await challengeService.updateUserChallenge( userChallengeData[0], 999 ) @@ -244,7 +248,7 @@ describe('Boss service', () => { skip: 0, } mockClient.save.mockResolvedValueOnce(mockQueryResult) - const result = await seasonService.updateUserChallenge( + const result = await challengeService.updateUserChallenge( userChallengeData[0], UserChallengeUpdateFlag.BOSS_START ) @@ -262,27 +266,27 @@ describe('Boss service', () => { }, } mockGetGraphData.mockResolvedValueOnce(graphData) - const result = await seasonService.getUserChallengeDataload( + const result = await challengeService.getUserChallengeDataload( updatedUserChallenge ) expect(result).toEqual(graphData.actualData) }) it('should return a empty dataload list when boss has no start date', async () => { - const result = await seasonService.getUserChallengeDataload( + const result = await challengeService.getUserChallengeDataload( userChallengeData[0] ) expect(result).toEqual([]) }) it('should return a empty dataload list', async () => { mockGetGraphData.mockResolvedValueOnce(null) - const result = await seasonService.getUserChallengeDataload( + const result = await challengeService.getUserChallengeDataload( userChallengeData[0] ) expect(result).toEqual([]) }) }) - describe('isSeasonDone method', () => { + describe('isChallengeDone method', () => { const userChallenge = { ...userChallengeData[0], state: UserChallengeState.BOSS, @@ -297,7 +301,10 @@ describe('Boss service', () => { const dataloads = graphData.actualData dataloads[2].value = 50 it('should return isDone = true and isWin = true', async () => { - const result = await seasonService.isSeasonDone(userChallenge, dataloads) + const result = await challengeService.isChallengeDone( + userChallenge, + dataloads + ) expect(result).toEqual({ isDone: true, isWin: true }) }) it('should return isDone = true and isWin = false when threshold < consumption ', async () => { @@ -309,20 +316,21 @@ describe('Boss service', () => { userConsumption: 200, }, } - const result = await seasonService.isSeasonDone( + const result = await challengeService.isChallengeDone( updatedUserChallenge, dataloads ) expect(result).toEqual({ isDone: true, isWin: false }) }) - it('should return isDone = false and isWin = false with last dataload = -1', async () => { + it('should return isDone = false and isWin = true with last dataload = -1', async () => { const updatedDataloads = [...dataloads] updatedDataloads[2].value = -1 - const result = await seasonService.isSeasonDone( + updatedDataloads[2].valueDetail = null + const result = await challengeService.isChallengeDone( userChallenge, updatedDataloads ) - expect(result).toEqual({ isDone: false, isWin: false }) + expect(result).toEqual({ isDone: false, isWin: true }) }) it('should return isDone = false and isWin = false with dataload not complete', async () => { const updatedUserChallenge = { @@ -332,7 +340,7 @@ describe('Boss service', () => { duration: Duration.fromObject({ day: 4 }), }, } - const result = await seasonService.isSeasonDone( + const result = await challengeService.isChallengeDone( updatedUserChallenge, dataloads ) diff --git a/src/services/season.service.ts b/src/services/challenge.service.ts similarity index 82% rename from src/services/season.service.ts rename to src/services/challenge.service.ts index b21e1bbe6..479b73fb3 100644 --- a/src/services/season.service.ts +++ b/src/services/challenge.service.ts @@ -5,14 +5,14 @@ import { UserChallenge, UserChallengeEntity, } from 'models/challenge.model' -import { BossEntity, UserBoss, UserBossEntity } from 'models/boss.model' +import { BossEntity, UserBoss } from 'models/boss.model' import { UserChallengeState, UserChallengeSuccess, } from 'enum/userChallenge.enum' import BossService from './boss.service' -import { UpdateUserChallenge } from 'enum/userChallenge.enum' +import { UserChallengeUpdateFlag } from 'enum/userChallenge.enum' import { DateTime } from 'luxon' import { Datachart, Dataload, Relation, TimePeriod } from 'models' import { getRelationship } from 'utils/utils' @@ -20,7 +20,7 @@ import ConsumptionDataManager from './consumption.service' import { TimeStep } from 'enum/timeStep.enum' import { UserBossState } from 'enum/userBoss.enum' -export default class SeasonService { +export default class ChallengeService { private readonly _client: Client constructor(_client: Client) { @@ -28,8 +28,8 @@ export default class SeasonService { } /** - * Retrieve list of Userseason and unlock the current season if the last one is done - * If all seasons are locked, then unlock the first one + * Retrieve list of Userchallenge and unlock the current challenge if the last one is done + * If all challenges are locked, then unlock the first one * @param {UserChallenge[]} userChallenges - status of fluids * @returns {UserChallenge[]} */ @@ -37,9 +37,9 @@ export default class SeasonService { userChallenges: UserChallenge[] ): UserChallenge[] { let isAllLocked = true - userChallenges.forEach((season, i) => { - if (season.state != UserChallengeState.LOCKED) isAllLocked = false - if (season.state === UserChallengeState.DONE) { + userChallenges.forEach((challenge, i) => { + if (challenge.state != UserChallengeState.LOCKED) isAllLocked = false + if (challenge.state === UserChallengeState.DONE) { if (userChallenges[i + 1].state === UserChallengeState.LOCKED) { userChallenges[i + 1].state = UserChallengeState.UNLOCKED } @@ -83,14 +83,14 @@ export default class SeasonService { * @returns {UserChallenge} */ public parseChallengeEntityToUserChallenge( - season: ChallengeEntity, + challenge: ChallengeEntity, boss: UserBoss ): UserChallenge { const userChallenge: UserChallenge = { - id: season.id, - title: season.title, - description: season.description, - target: season.target, + id: challenge.id, + title: challenge.title, + description: challenge.description, + target: challenge.target, boss: boss, state: UserChallengeState.LOCKED, progress: 0, @@ -103,7 +103,7 @@ export default class SeasonService { } /** - * Retrieve UserChallenge list with all seasons + * Retrieve UserChallenge list with all challenges * @returns {UserChallenge[]} */ public async buildUserChallengeList(): Promise<UserChallenge[]> { @@ -121,35 +121,40 @@ export default class SeasonService { const bossService = new BossService(this._client) let buildList: UserChallenge[] = [] if (challengeEntityList.length > 0 && userChallengeList.length === 0) { - challengeEntityList.forEach(async season => { - const bossEntityRelation: Relation = getRelationship(season, 'boss') + challengeEntityList.forEach(async challenge => { + const bossEntityRelation: Relation = getRelationship(challenge, 'boss') const boss: UserBoss = bossService.getBossfromBossEntities( bossEntityList || [], bossEntityRelation._id ) const userChallenge = this.parseChallengeEntityToUserChallenge( - season, + challenge, boss ) buildList.push(userChallenge) }) buildList = this.unLockCurrentUserChallenge(buildList) } else if (challengeEntityList.length > 0 && userChallengeList.length > 0) { - challengeEntityList.forEach(season => { + challengeEntityList.forEach(challenge => { const userChallengeIndex = userChallengeList.findIndex( - entity => entity.id === season.id + entity => entity.id === challenge.id ) if (userChallengeIndex >= 0) { const userChallenge: UserChallenge = userChallengeList[userChallengeIndex] buildList.push(userChallenge) } else { - const bossEntityRelation: Relation = getRelationship(season, 'boss') + const bossEntityRelation: Relation = getRelationship( + challenge, + 'boss' + ) const boss: UserBoss = bossService.getBossfromBossEntities( bossEntityList || [], bossEntityRelation._id ) - buildList.push(this.parseChallengeEntityToUserChallenge(season, boss)) + buildList.push( + this.parseChallengeEntityToUserChallenge(challenge, boss) + ) } }) buildList = this.unLockCurrentUserChallenge(buildList) @@ -158,25 +163,25 @@ export default class SeasonService { } /** - * Retrieve all SeasonEntities + * Retrieve all ChallengeEntities * @returns {ChallengeEntity[]} */ - public async getAllSeasonEntities(): Promise<ChallengeEntity[]> { + public async getAllChallengeEntities(): Promise<ChallengeEntity[]> { const query: QueryDefinition = Q(CHALLENGE_DOCTYPE) const { - data: seasons, + data: challenges, }: QueryResult<ChallengeEntity[]> = await this._client.query(query) - return seasons + return challenges } /** - * Delete all SeasonEntities + * Delete all ChallengeEntities * @returns {boolean} * @throws {Error} */ - public async deleteAllSeasonEntities(): Promise<boolean> { + public async deleteAllChallengeEntities(): Promise<boolean> { try { - const challengeEntity = await this.getAllSeasonEntities() + const challengeEntity = await this.getAllChallengeEntities() if (!challengeEntity) return true for (let index = 0; index < challengeEntity.length; index++) { await this._client.destroy(challengeEntity[index]) @@ -240,19 +245,19 @@ export default class SeasonService { /** * Update UserChallenge depending on the flag and retrieve it * @param {UserChallenge} userChallenge - userChallenge to update - * @param {UpdateUserChallenge} flag - update flag + * @param {UserChallengeUpdateFlag} flag - update flag * @returns {UserChallenge} - updated userChallenge * @throws {Error} */ public async updateUserChallenge( userChallenge: UserChallenge, - flag: UpdateUserChallenge + flag: UserChallengeUpdateFlag ): Promise<UserChallenge> { let updatedUserChallenge: UserChallenge let updatedBoss = userChallenge.boss const bossService = new BossService(this._client) switch (flag) { - case UserChallengeUpdateFlag.SEASON: + case UserChallengeUpdateFlag.CHALLENGE: case UserChallengeUpdateFlag.BOSS_CONSUMPTION: updatedUserChallenge = userChallenge break @@ -325,7 +330,7 @@ export default class SeasonService { ) return result } catch (error) { - console.log('Update user season error : ', error) + console.log('Update user challenge error : ', error) throw error } } @@ -333,7 +338,7 @@ export default class SeasonService { /** * Retrieve the dataload for a UserChallenge with boss ongoing * @param {UserChallenge} userChallenge - userChallenge to update - * @param {UpdateUserChallenge} flag - update flag + * @param {UserChallengeUpdateFlag} flag - update flag * @returns {Dataload[]} */ public async getUserChallengeDataload( @@ -362,12 +367,12 @@ export default class SeasonService { } /** - * Define if season is done and if is win or lost + * Define if challenge is done and if is win or lost * @param {UserChallenge} userChallenge - current userChallenge * @param {Dataload[]} dataloads - dataloads of current challenge * @returns {boolean, boolean} */ - public async isSeasonDone( + public async isChallengeDone( userChallenge: UserChallenge, dataloads: Dataload[] ): Promise<{ isDone: boolean; isWin: boolean }> { @@ -381,22 +386,19 @@ export default class SeasonService { const duration = userChallenge.boss.duration.days if (dataloads.length === duration) { - if ( - dataloads[duration - 1].valueDetail !== null && - typeof dataloads[duration - 1].valueDetail === 'object' - ) { - const newValueDetail: number[] | null = - dataloads[duration - 1].valueDetail - if ( - newValueDetail !== null && - newValueDetail.includes(-1) === false - ) { + const dataload = dataloads[duration - 1] + if (dataload.valueDetail) { + let completedValueDetail = true + if (dataload.valueDetail) { + dataload.valueDetail.forEach(value => { + if (!value || (value && value === -1)) + completedValueDetail = false + }) + } + if (completedValueDetail) { isDone = true } - } else if ( - dataloads[duration - 1].valueDetail === null && - dataloads[duration - 1].value !== -1 - ) { + } else if (dataload.valueDetail === null && dataload.value !== -1) { isDone = true } if (userChallenge.boss.userConsumption < userChallenge.boss.threshold) { diff --git a/src/services/initialization.service.spec.ts b/src/services/initialization.service.spec.ts index 1df846d2f..921745b99 100644 --- a/src/services/initialization.service.spec.ts +++ b/src/services/initialization.service.spec.ts @@ -74,13 +74,13 @@ jest.mock('./fluid.service', () => { const mockBuildUserChallengeList = jest.fn() const mockGetUserChallengeDataload = jest.fn() -const mockUpdateUserChallenge = jest.fn() -jest.mock('./season.service', () => { +const mockUserChallengeUpdateFlag = jest.fn() +jest.mock('./challenge.service', () => { return jest.fn(() => { return { buildUserChallengeList: mockBuildUserChallengeList, getUserChallengeDataload: mockGetUserChallengeDataload, - updateUserChallenge: mockUpdateUserChallenge, + updateUserChallenge: mockUserChallengeUpdateFlag, } }) }) @@ -529,7 +529,7 @@ describe('Initialization service', () => { userConsumption: 130.83585, }, } - mockUpdateUserChallenge.mockResolvedValueOnce( + mockUserChallengeUpdateFlag.mockResolvedValueOnce( expectedUpdatedUserChallenge ) const expectedResult = { diff --git a/src/services/initialization.service.ts b/src/services/initialization.service.ts index b76b7720a..65b29741a 100644 --- a/src/services/initialization.service.ts +++ b/src/services/initialization.service.ts @@ -22,7 +22,7 @@ import { FluidType } from 'enum/fluid.enum' import { Dataload, FluidStatus, Profile, UserChallenge } from 'models' import EcogestureService from 'services/ecogesture.service' -import SeasonService from 'services/season.service' +import ChallengeService from 'services/challenge.service' import ecogestureData from 'db/ecogestureData.json' import challengeEntityData from 'db/challengeEntity.json' import bossEntityData from 'db/bossEntity.json' @@ -39,7 +39,7 @@ import { hashFile } from 'utils/hash' import { getActualReportDate } from 'utils/date' import { TimeStep } from 'enum/timeStep.enum' import ConsumptionDataManager from './consumption.service' -import { UpdateUserChallenge } from 'enum/userChallenge.enum' +import { UserChallengeUpdateFlag } from 'enum/userChallenge.enum' import { getRoundFloat } from 'utils/math' export default class InitializationService { @@ -304,12 +304,12 @@ export default class InitializationService { result: boolean profile: Profile | null }> { - const seasonHash = hashFile(challengeEntityData) - const seasonService = new SeasonService(this._client) + const challengeHash = hashFile(challengeEntityData) + const challengeService = new ChallengeService(this._client) const profileService = new ProfileService(this._client) // Populate data if none challengeEntity exists - const loadedChallengeEntity = await seasonService.getAllSeasonEntities() + const loadedChallengeEntity = await challengeService.getAllChallengeEntities() if ( !loadedChallengeEntity || (loadedChallengeEntity && loadedChallengeEntity.length === 0) @@ -320,7 +320,7 @@ export default class InitializationService { await this._client.create(CHALLENGE_DOCTYPE, challengeEntityData[i]) } // Check of created document - const checkCount = await seasonService.getAllSeasonEntities() + const checkCount = await challengeService.getAllChallengeEntities() if ( !checkCount || (checkCount && checkCount.length !== challengeEntityData.length) @@ -331,11 +331,11 @@ export default class InitializationService { } // Update profil with the hash const updatedProfile = await profileService.updateProfile({ - seasonHash: seasonHash, + challengeHash: challengeHash, }) if (updatedProfile) { console.log( - '%c Initialization: Season entities created', + '%c Initialization: Challenge entities created', 'background: #222; color: white' ) return { @@ -352,11 +352,11 @@ export default class InitializationService { } // Update if the hash is not the same as the one from profile - if (hash !== seasonHash) { + if (hash !== challengeHash) { // Update the doctype try { // Deletion of all documents - await seasonService.deleteAllSeasonEntities() + await challengeService.deleteAllChallengeEntities() // Population with the data await Promise.all( challengeEntityData.map(async challengeEntity => { @@ -364,22 +364,22 @@ export default class InitializationService { }) ) // Check of created document - const checkCount = await seasonService.getAllSeasonEntities() + const checkCount = await challengeService.getAllChallengeEntities() if ( !checkCount || (checkCount && checkCount.length !== challengeEntityData.length) ) { throw new Error( - 'initChallengeEntity: Created season entities does not match' + 'initChallengeEntity: Created challenge entities does not match' ) } // Update profil with the hash const updatedProfile = await profileService.updateProfile({ - seasonHash: seasonHash, + challengeHash: challengeHash, }) if (updatedProfile) { console.log( - '%c Initialization: Season entities updated', + '%c Initialization: Challenge entities updated', 'background: #222; color: white' ) return { @@ -396,7 +396,7 @@ export default class InitializationService { } else { // Doctype already up to date console.log( - '%c Initialization: Season Entity loaded', + '%c Initialization: Challenge Entity loaded', 'background: #222; color: white' ) return { result: true, profile: null } @@ -498,7 +498,7 @@ export default class InitializationService { } else { // Doctype already up to date console.log( - '%c Initialization: Season Entity loaded', + '%c Initialization: Challenge Entity loaded', 'background: #222; color: white' ) return { result: true, profile: null } @@ -594,12 +594,12 @@ export default class InitializationService { * failure throw error */ public async initUserChallenges(): Promise<UserChallenge[]> { - const seasonService = new SeasonService(this._client) + const challengeService = new ChallengeService(this._client) try { - const userChallengeList = await seasonService.buildUserChallengeList() + const userChallengeList = await challengeService.buildUserChallengeList() if (userChallengeList) { console.log( - '%c Initialization: Seasons loaded', + '%c Initialization: Challenges loaded', 'background: #222; color: white' ) return userChallengeList @@ -620,10 +620,10 @@ export default class InitializationService { public async initBossProgress( userChallenge: UserChallenge ): Promise<{ updatedUserChallenge: UserChallenge; dataloads: Dataload[] }> { - const seasonService = new SeasonService(this._client) + const challengeService = new ChallengeService(this._client) const consumptionService = new ConsumptionDataManager(this._client) try { - const dataloads: Dataload[] = await seasonService.getUserChallengeDataload( + const dataloads: Dataload[] = await challengeService.getUserChallengeDataload( userChallenge ) const userConsumption: number = getRoundFloat( @@ -636,7 +636,7 @@ export default class InitializationService { userConsumption: userConsumption, }, } - const updatedUserChallenge: UserChallenge = await seasonService.updateUserChallenge( + const updatedUserChallenge: UserChallenge = await challengeService.updateUserChallenge( _userChallenge, UserChallengeUpdateFlag.BOSS_CONSUMPTION ) diff --git a/src/store/season/season.action.spec.ts b/src/store/challenge/challenge.action.spec.ts similarity index 59% rename from src/store/season/season.action.spec.ts rename to src/store/challenge/challenge.action.spec.ts index efbe75e93..f470183df 100644 --- a/src/store/season/season.action.spec.ts +++ b/src/store/challenge/challenge.action.spec.ts @@ -1,21 +1,19 @@ import { - SET_USER_SEASON_LIST, - UPDATE_USER_SEASON_LIST, - UNLOCK_NEXT_USER_SEASON, - SET_SEASON_CONSUMPTION, + SET_USER_CHALLENGE_LIST, + UPDATE_USER_CHALLENGE_LIST, + UNLOCK_NEXT_USER_CHALLENGE, + SET_CHALLENGE_CONSUMPTION, setUserChallengeList, updateUserChallengeList, unlockNextUserChallenge, - setSeasonConsumption, -} from './season.actions' + setChallengeConsumption, +} from './challenge.actions' import { userChallengeData } from '../../../test/__mocks__/userChallengeData.mock' -import { Dataload } from 'models' -import { DateTime } from 'luxon' -describe('season actions', () => { +describe('challenge actions', () => { it('should create an action to set userChallengeList', () => { const expectedAction = { - type: SET_USER_SEASON_LIST, + type: SET_USER_CHALLENGE_LIST, payload: userChallengeData, } expect(setUserChallengeList(userChallengeData)).toEqual(expectedAction) @@ -23,7 +21,7 @@ describe('season actions', () => { it('should create an action to update the userChallengeList', () => { const expectedAction = { - type: UPDATE_USER_SEASON_LIST, + type: UPDATE_USER_CHALLENGE_LIST, payload: userChallengeData[0], } expect(updateUserChallengeList(userChallengeData[0])).toEqual( @@ -31,9 +29,9 @@ describe('season actions', () => { ) }) - it('should create an action to unlock next season in the list', () => { + it('should create an action to unlock next challenge in the list', () => { const expectedAction = { - type: UNLOCK_NEXT_USER_SEASON, + type: UNLOCK_NEXT_USER_CHALLENGE, payload: userChallengeData[0], } expect(unlockNextUserChallenge(userChallengeData[0])).toEqual( @@ -41,12 +39,12 @@ describe('season actions', () => { ) }) - it('should create an action to update season with consumption in the list and set current data load', () => { + it('should create an action to update challenge with consumption in the list and set current data load', () => { const expectedAction = { - type: SET_SEASON_CONSUMPTION, + type: SET_CHALLENGE_CONSUMPTION, payload: { userChallenge: userChallengeData[0], currentDataload: [] }, } - expect(setSeasonConsumption(userChallengeData[0], [])).toEqual( + expect(setChallengeConsumption(userChallengeData[0], [])).toEqual( expectedAction ) }) diff --git a/src/store/challenge/challenge.actions.ts b/src/store/challenge/challenge.actions.ts new file mode 100644 index 000000000..6ed42b01f --- /dev/null +++ b/src/store/challenge/challenge.actions.ts @@ -0,0 +1,69 @@ +import { Dataload, UserChallenge } from 'models' + +export const SET_USER_CHALLENGE_LIST = 'SET_USER_CHALLENGE_LIST' +export const UPDATE_USER_CHALLENGE_LIST = 'UPDATE_USER_CHALLENGE_LIST' +export const UNLOCK_NEXT_USER_CHALLENGE = 'UNLOCK_NEXT_USER_CHALLENGE' +export const SET_CHALLENGE_CONSUMPTION = 'SET_CHALLENGE_CONSUMPTION' + +interface SetUserChallengeList { + type: typeof SET_USER_CHALLENGE_LIST + payload?: UserChallenge[] +} + +interface UserChallengeUpdateFlag { + type: typeof UPDATE_USER_CHALLENGE_LIST + payload?: UserChallenge +} + +interface UnlockNextUserChallenge { + type: typeof UNLOCK_NEXT_USER_CHALLENGE + payload?: UserChallenge +} + +interface SetChallengeConsumption { + type: typeof SET_CHALLENGE_CONSUMPTION + payload?: { userChallenge: UserChallenge; currentDataload: Dataload[] } +} + +export type ChallengeActionTypes = + | SetUserChallengeList + | UserChallengeUpdateFlag + | UnlockNextUserChallenge + | SetChallengeConsumption + +export function setUserChallengeList( + userChallengeList: UserChallenge[] +): ChallengeActionTypes { + return { + type: SET_USER_CHALLENGE_LIST, + payload: userChallengeList, + } +} + +export function updateUserChallengeList( + userChallenge: UserChallenge +): ChallengeActionTypes { + return { + type: UPDATE_USER_CHALLENGE_LIST, + payload: userChallenge, + } +} + +export function unlockNextUserChallenge( + userChallenge: UserChallenge +): ChallengeActionTypes { + return { + type: UNLOCK_NEXT_USER_CHALLENGE, + payload: userChallenge, + } +} + +export function setChallengeConsumption( + userChallenge: UserChallenge, + currentDataload: Dataload[] +): ChallengeActionTypes { + return { + type: SET_CHALLENGE_CONSUMPTION, + payload: { userChallenge, currentDataload }, + } +} diff --git a/src/store/season/season.reducer.spec.ts b/src/store/challenge/challenge.reducer.spec.ts similarity index 62% rename from src/store/season/season.reducer.spec.ts rename to src/store/challenge/challenge.reducer.spec.ts index faad3ea5b..8c44a5a40 100644 --- a/src/store/season/season.reducer.spec.ts +++ b/src/store/challenge/challenge.reducer.spec.ts @@ -1,10 +1,10 @@ -import { seasonReducer } from './season.reducer' +import { challengeReducer } from './challenge.reducer' import { - SET_USER_SEASON_LIST, - UPDATE_USER_SEASON_LIST, - UNLOCK_NEXT_USER_SEASON, - SET_SEASON_CONSUMPTION, -} from './season.actions' + SET_USER_CHALLENGE_LIST, + UPDATE_USER_CHALLENGE_LIST, + UNLOCK_NEXT_USER_CHALLENGE, + SET_CHALLENGE_CONSUMPTION, +} from './challenge.actions' import { Dataload, ChallengeState, UserChallenge } from 'models' import { UserChallengeState } from 'enum/userChallenge.enum' import { challengeStateData } from '../../../test/__mocks__/challengeStateData.mock' @@ -14,34 +14,34 @@ import { } from '../../../test/__mocks__/userChallengeData.mock' import { DateTime } from 'luxon' -describe('season reducer', () => { +describe('challenge reducer', () => { it('should return the initial state', () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any - const result = seasonReducer(undefined as any, { type: 'default' }) + const result = challengeReducer(undefined as any, { type: 'default' }) expect(result).toEqual(challengeStateData) }) - it('should handle SET_USER_SEASON_LIST with payload', () => { - const result = seasonReducer(challengeStateData, { - type: SET_USER_SEASON_LIST, + it('should handle SET_USER_CHALLENGE_LIST with payload', () => { + const result = challengeReducer(challengeStateData, { + type: SET_USER_CHALLENGE_LIST, payload: userChallengeData, }) const expectedResult: ChallengeState = { userChallengeList: userChallengeData, - currentSeason: userChallengeData[2], + currentChallenge: userChallengeData[2], currentDataload: [], } expect(result).toEqual(expectedResult) }) - it('should handle SET_USER_SEASON_LIST without payload', () => { - const result = seasonReducer(challengeStateData, { - type: SET_USER_SEASON_LIST, + it('should handle SET_USER_CHALLENGE_LIST without payload', () => { + const result = challengeReducer(challengeStateData, { + type: SET_USER_CHALLENGE_LIST, }) expect(result).toEqual(challengeStateData) }) - it('should handle UPDATE_USER_SEASON_LIST with payload', () => { + it('should handle UPDATE_USER_CHALLENGE_LIST with payload', () => { const updatedChallengeStateData = { ...challengeStateData, userChallengeList: userChallengeDefault, @@ -50,8 +50,8 @@ describe('season reducer', () => { ...userChallengeDefault[0], state: UserChallengeState.ONGOING, } - const result = seasonReducer(updatedChallengeStateData, { - type: UPDATE_USER_SEASON_LIST, + const result = challengeReducer(updatedChallengeStateData, { + type: UPDATE_USER_CHALLENGE_LIST, payload: updatedUserChallenge, }) const expectedResult: ChallengeState = { @@ -59,20 +59,20 @@ describe('season reducer', () => { updatedUserChallenge, ...userChallengeDefault.slice(1), ], - currentSeason: updatedUserChallenge, + currentChallenge: updatedUserChallenge, currentDataload: [], } expect(result).toEqual(expectedResult) }) - it('should handle UPDATE_USER_SEASON_LIST without payload', () => { - const result = seasonReducer(challengeStateData, { - type: UPDATE_USER_SEASON_LIST, + it('should handle UPDATE_USER_CHALLENGE_LIST without payload', () => { + const result = challengeReducer(challengeStateData, { + type: UPDATE_USER_CHALLENGE_LIST, }) expect(result).toEqual(challengeStateData) }) - it('should handle UNLOCK_NEXT_USER_SEASON with payload', () => { + it('should handle UNLOCK_NEXT_USER_CHALLENGE with payload', () => { const updatedChallengeStateData = { ...challengeStateData, userChallengeList: userChallengeDefault, @@ -85,8 +85,8 @@ describe('season reducer', () => { ...userChallengeDefault[1], state: UserChallengeState.UNLOCKED, } - const result = seasonReducer(updatedChallengeStateData, { - type: UNLOCK_NEXT_USER_SEASON, + const result = challengeReducer(updatedChallengeStateData, { + type: UNLOCK_NEXT_USER_CHALLENGE, payload: updatedUserChallenge, }) const expectedResult: ChallengeState = { @@ -95,20 +95,20 @@ describe('season reducer', () => { unlockedUserChallenge, ...userChallengeDefault.slice(2, 6), ], - currentSeason: null, + currentChallenge: null, currentDataload: [], } expect(result).toEqual(expectedResult) }) - it('should handle UNLOCK_NEXT_USER_SEASON without payload', () => { - const result = seasonReducer(challengeStateData, { - type: UNLOCK_NEXT_USER_SEASON, + it('should handle UNLOCK_NEXT_USER_CHALLENGE without payload', () => { + const result = challengeReducer(challengeStateData, { + type: UNLOCK_NEXT_USER_CHALLENGE, }) expect(result).toEqual(challengeStateData) }) - it('should handle SET_SEASON_CONSUMPTION with payload', () => { + it('should handle SET_CHALLENGE_CONSUMPTION with payload', () => { const updatedChallengeStateData = { ...challengeStateData, userChallengeList: userChallengeDefault, @@ -132,11 +132,11 @@ describe('season reducer', () => { updatedUserChallenge, ...userChallengeDefault.slice(1, 6), ], - currentSeason: null, + currentChallenge: null, currentDataload: dataload, } - const result = seasonReducer(updatedChallengeStateData, { - type: SET_SEASON_CONSUMPTION, + const result = challengeReducer(updatedChallengeStateData, { + type: SET_CHALLENGE_CONSUMPTION, payload: { userChallenge: updatedUserChallenge, currentDataload: dataload, @@ -145,9 +145,9 @@ describe('season reducer', () => { expect(result).toEqual(expectedResult) }) - it('should handle SET_SEASON_CONSUMPTION without payload', () => { - const result = seasonReducer(challengeStateData, { - type: SET_SEASON_CONSUMPTION, + it('should handle SET_CHALLENGE_CONSUMPTION without payload', () => { + const result = challengeReducer(challengeStateData, { + type: SET_CHALLENGE_CONSUMPTION, }) expect(result).toEqual(challengeStateData) }) diff --git a/src/store/season/season.reducer.ts b/src/store/challenge/challenge.reducer.ts similarity index 58% rename from src/store/season/season.reducer.ts rename to src/store/challenge/challenge.reducer.ts index 9d5eb38a5..2bd51b2ab 100644 --- a/src/store/season/season.reducer.ts +++ b/src/store/challenge/challenge.reducer.ts @@ -1,67 +1,73 @@ import { Reducer } from 'redux' import { - SET_USER_SEASON_LIST, - UPDATE_USER_SEASON_LIST, - UNLOCK_NEXT_USER_SEASON, - SET_SEASON_CONSUMPTION, - SeasonActionTypes, -} from './season.actions' + SET_USER_CHALLENGE_LIST, + UPDATE_USER_CHALLENGE_LIST, + UNLOCK_NEXT_USER_CHALLENGE, + SET_CHALLENGE_CONSUMPTION, + ChallengeActionTypes, +} from './challenge.actions' import { ChallengeState } from 'models' import { UserChallengeState } from 'enum/userChallenge.enum' const initialState: ChallengeState = { userChallengeList: [], - currentSeason: null, + currentChallenge: null, currentDataload: [], } -export const seasonReducer: Reducer<ChallengeState> = ( +export const challengeReducer: Reducer<ChallengeState> = ( state = initialState, - action: SeasonActionTypes + action: ChallengeActionTypes ): ChallengeState => { switch (action.type) { - case SET_USER_SEASON_LIST: + case SET_USER_CHALLENGE_LIST: if (action.payload !== undefined) { - const filteredCurrentSeason = action.payload.filter( - season => - season.state === UserChallengeState.ONGOING || - season.state === UserChallengeState.BOSS + const filteredCurrentChallenge = action.payload.filter( + challenge => + challenge.state === UserChallengeState.ONGOING || + challenge.state === UserChallengeState.BOSS ) - const currentSeason = filteredCurrentSeason[0] - ? filteredCurrentSeason[0] + const currentChallenge = filteredCurrentChallenge[0] + ? filteredCurrentChallenge[0] : null return { ...state, userChallengeList: action.payload, - currentSeason: currentSeason, + currentChallenge: currentChallenge, } } else { return state } - case UPDATE_USER_SEASON_LIST: + case UPDATE_USER_CHALLENGE_LIST: if (action.payload !== undefined) { const id = action.payload.id - const currentSeason = + const currentChallenge = action.payload.state === UserChallengeState.ONGOING || action.payload.state === UserChallengeState.BOSS ? action.payload : null const updatedList = [...state.userChallengeList] - const findIndex = updatedList.findIndex(season => season.id === id) + const findIndex = updatedList.findIndex( + challenge => challenge.id === id + ) updatedList[findIndex] = action.payload return { ...state, userChallengeList: updatedList, - currentSeason: currentSeason ? currentSeason : state.currentSeason, + currentChallenge: currentChallenge + ? currentChallenge + : state.currentChallenge, } } else { return state } - case UNLOCK_NEXT_USER_SEASON: + case UNLOCK_NEXT_USER_CHALLENGE: if (action.payload !== undefined) { const id = action.payload.id const updatedList = [...state.userChallengeList] - const findIndex = updatedList.findIndex(season => season.id === id) + const findIndex = updatedList.findIndex( + challenge => challenge.id === id + ) updatedList[findIndex] = action.payload if (typeof updatedList[findIndex + 1] !== 'undefined') { updatedList[findIndex + 1] = { @@ -72,25 +78,27 @@ export const seasonReducer: Reducer<ChallengeState> = ( return { ...state, userChallengeList: updatedList, - currentSeason: null, + currentChallenge: null, } } else { return state } - case SET_SEASON_CONSUMPTION: + case SET_CHALLENGE_CONSUMPTION: if (action.payload !== undefined) { const id = action.payload.userChallenge.id const updatedList = [...state.userChallengeList] - const findIndex = updatedList.findIndex(season => season.id === id) + const findIndex = updatedList.findIndex( + challenge => challenge.id === id + ) updatedList[findIndex] = action.payload.userChallenge return { ...state, userChallengeList: updatedList, - currentSeason: - state.currentSeason && - state.currentSeason.id === action.payload.userChallenge.id + currentChallenge: + state.currentChallenge && + state.currentChallenge.id === action.payload.userChallenge.id ? action.payload.userChallenge - : state.currentSeason, + : state.currentChallenge, currentDataload: action.payload.currentDataload, } } else { diff --git a/src/store/global/global.action.spec.ts b/src/store/global/global.action.spec.ts index 6be5d1be7..ebb05ef67 100644 --- a/src/store/global/global.action.spec.ts +++ b/src/store/global/global.action.spec.ts @@ -1,11 +1,11 @@ import { ScreenType } from 'enum/screen.enum' import { CHANGE_SCREEN_TYPE, - TOOGLE_SEASON_NOTIFICATION, + TOOGLE_CHALLENGE_NOTIFICATION, TOOGLE_REPORT_NOTIFICATION, SET_FLUID_STATUS, changeScreenType, - toogleSeasonNotification, + toogleChallengeNotification, toogleReportNotification, setFluidStatus, } from './global.actions' @@ -20,13 +20,13 @@ describe('global actions', () => { expect(changeScreenType(screenType)).toEqual(expectedAction) }) - it('should create an action to toogle season notification', () => { + it('should create an action to toogle challenge notification', () => { const notification = true const expectedAction = { - type: TOOGLE_SEASON_NOTIFICATION, + type: TOOGLE_CHALLENGE_NOTIFICATION, payload: notification, } - expect(toogleSeasonNotification(notification)).toEqual(expectedAction) + expect(toogleChallengeNotification(notification)).toEqual(expectedAction) }) it('should create an action to toogle report notification', () => { diff --git a/src/store/global/global.actions.ts b/src/store/global/global.actions.ts index a6a53a48c..b0a16c593 100644 --- a/src/store/global/global.actions.ts +++ b/src/store/global/global.actions.ts @@ -2,7 +2,7 @@ import { ScreenType } from 'enum/screen.enum' import { FluidStatus } from 'models' export const CHANGE_SCREEN_TYPE = 'CHANGE_SCREEN_TYPE' -export const TOOGLE_SEASON_NOTIFICATION = 'TOOGLE_SEASON_NOTIFICATION' +export const TOOGLE_CHALLENGE_NOTIFICATION = 'TOOGLE_CHALLENGE_NOTIFICATION' export const TOOGLE_REPORT_NOTIFICATION = 'TOOGLE_REPORT_NOTIFICATION' export const SET_FLUID_STATUS = 'SET_FLUID_STATUS' @@ -11,8 +11,8 @@ interface ChangeScreenType { payload?: ScreenType } -interface ToogleSeasonNotification { - type: typeof TOOGLE_SEASON_NOTIFICATION +interface ToogleChallengeNotification { + type: typeof TOOGLE_CHALLENGE_NOTIFICATION payload?: boolean } @@ -28,7 +28,7 @@ interface SetFluidStatus { export type GlobalActionTypes = | ChangeScreenType - | ToogleSeasonNotification + | ToogleChallengeNotification | ToogleReportNotification | SetFluidStatus @@ -39,9 +39,9 @@ export function changeScreenType(screenType: ScreenType): GlobalActionTypes { } } -export function toogleSeasonNotification(notif: boolean): GlobalActionTypes { +export function toogleChallengeNotification(notif: boolean): GlobalActionTypes { return { - type: TOOGLE_SEASON_NOTIFICATION, + type: TOOGLE_CHALLENGE_NOTIFICATION, payload: notif, } } diff --git a/src/store/global/global.reducer.spec.ts b/src/store/global/global.reducer.spec.ts index 32dc351e9..f1aa2e44f 100644 --- a/src/store/global/global.reducer.spec.ts +++ b/src/store/global/global.reducer.spec.ts @@ -1,7 +1,7 @@ import { globalReducer } from './global.reducer' import { CHANGE_SCREEN_TYPE, - TOOGLE_SEASON_NOTIFICATION, + TOOGLE_CHALLENGE_NOTIFICATION, TOOGLE_REPORT_NOTIFICATION, SET_FLUID_STATUS, } from './global.actions' @@ -29,7 +29,7 @@ const mockFluidStatus: FluidStatus[] = [ const mockInitialState: GlobalState = { screenType: ScreenType.MOBILE, - seasonNotification: false, + challengeNotification: false, reportNotification: false, fluidStatus: mockFluidStatus, fluidTypes: [], @@ -60,20 +60,20 @@ describe('global reducer', () => { expect(result).toEqual(mockInitialState) }) - it('should handle TOOGLE_SEASON_NOTIFICATION with payload', () => { + it('should handle TOOGLE_CHALLENGE_NOTIFICATION with payload', () => { const result = globalReducer(mockInitialState, { - type: TOOGLE_SEASON_NOTIFICATION, + type: TOOGLE_CHALLENGE_NOTIFICATION, payload: true, }) expect(result).toEqual({ ...mockInitialState, - seasonNotification: true, + challengeNotification: true, }) }) - it('should handle TOOGLE_SEASON_NOTIFICATION without payload', () => { + it('should handle TOOGLE_CHALLENGE_NOTIFICATION without payload', () => { const result = globalReducer(mockInitialState, { - type: TOOGLE_SEASON_NOTIFICATION, + type: TOOGLE_CHALLENGE_NOTIFICATION, }) expect(result).toEqual(mockInitialState) }) diff --git a/src/store/global/global.reducer.ts b/src/store/global/global.reducer.ts index c434ee6b5..748b3eef1 100644 --- a/src/store/global/global.reducer.ts +++ b/src/store/global/global.reducer.ts @@ -1,7 +1,7 @@ import { Reducer } from 'redux' import { CHANGE_SCREEN_TYPE, - TOOGLE_SEASON_NOTIFICATION, + TOOGLE_CHALLENGE_NOTIFICATION, TOOGLE_REPORT_NOTIFICATION, SET_FLUID_STATUS, GlobalActionTypes, @@ -12,7 +12,7 @@ import { FluidType } from 'enum/fluid.enum' const initialState: GlobalState = { screenType: ScreenType.MOBILE, - seasonNotification: false, + challengeNotification: false, reportNotification: false, fluidStatus: [ { @@ -56,11 +56,11 @@ export const globalReducer: Reducer<GlobalState> = ( screenType: action.payload, } : state - case TOOGLE_SEASON_NOTIFICATION: + case TOOGLE_CHALLENGE_NOTIFICATION: return action.payload != undefined ? { ...state, - seasonNotification: action.payload, + challengeNotification: action.payload, } : state case TOOGLE_REPORT_NOTIFICATION: diff --git a/src/store/index.ts b/src/store/index.ts index c255668f1..e633567c9 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -5,7 +5,7 @@ import { globalReducer } from 'store/global/global.reducer' import { profileReducer } from './profile/profile.reducer' import { chartReducer } from './chart/chart.reducer' import { modalReducer } from 'store/modal/modal.reducer' -import { seasonReducer } from './season/season.reducer' +import { challengeReducer } from './challenge/challenge.reducer' import { GlobalState, ModalState, Profile, ChallengeState } from 'models' import { ChartState } from 'models/chart.model' import { Client } from 'cozy-client' @@ -15,7 +15,7 @@ export interface EcolyoState { profile: Profile chart: ChartState modal: ModalState - season: ChallengeState + challenge: ChallengeState } export const ecolyoReducer = combineReducers({ @@ -23,7 +23,7 @@ export const ecolyoReducer = combineReducers({ profile: profileReducer, chart: chartReducer, modal: modalReducer, - season: seasonReducer, + challenge: challengeReducer, }) export interface AppStore { diff --git a/src/store/profile/profile.reducer.spec.ts b/src/store/profile/profile.reducer.spec.ts index 57e6b121e..5e86bb816 100644 --- a/src/store/profile/profile.reducer.spec.ts +++ b/src/store/profile/profile.reducer.spec.ts @@ -7,7 +7,7 @@ import { profileData } from '../../../test/__mocks__/profile.mock' const mockInitialState: Profile = { id: '', ecogestureHash: '', - seasonHash: '', + challengeHash: '', bossHash: '', isFirstConnection: false, haveSeenFavoriteModal: true, diff --git a/src/store/profile/profile.reducer.ts b/src/store/profile/profile.reducer.ts index dd3de7392..7d48d6423 100644 --- a/src/store/profile/profile.reducer.ts +++ b/src/store/profile/profile.reducer.ts @@ -10,7 +10,7 @@ import { DateTime } from 'luxon' const initialState: Profile = { id: '', ecogestureHash: '', - seasonHash: '', + challengeHash: '', bossHash: '', isFirstConnection: false, haveSeenFavoriteModal: true, diff --git a/src/store/season/season.actions.ts b/src/store/season/season.actions.ts deleted file mode 100644 index da3c22cf9..000000000 --- a/src/store/season/season.actions.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { Dataload, UserChallenge } from 'models' - -export const SET_USER_SEASON_LIST = 'SET_USER_SEASON_LIST' -export const UPDATE_USER_SEASON_LIST = 'UPDATE_USER_SEASON_LIST' -export const UNLOCK_NEXT_USER_SEASON = 'UNLOCK_NEXT_USER_SEASON' -export const SET_SEASON_CONSUMPTION = 'SET_SEASON_CONSUMPTION' - -interface SetUserChallengeList { - type: typeof SET_USER_SEASON_LIST - payload?: UserChallenge[] -} - -interface UpdateUserChallenge { - type: typeof UPDATE_USER_SEASON_LIST - payload?: UserChallenge -} - -interface UnlockNextUserChallenge { - type: typeof UNLOCK_NEXT_USER_SEASON - payload?: UserChallenge -} - -interface SetSeasonConsumption { - type: typeof SET_SEASON_CONSUMPTION - payload?: { userChallenge: UserChallenge; currentDataload: Dataload[] } -} - -export type SeasonActionTypes = - | SetUserChallengeList - | UpdateUserChallenge - | UnlockNextUserChallenge - | SetSeasonConsumption - -export function setUserChallengeList( - userChallengeList: UserChallenge[] -): SeasonActionTypes { - return { - type: SET_USER_SEASON_LIST, - payload: userChallengeList, - } -} - -export function updateUserChallengeList( - userChallenge: UserChallenge -): SeasonActionTypes { - return { - type: UPDATE_USER_SEASON_LIST, - payload: userChallenge, - } -} - -export function unlockNextUserChallenge( - userChallenge: UserChallenge -): SeasonActionTypes { - return { - type: UNLOCK_NEXT_USER_SEASON, - payload: userChallenge, - } -} - -export function setSeasonConsumption( - userChallenge: UserChallenge, - currentDataload: Dataload[] -): SeasonActionTypes { - return { - type: SET_SEASON_CONSUMPTION, - payload: { userChallenge, currentDataload }, - } -} diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 350c4351c..49052fd06 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -60,13 +60,13 @@ export function getRelationship<D>(doc: D, relName: string): Relation { */ export const importIconbyId = async (id: string, pathType: string) => { // Les svg doivent être au format id.svg - let importedSeasonIcon + let importedChallengeIcon try { - importedSeasonIcon = await import( + importedChallengeIcon = await import( /* webpackMode: "eager" */ `assets/icons/visu/${pathType}/${id}.svg` ) } catch (e) {} - if (importedSeasonIcon) { - return importedSeasonIcon.default + if (importedChallengeIcon) { + return importedChallengeIcon.default } } diff --git a/test/__mocks__/challengeEntity.mock.ts b/test/__mocks__/challengeEntity.mock.ts index b176a12b8..d27e0322e 100644 --- a/test/__mocks__/challengeEntity.mock.ts +++ b/test/__mocks__/challengeEntity.mock.ts @@ -3,8 +3,8 @@ import { allBossEntity, bossEntity } from './bossData.mock' export const challengeEntityData: ChallengeEntity = { id: 'CHALLENGE0001', - title: 'Season 1', - description: 'Description season 1', + title: 'Challenge 1', + description: 'Description challenge 1', target: 15, boss: bossEntity, quizType: 'cultureG', @@ -13,40 +13,40 @@ export const challengeEntityData: ChallengeEntity = { export const allChallengeEntityData: ChallengeEntity[] = [ { id: 'CHALLENGE0001', - title: 'Season 1', - description: 'Description season 1', + title: 'Challenge 1', + description: 'Description challenge 1', target: 15, boss: bossEntity, quizType: 'cultureG', }, { id: 'CHALLENGE0002', - title: 'Season 2', - description: 'Description season 2', + title: 'Challenge 2', + description: 'Description challenge 2', target: 15, boss: null, quizType: 'cultureG', }, { id: 'CHALLENGE0003', - title: 'Season 3', - description: 'Description season 3', + title: 'Challenge 3', + description: 'Description challenge 3', target: 15, boss: allBossEntity[1], quizType: 'cultureG', }, { id: 'CHALLENGE0004', - title: 'Season 4', - description: 'Description season 4', + title: 'Challenge 4', + description: 'Description challenge 4', target: 15, boss: allBossEntity[1], quizType: 'cultureG', }, { id: 'CHALLENGE0005', - title: 'Season 5', - description: 'Description season 5', + title: 'Challenge 5', + description: 'Description challenge 5', target: 15, boss: allBossEntity[1], quizType: 'cultureG', diff --git a/test/__mocks__/challengeStateData.mock.ts b/test/__mocks__/challengeStateData.mock.ts index ef37487c6..4a0f99267 100644 --- a/test/__mocks__/challengeStateData.mock.ts +++ b/test/__mocks__/challengeStateData.mock.ts @@ -3,12 +3,12 @@ import { userChallengeData } from './userChallengeData.mock' export const challengeStateData: ChallengeState = { userChallengeList: [], - currentSeason: null, + currentChallenge: null, currentDataload: [], } export const challengeStateDataFull: ChallengeState = { userChallengeList: userChallengeData, - currentSeason: null, + currentChallenge: null, currentDataload: [], } diff --git a/test/__mocks__/globalStateData.mock.ts b/test/__mocks__/globalStateData.mock.ts index fd0315ca0..c8385fc7a 100644 --- a/test/__mocks__/globalStateData.mock.ts +++ b/test/__mocks__/globalStateData.mock.ts @@ -4,7 +4,7 @@ import { GlobalState } from 'models' export const globalStateData: GlobalState = { screenType: ScreenType.MOBILE, - seasonNotification: false, + challengeNotification: false, reportNotification: false, fluidStatus: [ { diff --git a/test/__mocks__/profile.mock.ts b/test/__mocks__/profile.mock.ts index 4d59ea6b6..919440d63 100644 --- a/test/__mocks__/profile.mock.ts +++ b/test/__mocks__/profile.mock.ts @@ -5,7 +5,7 @@ export const profileData = { _rev: '16-57473da4fc26315247c217083175dfa0', id: '4d9403218ef13e65b2e3a8ad1700bc41', ecogestureHash: '9798a0aaccb47cff906fc4931a2eff5f9371dd8b', - seasonHash: '1136feb6185c7643e071d14180c0e95782aa4ba3', + challengeHash: '1136feb6185c7643e071d14180c0e95782aa4ba3', bossHash: '1136feb6185c7643e071d14180c0e95782aa4ba3', isFirstConnection: true, haveSeenFavoriteModal: false, diff --git a/test/__mocks__/userChallengeData.mock.ts b/test/__mocks__/userChallengeData.mock.ts index 359035279..bd50637a6 100644 --- a/test/__mocks__/userChallengeData.mock.ts +++ b/test/__mocks__/userChallengeData.mock.ts @@ -8,8 +8,8 @@ import { bossData, bossDefault } from './bossData.mock' export const userChallengeData: UserChallenge[] = [ { id: 'CHALLENGE0001', - title: 'Season 1', - description: 'Description season 1', + title: 'Challenge 1', + description: 'Description challenge 1', state: UserChallengeState.DONE, target: 15, progress: 0, @@ -21,8 +21,8 @@ export const userChallengeData: UserChallenge[] = [ }, { id: 'CHALLENGE0002', - title: 'Season 2', - description: 'Description season 2', + title: 'Challenge 2', + description: 'Description challenge 2', state: UserChallengeState.DONE, target: 15, progress: 0, @@ -34,8 +34,8 @@ export const userChallengeData: UserChallenge[] = [ }, { id: 'CHALLENGE0003', - title: 'Season 3', - description: 'Description season 3', + title: 'Challenge 3', + description: 'Description challenge 3', state: UserChallengeState.ONGOING, target: 15, progress: 0, @@ -47,8 +47,8 @@ export const userChallengeData: UserChallenge[] = [ }, { id: 'CHALLENGE0004', - title: 'Season 4', - description: 'Description season 4', + title: 'Challenge 4', + description: 'Description challenge 4', state: UserChallengeState.UNLOCKED, target: 15, progress: 0, @@ -60,8 +60,8 @@ export const userChallengeData: UserChallenge[] = [ }, { id: 'CHALLENGE0005', - title: 'Season 5', - description: 'Description season 5', + title: 'Challenge 5', + description: 'Description challenge 5', state: UserChallengeState.LOCKED, target: 15, progress: 0, @@ -76,8 +76,8 @@ export const userChallengeData: UserChallenge[] = [ export const userChallengeDefault: UserChallenge[] = [ { id: 'CHALLENGE0001', - title: 'Season 1', - description: 'Description season 1', + title: 'Challenge 1', + description: 'Description challenge 1', state: UserChallengeState.UNLOCKED, target: 15, progress: 0, @@ -89,8 +89,8 @@ export const userChallengeDefault: UserChallenge[] = [ }, { id: 'CHALLENGE0002', - title: 'Season 2', - description: 'Description season 2', + title: 'Challenge 2', + description: 'Description challenge 2', state: UserChallengeState.LOCKED, target: 15, progress: 0, @@ -102,8 +102,8 @@ export const userChallengeDefault: UserChallenge[] = [ }, { id: 'CHALLENGE0003', - title: 'Season 3', - description: 'Description season 3', + title: 'Challenge 3', + description: 'Description challenge 3', state: UserChallengeState.LOCKED, target: 15, progress: 0, @@ -115,8 +115,8 @@ export const userChallengeDefault: UserChallenge[] = [ }, { id: 'CHALLENGE0004', - title: 'Season 4', - description: 'Description season 4', + title: 'Challenge 4', + description: 'Description challenge 4', state: UserChallengeState.LOCKED, target: 15, progress: 0, @@ -128,8 +128,8 @@ export const userChallengeDefault: UserChallenge[] = [ }, { id: 'CHALLENGE0005', - title: 'Season 5', - description: 'Description season 5', + title: 'Challenge 5', + description: 'Description challenge 5', state: UserChallengeState.LOCKED, target: 15, progress: 0, -- GitLab