Skip to content

Commit

Permalink
Release 1.1.5
Browse files Browse the repository at this point in the history
Changelog:
- Fix: Bug les questions non applicables sont quand même affichées (NGC-465) #342
- Split testing : utiliser l'adresse IP plutôt que les cookies #341
- feat: use DottedName type in all app #340
- Update ambassadeurs.yaml #335
- Suisse / bugs avec iframeSimulation [NGC-470] #334
- Clean et migration de la situation (NGC-457 NGC-476) #325
  • Loading branch information
florianpanchout authored Jan 17, 2024
1 parent 6925a4f commit aaf04ae
Show file tree
Hide file tree
Showing 60 changed files with 499 additions and 259 deletions.
Binary file added public/images/ambassadeurs/wedemain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useRules } from '@/hooks/useRules'
import { useUser } from '@/publicodes-state'
import { safeEvaluateHelper } from '@/publicodes-state/helpers/safeEvaluateHelper'
import { safeGetSituation } from '@/publicodes-state/helpers/safeGetSituation'
import { Rules, Situation } from '@/publicodes-state/types'
import { DottedName, Rules, Situation } from '@/publicodes-state/types'
import { SuppportedRegions } from '@/types/international'
import { encodeRuleName } from '@/utils/publicodes/encodeRuleName'
import Engine, { Evaluation } from 'publicodes'
Expand Down Expand Up @@ -69,7 +69,7 @@ export default function ModeleDemoBlock({
)
}, [situation, engine])

const onChange = (dottedName: string, value: string) =>
const onChange = (dottedName: DottedName, value: string) =>
setSituation({ ...situation, [dottedName]: value })

