Move global hooks into hooks directory

pull/2529/head
Jérémy Rialland 2023-02-28 15:05:28 +01:00 committed by Johan Girod
parent 9941312a94
commit 4ebfb96a85
26 changed files with 26 additions and 30 deletions

View File

@ -16,8 +16,8 @@ import {
useEngine,
useSetupSafeSituation,
} from '@/components/utils/EngineContext'
import { useIsEmbedded } from '@/components/utils/useIsEmbedded'
import { Container, Spacing } from '@/design-system/layout'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import { useAxeCoreAnalysis } from '../hooks/useAxeCoreAnalysis'
import { useGetFullURL } from '../hooks/useGetFullURL'

View File

@ -7,8 +7,7 @@ import { CloseButton } from '@/design-system/buttons'
import { Emoji } from '@/design-system/emoji'
import { Strong } from '@/design-system/typography'
import { Body } from '@/design-system/typography/paragraphs'
import { useIsEmbedded } from '../utils/useIsEmbedded'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
export default function BetaBanner() {
const isEmbedded = useIsEmbedded()

View File

@ -4,15 +4,15 @@ import { useLocation } from 'react-router-dom'
import styled from 'styled-components'
import Meta from '@/components/utils/Meta'
import { useIsEmbedded } from '@/components/utils/useIsEmbedded'
import useSearchParamsSimulationSharing from '@/components/utils/useSearchParamsSimulationSharing'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { Chip } from '@/design-system'
import { Emoji } from '@/design-system/emoji'
import { Spacing } from '@/design-system/layout'
import { H1 } from '@/design-system/typography/heading'
import { Intro } from '@/design-system/typography/paragraphs'
import { useCurrentSimulatorData } from '@/hooks/useCurrentSimulatorData'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import useSimulationConfig from '@/hooks/useSimulationConfig'
import { situationSelector } from '@/store/selectors/simulationSelectors'
import { NextSteps } from '../pages/Simulateurs/NextSteps'

View File

@ -5,6 +5,7 @@ import styled from 'styled-components'
import { Spacing } from '@/design-system/layout'
import { Link } from '@/design-system/typography/link'
import { SmallBody } from '@/design-system/typography/paragraphs'
import { useNextQuestions } from '@/hooks/useNextQuestion'
import { goToQuestion } from '@/store/actions/actions'
import { RootState } from '@/store/reducers/rootReducer'
import {
@ -12,8 +13,6 @@ import {
currentQuestionSelector,
} from '@/store/selectors/simulationSelectors'
import { useNextQuestions } from './utils/useNextQuestion'
export default function QuickLinks() {
const currentQuestion = useSelector(currentQuestionSelector)
const nextSteps = useNextQuestions()

View File

@ -8,8 +8,7 @@ import Conversation, {
} from '@/components/conversation/Conversation'
import Progress from '@/components/ui/Progress'
import { Body } from '@/design-system/typography/paragraphs'
import { useSimulationProgress } from './../utils/useNextQuestion'
import { useSimulationProgress } from '@/hooks/useNextQuestion'
const QuestionsContainer = styled.div`
padding: ${({ theme }) => ` ${theme.spacings.xs} ${theme.spacings.lg}`};

View File

@ -7,11 +7,11 @@ import { ForceThemeProvider } from '@/components/utils/DarkModeContext'
import { Grid } from '@/design-system/layout'
import { Link } from '@/design-system/typography/link'
import { SmallBody } from '@/design-system/typography/paragraphs'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import { firstStepCompletedSelector } from '@/store/selectors/simulationSelectors'
import { Logo } from '../Logo'
import { WatchInitialRender } from '../utils/useInitialRender'
import { useIsEmbedded } from '../utils/useIsEmbedded'
type SimulationGoalsProps = {
legend: string

View File

@ -6,7 +6,6 @@ import { useDispatch, useSelector } from 'react-redux'
import styled from 'styled-components'
import { EvaluatedRule, useEngine } from '@/components/utils/EngineContext'
import { useNextQuestions } from '@/components/utils/useNextQuestion'
import { Message, PopoverWithTrigger } from '@/design-system'
import { Button } from '@/design-system/buttons'
import { Emoji } from '@/design-system/emoji'
@ -17,6 +16,7 @@ import { H2, H3 } from '@/design-system/typography/heading'
import { Link } from '@/design-system/typography/link'
import { Body, Intro } from '@/design-system/typography/paragraphs'
import { useCurrentSimulatorData } from '@/hooks/useCurrentSimulatorData'
import { useNextQuestions } from '@/hooks/useNextQuestion'
import { answerQuestion, resetSimulation } from '@/store/actions/actions'
import { resetCompany } from '@/store/actions/companyActions'
import { isCompanyDottedName } from '@/store/reducers/companySituationReducer'

View File

@ -4,7 +4,7 @@ import { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useEngine } from '@/components/utils/EngineContext'
import { useNextQuestions } from '@/components/utils/useNextQuestion'
import { useNextQuestions } from '@/hooks/useNextQuestion'
import {
goToQuestion,
stepAction,

View File

@ -1,8 +1,8 @@
import { ReactNode, createContext, useState } from 'react'
import { ThemeProvider } from 'styled-components'
import { useIsEmbedded } from '@/components/utils/useIsEmbedded'
import { useDarkMode } from '@/hooks/useDarkMode'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import { getItem, setItem } from '@/storage/safeLocalStorage'
type DarkModeContextType = [boolean, (darkMode: boolean) => void]

View File

@ -1,10 +1,9 @@
import React, { useEffect, useRef, useState } from 'react'
import { ThemeProvider } from 'styled-components'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import { hexToHSL } from '@/utils/hexToHSL'
import { useIsEmbedded } from './useIsEmbedded'
type ProviderProps = {
color?: [number, number, number]
children: React.ReactNode

View File

@ -1,6 +1,6 @@
import { useLocation } from 'react-router-dom'
import { useIsEmbedded } from '@/components/utils/useIsEmbedded'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import { Merge, ToOptional } from '@/types/utils'
import useSimulatorsData, { SimulatorDataValues } from './useSimulatorsData'

View File

@ -11,7 +11,7 @@ import {
} from '@/store/selectors/simulationSelectors'
import { ImmutableType } from '@/types/utils'
import { useEngine } from './EngineContext'
import { useEngine } from '../components/utils/EngineContext'
type MissingVariables = Partial<Record<DottedName, number>>

View File

@ -3,7 +3,7 @@ import { PublicodesExpression, RuleNode } from 'publicodes'
import { useDispatch, useSelector } from 'react-redux'
import { useEngine } from '@/components/utils/EngineContext'
import { useNextQuestions } from '@/components/utils/useNextQuestion'
import { useNextQuestions } from '@/hooks/useNextQuestion'
import { stepAction, updateSituation } from '@/store/actions/actions'
import { answeredQuestionsSelector } from '@/store/selectors/simulationSelectors'

View File

@ -2,7 +2,6 @@ import { Trans, useTranslation } from 'react-i18next'
import { TrackPage } from '@/components/ATInternetTracking'
import PageHeader from '@/components/PageHeader'
import { useIsEmbedded } from '@/components/utils/useIsEmbedded'
import { Chip } from '@/design-system'
import InfoBulle from '@/design-system/InfoBulle'
import { Card } from '@/design-system/card'
@ -15,6 +14,7 @@ import { Link } from '@/design-system/typography/link'
import { Li, Ul } from '@/design-system/typography/list'
import { Body, Intro } from '@/design-system/typography/paragraphs'
import { MergedSimulatorDataValues } from '@/hooks/useCurrentSimulatorData'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import useSimulatorsData from '@/hooks/useSimulatorsData'
import { useSitePaths } from '@/sitePaths'

View File

@ -11,8 +11,8 @@ import Simulation, {
} from '@/components/Simulation'
import { InstitutionsPartenairesArtisteAuteur } from '@/components/simulationExplanation/InstitutionsPartenaires'
import { EngineContext } from '@/components/utils/EngineContext'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { H2 } from '@/design-system/typography/heading'
import useSimulationConfig from '@/hooks/useSimulationConfig'
import { configArtisteAuteur } from './simulationConfig'

View File

@ -4,8 +4,8 @@ import { Route, Routes, useLocation } from 'react-router-dom'
import { ScrollToTop } from '@/components/utils/Scroll'
import { usePersistingState } from '@/components/utils/persistState'
import { useIsEmbedded } from '@/components/utils/useIsEmbedded'
import { Link } from '@/design-system/typography/link'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import useSimulatorsData from '@/hooks/useSimulatorsData'
import { useSitePaths } from '@/sitePaths'

View File

@ -3,8 +3,8 @@ import { Route, Routes } from 'react-router-dom'
import styled from 'styled-components'
import { TrackChapter } from '@/components/ATInternetTracking'
import { useIsEmbedded } from '@/components/utils/useIsEmbedded'
import { Link } from '@/design-system/typography/link'
import { useIsEmbedded } from '@/hooks/useIsEmbedded'
import useSimulatorsData from '@/hooks/useSimulatorsData'
import { useSitePaths } from '@/sitePaths'

View File

@ -11,10 +11,10 @@ import RuleInput from '@/components/conversation/RuleInput'
import { FadeIn } from '@/components/ui/animate'
import { EngineContext } from '@/components/utils/EngineContext'
import { Markdown } from '@/components/utils/markdown'
import { useNextQuestions } from '@/components/utils/useNextQuestion'
import { Spacing } from '@/design-system/layout'
import { H3 } from '@/design-system/typography/heading'
import { Intro, SmallBody } from '@/design-system/typography/paragraphs'
import { useNextQuestions } from '@/hooks/useNextQuestion'
import { updateSituation } from '@/store/actions/actions'
import {
situationSelector,

View File

@ -12,12 +12,12 @@ import RuleInput from '@/components/conversation/RuleInput'
import Warning from '@/components/ui/WarningBlock'
import { FromTop } from '@/components/ui/animate'
import DefaultHelmet from '@/components/utils/DefaultHelmet'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { Grid } from '@/design-system/layout'
import { Strong } from '@/design-system/typography'
import { H2, H3 } from '@/design-system/typography/heading'
import { Li, Ul } from '@/design-system/typography/list'
import { Body, Intro, SmallBody } from '@/design-system/typography/paragraphs'
import useSimulationConfig from '@/hooks/useSimulationConfig'
import { useSitePaths } from '@/sitePaths'
import { updateSituation } from '@/store/actions/actions'
import { SimulationConfig } from '@/store/reducers/rootReducer'

View File

@ -5,12 +5,12 @@ import Progress from '@/components/ui/Progress'
import { FromTop } from '@/components/ui/animate'
import { useEngine } from '@/components/utils/EngineContext'
import { Markdown } from '@/components/utils/markdown'
import { useSimulationProgress } from '@/components/utils/useNextQuestion'
import { Message } from '@/design-system'
import { Container, Grid, Spacing } from '@/design-system/layout'
import { Strong } from '@/design-system/typography'
import { H2, H3 } from '@/design-system/typography/heading'
import { Body, Intro } from '@/design-system/typography/paragraphs'
import { useSimulationProgress } from '@/hooks/useNextQuestion'
import { SimpleField } from '../components/Fields'
import { DéclarationRevenu } from './components/DéclarationRevenu'

View File

@ -5,10 +5,10 @@ import { Condition } from '@/components/EngineValue'
import PrintExportRecover from '@/components/simulationExplanation/PrintExportRecover'
import DefaultHelmet from '@/components/utils/DefaultHelmet'
import { useEngine } from '@/components/utils/EngineContext'
import { useSimulationProgress } from '@/components/utils/useNextQuestion'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { Step, Stepper } from '@/design-system'
import { Spacing } from '@/design-system/layout'
import { useSimulationProgress } from '@/hooks/useNextQuestion'
import useSimulationConfig from '@/hooks/useSimulationConfig'
import { useSitePaths } from '@/sitePaths'
import { SimulationConfig } from '@/store/reducers/rootReducer'
import { omit } from '@/utils'

View File

@ -11,13 +11,13 @@ import DefaultHelmet from '@/components/utils/DefaultHelmet'
import { EngineContext, EngineProvider } from '@/components/utils/EngineContext'
import { Markdown } from '@/components/utils/markdown'
import { usePersistingState } from '@/components/utils/persistState'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { Button } from '@/design-system/buttons'
import { Emoji } from '@/design-system/emoji'
import { Grid, Spacing } from '@/design-system/layout'
import PopoverConfirm from '@/design-system/popover/PopoverConfirm'
import { headings } from '@/design-system/typography'
import { Intro, SmallBody } from '@/design-system/typography/paragraphs'
import useSimulationConfig from '@/hooks/useSimulationConfig'
import {
buildSituationFromObject,
evaluateQuestion,

View File

@ -35,7 +35,6 @@ import DefaultHelmet from '@/components/utils/DefaultHelmet'
import { useEngine } from '@/components/utils/EngineContext'
import { ScrollToTop } from '@/components/utils/Scroll'
import { Markdown } from '@/components/utils/markdown'
import useSimulationConfig from '@/components/utils/useSimulationConfig'
import { Message, Popover } from '@/design-system'
import { Button } from '@/design-system/buttons'
import { Emoji } from '@/design-system/emoji'
@ -46,6 +45,7 @@ import { Link } from '@/design-system/typography/link'
import { Body, Intro } from '@/design-system/typography/paragraphs'
import { useQuestionList } from '@/hooks/useQuestionList'
import { useSetEntreprise } from '@/hooks/useSetEntreprise'
import useSimulationConfig from '@/hooks/useSimulationConfig'
import useSimulatorsData, { SimulatorData } from '@/hooks/useSimulatorsData'
import { useSitePaths } from '@/sitePaths'
import { resetCompany } from '@/store/actions/companyActions'

View File

@ -2,7 +2,7 @@ import rules from 'modele-social'
import Engine from 'publicodes'
import { describe, expect, it } from 'vitest'
import { getNextQuestions } from '../source/components/utils/useNextQuestion'
import { getNextQuestions } from '../source/hooks/useNextQuestion'
describe('conversation', function () {
it('should start with the first missing variable', function () {