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

use wikidata logo #1905

Closed
wants to merge 14 commits into from
Closed
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
6 changes: 0 additions & 6 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ jobs:
NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE=${{ vars.NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE }}
NEXT_PUBLIC_GHOST_KEY=${{ vars.NEXT_PUBLIC_GHOST_KEY }}
NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL=${{ vars.NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL }}
NEXT_PUBLIC_BREVO_API_URL=${{ vars.NEXT_PUBLIC_BREVO_API_URL }}
BREVO_API_KEY=${{ secrets.BREVO_API_KEY }}
S3_CONFIG_ACCESS_KEY_ID=${{ secrets.S3_CONFIG_ACCESS_KEY_ID }}
S3_CONFIG_SECRET_ACCESS_KEY=${{ secrets.S3_CONFIG_SECRET_ACCESS_KEY }}
S3_CONFIG_REGION=${{ secrets.S3_CONFIG_REGION }}
S3_CONFIG_ENDPOINT=${{ secrets.S3_CONFIG_ENDPOINT }}
NEXT_PUBLIC_MATOMO_URL=${{ vars.NEXT_PUBLIC_MATOMO_URL }}
NEXT_PUBLIC_MATOMO_SITE_ID=${{ vars.NEXT_PUBLIC_MATOMO_SITE_ID }}

Expand Down
15 changes: 1 addition & 14 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,9 @@ ARG NEXT_PUBLIC_BAL_API_URL
ARG NEXT_PUBLIC_GHOST_URL
ARG NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE
ARG NEXT_PUBLIC_GHOST_KEY
ARG S3_CONFIG_ACCESS_KEY_ID
ARG S3_CONFIG_SECRET_ACCESS_KEY
ARG S3_CONFIG_REGION
ARG S3_CONFIG_ENDPOINT
ARG NEXT_PUBLIC_MATOMO_URL
ARG NEXT_PUBLIC_MATOMO_SITE_ID
ARG NEXT_PUBLIC_BREVO_API_URL
ARG BREVO_API_KEY
ARG NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL
ARG NEXT_PUBLIC_ALTCHA_API_KEY

# Les variables d'environnement sont exportées avant le build
ENV NEXT_PUBLIC_API_BAN_URL=${NEXT_PUBLIC_API_BAN_URL}
Expand All @@ -47,16 +40,10 @@ ENV NEXT_PUBLIC_BAL_API_URL=${NEXT_PUBLIC_BAL_API_URL}
ENV NEXT_PUBLIC_GHOST_URL=${NEXT_PUBLIC_GHOST_URL}
ENV NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE=${NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE}
ENV NEXT_PUBLIC_GHOST_KEY=${NEXT_PUBLIC_GHOST_KEY}
ENV S3_CONFIG_ACCESS_KEY_ID=${S3_CONFIG_ACCESS_KEY_ID}
ENV S3_CONFIG_SECRET_ACCESS_KEY=${S3_CONFIG_SECRET_ACCESS_KEY}
ENV S3_CONFIG_REGION=${S3_CONFIG_REGION}
ENV S3_CONFIG_ENDPOINT=${S3_CONFIG_ENDPOINT}
ENV NEXT_PUBLIC_MATOMO_URL=${NEXT_PUBLIC_MATOMO_URL}
ENV NEXT_PUBLIC_MATOMO_SITE_ID=${NEXT_PUBLIC_MATOMO_SITE_ID}
ENV NEXT_PUBLIC_BREVO_API_URL=${NEXT_PUBLIC_BREVO_API_URL}
ENV NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL=${NEXT_PUBLIC_MOISSONNEUR_BAL_API_URL}
ENV BREVO_API_KEY=${BREVO_API_KEY}
ENV NEXT_PUBLIC_ALTCHA_API_KEY=${NEXT_PUBLIC_ALTCHA_API_KEY}


RUN npm run build

Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"lodash": "^4.17.21",
"maplibre-gl": "^4.7.1",
"next": "14.2.5",
"next-runtime-env": "^3.2.2",
"node-fetch": "^3.3.2",
"path": "^0.12.7",
"prop-types": "^15.8.1",
Expand Down
Binary file added public/documentation-bal/book.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/documentation-bal/community.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/documentation-bal/document-download.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added public/documentation-bal/guide-mes-adresses.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/documentation-bal/logo-bal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/documentation-bal/logo-ban.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/documentation-bal/questions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/documentation-bal/ressources.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions src/app/api/brevo-newsletters/route.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { customFetch } from '@/lib/fetch'
import { NextRequest, NextResponse } from 'next/server'
import { env } from 'next-runtime-env'

if (!process.env.BREVO_API_KEY || !process.env.NEXT_PUBLIC_BREVO_API_URL) {
throw new Error('BREVO_API_KEY or NEXT_PUBLIC_BREVO_API_URL is not defined in the environment')
}
export const dynamic = 'force-dynamic'

