Conversation
| <Radar | ||
| dataKey="benef" | ||
| fill="var(--color-benef)" | ||
| stroke="var(--color-benef)" | ||
| {...radarConfig} | ||
| /> | ||
| <Radar | ||
| dataKey="temoin" | ||
| fill="var(--color-temoin)" | ||
| stroke="var(--color-temoin)" | ||
| {...radarConfig} | ||
| /> | ||
| { | ||
| <Radar | ||
| dataKey="temoin" | ||
| fill="var(--color-temoin)" | ||
| stroke="var(--color-temoin)" | ||
| {...radarConfig} |
There was a problem hiding this comment.
Does it still make sense having both temoin and benef, back to our discussion ? Is the backend returing a single set of data or 2 for the comparison ?
| indicatorKeys.forEach((key) => { | ||
| const value = data[key]; | ||
| data[key] = precise(value) as BiodiversityData[typeof key]; | ||
| }); |
There was a problem hiding this comment.
It's not a good practice to update in place data, coming directly from coordo-ts. It should be considered as Immutable.
Object.fromEntries(
Ojbect.entries(data).map(
([key, value]) => [key, indicatorKeys.contains(key) ? precise(value) : value]
)
)| speciesRichnessTaxon3: 24, | ||
| }, | ||
| title: "Point #se-4", // to replace | ||
| title: `Placette n°${data.cod} dans la forêt ${forests.find((f) => f.value === data.for)?.label || "n°" + data.for}`, |
There was a problem hiding this comment.
This should be internationalized. You can inject dynamic value in a string
- fr:
"title": "Placette n°{{ code }} dans la forêt {{ label }}", - en:
"title": "Point n°{{ code }} in the forest {{ label }}",(to refine)
and then in the code
t("title", { code: data.code, label: forests.find((f) => f.value === data.for)?.label || `n°${data.for}`})| export function precise(value: number) { | ||
| if (!value || Number.isNaN(value)) return 0; | ||
| if (value > 999) return Number(value.toFixed(1)); | ||
| return Number(value.toFixed(2)); | ||
| } |
There was a problem hiding this comment.
For readability (I think there is even a biome rule that can enforce having consistent return with brackets) + redundant type
| export function precise(value: number) { | |
| if (!value || Number.isNaN(value)) return 0; | |
| if (value > 999) return Number(value.toFixed(1)); | |
| return Number(value.toFixed(2)); | |
| } | |
| export function precise(value?: number | null) { | |
| if (!value || Number.isNaN(value)){ | |
| return 0; | |
| } | |
| if (value > 999){ | |
| return value.toFixed(1); | |
| } | |
| return value.toFixed(2); | |
| } |
david-bretaud-dev
left a comment
There was a problem hiding this comment.
A few comments, little suggestion or question, but good to go IMO
precise