1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 05:15:02 +00:00
mon-entreprise/source/components/Targets.js
Maxime Quandalle 6ea5dd0870 Migration de React "class" à "function"
Le but de la refacto est de généraliser l'utilisation des hook

Nombre de composants convertis: 52
Nombre de composants restants: 12

Il est possible de compter les composants class restants en utilisant
grep "render()"

L'occasion aussi de remplacer la dernière occurence de UNSAFE_componentWillMount
2019-09-11 11:17:23 +02:00

35 lines
1.1 KiB
JavaScript

import withColours from 'Components/utils/withColours'
import withSitePaths from 'Components/utils/withSitePaths'
import { compose } from 'ramda'
import React from 'react'
import emoji from 'react-easy-emoji'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
import { analysisWithDefaultsSelector } from 'Selectors/analyseSelectors'
import './Targets.css'
export default compose(
connect(state => ({ analysis: analysisWithDefaultsSelector(state) })),
withColours,
withSitePaths
)(function Targets({ analysis, colours, sitePaths }) {
let { nodeValue, unité: unit, dottedName } = analysis.targets[0]
return (
<div id="targets">
<span className="icon"></span>
<span className="content" style={{ color: colours.textColour }}>
<span className="figure">
<span className="value">{nodeValue?.toFixed(1)}</span>{' '}
<span className="unit">{unit}</span>
</span>
<Link
title="Quel est calcul ?"
style={{ color: colours.colour }}
to={sitePaths.documentation.index + '/' + dottedName}
className="explanation">
{emoji('📖')}
</Link>
</span>
</div>
)
})