// Optin to the newsletter
export async function POST(request: NextRequest) {
if (!env('BREVO_API_KEY') || !env('NEXT_PUBLIC_BREVO_API_URL')) {
return NextResponse.json(
{ error: 'BREVO_API_KEY or NEXT_PUBLIC_BREVO_API_URL is not defined in the environment' },
{ status: 500 }
)
}
const requestBody = await request.json()
const { email } = requestBody
const options = {
method: 'POST',
headers: { 'accept': 'application/json', 'content-type': 'application/json', 'api-key': process.env.BREVO_API_KEY } as RequestInit['headers'],
headers: { 'accept': 'application/json', 'content-type': 'application/json', 'api-key': env('BREVO_API_KEY') } as RequestInit['headers'],
body: JSON.stringify({ email, listIds: [10] }),
}

const response = await customFetch(`${process.env.NEXT_PUBLIC_BREVO_API_URL}/contacts`, options)
const response = await customFetch(`${env('NEXT_PUBLIC_BREVO_API_URL')}/contacts`, options)

return NextResponse.json(response)
}
Expand All @@ -30,14 +35,14 @@ export async function GET() {
try {
do {
const { campaigns, count: _count } = await customFetch(
`${process.env.NEXT_PUBLIC_BREVO_API_URL}/emailCampaigns?status=sent&limit=30&offset=${offset}&startDate=${from.toISOString()}&endDate=${new Date(
`${env('NEXT_PUBLIC_BREVO_API_URL')}/emailCampaigns?status=sent&limit=30&offset=${offset}&startDate=${from.toISOString()}&endDate=${new Date(
to
).toISOString()}`,
{
headers: {
'accept': 'application/json',
'content-type': 'application/json',
'api-key': process.env.BREVO_API_KEY,
'api-key': env('BREVO_API_KEY'),
} as RequestInit['headers'],
}
)
Expand Down
9 changes: 6 additions & 3 deletions src/app/api/certificat/[idAdresse]/components/certificat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
View,
} from '@react-pdf/renderer'
import { stylesDSFR } from './certificat.stylesheet'
import { env } from 'next-runtime-env'

const NEXT_PUBLIC_ADRESSE_URL = process.env.NEXT_PUBLIC_ADRESSE_URL
const NEXT_PUBLIC_ADRESSE_URL = env('NEXT_PUBLIC_ADRESSE_URL')

interface CertificatNumerotationProps {
data: {
Expand All @@ -29,17 +30,18 @@ interface CertificatNumerotationProps {
telephone?: string
email?: string
}
logoUrl: string
}

const CertificatNumerotation: React.FC<CertificatNumerotationProps> = ({ data, qrCodeDataURL, mairie }) => {
const CertificatNumerotation: React.FC<CertificatNumerotationProps> = ({ data, qrCodeDataURL, mairie, logoUrl }) => {
const nomCommune = data.full_address.districtDefaultLabel
const libelleVoie = data.full_address.commonToponymDefaultLabel
const numero = data.full_address.number
const suffix = data.full_address.suffix || ''
const { cog } = data.full_address
const parcelles = data.cadastre_ids.map(id => id.replace(/(\d+)([A-Z])/, '$1 $2'))

const logoUrl = `public/logos/certificat/${cog}.png`
// const logoUrl = `public/logos/certificat/${cog}.png`
const logoAdresse = `public/logos/certificat/adresse-logo.png`

const dateObj = new Date(data.createdAt)
Expand All @@ -66,6 +68,7 @@ const CertificatNumerotation: React.FC<CertificatNumerotationProps> = ({ data, q
<Page size="A4" style={stylesDSFR.page}>
<View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
<Image src={logoAdresse} style={stylesDSFR.logoAdresse} />
<Image src={logoUrl} style={stylesDSFR.logoBloc} />
</View>
<Text> {'\n'}</Text>
{/* Conteneur pour le logo de la mairie et les informations */}
Expand Down
8 changes: 4 additions & 4 deletions src/app/api/certificat/[idAdresse]/route.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NextRequest, NextResponse } from 'next/server'
import { getAddress, getDistrict } from '@/lib/api-ban'
const NEXT_PUBLIC_API_BAN_URL = process.env.NEXT_PUBLIC_API_BAN_URL
const BAN_API_TOKEN = process.env.BAN_API_TOKEN
import { env } from 'next-runtime-env'

const NEXT_PUBLIC_API_BAN_URL = env('NEXT_PUBLIC_API_BAN_URL')
const BAN_API_TOKEN = env('BAN_API_TOKEN')

const isAddressCertifiable = async ({ banId, sources, certifie, parcelles }: any): Promise<boolean> => {
return !!banId && sources?.includes('bal') && certifie && parcelles?.length > 0
Expand All @@ -11,10 +13,8 @@ const isDistrictCertifiable = async (banIdDistrict: string | null): Promise<bool
if (!banIdDistrict) {
return false
}

const rawResponse = await getDistrict(banIdDistrict)
const district = rawResponse.response

if (!district) {
return false
}
Expand Down
12 changes: 9 additions & 3 deletions src/app/api/certificat/pdf/[idCertificat]/route.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { NextRequest, NextResponse } from 'next/server'
import QRCode from 'qrcode'
import ReactPDF from '@react-pdf/renderer'

import { getMairie } from '@/lib/api-etablissement-public'
import { CertificatNumerotation } from '@/app/api/certificat/[idAdresse]/components/certificat'
import { env } from 'next-runtime-env'
import { getCommuneLogo } from '@/lib/api-wikidata'

const NEXT_PUBLIC_ADRESSE_URL = process.env.NEXT_PUBLIC_ADRESSE_URL
const NEXT_PUBLIC_API_BAN_URL = process.env.NEXT_PUBLIC_API_BAN_URL
const NEXT_PUBLIC_ADRESSE_URL = env('NEXT_PUBLIC_ADRESSE_URL')
const NEXT_PUBLIC_API_BAN_URL = env('NEXT_PUBLIC_API_BAN_URL')

export async function GET(request: NextRequest, { params }: { params: { idCertificat: string } }) {
const response = await fetch(`${NEXT_PUBLIC_API_BAN_URL}/api/certificate/${params.idCertificat}`, {
Expand All @@ -26,13 +27,18 @@ export async function GET(request: NextRequest, { params }: { params: { idCertif
const qrCodeDataURL = await QRCode.toDataURL(certificatUrl)

const mairie = await getMairie(data.full_address.cog)

const mairieData = mairie || { telephone: undefined, email: undefined }

const logoUrl = await getCommuneLogo(data.full_address.cog) || ' '

const pdfStream = await ReactPDF.renderToStream(
<CertificatNumerotation
data={data}
qrCodeDataURL={qrCodeDataURL}
mairie={mairieData}
logoUrl={logoUrl}

/>
)

Expand Down
9 changes: 9 additions & 0 deletions src/app/api/proxy-flag-commune/[codeCommune]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { getCommuneFlag } from '@/lib/api-blasons-communes'
import { NextRequest, NextResponse } from 'next/server'

export async function GET(request: NextRequest, { params }: { params: { codeCommune: string } }) {
const { codeCommune } = params
const flagUrl = await getCommuneFlag(codeCommune)

return NextResponse.json(flagUrl)
}
13 changes: 7 additions & 6 deletions src/app/blog/[slug]/components/AsideContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import Link from 'next/link'
import { getPosts } from '@/lib/blog'

import { AsideLinkList, AsideFollowList } from './AsideContent.styled'
import { env } from 'next-runtime-env'

const SOCIAL_NETWORKS_URL_MASTODON = env('NEXT_PUBLIC_SOCIAL_NETWORKS_URL_MASTODON')
const SOCIAL_NETWORKS_URL_FACEBOOK = env('NEXT_PUBLIC_SOCIAL_NETWORKS_URL_FACEBOOK')
const SOCIAL_NETWORKS_URL_LINKEDIN = env('NEXT_PUBLIC_SOCIAL_NETWORKS_URL_LINKEDIN')
const SOCIAL_NETWORKS_URL_GITHUB = env('NEXT_PUBLIC_SOCIAL_NETWORKS_URL_GITHUB')
const SOCIAL_NETWORKS_URL_XCOM = env('NEXT_PUBLIC_SOCIAL_NETWORKS_URL_XCOM')

const {
NEXT_PUBLIC_SOCIAL_NETWORKS_URL_XCOM: SOCIAL_NETWORKS_URL_XCOM,
NEXT_PUBLIC_SOCIAL_NETWORKS_URL_MASTODON: SOCIAL_NETWORKS_URL_MASTODON,
NEXT_PUBLIC_SOCIAL_NETWORKS_URL_FACEBOOK: SOCIAL_NETWORKS_URL_FACEBOOK,
NEXT_PUBLIC_SOCIAL_NETWORKS_URL_LINKEDIN: SOCIAL_NETWORKS_URL_LINKEDIN,
} = process.env
const NB_HIGHLIGHTED_POSTS = 3

async function AsideContent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {

import type { FillLayer } from 'react-map-gl/maplibre'
import type { Address } from '../types.d'
import { env } from 'next-runtime-env'

const API_BAN_URL = process.env.NEXT_PUBLIC_API_BAN_URL
const API_BAN_URL = env('NEXT_PUBLIC_API_BAN_URL')

function LayerBan({ address }: { address: Address }) {
const isAdresseFilter = useMemo(() => ['==', ['get', 'id'], address?.id], [address])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { Table } from '@codegouvfr/react-dsfr/Table'
import { DistrictMicroToponymListInfo } from './DistrictMicroToponymList.styles'

import type { TypeDistrictExtended } from '../../types/LegacyBan.types'
import { env } from 'next-runtime-env'

const URL_CARTOGRAPHY_BAN = process.env.NEXT_PUBLIC_URL_CARTOGRAPHY_BAN
const URL_CARTOGRAPHY_BAN = env('NEXT_PUBLIC_URL_CARTOGRAPHY_BAN')

interface DistrictMicroToponymListProps {
district: TypeDistrictExtended
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {

import type { SortAddressesEntry } from '../../tools/sortAddresses'
import type { TypeMicroToponymExtended } from '../../types/LegacyBan.types'
import { env } from 'next-runtime-env'

const URL_CARTOGRAPHY_BAN = process.env.NEXT_PUBLIC_URL_CARTOGRAPHY_BAN
const URL_CARTOGRAPHY_BAN = env('NEXT_PUBLIC_URL_CARTOGRAPHY_BAN')

interface MicroToponymAddressListProps {
microToponym: TypeMicroToponymExtended
Expand Down
3 changes: 3 additions & 0 deletions src/app/carte-base-adresse-nationale/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { BALWidgetContext } from '@/contexts/BALWidget.context'
import { BanMapProvider, useBanMapConfig } from './components/ban-map/BanMap.context'
import { theme } from './components/ban-map/theme'
import Legend from './components/Legend'
import { PublicEnvScript } from 'next-runtime-env'

import {
CartoWrapper,
CartoMenu,
Expand Down Expand Up @@ -92,6 +94,7 @@ export default function RootLayout({ children }: { children: JSX.Element }) {

return (
<BanMapProvider>
<PublicEnvScript />
<Carto>
{ children }
</Carto>
Expand Down
3 changes: 2 additions & 1 deletion src/app/carte-base-adresse-nationale/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useRouter } from 'next/navigation'
import { useBanMapConfig } from './components/ban-map/BanMap.context'

import type { Address } from './components/ban-map/types'
import { env } from 'next-runtime-env'

interface LinkProps {
href: string
Expand All @@ -43,7 +44,7 @@ type MapBreadcrumbPathSegment = string | { label: string, linkProps?: LinkProps
const DEFAULT_CENTER = [1.7, 46.9]
const DEFAULT_ZOOM = 6
const DEFAULT_URL_DISTRICT_FLAG = '/commune/default-logo.svg'
const URL_CARTOGRAPHY_BAN = process.env.NEXT_PUBLIC_URL_CARTOGRAPHY_BAN
const URL_CARTOGRAPHY_BAN = env('NEXT_PUBLIC_URL_CARTOGRAPHY_BAN')

const getBanItemTypes = (banItem?: { type: 'commune' | 'voie' | 'lieu-dit' | 'numero' }) => {
switch (banItem?.type) {
Expand Down
3 changes: 2 additions & 1 deletion src/app/certificat/[idCertificat]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
FieldLabel,
FieldValue,
} from './page.styles'
import { env } from 'next-runtime-env'

const { NEXT_PUBLIC_API_BAN_URL } = process.env
const NEXT_PUBLIC_API_BAN_URL = env('NEXT_PUBLIC_API_BAN_URL')

async function Certificat({ params }: { params: { idCertificat: string } }) {
const { idCertificat } = params
Expand Down
1 change: 1 addition & 0 deletions src/app/commune/[codeCommune]/page.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const StyledCommunePage = styled.div<{ $certificationPercentage: number }
margin-bottom: 2rem;

.commune-general-info {
line-height: normal;
display: flex;
flex-direction: column;
align-items: center;
Expand Down
3 changes: 1 addition & 2 deletions src/app/commune/[codeCommune]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Table } from '@codegouvfr/react-dsfr/Table'
import CardWrapper from '@/components/CardWrapper'
import Section from '@/components/Section'
import {
getBanItem,
getDistrict,
getCommune as getBANCommune,
assemblageSources,
Expand All @@ -14,7 +13,7 @@ import { formatFr } from '@/lib/array'
import { getRevisionDetails, getRevisions } from '@/lib/api-depot'
import { getMairiePageURL } from '@/lib/api-etablissement-public'
import { getCommune as getAPIGeoCommune, getEPCI } from '@/lib/api-geo'
import { getCommuneFlag } from '@/lib/api-wikidata'
import { getCommuneFlag } from '@/lib/api-blasons-communes'

import { CommuneDownloadSection } from '../../../components/Commune/CommuneDownloadSection'
import { CommuneNavigation } from '../../../components/Commune/CommuneNavigation'
Expand Down
Loading