Skip to content

Commit

Permalink
Merge branch 'main' into article-lexique-eau
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliePouliquen authored Sep 6, 2024
2 parents 5754a38 + 685010f commit f2b646a
Show file tree
Hide file tree
Showing 502 changed files with 6,429 additions and 2,112 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
"exclude": ["node_modules", "cypress/**/*"]
},
"globals": {
"React": "writable",
"NodeJS": "writable",
"JSX": "writable"
"React": "readonly",
"NodeJS": "readonly",
"JSX": "readonly",
"jest": "readonly"
},
"rules": {
"react/no-unescaped-entities": "off",
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/run-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Unit Tests

on:
push:
branches:
- main
pull_request:
branches:
- '**'

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --immutable

- name: Run unit tests
run: yarn test --coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ dist

# Sentry Config File
.env.sentry-build-plugin

coverage
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"activityBar.background": "#296c36",
"titleBar.activeBackground": "#296c36",
"titleBar.activeForeground": "#FAF9FD"
}
},
"editor.formatOnSave": true
}
38 changes: 38 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

import type { Config } from 'jest'

const config: Config = {
// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: false,

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',

// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1',
},

// The test environment that will be used for testing
testEnvironment: 'jsdom',

// The regexp pattern or array of patterns that Jest uses to detect test files
testRegex: '.spec.ts$',

// A map from regular expressions to paths to transformers
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
}

export default config
19 changes: 9 additions & 10 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
//@ts-check
/* eslint-disable @typescript-eslint/no-var-requires */
const withMDX = require('@next/mdx')({
extension: /\.mdx$/,
})

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})

const { withSentryConfig } = require('@sentry/nextjs')

