Skip to content

Commit

Permalink
Merge branch 'preprod' into refactor-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Clemog authored Jun 18, 2024
2 parents 7cf5757 + 4d8a06d commit 038881b
Show file tree
Hide file tree
Showing 83 changed files with 746 additions and 368 deletions.
5 changes: 5 additions & 0 deletions config/redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ const redirects = [
'/organisations/:orgaSlug/campagnes/campagne-1?isRedirectFromLegacy=true',
permanent: true,
},
{
source: '/ambassadeurs',
destination: '/nos-relais',
permanent: true,
},
]

module.exports = redirects
4 changes: 2 additions & 2 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.2",
"version": "1.5.3",
"description": "The leading open source climate footprint calculator",
"repository": {
"type": "git",
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@babel/runtime": "^7.23.1",
"@incubateur-ademe/nosgestesclimat": "2.5.1",
"@incubateur-ademe/nosgestesclimat": "2.5.2",
"@mdx-js/loader": "^3.0.0",
"@mdx-js/react": "^3.0.0",
"@next/bundle-analyzer": "^14.1.0",
Expand Down
Binary file modified public/images/ambassadeurs/CNED.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 modified public/images/ambassadeurs/Grandpoitiers.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 modified public/images/ambassadeurs/Grenoble.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 modified public/images/ambassadeurs/La Poste.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/ambassadeurs/TF1 info.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/ambassadeurs/ac.png
Binary file not shown.
Binary file removed public/images/ambassadeurs/acaclimat.png
Binary file not shown.
Binary file added public/images/ambassadeurs/academieduclimat.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/images/ambassadeurs/avenir.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/images/ambassadeurs/bnp.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 removed public/images/ambassadeurs/bnpp.jpg
Binary file not shown.
Binary file removed public/images/ambassadeurs/bon pote.png
Binary file not shown.
Binary file added public/images/ambassadeurs/bonpote.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 modified public/images/ambassadeurs/bpce.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 modified public/images/ambassadeurs/chaville.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 modified public/images/ambassadeurs/citiz.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 modified public/images/ambassadeurs/climates.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/images/ambassadeurs/code-climat.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/images/ambassadeurs/covea.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 modified public/images/ambassadeurs/ecofrugal.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/images/ambassadeurs/ecolucide.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/images/ambassadeurs/france_info.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/images/ambassadeurs/france_inter.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/images/ambassadeurs/gabriele.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 removed public/images/ambassadeurs/gpso.png
Binary file not shown.
Binary file modified public/images/ambassadeurs/greenly.png
Binary file added public/images/ambassadeurs/he.png
96 changes: 96 additions & 0 deletions public/images/ambassadeurs/illu-cinema.svg

Large diffs are not rendered by default.

Binary file modified public/images/ambassadeurs/je veux aider.png
Binary file added public/images/ambassadeurs/jeuneengage.png
Binary file modified public/images/ambassadeurs/la rochelle.png
Binary file added public/images/ambassadeurs/leboncoin.png
Binary file added public/images/ambassadeurs/lyon.png
Binary file modified public/images/ambassadeurs/mpp.png
Binary file added public/images/ambassadeurs/omaj.png
Binary file added public/images/ambassadeurs/paris-ouest.png
Binary file added public/images/ambassadeurs/poste.png
Binary file removed public/images/ambassadeurs/silicet.png
Diff not rendered.
Binary file added public/images/ambassadeurs/silicetbidule.png
Binary file added public/images/ambassadeurs/sncf-voyageurs.png
Binary file modified public/images/ambassadeurs/sogood.png
Binary file added public/images/ambassadeurs/steply.png
Binary file modified public/images/ambassadeurs/ucl.png
Binary file modified public/images/ambassadeurs/vendredi.png
Binary file added public/images/ambassadeurs/ville-nantes.png
Binary file added public/images/ambassadeurs/wagner.png
Binary file added public/images/ambassadeurs/yami.png

This file was deleted.

124 changes: 124 additions & 0 deletions src/app/(layout-with-navigation)/(pages-statiques)/nos-relais/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import Trans from '@/components/translation/Trans'
import InlineLink from '@/design-system/inputs/InlineLink'
import Card from '@/design-system/layout/Card'
import Title from '@/design-system/layout/Title'
import { getServerTranslation } from '@/helpers/getServerTranslation'
import { getMetadataObject } from '@/helpers/metadata/getMetadataObject'
import ambassadeursYaml from '@/locales/ambassadeurs/fr/ambassadeurs.yaml'
import Image from 'next/image'

export async function generateMetadata() {
const { t } = await getServerTranslation()
return getMetadataObject({
title: t('Nos relais - Nos Gestes Climat'),
description: t(
'Découvrez les relais de Nos Gestes Climat : organisations, collectivités, médias, influenceurs, etc.'
),
alternates: {
canonical: '/relais',
},
})
}

const ambassadeurs = ambassadeursYaml as any
const categories = Object.keys(ambassadeurs)

export default async function NosRelais() {
const { t } = await getServerTranslation()

return (
<div>
<Title>
<Trans>
Ils relaient{' '}
<span className="text-primary-700">Nos Gestes Climat</span>
</Trans>
</Title>

<div className="flex flex-wrap items-center md:flex-nowrap md:gap-16">
<div>
<p>
<Trans>
Plus de 40 acteurs relaient{' '}
<span className="text-secondary-700">ou</span> ont relayé Nos
Gestes Climat à travers 
<a
href="https://accelerateur-transition-ecologique-ademe.notion.site/Int-grer-Nos-Gestes-Climat-en-iframe-abdeb175baf84143922006964d80348c"
target="_blank"
rel="noopener noreferrer">
l’intégration du calculateur
</a>{' '}
sur leur site internet{' '}
<span className="text-secondary-700">ou</span> sa diffusion via{' '}
<InlineLink href="/organisations">des campagnes</InlineLink>{' '}
(mail, réseaux sociaux et/ou affichage). C’est majoritairement
grâce à eux que nous sensibilisons près de 2 000 nouvelles
personnes en moyenne chaque jour et nous les en remercions.
</Trans>
</p>

<p>
<Trans>
Vous avez relayé Nos Gestes Climat et souhaitez apparaître dans
notre galerie de relais ? Merci de nous envoyer un message avec{' '}
<span className="text-secondary-700">votre logo</span> via{' '}
<InlineLink href="/contact">notre page de contact</InlineLink>.
</Trans>
</p>

<p className="mb-8 italic">
<Trans>
N.B. : aucun acteur cité ci-dessous ne finance Nos Gestes Climat,
qui est et restera un service public, indépendant et gratuit de
l’ADEME.
</Trans>
</p>
</div>
<Image
width="300"
height="400"
className="ml-auto w-48 self-start md:-mt-16 md:w-auto"
alt={t(
'Un grand-père et sa petite-fille au cinéma, mangeant du pop-corn.'
)}
src="/images/ambassadeurs/illu-cinema.svg"
/>
</div>

{categories.map((category: any) => (
<div key={category} className="mb-16">
<h2>{category}</h2>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
{ambassadeurs[category].map((ambassadeur: any) => (
<Card
key={ambassadeur.title}
href={ambassadeur.link}
tag="a"
className="border-none bg-primary-50 no-underline"
target="_blank">
<Image
src={'/images/ambassadeurs/' + ambassadeur.image}
width="100"
height="100"
className="mx-auto mb-4 h-36 w-2/3 object-contain"
alt={ambassadeur.title}
/>
<p className="mb-4 font-bold">{ambassadeur.title}</p>
{ambassadeur.link ? (
<p className="my-0 underline">
{
ambassadeur.link
.replace('https://', '')
.replace('www.', '')
.split('/')[0]
}
</p>
) : null}
</Card>
))}
</div>
</div>
))}
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import GroupLoader from '@/components/groups/GroupLoader'
import GroupNotFound from '@/components/groups/GroupNotFound'
import GoBackLink from '@/design-system/inputs/GoBackLink'
import { useFetchGroup } from '@/hooks/groups/useFetchGroup'
import { useFixComputedResults } from '@/hooks/groups/useFixComputedResults'
import { useGroupIdInQueryParams } from '@/hooks/groups/useGroupIdInQueryParams'
import { useGroupPagesGuard } from '@/hooks/navigation/useGroupPagesGuard'
import EditableGroupTitle from './_components/EditableGroupTitle'
Expand All @@ -18,23 +19,26 @@ export default function GroupResultsPage() {
const { groupIdInQueryParams } = useGroupIdInQueryParams()
const { data: group, isLoading } = useFetchGroup(groupIdInQueryParams)

// TODO : Remove this hook when the computed results are fixed
const groupWithSafeComputedResults = useFixComputedResults(group)

// If we are still fetching the group (or we are redirecting the user), we display a loader
if (!isGuardInit || isGuardRedirecting || isLoading) {
return <GroupLoader />
}

// If the group doesn't exist, we display a 404 page
if (!group) {
if (!groupWithSafeComputedResults) {
return <GroupNotFound />
}

return (
<div>
<GoBackLink className="mb-4 font-bold" />

<EditableGroupTitle group={group} />
<EditableGroupTitle group={groupWithSafeComputedResults} />

<GroupResults group={group} />
<GroupResults group={groupWithSafeComputedResults} />
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Trans from '@/components/translation/Trans'
import {
LIST_MAIN_NEWSLETTER,
LIST_NOS_GESTES_LOGEMENT_NEWSLETTER,
LIST_NOS_GESTES_TRANSPORT_NEWSLETTER,
} from '@/constants/brevo'
import { endClickSaveSimulation } from '@/constants/tracking/pages/end'
Expand All @@ -17,9 +18,10 @@ import { useSaveSimulation } from '@/hooks/simulation/useSaveSimulation'
import { useClientTranslation } from '@/hooks/useClientTranslation'
import { useLocale } from '@/hooks/useLocale'
import { useNumberSubscribers } from '@/hooks/useNumberSubscriber'
import { useCurrentSimulation, useUser } from '@/publicodes-state'
import { useCurrentSimulation, useEngine, useUser } from '@/publicodes-state'
import { isEmailValid } from '@/utils/isEmailValid'
import { trackEvent } from '@/utils/matomo/trackEvent'
import { captureException } from '@sentry/react'
import { useEffect, useRef, useState } from 'react'
import { SubmitHandler, useForm as useReactHookForm } from 'react-hook-form'
import { twMerge } from 'tailwind-merge'
Expand All @@ -30,6 +32,7 @@ type Inputs = {
email?: string
'newsletter-saisonniere': boolean
'newsletter-transports': boolean
'newsletter-logement': boolean
}

export default function GetResultsByEmail({
Expand All @@ -44,6 +47,8 @@ export default function GetResultsByEmail({

const currentSimulation = useCurrentSimulation()

const { getComputedResults } = useEngine()

// Avoid refetching useGetNewsletterSubscriptions when defining an email for the first time
const emailRef = useRef<string>(user?.email ?? '')

Expand All @@ -53,10 +58,15 @@ export default function GetResultsByEmail({

const isSubscribedMainNewsletter =
newsletterSubscriptions?.includes(LIST_MAIN_NEWSLETTER)

const isSubscribedTransportNewsletter = newsletterSubscriptions?.includes(
LIST_NOS_GESTES_TRANSPORT_NEWSLETTER
)

const isSubscribedLogementNewsletter = newsletterSubscriptions?.includes(
LIST_NOS_GESTES_LOGEMENT_NEWSLETTER
)

const { register, handleSubmit, setValue } = useReactHookForm<Inputs>({
defaultValues: {
name: user?.name,
Expand All @@ -74,6 +84,11 @@ export default function GetResultsByEmail({
'newsletter-transports',
newsletterSubscriptions.includes(LIST_NOS_GESTES_TRANSPORT_NEWSLETTER)
)

setValue(
'newsletter-logement',
newsletterSubscriptions.includes(LIST_NOS_GESTES_LOGEMENT_NEWSLETTER)
)
}, [newsletterSubscriptions, setValue])

const { saveSimulation, isPending, isSuccess, isError, error } =
Expand Down Expand Up @@ -102,10 +117,21 @@ export default function GetResultsByEmail({

updateEmail(formEmail)

if (currentSimulation?.computedResults?.bilan === 0) {
// Send an error to Sentry
captureException(
new Error('GetResultsByEmail: computedResults.bilan === 0')
)
}

// We save the simulation (and signify the backend to send the email)
await saveSimulation({
simulation: {
...currentSimulation,
computedResults:
currentSimulation?.computedResults?.bilan === 0
? getComputedResults(currentSimulation.situation)
: currentSimulation.computedResults,
savedViaEmail: true,
},
shouldSendSimulationEmail: true,
Expand Down Expand Up @@ -199,6 +225,21 @@ export default function GetResultsByEmail({
{...register('newsletter-transports')}
/>
)}

{!isSubscribedLogementNewsletter && (
<CheckboxInputGroup
label={
<span>
<Emoji>🏡</Emoji>{' '}
<Trans>
<strong>Nos Gestes Logement</strong> : informez-vous sur
l'impact carbone du logement, en quelques e-mails
</Trans>
</span>
}
{...register('newsletter-logement')}
/>
)}
</div>

<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const questions = [
Il est quasiment impossible de vivre à moins de 2 tonnes dans notre
société actuellement.{' '}
<span className="text-secondary-700">
L’État, le secteur privé et les citoyens
L’État, les collectivités locales, le secteur privé et les citoyens
</span>{' '}
devront tous contribuer pour atteindre cet objectif.
</Trans>
Expand Down
Loading

0 comments on commit 038881b

Please sign in to comment.