From 52bc504c51fe14bfd73ce29ce4565b41f07809ed Mon Sep 17 00:00:00 2001 From: Alice Dahan Date: Fri, 15 Nov 2024 15:20:36 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20R=C3=A9organise=20les=20composants?= =?UTF-8?q?=20de=20recherche=20APE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GuichetInfo.tsx | 0 .../_components/ActivitéNonDisponible.tsx | 3 +- .../choix-du-statut/détails-activité.tsx | 12 ++--- .../recherche-code-ape/SearchCodeAPE.tsx | 21 +++------ .../{ => components}/ActivityNotFound.tsx | 0 .../components/HelpGuichetUnique.tsx | 26 +++++++++++ .../{ => components}/Result.tsx | 44 ++++++------------- site/source/utils/guichetToPLMétier.ts | 2 +- 8 files changed, 55 insertions(+), 53 deletions(-) rename site/source/{pages/assistants/recherche-code-ape => components}/GuichetInfo.tsx (100%) rename site/source/pages/assistants/recherche-code-ape/{ => components}/ActivityNotFound.tsx (100%) create mode 100644 site/source/pages/assistants/recherche-code-ape/components/HelpGuichetUnique.tsx rename site/source/pages/assistants/recherche-code-ape/{ => components}/Result.tsx (74%) diff --git a/site/source/pages/assistants/recherche-code-ape/GuichetInfo.tsx b/site/source/components/GuichetInfo.tsx similarity index 100% rename from site/source/pages/assistants/recherche-code-ape/GuichetInfo.tsx rename to site/source/components/GuichetInfo.tsx diff --git a/site/source/pages/assistants/choix-du-statut/_components/ActivitéNonDisponible.tsx b/site/source/pages/assistants/choix-du-statut/_components/ActivitéNonDisponible.tsx index 4f0cf2183..1da7c3343 100644 --- a/site/source/pages/assistants/choix-du-statut/_components/ActivitéNonDisponible.tsx +++ b/site/source/pages/assistants/choix-du-statut/_components/ActivitéNonDisponible.tsx @@ -1,9 +1,8 @@ +import { GuichetEntry } from '@/components/GuichetInfo' import { Message } from '@/design-system' import { H3 } from '@/design-system/typography/heading' import { Intro } from '@/design-system/typography/paragraphs' -import { GuichetEntry } from '../../recherche-code-ape/GuichetInfo' - export function estNonDisponible(guichet: GuichetEntry): boolean { return ( !!guichet.caisseDeRetraiteSpéciale || diff --git a/site/source/pages/assistants/choix-du-statut/détails-activité.tsx b/site/source/pages/assistants/choix-du-statut/détails-activité.tsx index 1e447fbb2..6d7911455 100644 --- a/site/source/pages/assistants/choix-du-statut/détails-activité.tsx +++ b/site/source/pages/assistants/choix-du-statut/détails-activité.tsx @@ -3,6 +3,12 @@ import { Trans, useTranslation } from 'react-i18next' import { useDispatch } from 'react-redux' import { Navigate } from 'react-router-dom' +import { + getGuichetTitle, + GuichetDescription, + GuichetEntry, + useGuichetInfo, +} from '@/components/GuichetInfo' import Skeleton from '@/components/ui/Skeleton' import { useEngine } from '@/components/utils/EngineContext' import { Message, RadioCardGroup } from '@/design-system' @@ -18,12 +24,6 @@ import { useSitePaths } from '@/sitePaths' import { batchUpdateSituation } from '@/store/actions/actions' import { guichetToPLMétier } from '@/utils/guichetToPLMétier' -import { - getGuichetTitle, - GuichetDescription, - GuichetEntry, - useGuichetInfo, -} from '../recherche-code-ape/GuichetInfo' import { AvertissementActivitéNonDisponible, estNonDisponible, diff --git a/site/source/pages/assistants/recherche-code-ape/SearchCodeAPE.tsx b/site/source/pages/assistants/recherche-code-ape/SearchCodeAPE.tsx index 08e4cc9a3..327c6a3b7 100644 --- a/site/source/pages/assistants/recherche-code-ape/SearchCodeAPE.tsx +++ b/site/source/pages/assistants/recherche-code-ape/SearchCodeAPE.tsx @@ -8,12 +8,11 @@ import { FromTop } from '@/components/ui/animate' import { usePersistingState } from '@/components/utils/persistState' import { Message, RadioCardGroup, SearchField } from '@/design-system' import { VisibleRadio } from '@/design-system/field/Radio/Radio' -import { RadioCardSkeleton } from '@/design-system/field/Radio/RadioCard' import { Spacing } from '@/design-system/layout' import { SmallBody } from '@/design-system/typography/paragraphs' import { usePromise } from '@/hooks/usePromise' -import { Result } from './Result' +import { Result } from './components/Result' type Data = typeof import('@/public/data/ape-search.json') @@ -268,18 +267,12 @@ export default function SearchCodeAPE({ {list.slice(0, 25).map(({ item, debug }) => { return ( <> - - - + {underSelection && selected === item.codeApe && ( {underSelection} )} diff --git a/site/source/pages/assistants/recherche-code-ape/ActivityNotFound.tsx b/site/source/pages/assistants/recherche-code-ape/components/ActivityNotFound.tsx similarity index 100% rename from site/source/pages/assistants/recherche-code-ape/ActivityNotFound.tsx rename to site/source/pages/assistants/recherche-code-ape/components/ActivityNotFound.tsx diff --git a/site/source/pages/assistants/recherche-code-ape/components/HelpGuichetUnique.tsx b/site/source/pages/assistants/recherche-code-ape/components/HelpGuichetUnique.tsx new file mode 100644 index 000000000..e1f3b1e93 --- /dev/null +++ b/site/source/pages/assistants/recherche-code-ape/components/HelpGuichetUnique.tsx @@ -0,0 +1,26 @@ +import { HelpButtonWithPopover } from '@/design-system/buttons' +import { Link } from '@/design-system/typography/link' +import { Body } from '@/design-system/typography/paragraphs' + +export function HelpGuichetUnique() { + return ( + + + Le{' '} + + Guichet électronique des formalités d’entreprises + {' '} + (Guichet unique) est un portail internet sécurisé, auprès duquel toute + entreprise est tenue de déclarer sa création, depuis le 1er janvier + 2023. + + + Il utilise une classification des activités différente de celle utilisée + par l'INSEE pour code APE. + + + ) +} diff --git a/site/source/pages/assistants/recherche-code-ape/Result.tsx b/site/source/pages/assistants/recherche-code-ape/components/Result.tsx similarity index 74% rename from site/source/pages/assistants/recherche-code-ape/Result.tsx rename to site/source/pages/assistants/recherche-code-ape/components/Result.tsx index 5c64559fd..def425a11 100644 --- a/site/source/pages/assistants/recherche-code-ape/Result.tsx +++ b/site/source/pages/assistants/recherche-code-ape/components/Result.tsx @@ -2,17 +2,18 @@ import { useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { css, styled } from 'styled-components' +import GuichetInfo from '@/components/GuichetInfo' import { Appear } from '@/components/ui/animate' import { Chip } from '@/design-system' -import { Button, HelpButtonWithPopover } from '@/design-system/buttons' +import { Button } from '@/design-system/buttons' +import { RadioCardSkeleton } from '@/design-system/field/Radio/RadioCard' import { ChevronIcon } from '@/design-system/icons' import { Grid } from '@/design-system/layout' import { H4, H5, H6 } from '@/design-system/typography/heading' -import { Link } from '@/design-system/typography/link' import { Li, Ul } from '@/design-system/typography/list' -import { Body, SmallBody } from '@/design-system/typography/paragraphs' +import { SmallBody } from '@/design-system/typography/paragraphs' -import GuichetInfo from './GuichetInfo' +import { HelpGuichetUnique } from './HelpGuichetUnique' interface ResultProps { debug: string | null @@ -23,16 +24,22 @@ interface ResultProps { contenuAnnexe: string[] contenuExclu: string[] } + disabled?: boolean hideGuichetUnique: boolean } -export const Result = ({ item, hideGuichetUnique }: ResultProps) => { +export const Result = ({ item, disabled, hideGuichetUnique }: ResultProps) => { const { title, codeApe, contenuCentral, contenuAnnexe, contenuExclu } = item const [open, setOpen] = useState(false) const { t } = useTranslation() return ( - <> +
{title}
{ )} )} - +
) } @@ -123,26 +130,3 @@ const StyledChevron = styled(ChevronIcon)<{ $isOpen: boolean }>` transform: rotate(90deg); `} ` - -export function HelpGuichetUnique() { - return ( - - - Le{' '} - - Guichet électronique des formalités d’entreprises - {' '} - (Guichet unique) est un portail internet sécurisé, auprès duquel toute - entreprise est tenue de déclarer sa création, depuis le 1er janvier - 2023. - - - Il utilise une classification des activités différente de celle utilisée - par l'INSEE pour code APE. - - - ) -} diff --git a/site/source/utils/guichetToPLMétier.ts b/site/source/utils/guichetToPLMétier.ts index a931e8a18..5aef63eef 100644 --- a/site/source/utils/guichetToPLMétier.ts +++ b/site/source/utils/guichetToPLMétier.ts @@ -1,4 +1,4 @@ -import { GuichetEntry } from '@/pages/assistants/recherche-code-ape/GuichetInfo' +import { GuichetEntry } from '@/components/GuichetInfo' type PLRMétier = | "'rattaché CIPAV'"