From dac840c38895cdf86bde5072593525077fb2e9ed Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Mon, 24 Jul 2023 07:19:17 +0000 Subject: [PATCH] refactor: remove useless callbacks --- src/components/Action/ActionBegin.tsx | 5 +--- src/components/Action/ActionView.tsx | 9 ++---- .../__snapshots__/ActionView.spec.tsx.snap | 2 +- src/components/Analysis/AnalysisView.tsx | 7 ++--- src/components/Challenge/ChallengeView.tsx | 7 ++--- .../__snapshots__/ChallengeView.spec.tsx.snap | 2 +- .../CommonKit/ErrorPage/ErrorPage.tsx | 18 ++++-------- .../__snapshots__/ErrorPage.spec.tsx.snap | 2 +- src/components/Connection/FormOAuth.tsx | 6 +--- .../PartnerConnectModal/EpglConnectModal.tsx | 21 +++++--------- .../PartnerConnectModal/GrdfConnectModal.tsx | 29 ++++++------------- .../Connection/SGEConnect/SgeConnectView.tsx | 7 ++--- .../SgeConnectView.spec.tsx.snap | 2 +- src/components/Content/Content.tsx | 14 +++------ src/components/Duel/DuelOngoing.tsx | 9 +++--- src/components/Duel/DuelView.tsx | 11 +++---- src/components/Ecogesture/EcogestureView.tsx | 9 ++---- .../Ecogesture/SingleEcogesture.tsx | 7 ++--- .../EcogestureView.spec.tsx.snap | 2 +- .../SingleEcogesture.spec.tsx.snap | 2 +- .../EcogestureForm/EcogestureFormView.tsx | 7 ++--- .../EcogestureFormView.spec.tsx.snap | 2 +- .../EcogestureSelection.tsx | 8 ++--- .../EcogestureSelectionEnd.tsx | 7 ++--- .../EcogestureSelectionRestart.tsx | 8 ++--- .../EcogestureSelection.spec.tsx.snap | 2 +- .../Exploration/ExplorationError.tsx | 8 ++--- .../Exploration/ExplorationOngoing.tsx | 7 ++--- .../Exploration/ExplorationView.tsx | 10 ++----- src/components/Home/ConsumptionView.tsx | 8 ++--- .../Konnector/KonnectorViewerList.tsx | 12 ++++---- src/components/Options/GCU/GCUView.tsx | 10 ++----- .../GCU/__snapshots__/GCUView.spec.tsx.snap | 2 +- .../Options/LegalNotice/LegalNoticeView.tsx | 9 ++---- .../LegalNoticeView.spec.tsx.snap | 2 +- src/components/Options/OptionsView.tsx | 7 ++--- .../ProfileTypeOptions/ProfileTypeOptions.tsx | 6 ++-- .../Options/Unsubscribe/UnSubscribe.tsx | 7 ++--- .../__snapshots__/UnSubscribe.spec.tsx.snap | 2 +- .../__snapshots__/OptionsView.spec.tsx.snap | 2 +- .../ProfileType/ProfileTypeView.tsx | 8 ++--- src/components/Quiz/QuizView.tsx | 10 ++----- 42 files changed, 103 insertions(+), 212 deletions(-) diff --git a/src/components/Action/ActionBegin.tsx b/src/components/Action/ActionBegin.tsx index 52b1c8a3f..42e2a2633 100644 --- a/src/components/Action/ActionBegin.tsx +++ b/src/components/Action/ActionBegin.tsx @@ -36,9 +36,6 @@ const ActionBegin = ({ const toggleLaunchModal = useCallback(() => { setOpenLaunchModal(prev => !prev) }, []) - const goToList = useCallback(() => { - setShowList(true) - }, [setShowList]) useEffect(() => { let subscribed = true @@ -117,7 +114,7 @@ const ActionBegin = ({ {t('action.apply')} </Button> <Button - onClick={goToList} + onClick={() => setShowList(true)} classes={{ root: 'btn-secondary-negative', label: 'text-16-normal', diff --git a/src/components/Action/ActionView.tsx b/src/components/Action/ActionView.tsx index ba49a6383..a530002f1 100644 --- a/src/components/Action/ActionView.tsx +++ b/src/components/Action/ActionView.tsx @@ -6,15 +6,12 @@ import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' import { UserActionState } from 'enum/userAction.enum' import { UserChallenge } from 'models' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { useAppSelector } from 'store/hooks' const ActionView = () => { const { currentChallenge } = useAppSelector(state => state.ecolyo.challenge) const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) const renderAction = (challenge: UserChallenge) => { switch (challenge.action.state) { @@ -33,11 +30,11 @@ const ActionView = () => { <> <CozyBar titleKey={'common.title_action'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_action'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> {currentChallenge && renderAction(currentChallenge)} </Content> </> diff --git a/src/components/Action/__snapshots__/ActionView.spec.tsx.snap b/src/components/Action/__snapshots__/ActionView.spec.tsx.snap index ec1ba3e6c..1136e5081 100644 --- a/src/components/Action/__snapshots__/ActionView.spec.tsx.snap +++ b/src/components/Action/__snapshots__/ActionView.spec.tsx.snap @@ -24,7 +24,7 @@ exports[`ActionView component should render ActionChoose component 1`] = ` setHeaderHeight={[Function]} /> <mock-content - height={0} + heightOffset={0} > <ActionChoose userChallenge={ diff --git a/src/components/Analysis/AnalysisView.tsx b/src/components/Analysis/AnalysisView.tsx index dea8806b2..650eee647 100644 --- a/src/components/Analysis/AnalysisView.tsx +++ b/src/components/Analysis/AnalysisView.tsx @@ -28,9 +28,6 @@ const AnalysisView = () => { } = useAppSelector(state => state.ecolyo) const dispatch = useAppDispatch() const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) const dateChartService = new DateChartService() @@ -121,7 +118,7 @@ const AnalysisView = () => { <> <CozyBar titleKey={'common.title_analysis'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_analysis'} > <DateNavigator @@ -134,7 +131,7 @@ const AnalysisView = () => { timeStep={TimeStep.MONTH} /> </Header> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <MonthlyAnalysis saveLastScrollPosition={saveLastScrollPosition} scrollPosition={scrollPosition} diff --git a/src/components/Challenge/ChallengeView.tsx b/src/components/Challenge/ChallengeView.tsx index daa50f417..0817c84b3 100644 --- a/src/components/Challenge/ChallengeView.tsx +++ b/src/components/Challenge/ChallengeView.tsx @@ -26,9 +26,6 @@ const ChallengeView = () => { const [isLastDuelDone, setIsLastDuelDone] = useState<boolean>(false) const [containerTranslation, setContainerTranslation] = useState<number>(marginPx) - const defineHeaderHeight = (height: number) => { - setHeaderHeight(height) - } const resetValues = () => { // Method used to cancel a swipe on a simple click @@ -110,10 +107,10 @@ const ChallengeView = () => { <> <CozyBar titleKey={'common.title_challenge'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_challenge'} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <div className="challengeSlider" onClick={resetValues} diff --git a/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap b/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap index 5b7b889d7..7736d9c4a 100644 --- a/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap +++ b/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap @@ -22,7 +22,7 @@ exports[`ChallengeView component should be rendered correctly 1`] = ` setHeaderHeight={[Function]} /> <mock-content - height={0} + heightOffset={0} > <div className="challengeSlider" diff --git a/src/components/CommonKit/ErrorPage/ErrorPage.tsx b/src/components/CommonKit/ErrorPage/ErrorPage.tsx index 69136c086..2a0c99ac1 100644 --- a/src/components/CommonKit/ErrorPage/ErrorPage.tsx +++ b/src/components/CommonKit/ErrorPage/ErrorPage.tsx @@ -5,7 +5,7 @@ import Content from 'components/Content/Content' import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' import { useI18n } from 'cozy-ui/transpiled/react/I18n' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' import './errorPage.scss' @@ -15,31 +15,25 @@ interface ErrorPageProps { } const ErrorPage = ({ text, returnPage }: ErrorPageProps) => { - const navigate = useNavigate() const { t } = useI18n() - + const navigate = useNavigate() const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = (height: number) => { - setHeaderHeight(height) - } - const handleClick = useCallback(() => { - navigate(`/${returnPage}`) - }, [navigate, returnPage]) + return ( <> <CozyBar titleKey={'error_page.main'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'error_page.main'} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <div className="error-container"> <StyledIcon className="profile-icon" icon={BearIcon} size={250} /> <div className="text-18-bold head">{text}</div> <Button aria-label={t('error_page.back')} - onClick={handleClick} + onClick={() => navigate(`/${returnPage}`)} variant={'contained'} classes={{ root: 'btn-highlight', diff --git a/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap b/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap index 0a6cf7c48..e8c666f6a 100644 --- a/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap +++ b/src/components/CommonKit/ErrorPage/__snapshots__/ErrorPage.spec.tsx.snap @@ -21,7 +21,7 @@ exports[`ErrorPage component should be rendered correctly 1`] = ` /> </Component> <Component - height={0} + heightOffset={0} > <div id="content" diff --git a/src/components/Connection/FormOAuth.tsx b/src/components/Connection/FormOAuth.tsx index 46df15916..471fe2eb9 100644 --- a/src/components/Connection/FormOAuth.tsx +++ b/src/components/Connection/FormOAuth.tsx @@ -50,10 +50,6 @@ const FormOAuth = ({ konnector, onSuccess, fluidStatus }: FormOAuthProps) => { [endOAuth, onSuccess] ) - const handleOAuthCancel = useCallback(() => { - endOAuth() - }, [endOAuth]) - const isWaiting = status === WAITING useEffect(() => { @@ -88,7 +84,7 @@ const FormOAuth = ({ konnector, onSuccess, fluidStatus }: FormOAuthProps) => { konnector={konnector} redirectSlug={client.appMetadata.slug} onSuccess={handleAccountId} - onCancel={handleOAuthCancel} + onCancel={endOAuth} t={t} /> )} diff --git a/src/components/Connection/PartnerConnectModal/EpglConnectModal.tsx b/src/components/Connection/PartnerConnectModal/EpglConnectModal.tsx index 2442a5f02..d9f2fe121 100644 --- a/src/components/Connection/PartnerConnectModal/EpglConnectModal.tsx +++ b/src/components/Connection/PartnerConnectModal/EpglConnectModal.tsx @@ -3,7 +3,7 @@ import CloseIcon from 'assets/icons/ico/close.svg' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import Icon from 'cozy-ui/transpiled/react/Icon' import { Step } from 'models/step.model' -import React, { useCallback, useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react' import './PartnerConnectModal.scss' import EpglCreateAccount from './Steps/EpglCreateAccount' import EpglDoYouHaveAccount from './Steps/EpglDoYouHaveAccount' @@ -36,29 +36,24 @@ const EpglConnectModal = ({ } }, [open]) - const goToCreateAccountStep = useCallback(() => { - setCurrentStep(StepEnum.CreateAccount) - }, []) - const goToDoYouHaveAccountStep = useCallback(() => { - setCurrentStep(StepEnum.DoYouHaveAccount) - }, []) - const handleGoToPartnerSite = useCallback(() => { + const handleGoToPartnerSite = () => { goToPartnerSite() setHasCreatedAccount(true) setShowForm(true) handleCloseClick() - }, [goToPartnerSite, handleCloseClick, setHasCreatedAccount, setShowForm]) - const handleShowForm = useCallback(() => { + } + + const handleShowForm = () => { setShowForm(true) handleCloseClick() - }, [handleCloseClick, setShowForm]) + } const steps: Record<StepEnum, Step> = { [StepEnum.DoYouHaveAccount]: { content: <EpglDoYouHaveAccount />, leftButton: ( <Button - onClick={goToCreateAccountStep} + onClick={() => setCurrentStep(StepEnum.CreateAccount)} classes={{ root: 'btn-profile-back', label: 'text-16-bold', @@ -83,7 +78,7 @@ const EpglConnectModal = ({ content: <EpglCreateAccount />, leftButton: ( <Button - onClick={goToDoYouHaveAccountStep} + onClick={() => setCurrentStep(StepEnum.DoYouHaveAccount)} classes={{ root: 'btn-profile-back', label: 'text-16-bold', diff --git a/src/components/Connection/PartnerConnectModal/GrdfConnectModal.tsx b/src/components/Connection/PartnerConnectModal/GrdfConnectModal.tsx index 871172766..ee371a713 100644 --- a/src/components/Connection/PartnerConnectModal/GrdfConnectModal.tsx +++ b/src/components/Connection/PartnerConnectModal/GrdfConnectModal.tsx @@ -5,7 +5,7 @@ import FormOAuth from 'components/Connection/FormOAuth' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import { FluidStatus, Konnector } from 'models' import { Step } from 'models/step.model' -import React, { useCallback, useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react' import './PartnerConnectModal.scss' import GrdfCreateAccount from './Steps/GrdfCreateAccount' import GrdfDoYouHaveAccount from './Steps/GrdfDoYouHaveAccount' @@ -48,32 +48,21 @@ const GrdfConnectModal = ({ } }, [showForm, open]) - const goToCreateAccountStep = useCallback(() => { - setCurrentStep(StepEnum.CreateAccount) - }, []) - const goToGiveConsentStep = useCallback(() => { - setCurrentStep(StepEnum.GiveConsent) - }, []) - const goToDoYouHaveAccountStep = useCallback(() => { - setCurrentStep(StepEnum.DoYouHaveAccount) - }, []) - const handleGoToPartnerSite = useCallback(() => { + const handleGoToPartnerSite = () => { goToPartnerSite() setShowForm(true) handleCloseClick() - }, [goToPartnerSite, handleCloseClick, setShowForm]) - const handleGiveConsentPrevious = useCallback( - () => - showForm ? handleCloseClick() : setCurrentStep(StepEnum.DoYouHaveAccount), - [handleCloseClick, showForm] - ) + } + const handleGiveConsentPrevious = () => { + showForm ? handleCloseClick() : setCurrentStep(StepEnum.DoYouHaveAccount) + } const steps: Record<StepEnum, Step> = { [StepEnum.DoYouHaveAccount]: { content: <GrdfDoYouHaveAccount />, leftButton: ( <Button - onClick={goToCreateAccountStep} + onClick={() => setCurrentStep(StepEnum.CreateAccount)} classes={{ root: 'btn-profile-back', label: 'text-16-bold', @@ -84,7 +73,7 @@ const GrdfConnectModal = ({ ), rightButton: ( <Button - onClick={goToGiveConsentStep} + onClick={() => setCurrentStep(StepEnum.GiveConsent)} classes={{ root: 'btn-profile-next', label: 'text-16-bold', @@ -98,7 +87,7 @@ const GrdfConnectModal = ({ content: <GrdfCreateAccount />, leftButton: ( <Button - onClick={goToDoYouHaveAccountStep} + onClick={() => setCurrentStep(StepEnum.DoYouHaveAccount)} classes={{ root: 'btn-profile-back', label: 'text-16-bold', diff --git a/src/components/Connection/SGEConnect/SgeConnectView.tsx b/src/components/Connection/SGEConnect/SgeConnectView.tsx index f4e08fb84..2a0377228 100644 --- a/src/components/Connection/SGEConnect/SgeConnectView.tsx +++ b/src/components/Connection/SGEConnect/SgeConnectView.tsx @@ -32,9 +32,6 @@ const SgeConnectView = () => { sgeConnect.currentStep ) const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) const isNextValid = useCallback(() => { switch (currentStep) { @@ -133,11 +130,11 @@ const SgeConnectView = () => { <> <CozyBar titleKey={'common.title_sge_connect'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_sge_connect'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <div className="sge-view"> <div className="sge-container"> <FormProgress step={currentStep} formType={'sge'} /> diff --git a/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap index 03e2a662a..bb15318ab 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap @@ -301,7 +301,7 @@ exports[`SgeConnectView component should be rendered correctly 1`] = ` </div> </Header> <mock-content - height={-48} + heightOffset={-48} > <div className="sge-view" diff --git a/src/components/Content/Content.tsx b/src/components/Content/Content.tsx index 72e9e0040..f2ca41249 100644 --- a/src/components/Content/Content.tsx +++ b/src/components/Content/Content.tsx @@ -7,15 +7,10 @@ import { openFeedbackModal } from 'store/modal/modal.slice' import './content.scss' interface ContentProps { children: React.ReactNode - height?: number - background?: string + heightOffset?: number } -const Content = ({ - children, - height = 0, - background = 'inherit', -}: ContentProps) => { +const Content = ({ children, heightOffset = 0 }: ContentProps) => { const dispatch = useAppDispatch() const { global: { screenType }, @@ -60,13 +55,12 @@ const Content = ({ <div className={'content-view'} style={{ - marginTop: height, + marginTop: heightOffset, paddingBottom: 0, minHeight: screenType !== ScreenType.DESKTOP - ? `calc(100vh - ${height}px - ${cozyBarHeight}px - ${cozyNavHeight}px - env(safe-area-inset-top) - env(safe-area-inset-bottom) - env(safe-area-inset-bottom))` + ? `calc(100vh - ${heightOffset}px - ${cozyBarHeight}px - ${cozyNavHeight}px - env(safe-area-inset-top) - env(safe-area-inset-bottom) - env(safe-area-inset-bottom))` : `unset`, - background: background, }} > {children} diff --git a/src/components/Duel/DuelOngoing.tsx b/src/components/Duel/DuelOngoing.tsx index 97804bdf2..179dc70f9 100644 --- a/src/components/Duel/DuelOngoing.tsx +++ b/src/components/Duel/DuelOngoing.tsx @@ -99,10 +99,6 @@ const DuelOngoing = ({ userChallenge, isFinished }: DuelOngoingProps) => { navigate, ]) - const setLastResult = useCallback(async () => { - navigate('/challenges') - }, [navigate]) - useEffect(() => { let subscribed = true async function setChallengeResult() { @@ -208,7 +204,10 @@ const DuelOngoing = ({ userChallenge, isFinished }: DuelOngoingProps) => { win={winChallenge} handleCloseClick={setResult} /> - <LastDuelModal open={isLastDuel} handleCloseClick={setLastResult} /> + <LastDuelModal + open={isLastDuel} + handleCloseClick={() => navigate('/challenges')} + /> </> ) } diff --git a/src/components/Duel/DuelView.tsx b/src/components/Duel/DuelView.tsx index 4704f47a8..dbf94aeeb 100644 --- a/src/components/Duel/DuelView.tsx +++ b/src/components/Duel/DuelView.tsx @@ -6,13 +6,14 @@ import Header from 'components/Header/Header' import { UserChallengeState } from 'enum/userChallenge.enum' import { UserDuelState } from 'enum/userDuel.enum' import { UserChallenge } from 'models' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { useLocation, useNavigate } from 'react-router-dom' import { useAppSelector } from 'store/hooks' import DuelEmptyValueModal from './DuelEmptyValueModal' import DuelOngoing from './DuelOngoing' const DuelView = () => { + const navigate = useNavigate() const { userChallengeList } = useAppSelector(state => state.ecolyo.challenge) const [headerHeight, setHeaderHeight] = useState<number>(0) const id = new URLSearchParams(useLocation().search).get('id') @@ -20,10 +21,6 @@ const DuelView = () => { challenge => challenge.id === id ) - const navigate = useNavigate() - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) const goBackToChallenge = () => { navigate('/challenges') } @@ -51,11 +48,11 @@ const DuelView = () => { <> <CozyBar titleKey={'common.title_duel'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_duel'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <div> {challengeToDisplay && (challengeToDisplay.state === UserChallengeState.DUEL || diff --git a/src/components/Ecogesture/EcogestureView.tsx b/src/components/Ecogesture/EcogestureView.tsx index b20ef1292..fa44a5f18 100644 --- a/src/components/Ecogesture/EcogestureView.tsx +++ b/src/components/Ecogesture/EcogestureView.tsx @@ -38,10 +38,6 @@ const TabPanel = ({ children, tab, value }: TabPanelProps) => { } const EcogestureView = () => { - const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = (height: number) => { - setHeaderHeight(height) - } const { t } = useI18n() const client = useClient() const tab = new URLSearchParams(useLocation().search).get('tab') @@ -50,6 +46,7 @@ const EcogestureView = () => { state => state.ecolyo ) + const [headerHeight, setHeaderHeight] = useState<number>(0) const [tabValue, setTabValue] = useState<EcogestureTab>( tab ? parseInt(tab) : EcogestureTab.OBJECTIVE ) @@ -178,7 +175,7 @@ const EcogestureView = () => { <> <CozyBar titleKey={'common.title_ecogestures'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_ecogestures'} > <Tabs @@ -219,7 +216,7 @@ const EcogestureView = () => { </Tabs> </Header> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> {isLoading && ( <div className="loaderContainer"> <Loader text={t('ecogestures.loading')} /> diff --git a/src/components/Ecogesture/SingleEcogesture.tsx b/src/components/Ecogesture/SingleEcogesture.tsx index 385db2a33..72525b837 100644 --- a/src/components/Ecogesture/SingleEcogesture.tsx +++ b/src/components/Ecogesture/SingleEcogesture.tsx @@ -49,9 +49,6 @@ const SingleEcogesture = () => { ) const { currentChallenge } = useAppSelector(state => state.ecolyo.challenge) const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = (height: number) => { - setHeaderHeight(height) - } const [, setValidExploration] = useExploration() const toggleMoreDetail = () => { setIsMoreDetail(prev => !prev) @@ -123,11 +120,11 @@ const SingleEcogesture = () => { <> <CozyBar titleKey={'common.title_ecogesture'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_ecogesture'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> {isLoading && ( <div className="loaderContainer"> <Loader /> diff --git a/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap index dfb1e8a5a..4369c61f4 100644 --- a/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap @@ -565,7 +565,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` </WithStyles(ForwardRef(Tabs))> </mock-header> <mock-content - height={0} + heightOffset={0} > <TabPanel tab={0} diff --git a/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap index 031efb610..f8389c766 100644 --- a/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap @@ -32,7 +32,7 @@ exports[`SingleEcogesture component should be rendered correctly 1`] = ` /> </Component> <Component - height={0} + heightOffset={0} > <div id="content" diff --git a/src/components/EcogestureForm/EcogestureFormView.tsx b/src/components/EcogestureForm/EcogestureFormView.tsx index 553f9b3af..ba87afbd4 100644 --- a/src/components/EcogestureForm/EcogestureFormView.tsx +++ b/src/components/EcogestureForm/EcogestureFormView.tsx @@ -31,9 +31,6 @@ const EcogestureFormView = () => { const dispatch: Dispatch<AppActionsTypes> = useDispatch() const navigate = useNavigate() const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = (height: number) => { - setHeaderHeight(height) - } const shouldOpenModal = new URLSearchParams(useLocation().search).get('modal') const [step, setStep] = useState<EcogestureStepForm>( @@ -99,10 +96,10 @@ const EcogestureFormView = () => { <> <CozyBar titleKey={'common.title_ecogestures'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_ecogestures'} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> {isLoading && ( <div className="loaderContainer"> <Loader /> diff --git a/src/components/EcogestureForm/__snapshots__/EcogestureFormView.spec.tsx.snap b/src/components/EcogestureForm/__snapshots__/EcogestureFormView.spec.tsx.snap index 304c1fddd..b343a1c96 100644 --- a/src/components/EcogestureForm/__snapshots__/EcogestureFormView.spec.tsx.snap +++ b/src/components/EcogestureForm/__snapshots__/EcogestureFormView.spec.tsx.snap @@ -22,7 +22,7 @@ exports[`EcogestureFormView component should be rendered correctly 1`] = ` setHeaderHeight={[Function]} /> <mock-content - height={0} + heightOffset={0} > <EcogestureFormSingleChoice answerType={ diff --git a/src/components/EcogestureSelection/EcogestureSelection.tsx b/src/components/EcogestureSelection/EcogestureSelection.tsx index 6449919bd..04d8e343b 100644 --- a/src/components/EcogestureSelection/EcogestureSelection.tsx +++ b/src/components/EcogestureSelection/EcogestureSelection.tsx @@ -29,10 +29,6 @@ const EcogestureSelection = () => { const [openEcogestureSelectionModal, setOpenEcogestureSelectionModal] = useState(false) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) - const ecogestureService = useMemo( () => new EcogestureService(client), [client] @@ -137,7 +133,7 @@ const EcogestureSelection = () => { backFunction={() => navigate('/ecogestures')} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_ecogestures_choice'} displayBackArrow={true} > @@ -147,7 +143,7 @@ const EcogestureSelection = () => { : ''} </div> </Header> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> {isLoading && ( <div className="loaderContainer"> <Loader /> diff --git a/src/components/EcogestureSelection/EcogestureSelectionEnd.tsx b/src/components/EcogestureSelection/EcogestureSelectionEnd.tsx index 5742708e6..27c356afb 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionEnd.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionEnd.tsx @@ -2,7 +2,7 @@ import { Button } from '@material-ui/core' import icon from 'assets/icons/visu/profileType/finish.svg' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import { useI18n } from 'cozy-ui/transpiled/react/I18n' -import React, { useCallback } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import './ecogestureSelectionEnd.scss' @@ -10,9 +10,6 @@ const EcogestureSelectionEnd = () => { const { t } = useI18n() const navigate = useNavigate() - const goToObjectives = useCallback(() => { - navigate('/ecogestures?tab=0') - }, [navigate]) return ( <div className="eg-selection-end-container"> <div className="content"> @@ -34,7 +31,7 @@ const EcogestureSelectionEnd = () => { root: 'btn-highlight', label: 'text-16-bold', }} - onClick={goToObjectives} + onClick={() => navigate('/ecogestures?tab=0')} > {t('ecogesture_selection.button_ok')} </Button> diff --git a/src/components/EcogestureSelection/EcogestureSelectionRestart.tsx b/src/components/EcogestureSelection/EcogestureSelectionRestart.tsx index 33a68a477..f404b7108 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionRestart.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionRestart.tsx @@ -2,7 +2,7 @@ import { Button } from '@material-ui/core' import icon from 'assets/icons/visu/ecogesture/ECOGESTURE0001.svg' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import { useI18n } from 'cozy-ui/transpiled/react/I18n' -import React, { useCallback } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import './ecogestureSelectionRestart.scss' @@ -18,10 +18,6 @@ const EcogestureSelectionRestart = ({ const { t } = useI18n() const navigate = useNavigate() - const goToObjectives = useCallback(() => { - navigate('/ecogestures?tab=0') - }, [navigate]) - return ( <div className="eg-selection-restart-container"> <div className="content"> @@ -45,7 +41,7 @@ const EcogestureSelectionRestart = ({ root: 'btn-secondary-negative', label: 'text-16-normal', }} - onClick={goToObjectives} + onClick={() => navigate('/ecogestures?tab=0')} > {t('ecogesture_selection.button_go_to_ecogesture')} </Button> diff --git a/src/components/EcogestureSelection/__snapshots__/EcogestureSelection.spec.tsx.snap b/src/components/EcogestureSelection/__snapshots__/EcogestureSelection.spec.tsx.snap index c8243370c..ef4f90c15 100644 --- a/src/components/EcogestureSelection/__snapshots__/EcogestureSelection.spec.tsx.snap +++ b/src/components/EcogestureSelection/__snapshots__/EcogestureSelection.spec.tsx.snap @@ -31,7 +31,7 @@ exports[`EcogestureSelection component should be rendered correctly 1`] = ` </div> </mock-header> <mock-content - height={0} + heightOffset={0} > <mock-ecogestureselectiondetail ecogesture={ diff --git a/src/components/Exploration/ExplorationError.tsx b/src/components/Exploration/ExplorationError.tsx index efd22f0f0..64702698d 100644 --- a/src/components/Exploration/ExplorationError.tsx +++ b/src/components/Exploration/ExplorationError.tsx @@ -1,6 +1,6 @@ import Button from '@material-ui/core/Button' import { useI18n } from 'cozy-ui/transpiled/react/I18n' -import React, { useCallback } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import './explorationError.scss' @@ -8,10 +8,6 @@ const ExplorationError = () => { const { t } = useI18n() const navigate = useNavigate() - const goBack = useCallback(() => { - navigate(-1) - }, [navigate]) - return ( <div className="exploration-error-container"> <div className="exploration-error-message"> @@ -20,7 +16,7 @@ const ExplorationError = () => { <div className="exploration-error-button"> <Button aria-label={t('exploration.accessibility.button_go_back')} - onClick={goBack} + onClick={() => navigate(-1)} classes={{ root: 'btn-secondary-negative', label: 'text-16-normal', diff --git a/src/components/Exploration/ExplorationOngoing.tsx b/src/components/Exploration/ExplorationOngoing.tsx index 62d7c23a9..2132bae32 100644 --- a/src/components/Exploration/ExplorationOngoing.tsx +++ b/src/components/Exploration/ExplorationOngoing.tsx @@ -11,7 +11,7 @@ import { UserExplorationType, } from 'enum/userExploration.enum' import { UserChallenge } from 'models' -import React, { useCallback } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import ChallengeService from 'services/challenge.service' import UsageEventService from 'services/usageEvent.service' @@ -28,9 +28,6 @@ const ExplorationOngoing = ({ userChallenge }: ExplorationOngoingProps) => { const client: Client = useClient() const dispatch = useAppDispatch() const navigate = useNavigate() - const goBack = useCallback(() => { - navigate(-1) - }, [navigate]) const startExploration = async () => { if (userChallenge.exploration.state !== UserExplorationState.ONGOING) { const challengeService = new ChallengeService(client) @@ -75,7 +72,7 @@ const ExplorationOngoing = ({ userChallenge }: ExplorationOngoingProps) => { </Button> <Button aria-label={t('exploration.accessibility.button_already_done')} - onClick={goBack} + onClick={() => navigate(-1)} classes={{ root: 'btn-secondary-negative', label: 'text-16-normal', diff --git a/src/components/Exploration/ExplorationView.tsx b/src/components/Exploration/ExplorationView.tsx index d10e22917..2d58bc647 100644 --- a/src/components/Exploration/ExplorationView.tsx +++ b/src/components/Exploration/ExplorationView.tsx @@ -3,7 +3,7 @@ import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' import { UserExplorationState } from 'enum/userExploration.enum' import { UserChallenge } from 'models' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { useAppSelector } from 'store/hooks' import ExplorationError from './ExplorationError' import ExplorationFinished from './ExplorationFinished' @@ -13,10 +13,6 @@ const ExplorationView = () => { const { currentChallenge } = useAppSelector(state => state.ecolyo.challenge) const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) - const renderExploration = (challenge: UserChallenge) => { switch (challenge.exploration.state) { case UserExplorationState.UNLOCKED: @@ -34,11 +30,11 @@ const ExplorationView = () => { <> <CozyBar titleKey={'common.title_exploration'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_exploration'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> {currentChallenge && renderExploration(currentChallenge)} </Content> </> diff --git a/src/components/Home/ConsumptionView.tsx b/src/components/Home/ConsumptionView.tsx index ce5b641c7..d7766c732 100644 --- a/src/components/Home/ConsumptionView.tsx +++ b/src/components/Home/ConsumptionView.tsx @@ -80,10 +80,6 @@ const ConsumptionView = ({ fluidType }: { fluidType: FluidType }) => { ? `${fluidStatus[fluidType].lastDataDate!.toLocaleString() + fluidType}` : '' - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) - const handleCloseReleaseNoteModal = useCallback(() => { setOpenReleaseNoteModal(false) dispatch( @@ -224,7 +220,7 @@ const ConsumptionView = ({ fluidType }: { fluidType: FluidType }) => { <> <CozyBar titleKey={'common.title_consumption'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_consumption'} > <DateNavigator @@ -236,7 +232,7 @@ const ConsumptionView = ({ fluidType }: { fluidType: FluidType }) => { timeStep={currentTimeStep} /> </Header> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <FluidButtons activeFluid={fluidType} key={updateKey} /> {openReleaseNoteModal && ( diff --git a/src/components/Konnector/KonnectorViewerList.tsx b/src/components/Konnector/KonnectorViewerList.tsx index 98acb829e..36e108c24 100644 --- a/src/components/Konnector/KonnectorViewerList.tsx +++ b/src/components/Konnector/KonnectorViewerList.tsx @@ -3,7 +3,7 @@ import { useI18n } from 'cozy-ui/transpiled/react/I18n' import Icon from 'cozy-ui/transpiled/react/Icon' import { FluidType } from 'enum/fluid.enum' import { FluidStatus } from 'models' -import React, { useCallback } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import { useAppSelector } from 'store/hooks' import { getAddPicto } from 'utils/picto' @@ -14,12 +14,10 @@ const KonnectorViewerList = () => { const { t } = useI18n() const { fluidStatus } = useAppSelector(state => state.ecolyo.global) const navigate = useNavigate() - const goToFluid = useCallback( - fluidType => { - navigate(`/consumption/${getFluidName(fluidType)}`) - }, - [navigate] - ) + const goToFluid = (fluidType: FluidType) => { + navigate(`/consumption/${getFluidName(fluidType)}`) + } + return ( <> {fluidStatus.map((fluidStatusItem: FluidStatus, key: number) => ( diff --git a/src/components/Options/GCU/GCUView.tsx b/src/components/Options/GCU/GCUView.tsx index 999dd89a8..d698b8e62 100644 --- a/src/components/Options/GCU/GCUView.tsx +++ b/src/components/Options/GCU/GCUView.tsx @@ -2,24 +2,20 @@ import Content from 'components/Content/Content' import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' import GCUContent from 'components/Options/GCU/GCUContent' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' const GCUView = () => { const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) - return ( <> <CozyBar titleKey={'common.title_gcu'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_gcu'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <GCUContent /> </Content> </> diff --git a/src/components/Options/GCU/__snapshots__/GCUView.spec.tsx.snap b/src/components/Options/GCU/__snapshots__/GCUView.spec.tsx.snap index bcc93b8a7..da0d5940a 100644 --- a/src/components/Options/GCU/__snapshots__/GCUView.spec.tsx.snap +++ b/src/components/Options/GCU/__snapshots__/GCUView.spec.tsx.snap @@ -12,7 +12,7 @@ exports[`GCUView component should be rendered correctly 1`] = ` setHeaderHeight={[Function]} /> <mock-content - height={0} + heightOffset={0} > <GCUContent /> </mock-content> diff --git a/src/components/Options/LegalNotice/LegalNoticeView.tsx b/src/components/Options/LegalNotice/LegalNoticeView.tsx index cd7b6723a..7d86ded1a 100644 --- a/src/components/Options/LegalNotice/LegalNoticeView.tsx +++ b/src/components/Options/LegalNotice/LegalNoticeView.tsx @@ -1,25 +1,22 @@ import Content from 'components/Content/Content' import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import LegalNoticeContent from './LegalNoticeContent' import './legalNoticeView.scss' const LegalNoticeView = () => { const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) return ( <> <CozyBar titleKey={'common.title_legal_notice'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_legal_notice'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <LegalNoticeContent /> </Content> </> diff --git a/src/components/Options/LegalNotice/__snapshots__/LegalNoticeView.spec.tsx.snap b/src/components/Options/LegalNotice/__snapshots__/LegalNoticeView.spec.tsx.snap index 52b42634c..e3e3b81e1 100644 --- a/src/components/Options/LegalNotice/__snapshots__/LegalNoticeView.spec.tsx.snap +++ b/src/components/Options/LegalNotice/__snapshots__/LegalNoticeView.spec.tsx.snap @@ -12,7 +12,7 @@ exports[`LegalNoticeView component should be rendered correctly 1`] = ` setHeaderHeight={[Function]} /> <mock-content - height={0} + heightOffset={0} > <LegalNoticeContent /> </mock-content> diff --git a/src/components/Options/OptionsView.tsx b/src/components/Options/OptionsView.tsx index baf6819f2..5d36989a8 100644 --- a/src/components/Options/OptionsView.tsx +++ b/src/components/Options/OptionsView.tsx @@ -15,18 +15,15 @@ import Version from './Version/Version' const OptionsView = () => { const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = (height: number) => { - setHeaderHeight(height) - } return ( <> <CozyBar titleKey={'common.title_options'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_options'} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <ProfileTypeOptions /> <ExportData /> <ReportOptions /> diff --git a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx index a09e959c0..4d18cfef7 100644 --- a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx +++ b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx @@ -19,7 +19,7 @@ import { ThreeChoicesAnswer, } from 'enum/profileType.enum' import { UserExplorationID } from 'enum/userExploration.enum' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' import { useAppSelector } from 'store/hooks' import './profileTypeOptions.scss' @@ -38,9 +38,9 @@ const ProfileTypeOptions = () => { setActive(prev => !prev) } - const goToForm = useCallback(() => { + const goToForm = () => { navigate('/profileType') - }, [navigate]) + } return ( <div className="profile-type-root"> diff --git a/src/components/Options/Unsubscribe/UnSubscribe.tsx b/src/components/Options/Unsubscribe/UnSubscribe.tsx index ed3637f26..ef117a084 100644 --- a/src/components/Options/Unsubscribe/UnSubscribe.tsx +++ b/src/components/Options/Unsubscribe/UnSubscribe.tsx @@ -16,9 +16,6 @@ const UnSubscribe = () => { const navigate = useNavigate() const dispatch = useAppDispatch() const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = (height: number) => { - setHeaderHeight(height) - } const unSubscribe = async () => { dispatch(updateProfile({ sendAnalysisNotification: false })) navigate('/consumption') @@ -28,10 +25,10 @@ const UnSubscribe = () => { <> <CozyBar titleKey={'common.title_analysis'} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_analysis'} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <div className="unsubscribe-container"> <StyledIcon className="profile-icon" icon={BearIcon} size={250} /> diff --git a/src/components/Options/Unsubscribe/__snapshots__/UnSubscribe.spec.tsx.snap b/src/components/Options/Unsubscribe/__snapshots__/UnSubscribe.spec.tsx.snap index d06e84f78..40c3d3fdd 100644 --- a/src/components/Options/Unsubscribe/__snapshots__/UnSubscribe.spec.tsx.snap +++ b/src/components/Options/Unsubscribe/__snapshots__/UnSubscribe.spec.tsx.snap @@ -22,7 +22,7 @@ exports[`UnSubscribe component should be rendered correctly 1`] = ` setHeaderHeight={[Function]} /> <mock-content - height={0} + heightOffset={0} > <div className="unsubscribe-container" diff --git a/src/components/Options/__snapshots__/OptionsView.spec.tsx.snap b/src/components/Options/__snapshots__/OptionsView.spec.tsx.snap index 7690e5226..5417b1055 100644 --- a/src/components/Options/__snapshots__/OptionsView.spec.tsx.snap +++ b/src/components/Options/__snapshots__/OptionsView.spec.tsx.snap @@ -10,7 +10,7 @@ exports[`OptionsView component should be rendered correctly 1`] = ` setHeaderHeight={[Function]} /> <mock-content - height={0} + heightOffset={0} > <ProfileTypeOptions /> <ExportData /> diff --git a/src/components/ProfileType/ProfileTypeView.tsx b/src/components/ProfileType/ProfileTypeView.tsx index 5fdbf3506..127369ad7 100644 --- a/src/components/ProfileType/ProfileTypeView.tsx +++ b/src/components/ProfileType/ProfileTypeView.tsx @@ -73,10 +73,6 @@ const ProfileTypeView = () => { const [isLoading, setIsLoading] = useState<boolean>(true) const [viewedStep, setViewedStep] = useState<number>(-1) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) - // if ecogesture profile is completed, update default profileType useEffect(() => { if (profile.isProfileEcogestureCompleted) { @@ -229,11 +225,11 @@ const ProfileTypeView = () => { <> <CozyBar titleKey={'common.title_profiletype'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_profiletype'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> <div className={'profile-type-container'}> {isLoading && <Loader />} {!isLoading && ( diff --git a/src/components/Quiz/QuizView.tsx b/src/components/Quiz/QuizView.tsx index 05caa6e91..9bb016762 100644 --- a/src/components/Quiz/QuizView.tsx +++ b/src/components/Quiz/QuizView.tsx @@ -3,7 +3,7 @@ import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' import { UserQuizState } from 'enum/userQuiz.enum' import { UserChallenge } from 'models' -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { useAppSelector } from 'store/hooks' import QuizBegin from './QuizBegin' import QuizFinish from './QuizFinish' @@ -13,10 +13,6 @@ const QuizView = () => { const { currentChallenge } = useAppSelector(state => state.ecolyo.challenge) const [headerHeight, setHeaderHeight] = useState<number>(0) - const defineHeaderHeight = useCallback((height: number) => { - setHeaderHeight(height) - }, []) - const renderQuiz = (challenge: UserChallenge) => { switch (challenge.quiz.state) { case UserQuizState.UNLOCKED: @@ -34,11 +30,11 @@ const QuizView = () => { <> <CozyBar titleKey={'common.title_quiz'} displayBackArrow={true} /> <Header - setHeaderHeight={defineHeaderHeight} + setHeaderHeight={setHeaderHeight} desktopTitleKey={'common.title_quiz'} displayBackArrow={true} /> - <Content height={headerHeight}> + <Content heightOffset={headerHeight}> {currentChallenge && renderQuiz(currentChallenge)} </Content> </> -- GitLab