const redirects = require('./config/redirects.js')
Expand All @@ -18,13 +15,14 @@ const nextConfig = {
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
reactStrictMode: true,
images: {
// @ts-expect-error remotePatterns is not typed
remotePatterns: remoteImagesPatterns,
},
async redirects() {
return redirects
},
webpack: (config, { dev }) => {
if (config.cache && !dev) {
webpack: (config) => {
if (config.cache) {
config.cache = Object.freeze({
type: 'memory',
})
Expand All @@ -47,6 +45,7 @@ const nextConfig = {
'/actions/plus': ['public/images/blog', 'public/NGC_Kit.diffusion.zip'],
'/sitemap.xml': ['public/images/blog', 'public/NGC_Kit.diffusion.zip'],
},
optimizePackageImports: ['@incubateur-ademe/nosgestesclimat'],
webpackBuildWorker: true,
turbo: {
rules: {
Expand Down Expand Up @@ -90,7 +89,7 @@ const sentryConfig = [
},
]

module.exports = withSentryConfig(
withBundleAnalyzer(withMDX(nextConfig)),
...sentryConfig
)
module.exports =
process.env.NODE_ENV !== 'development'
? withSentryConfig(withMDX(nextConfig), ...sentryConfig)
: nextConfig
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nosgestesclimat-site-nextjs",
"license": "MIT",
"version": "1.5.7",
"version": "2.0.0",
"description": "The leading open source climate footprint calculator",
"repository": {
"type": "git",
Expand All @@ -11,6 +11,7 @@
"node": "20"
},
"scripts": {
"test": "jest",
"dev": "next dev",
"dev:turbo": "next dev --turbo",
"build": "next build",
Expand All @@ -32,17 +33,20 @@
"dependencies": {
"@babel/runtime": "^7.23.1",
"@incubateur-ademe/legal-pages-react": "^0.2.0",
"@incubateur-ademe/nosgestesclimat": "3.0.0-rc.3",
"@incubateur-ademe/nosgestesclimat": "^3.1.0",
"@mdx-js/loader": "^3.0.0",
"@mdx-js/react": "^3.0.0",
"@next/bundle-analyzer": "^14.1.0",
"@next/mdx": "^14.0.2",
"@next/mdx": "^14.2.7",
"@publicodes/react-ui": "^1.3.3",
"@publicodes/tools": "^1.2.0",
"@sentry/nextjs": "^8",
"@sentry/react": "^8.10.0",
"@socialgouv/react-departements": "^3.0.0",
"@swc/core": "^1.7.12",
"@swc/jest": "^0.2.36",
"@tanstack/react-query": "^5.28.4",
"@types/jest": "^29.5.12",
"axios": "^1.6.8",
"dayjs": "^1.11.10",
"framer-motion": "^11.0.14",
Expand All @@ -53,8 +57,9 @@
"i18next-browser-languagedetector": "^7.2.0",
"i18next-parser": "^8.13.0",
"i18next-resources-to-backend": "^1.2.0",
"jest": "^29.7.0",
"markdown-to-jsx": "^7.3.2",
"next": "^14.2.5",
"next": "^14.2.7",
"next-i18n-router": "^4.1.1",
"postcss": "8.4.36",
"process": "^0.11.10",
Expand All @@ -68,6 +73,7 @@
"react-hook-form": "^7.51.2",
"react-i18next": "^14.0.5",
"react-modal": "^3.16.1",
"react-number-format": "^5.4.1",
"react-select": "^5.8.0",
"react-toastify": "^10.0.5",
"react-tooltip": "^5.26.3",
Expand All @@ -86,6 +92,7 @@
"@babel/core": "^7.24.0",
"@babel/eslint-parser": "^7.23.10",
"@babel/runtime": "^7.23.1",
"@faker-js/faker": "^8.4.1",
"@incubateur-ademe/nosgestesclimat-scripts": "^0.6.0",
"@simonsmith/cypress-image-snapshot": "^9.0.1",
"@types/mdx": "^2.0.10",
Expand Down Expand Up @@ -118,6 +125,7 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"glob": "^10.4.1",
"jest-environment-jsdom": "^29.7.0",
"json-stable-stringify": "^1.1.0",
"postcss-loader": "^8.1.0",
"prettier": "^3.1.0",
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
1 change: 1 addition & 0 deletions public/images/icons/save-check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/app/(large-layout)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ContentLarge from '@/components/layout/ContentLarge'
import Header from '@/components/layout/Header'
import { PropsWithChildren } from 'react'

export default async function LargeLayout({ children }: PropsWithChildren) {
return (
<>
<Header />
<ContentLarge>{children}</ContentLarge>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function NorthStarIframe() {
ref={iFrameRef}
id="iframe-metabase-northstar"
title="Statistiques Northstar Metabase"
src="https://metabase-ngc.osc-fr1.scalingo.io/public/dashboard/0f6974c5-1254-47b4-b6d9-6e6f22a6faf7"
src="https://metabase.nosgestesclimat.fr/public/dashboard/0f6974c5-1254-47b4-b6d9-6e6f22a6faf7"
width="100%"
height="1800px"
className="border-none"></iframe>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import Trans from '@/components/translation/Trans'
import Title from '@/design-system/layout/Title'
import { useNumberSubscribers } from '@/hooks/useNumberSubscriber'
import { UseQueryResult } from '@tanstack/react-query'
import {
useAllSimulationsTerminees,
useAllTimeVisits,
Expand All @@ -13,7 +11,9 @@ import {
useCurrentMonthVisits,
useCurrentMonthWebsites,
useGetSharedSimulationEvents,
} from '../_helpers/matomo'
} from '@/helpers/matomo'
import { useNumberSubscribers } from '@/hooks/useNumberSubscriber'
import { UseQueryResult } from '@tanstack/react-query'
import AcquisitionBlock from './content/AcquisitionBlock'
import MetabaseIframe from './content/MetabaseIframe'
import SimulationsBlock from './content/SimulationsBlock'
Expand Down Expand Up @@ -153,7 +153,7 @@ export default function StatsContent() {
<MetabaseIframe
id="stats-quali"
titre="stats-quali"
src="https://metabase-ngc.osc-fr1.scalingo.io/public/dashboard/f36c5cc4-abb9-4ac6-98b5-13bed7318e7d#titled=false"
src="https://metabase.nosgestesclimat.fr/public/dashboard/f36c5cc4-abb9-4ac6-98b5-13bed7318e7d#titled=false"
height="800px"
/>{' '}
</div>
Expand All @@ -172,13 +172,13 @@ export default function StatsContent() {
<MetabaseIframe
id="stats-orga"
titre="stats mode orga"
src="https://metabase-ngc.osc-fr1.scalingo.io/public/dashboard/f64f2de4-fc94-431e-a6c0-01f9c0095267#titled=false"
src="https://metabase.nosgestesclimat.fr/public/dashboard/f64f2de4-fc94-431e-a6c0-01f9c0095267#titled=false"
/>
<h3 className="mt-4">Mode "Challenge tes amis"</h3>
<MetabaseIframe
id="stats-amis"
titre="stats-amis"
src="https://metabase-ngc.osc-fr1.scalingo.io/public/dashboard/8a32d8a6-3716-40a7-9ce0-f9991c54acf4#titled=false"
src="https://metabase.nosgestesclimat.fr/public/dashboard/8a32d8a6-3716-40a7-9ce0-f9991c54acf4#titled=false"
/>{' '}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useSimulationsChart } from '@/helpers/matomo'
import { useEffect, useState } from 'react'

import { useSimulationsChart } from '../../_helpers/matomo'
import Chart from './chart/Chart'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useVisitsChart } from '@/helpers/matomo'
import { useEffect, useState } from 'react'

import { useVisitsChart } from '../../_helpers/matomo'
import Chart from './chart/Chart'

type Props = {
Expand Down
File renamed without changes.

This file was deleted.

This file was deleted.

Loading

0 comments on commit f2b646a

Please sign in to comment.