Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Feb 5, 2024
1 parent 926f69b commit 82eff7d
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 85 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
VITE_OIDC_ISSUER=
VITE_OIDC_CLIENT_ID=
VITE_PORTAIL_URL=
VITE_APP_VERSION=$npm_package_version
VITE_LUNATIC_VERSION=$npm_package_dependencies__inseefr_lunatic
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<!--<link rel="preload" href="/dsfr/fonts/Marianne-Bold_Italic.woff2" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Spectral-Regular.woff2" as="font" crossorigin="anonymous" />-->
<!--<link rel="preload" href="/dsfr/fonts/Spectral-ExtraBold.woff2" as="font" crossorigin="anonymous" />-->
<title>Vite + React + TS</title>
</head>

<body>
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
"prebuild": "only-include-used-icons && npx @inseefr/lunatic workers"
},
"dependencies": {
"@codegouvfr/react-dsfr": "^1.2.1",
"@codegouvfr/react-dsfr": "^1.2.2",
"@emotion/react": "^11.11.3",
"@inseefr/lunatic": "^2.7.14",
"@inseefr/lunatic": "^2.7.15",
"@inseefr/lunatic-dsfr": "^1.0.21",
"@tanstack/react-query": "^5.18.0",
"@tanstack/react-router": "^1.15.7",
"@tanstack/react-query": "^5.18.1",
"@tanstack/react-router": "^1.15.17",
"axios": "^1.6.7",
"oidc-spa": "^3.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.49.3",
"tss-react": "^4.9.3",
"react-hook-form": "^7.50.0",
"tss-react": "^4.9.4",
"vite-tsconfig-paths": "^4.3.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20.11.13",
"@types/react": "^18.2.48",
"@types/node": "^20.11.16",
"@types/react": "^18.2.53",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"typescript": "^5.3.3",
"vite": "^5.0.12"
}
Expand Down
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface ImportMetaEnv {
readonly VITE_OIDC_CLIENT_ID: string
readonly VITE_APP_VERSION: string
readonly VITE_LUNATIC_VERSION: string
readonly VITE_PORTAIL_URL: string
}

interface ImportMeta {
Expand Down
11 changes: 11 additions & 0 deletions src/hooks/useDocumentTitle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useEffect } from 'react'

export function useDocumentTitle(title: string) {
useEffect(() => {
const prevTitle = document.title
document.title = title
return () => {
document.title = prevTitle
}
})
}
17 changes: 17 additions & 0 deletions src/pages/Accessibility/AccessibilityPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Breadcrumb } from '@codegouvfr/react-dsfr/Breadcrumb'
import { Grid } from 'components/Grid'

export function AccessibilityPage() {
return (
<Grid>
<Breadcrumb
currentPageLabel="Accessibilité"
homeLinkProps={{
to: '/',
}}
segments={[]}
/>
<h2>Accessibilité</h2>
</Grid>
)
}
12 changes: 12 additions & 0 deletions src/pages/Accessibility/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createRoute } from '@tanstack/react-router'
import { rootRoute } from 'router/router'
import { AccessibilityPage } from './AccessibilityPage'

export const accessibilityRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'accessibilite',
component: AccessibilityPage,
loader: () => {
document.title = 'Accessibilité'
},
})
3 changes: 3 additions & 0 deletions src/pages/Error/ErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fr } from '@codegouvfr/react-dsfr'
import Button from '@codegouvfr/react-dsfr/Button'
import TechnicalError from '@codegouvfr/react-dsfr/dsfr/artwork/pictograms/system/technical-error.svg'
import { Container } from 'components/Container'
import { useDocumentTitle } from 'hooks/useDocumentTitle'

const getErrorInformations = (code: 301 | 404 | undefined) => {
switch (code) {
Expand All @@ -22,6 +23,8 @@ export function ErrorPage(props: { code: 301 | 404 | undefined }) {

const { title, subtitle, paragraph } = getErrorInformations(code)

useDocumentTitle(title)

return (
<Container>
<div
Expand Down
17 changes: 17 additions & 0 deletions src/pages/Legals/LegalsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Breadcrumb } from '@codegouvfr/react-dsfr/Breadcrumb'
import { Grid } from 'components/Grid'

export function LegalPage() {
return (
<Grid>
<Breadcrumb
currentPageLabel="Mentions Légales"
homeLinkProps={{
to: '/',
}}
segments={[]}
/>
<h2>Mentions légales</h2>
</Grid>
)
}
12 changes: 12 additions & 0 deletions src/pages/Legals/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createRoute } from '@tanstack/react-router'
import { rootRoute } from 'router/router'
import { LegalPage } from './LegalsPage'

export const legalsRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'mentions-legales',
component: LegalPage,
loader: () => {
document.title = 'Mentions Légales'
},
})
17 changes: 17 additions & 0 deletions src/pages/NavigationAssistance/NavigationAssistancePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Breadcrumb from '@codegouvfr/react-dsfr/Breadcrumb'
import { Grid } from 'components/Grid'

export function NavigationAssistancePage() {
return (
<Grid>
<Breadcrumb
currentPageLabel="Aide à la navigation"
homeLinkProps={{
to: '/',
}}
segments={[]}
/>
<h2>Aide à la navigation</h2>
</Grid>
)
}
12 changes: 12 additions & 0 deletions src/pages/NavigationAssistance/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createRoute } from '@tanstack/react-router'
import { rootRoute } from 'router/router'
import { NavigationAssistancePage } from './NavigationAssistancePage'