const defaultValues = demoDottedNames.reduce(
Expand All @@ -84,7 +84,7 @@ export default function ModeleDemoBlock({
)

return (
<div className="bg-primary-100 my-4 rounded-md p-4">
<div className="my-4 rounded-md bg-primary-100 p-4">
<ul>
{demoDottedNames.map((el) => (
<li key={el} className="mb-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { decodeRuleName, encodeRuleName } = utils
export default function ActionDetail({
params,
}: {
params: { dottedName: string[] }
params: { dottedName: DottedName[] }
}) {
const { getCategory } = useEngine()
const pathParamsDottedName = params?.dottedName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Trans from '@/components/translation/Trans'
import ButtonLink from '@/design-system/inputs/ButtonLink'
import { getMetadataObject } from '@/helpers/metadata/getMetadataObject'
import { DottedName } from '@/publicodes-state/types'
import ActionDetail from './_components/ActionDetail'

export async function generateMetadata({
params: { dottedName },
}: {
params: { dottedName: string[] }
params: { dottedName: DottedName[] }
}) {
return getMetadataObject({
title:
Expand All @@ -22,7 +23,7 @@ export async function generateMetadata({
export default function ActionDetailPage({
params,
}: {
params: { dottedName: string[] }
params: { dottedName: DottedName[] }
}) {
return (
<div className="mx-auto max-w-[600px]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@/helpers/getCategoryColorClass'
import { useClientTranslation } from '@/hooks/useClientTranslation'
import { useRule, useTempEngine, useUser } from '@/publicodes-state'
import { DottedName } from '@/publicodes-state/types'
import { trackEvent } from '@/utils/matomo/trackEvent'
import { encodeRuleName } from '@/utils/publicodes/encodeRuleName'
import Image from 'next/image'
Expand All @@ -21,7 +22,7 @@ type Props = {
action: any
total: number
rule: any
setFocusedAction: (dottedName: string) => void
setFocusedAction: (dottedName: DottedName) => void
isFocused: boolean
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getMatomoEventActionAccepted } from '@/constants/matomo'
import { FormProvider, useEngine, useUser } from '@/publicodes-state'
import { DottedName } from '@/publicodes-state/types'
import { trackEvent } from '@/utils/matomo/trackEvent'
import ActionCard from './ActionCard'
import ActionForm from './ActionForm'
Expand All @@ -9,7 +10,7 @@ type Props = {
rules: any
bilan: any
focusedAction: string
setFocusedAction: (dottedName: string) => void
setFocusedAction: (dottedName: DottedName) => void
}

export default function ActionList({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useClientTranslation } from '@/hooks/useClientTranslation'
import { useRule } from '@/publicodes-state'
import { NodeValue } from '@/publicodes-state/types'
import { DottedName, NodeValue } from '@/publicodes-state/types'
import { TranslationFunctionType } from '@/types/translation'
import { getCorrectedValue } from '@/utils/getCorrectedValue'
import { getCarbonFootprint } from '../../../_helpers/getCarbonFootprint'
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function ActionValue({
total: number
isDisabled: boolean
hasFormula: boolean
dottedName: string
dottedName: DottedName
isBlurred?: boolean
}) {
const { t, i18n } = useClientTranslation()
Expand Down Expand Up @@ -66,7 +66,7 @@ export default function ActionValue({

return (
<div
className={`border-primary-500 bg-primary-500 mb-6 inline-block rounded-[0.25rem] border-2 border-solid pl-2 pr-[2px] text-white ${
className={`mb-6 inline-block rounded-[0.25rem] border-2 border-solid border-primary-500 bg-primary-500 pl-2 pr-[2px] text-white ${
correctedValue != undefined && correctedValue < 0 ? 'bg-red-500' : ''
}${isBlurred ? 'blur-[2px] grayscale' : ''}`}>
<span>
Expand All @@ -76,7 +76,7 @@ export default function ActionValue({
</span>

{total && relativeValue > 0 && (
<span className="text-primary-700 bg-primary-100 ml-2 rounded-e-sm px-1">
<span className="ml-2 rounded-e-sm bg-primary-100 px-1 text-primary-700">
{relativeValue}%
</span>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use client'
import { getBackgroundColor } from '@/helpers/getCategoryColorClass'
import { useRule } from '@/publicodes-state'
import { DottedName } from '@/publicodes-state/types'
import { useRouter, useSearchParams } from 'next/navigation'

type Props = {
dottedName: string
dottedName: DottedName
countByCategory: any
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DottedName } from '@/publicodes-state/types'

// Gathered from nosgestesclimat-site
const filteredDottedNames = [
const filteredDottedNames: DottedName[] = [
'divers . publicité',
'services sociétaux . pression locale',
'services sociétaux . voter',
Expand All @@ -10,7 +12,7 @@ const filteredDottedNames = [
]

export const filterRelevantMissingVariables = (missingVariables: any) => {
return missingVariables.filter((dottedName: string) => {
return missingVariables.filter((dottedName: DottedName) => {
return !filteredDottedNames.includes(dottedName)
})
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DottedName } from '@/publicodes-state/types'
import { getCorrectedValue } from '@/utils/getCorrectedValue'
import { sortBy } from '@/utils/sortBy'
import { filterIrrelevantActions } from './filterIrrelevantActions'
Expand All @@ -7,7 +8,7 @@ type Props = {
rules: any
radical: boolean
metric: string
getRuleObject: (dottedName: string) => any
getRuleObject: (dottedName: DottedName) => any
actionChoices: any
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ButtonLink from '@/design-system/inputs/ButtonLink'
import Markdown from '@/design-system/utils/Markdown'
import getPost from '@/helpers/markdown/getPost'
import { getMetadataObject } from '@/helpers/metadata/getMetadataObject'
import { DottedName } from '@/publicodes-state/types'

export async function generateMetadata() {
return getMetadataObject({
Expand All @@ -16,7 +17,7 @@ export async function generateMetadata() {

type Props = {
params: {
dottedName: string[]
dottedName: DottedName[]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from '@/components/Link'
import Card from '@/design-system/layout/Card'
import { getRuleTitle } from '@/helpers/publicodes/getRuleTitle'
import { useTempEngine } from '@/publicodes-state'
import { NGCRule, NGCRules } from '@/publicodes-state/types'
import { DottedName, NGCRule, NGCRules } from '@/publicodes-state/types'
import { Post } from '@/types/posts'
import { encodeRuleName } from '@/utils/publicodes/encodeRuleName'

Expand Down Expand Up @@ -34,7 +34,7 @@ export default function ActionPlusList({ actions }: Props) {
<div className="mb-8 text-2xl">{rule.icônes || '🎯'}</div>
<div className="text-center">
{getRuleTitle(
rule as NGCRule & { dottedName: string; titre: string }
rule as NGCRule & { dottedName: DottedName; titre: string }
)}
</div>
</Card>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { orderedCategories } from '@/constants/orderedCategories'
import { NodeValue } from '@/publicodes-state/types'
import { DottedName, NodeValue } from '@/publicodes-state/types'
import { SimulationResults } from '@/types/groups'

export const getSimulationResults = ({
getValue,
}: {
getValue: (dottedName: string) => NodeValue
getValue: (dottedName: DottedName) => NodeValue
}): SimulationResults => {
const resultsObject: any = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useEngine,
useTempEngine,
} from '@/publicodes-state'
import { DottedName } from '@/publicodes-state/types'
import { Member } from '@/types/groups'

export function getSubcategories({
Expand All @@ -14,7 +15,7 @@ export function getSubcategories({
}: {
rules: any
category: string
getRuleObject: (dottedName: string) => any
getRuleObject: (dottedName: DottedName) => any
}): string[] | undefined {
const rule = getRuleObject(category)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import AccordionItem from '@/design-system/layout/accordion/AccordionItem'
import BarChart from '@/design-system/utils/BarChart'
import Emoji from '@/design-system/utils/Emoji'
import { useRule } from '@/publicodes-state'
import { DottedName } from '@/publicodes-state/types'
import SubcategoriesList from './accordionItemWithRule/SubcategoriesList'

export default function AccordionItemWithRule({
dottedName,
maxValue,
index,
}: {
dottedName: string
dottedName: DottedName
maxValue: number
index?: number
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Trans from '@/components/translation/Trans'
import Button from '@/design-system/inputs/Button'
import Card from '@/design-system/layout/Card'
import { useUser } from '@/publicodes-state'
import { Persona as PersonaType } from '@/publicodes-state/types'
import { DottedName, Persona as PersonaType } from '@/publicodes-state/types'

type Props = {
persona: PersonaType
dottedName: string
dottedName: DottedName
}

export default function Persona({ persona, dottedName }: Props) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from '@/components/Link'
import { Rules } from '@/publicodes-state/types'
import { DottedName, Rules } from '@/publicodes-state/types'
import { capitalizeString } from '@/utils/capitalizeString'
import { encodeRuleName } from '@/utils/publicodes/encodeRuleName'
import { Rule, utils } from 'publicodes'
Expand Down Expand Up @@ -41,7 +41,7 @@ export default function RuleDetail({
}: {
ruleData: Rule | string | number
context: {
dottedName: string
dottedName: DottedName
rules: Rules
}
}) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/documentation/_components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Trans from '@/components/translation/Trans'
import Card from '@/design-system/layout/Card'
import { getRuleTitle } from '@/helpers/publicodes/getRuleTitle'
import { NGCRules } from '@/publicodes-state/types'
import { DottedName, NGCRules } from '@/publicodes-state/types'
import Fuse from 'fuse.js'
import { utils } from 'publicodes'
import { useEffect, useMemo, useRef, useState } from 'react'
Expand All @@ -10,7 +10,7 @@ import RuleListItem from './RuleListIem'

export type SearchItem = {
title: string
dottedName: string
dottedName: DottedName
espace: Array<string>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import Card from '@/design-system/layout/Card'
import Emoji from '@/design-system/utils/Emoji'
import { getBackgroundColor } from '@/helpers/getCategoryColorClass'
import { useEngine } from '@/publicodes-state'
import { NGCRule } from '@/publicodes-state/types'
import { DottedName, NGCRule } from '@/publicodes-state/types'
import Markdown from 'markdown-to-jsx'
import { utils } from 'publicodes'

type Props = {
dottedName: string
dottedName: DottedName
summary: string
rule: NGCRule
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/actions/howToAct/RecommendedAction.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Link from '@/components/Link'
import ActionCard from '@/design-system/actions/ActionCard'
import { useRule } from '@/publicodes-state'
import { DottedName } from '@/publicodes-state/types'

export default function RecommendedAction({
actionDottedName,
}: {
actionDottedName: string
actionDottedName: DottedName
}) {
const { icons, title, numericValue } = useRule(actionDottedName)

Expand Down
3 changes: 2 additions & 1 deletion src/components/actions/howToAct/RecommendedActions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import { useActions, useEngine } from '@/publicodes-state'
import { DottedName } from '@/publicodes-state/types'
import { useMemo } from 'react'
import RecommendedAction from './RecommendedAction'

Expand All @@ -12,7 +13,7 @@ export default function RecommendedActions() {
() =>
orderedActionDottedNames
.reduce(
(accumulator: string[], currentActionDottedName: string) =>
(accumulator: string[], currentActionDottedName: DottedName) =>
accumulator.find(
(actionDottedName) =>
getCategory(actionDottedName) ===
Expand Down
9 changes: 6 additions & 3 deletions src/components/form/question/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */

import Trans from '@/components/translation/Trans'
import { QUESTION_DESCRIPTION_BUTTON_ID } from '@/constants/accessibility'
import { getMatomoEventClickHelp } from '@/constants/matomo'
Expand Down Expand Up @@ -56,7 +58,9 @@ export default function Label({
className={twMerge(
'mb-0 inline text-base md:text-lg',
titleClassName
)}>
)}
tabIndex={0}
id={QUESTION_DESCRIPTION_BUTTON_ID}>
{label}
</h1>{' '}
{description ? (
Expand All @@ -66,8 +70,7 @@ export default function Label({
setIsOpen((previsOpen) => !previsOpen)
}}
className={`inline-block ${buttonSizeClassNames[size]} rounded-full border-none bg-primary-500 text-base font-bold text-white`}
title={t("Voir plus d'informations")}
id={QUESTION_DESCRIPTION_BUTTON_ID}>
title={t("Voir plus d'informations")}>
<code>i</code>
</button>
) : null}
Expand Down
6 changes: 3 additions & 3 deletions src/components/layout/header/HeaderDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function HeaderDesktop() {
const { t } = useClientTranslation()

const pathname = usePathname()

console.log('pathname', pathname)
const { getCurrentSimulation } = useUser()

const currentSimulation = getCurrentSimulation()
Expand Down Expand Up @@ -86,9 +86,9 @@ export default function HeaderDesktop() {
<Trans>Profil</Trans>
</NavLink>

{!HIDE_CTA_PATHS.includes(pathname) && (
{!HIDE_CTA_PATHS.find((path) => pathname.includes(path)) ? (
<CTAButton progression={currentSimulation?.progression || 0} />
)}
) : null}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit aaf04ae

Please sign in to comment.