Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix home page stats dependencies #1690

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Environment config
.env*

# Runtime
pids
*.pid
*.seed
*.pid.lock

# Logs
logs
*.log
npm-debug.log*
CHANGELOG.md

# Mac
*.DS_Store
.AppleDouble
.LSOverride

# Build
.next

# Cache
.yarn-cache
.npm
.eslintcache
.changelog

# Node
node_modules

# Reports
coverage
reports

# Git config
.git
.github
.gitignore

#Editor Config
.editorconfig

#Docker config
Dockerfile*
docker-compose.yml
.dockerignore

#Babel config
.babelrc

#Scalingo config
scalingo.json

#Other
*.md
LICENSE
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:16.19.0-alpine
WORKDIR /app

# installing dependencies
COPY package.json yarn.lock .
COPY package.json yarn.lock ./
RUN mkdir public
RUN yarn install

Expand Down
8 changes: 5 additions & 3 deletions components/bases-locales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ const BasesLocales = React.memo(({stats}) => {
</div>
</Section>

<Section background='color' title='État du déploiement des Bases Adresses Locales'>
<MapBalSection stats={stats} />
</Section>
{stats && (
<Section background='color' title='État du déploiement des Bases Adresses Locales'>
<MapBalSection stats={stats} />
</Section>
)}

<style jsx>{`
.notification-content {
Expand Down
4 changes: 3 additions & 1 deletion components/maplibre/ban-map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {flatten, forEach} from 'lodash'
import DeviceContext from '@/contexts/device'
import {Layer, Source, useMap, Popup} from 'react-map-gl/maplibre'

const API_BAN_URL = process.env.NEXT_PUBLIC_API_BAN_URL || 'https://plateforme.adresse.data.gouv.fr'

let hoveredFeature = null

const SOURCES = ['adresses', 'toponymes']
Expand Down Expand Up @@ -322,7 +324,7 @@ function BanMap({address, bbox, onSelect, isMobile}) {
type='vector'
format='pbf'
tiles={[
'https://plateforme.adresse.data.gouv.fr/tiles/ban/{z}/{x}/{y}.pbf'
`${API_BAN_URL}/tiles/ban/{z}/{x}/{y}.pbf`
]}
minzoom={10}
maxzoom={14}
Expand Down
42 changes: 38 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,42 @@ services:
dockerfile: 'Dockerfile.dev'
container_name: frontend
volumes:
- ./:/app
- /app/node_modules
- /app/.next
- ./build/:/app/build
- ./components/:/app/components
- ./contexts/:/app/contexts
- ./data/:/app/data
- ./hooks/:/app/hooks
- ./layouts/:/app/layouts
- ./lib/:/app/lib
- ./pages/:/app/pages
- ./public/:/app/public
- ./scripts/:/app/scripts
- ./server/:/app/server
- ./styles/:/app/styles
- ./views/:/app/views
- ./events.json:/app/events.json
- ./next.config.js:/app/next.config.js
- ./.babelrc:/app/.babelrc
ports:
- "${PORT:-3000}:${PORT:-3000}"
- "${PORT:-3000}:3000"
environment:
- NEXT_PUBLIC_ADRESSE_URL=${NEXT_PUBLIC_ADRESSE_URL}
- NEXT_PUBLIC_API_GEO_URL=${NEXT_PUBLIC_API_GEO_URL}
- NEXT_PUBLIC_API_BAN_URL=${NEXT_PUBLIC_API_BAN_URL}
- NEXT_PUBLIC_API_ADRESSE=${NEXT_PUBLIC_API_ADRESSE}
- NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC=${NEXT_PUBLIC_API_ETABLISSEMENTS_PUBLIC}
- NEXT_PUBLIC_MATOMO_URL=${NEXT_PUBLIC_MATOMO_URL}
- NEXT_PUBLIC_MATOMO_SITE_ID=${NEXT_PUBLIC_MATOMO_SITE_ID}
- MATOMO_TOKEN_AUTH=${MATOMO_TOKEN_AUTH}
- ENABLE_HELMET=${ENABLE_HELMET}
- NEXT_PUBLIC_API_DEPOT_URL=${NEXT_PUBLIC_API_DEPOT_URL}
- API_DEPOT_TOKEN=${API_DEPOT_TOKEN}
- SESSION_SECRET=${SESSION_SECRET}
- NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED=${NEXT_PUBLIC_CERTIFICAT_NUMEROTATION_ENABLED}
- PATH_STATIC_FILE=${PATH_STATIC_FILE}
- GHOST_KEY=${GHOST_KEY}
- NEXT_PUBLIC_GHOST_URL=${NEXT_PUBLIC_GHOST_URL}
- NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE=${NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE}
- NEXT_PUBLIC_BAL_ADMIN_API_URL=${NEXT_PUBLIC_BAL_ADMIN_API_URL}
- NEXT_PUBLIC_BAL_API_URL=${NEXT_PUBLIC_BAL_API_URL}
- NEXT_PUBLIC_MES_ADRESSES=${NEXT_PUBLIC_MES_ADRESSES}
38 changes: 22 additions & 16 deletions lib/api-ban.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@ import HttpError from './http-error'
export const API_BAN_URL = process.env.NEXT_PUBLIC_API_BAN_URL || 'https://plateforme.adresse.data.gouv.fr'

export async function _fetch(url, customOptions = {}) {
const options = {
mode: 'cors',
method: 'GET',
...customOptions
try {
const options = {
mode: 'cors',
method: 'GET',
...customOptions
}

const response = await fetch(url, options)
const contentType = response.headers.get('content-type')

if (!response.ok) {
throw new HttpError(response)
}

if (response.ok && contentType && contentType.includes('application/json')) {
return response.json()
}

throw new Error('Une erreur est survenue')
} catch (error) {
console.error(error)
}

const response = await fetch(url, options)
const contentType = response.headers.get('content-type')

if (!response.ok) {
throw new HttpError(response)
}

if (response.ok && contentType && contentType.includes('application/json')) {
return response.json()
}

throw new Error('Une erreur est survenue')
return null
}

export function getAddress(idAddress) {
Expand Down
5 changes: 3 additions & 2 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ export async function getServerSideProps() {
}

Home.defaultProps = {
posts: null
posts: null,
stats: null
}

Home.propTypes = {
stats: PropTypes.object.isRequired,
stats: PropTypes.object,
posts: PropTypes.array
}

Expand Down
14 changes: 10 additions & 4 deletions pages/programme-bal.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@ function ProgrammeBAL({stats}) {
<img className='fr-responsive-img' src='/images/bal-landing-page/checkbox.png' alt='' width='100%' />
</div>
</div>
<div style={{marginTop: 50}} className='fr-grid-row'>
<h2>Déjà <strong>{stats.bal.nbCommunesCouvertes}</strong> communes ont mis jour leurs bases d’adresses</h2>
</div>
{stats && (
<div style={{marginTop: 50}} className='fr-grid-row'>
<h2>Déjà <strong>{stats.bal.nbCommunesCouvertes}</strong> communes ont mis jour leurs bases d’adresses</h2>
</div>
)}
<div className='fr-grid-row space-between-row'>
<div className='fr-col-md-5 verbatim-card'>
<Image src='/images/bal-landing-page/verbatim.svg' alt='icone verbatim' width={30} height={30} />
Expand Down Expand Up @@ -377,8 +379,12 @@ export async function getServerSideProps() {
}
}

ProgrammeBAL.defaultProps = {
stats: null,
}

ProgrammeBAL.propTypes = {
stats: PropTypes.object.isRequired,
stats: PropTypes.object,
}

export default ProgrammeBAL
Expand Down
Loading