export const navigationAssistanceRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'aide-a-la-navigation',
component: NavigationAssistancePage,
loader: () => {
document.title = 'Aide à la navigation'
},
})
17 changes: 17 additions & 0 deletions src/pages/Security/SecurityPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Breadcrumb from '@codegouvfr/react-dsfr/Breadcrumb'
import { Grid } from 'components/Grid'

export function SecurityPage() {
return (
<Grid>
<Breadcrumb
currentPageLabel="Sécurité"
homeLinkProps={{
to: '/',
}}
segments={[]}
/>
<h2>Sécurité</h2>
</Grid>
)
}
12 changes: 12 additions & 0 deletions src/pages/Security/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createRoute } from '@tanstack/react-router'
import { rootRoute } from 'router/router'
import { SecurityPage } from './SecurityPage'

export const securityRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'securite',
component: SecurityPage,
loader: () => {
document.title = 'Sécurité'
},
})
33 changes: 33 additions & 0 deletions src/pages/SiteMap/SiteMapPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Breadcrumb } from '@codegouvfr/react-dsfr/Breadcrumb'
import { Grid } from 'components/Grid'

import { Link } from '@tanstack/react-router'

export function SiteMapPage() {
return (
<Grid>
<Breadcrumb
currentPageLabel="Plan du site"
homeLinkProps={{
to: '/',
}}
segments={[]}
/>
<h2>Plan du site</h2>
<ul>
<li>
<Link to="/">Accueil</Link>
</li>
<li>
<Link to="">Mentions légales</Link>
</li>
<li>
<Link to="/accessibilite">Accessibilité</Link>
</li>
<li>
<Link to="/securite">Sécurité</Link>
</li>
</ul>
</Grid>
)
}
12 changes: 12 additions & 0 deletions src/pages/SiteMap/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createRoute } from '@tanstack/react-router'
import { rootRoute } from 'router/router'
import { SiteMapPage } from './SiteMapPage'

export const siteMapRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'plan-du-site',
component: SiteMapPage,
loader: () => {
document.title = 'Plan du site'
},
})
2 changes: 1 addition & 1 deletion src/pages/Visualize/Visualize.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Orchestrator } from 'components/Orchestrator/Orchestrator'
import { VisualizeForm } from './Form/VisualizeForm'
import { visualizeRoute } from './visualizeRoute'
import { visualizeRoute } from './route'
import { axiosGet } from 'utils/axios'

export function VisualizePage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const visualizeRoute = createRoute({
context: { queryClient },
deps: { sourceUrl, dataUrl, metadataUrl, nomenclature },
}) => {
document.title = 'Visualisation'
if (!sourceUrl) {
return
}
Expand Down
17 changes: 6 additions & 11 deletions src/router/Layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,13 @@ export function Footer() {
</>
}
websiteMapLinkProps={{
to: '',
//to: '/plan-du-site',
to: '/plan-du-site',
}}
accessibilityLinkProps={{
to: '',
//to: '/accessibilite',
to: '/accessibilite',
}}
termsLinkProps={{
to: '',
//to: '/mentions-legales',
to: '/mentions-legales',
}}
operatorLogo={{
alt: 'Insee, mesurer pour comprendre',
Expand All @@ -56,15 +53,13 @@ export function Footer() {
{
text: 'Sécurité',
linkProps: {
to: '',
//to: '/securite'
to: '/securite',
},
},
{
text: 'Aide à la navigation ',
text: 'Aide à la navigation',
linkProps: {
to: '',
//to: '/aide-a-la-navigation'
to: '/aide-a-la-navigation',
},
},
<span className={fr.cx('fr-footer__bottom-link')}>
Expand Down
8 changes: 7 additions & 1 deletion src/router/Layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ export function Header() {

return (
<DsfrHeader
brandTop="République Française"
brandTop={
<>
République
<br />
Française
</>
}
homeLinkProps={{
to: '/',
title:
Expand Down
29 changes: 15 additions & 14 deletions src/router/router.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { QueryClient } from '@tanstack/react-query'
import { Layout } from './Layout'
import {
createRootRouteWithContext,
createRoute,
Outlet,
} from '@tanstack/react-router'
import { createRootRouteWithContext, Outlet } from '@tanstack/react-router'
import { ErrorPage } from 'pages/Error/ErrorPage'
import { visualizeRoute } from 'pages/Visualize/visualizeRoute'
import { visualizeRoute } from 'pages/Visualize/route'
import { accessibilityRoute } from 'pages/Accessibility/route'
import { securityRoute } from 'pages/Security/route'
import { siteMapRoute } from 'pages/SiteMap/route'
import { legalsRoute } from 'pages/Legals/route'
import { navigationAssistanceRoute } from 'pages/NavigationAssistance/route'

export const rootRoute = createRootRouteWithContext<{
queryClient: QueryClient
Expand All @@ -23,11 +24,11 @@ export const rootRoute = createRootRouteWithContext<{
),
})

// test route, need to be removed
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/',
component: () => <>Index Route</>,
})

export const routeTree = rootRoute.addChildren([indexRoute, visualizeRoute])
export const routeTree = rootRoute.addChildren([
visualizeRoute,
accessibilityRoute,
securityRoute,
siteMapRoute,
legalsRoute,
navigationAssistanceRoute
])
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

"verbatimModuleSyntax": true,

"baseUrl": "./src",
"baseUrl": "./src"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }],
"references": [{ "path": "./tsconfig.node.json" }]
}
Loading

0 comments on commit 82eff7d

Please sign in to comment.