diff --git a/mon-entreprise/package.json b/mon-entreprise/package.json index f06be107c..3348369ad 100644 --- a/mon-entreprise/package.json +++ b/mon-entreprise/package.json @@ -49,7 +49,6 @@ "react-router-hash-link": "^1.2.2", "react-spring": "=8.0.27", "react-syntax-highlighter": "^10.1.1", - "react-to-print": "^2.5.1", "react-transition-group": "^2.2.1", "recharts": "^1.8.5", "reduce-reducers": "^1.0.4", diff --git a/mon-entreprise/source/components/conversation/conversation.css b/mon-entreprise/source/components/conversation/conversation.css index 5e875b2bb..60fa02535 100644 --- a/mon-entreprise/source/components/conversation/conversation.css +++ b/mon-entreprise/source/components/conversation/conversation.css @@ -68,13 +68,13 @@ z-index: -1; } -.step.input { +.step .input { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; } -.step.input > :first-child { +.step .input > :first-child { text-align: right; } diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/Result.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/Result.tsx deleted file mode 100644 index 265045d39..000000000 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/Result.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import RuleLink from 'Components/RuleLink' -import { useEvaluation } from 'Components/utils/EngineContext' -import { formatValue } from 'publicodes' -import React from 'react' -import emoji from 'react-easy-emoji' -import { Trans } from 'react-i18next' -import Skeleton from 'react-loading-skeleton' -import ReactToPrint from 'react-to-print' -import Animate from 'Components/ui/animate' -import simulationConfig from './config.yaml' -import { DottedName } from 'Rules' - -type ResultsProp = { - componentRef?: any -} -export function Results({ componentRef }: ResultsProp) { - const results = useEvaluation(simulationConfig.objectifs as Array) - const onGoingComputation = !results.filter(node => node.nodeValue != null) - .length - return ( -
-

- - Aide à la déclaration - - {emoji('📄')} -

- {onGoingComputation && ( -

- - - Calcul en cours... - - -

- )} - <> - - {results.map(r => ( - -

- {r.title} {r.summary} -

- {r.description &&

{r.description}

} -

- - {r.nodeValue != null ? ( - formatValue({ - nodeValue: r.nodeValue || 0, - language: 'fr', - unit: '€', - precision: 0 - }) - ) : ( - - )} - -

-
- ))} -

- Résultats calculés le {new Date().toLocaleDateString()} -

- {!onGoingComputation && ( -
- - ( - - )} - content={() => componentRef.current} - /> -
- )} -
- -
- ) -} diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx index e2bc5f84d..579924cb8 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/AideDéclarationIndépendant/index.tsx @@ -8,13 +8,7 @@ import { ScrollToTop } from 'Components/utils/Scroll' import useDisplayOnIntersecting from 'Components/utils/useDisplayOnIntersecting' import RuleInput from 'Components/conversation/RuleInput' import { ParsedRule } from 'publicodes' -import React, { - useCallback, - useEffect, - useRef, - useState, - useContext -} from 'react' +import React, { useCallback, useEffect, useState, useContext } from 'react' import { Trans } from 'react-i18next' import { useDispatch, useSelector } from 'react-redux' import { RootState } from 'Reducers/rootReducer' @@ -24,8 +18,11 @@ import styled from 'styled-components' import Animate from 'Components/ui/animate' import { CompanySection } from '../Home' import simulationConfig from './config.yaml' -import { Results } from './Result' import { useNextQuestions } from 'Components/utils/useNextQuestion' +import emoji from 'react-easy-emoji' +import RuleLink from 'Components/RuleLink' +import { formatValue } from 'Engine/format' +import Skeleton from 'react-loading-skeleton' export default function() { const dispatch = useDispatch() @@ -37,37 +34,30 @@ export default function() { dispatch(setSimulationConfig(simulationConfig, true)) }, []) - const { resultsRef, displayForm, updateIncome, currentIncome } = (() => { - const dottedName = 'dirigeant . rémunération totale' - const [resultsRef, resultsInViewPort] = useDisplayOnIntersecting({ - threshold: 0.5, - unobserve: false - }) - const value = useSelector(situationSelector)[dottedName] - const [currentIncome, setCurrentIncome] = useState(value) - const [displayForm, setDisplayForm] = useState(currentIncome != null) - const updateIncome = useCallback( - income => { - setDisplayForm(income != null) - setCurrentIncome(income) - }, - [setDisplayForm, setCurrentIncome] - ) - const dispatch = useDispatch() - useEffect(() => { - if (resultsInViewPort && displayForm) { - dispatch(updateSituation(dottedName, currentIncome)) - } else { - dispatch(updateSituation(dottedName, null)) - } - }, [resultsInViewPort, displayForm, currentIncome]) + const dottedName = 'dirigeant . rémunération totale' + const [resultsRef, resultsInViewPort] = useDisplayOnIntersecting({ + threshold: 0.5, + unobserve: false + }) + const value = useSelector(situationSelector)[dottedName] + const [currentIncome, setCurrentIncome] = useState(value) + const displayForm = currentIncome != null + const updateIncome = useCallback( + income => { + setCurrentIncome(income) + }, + [setCurrentIncome] + ) + useEffect(() => { + if (resultsInViewPort && displayForm) { + dispatch(updateSituation(dottedName, currentIncome)) + } else { + dispatch(updateSituation(dottedName, null)) + } + }, [resultsInViewPort, displayForm, currentIncome]) - return { updateIncome, resultsRef, displayForm, currentIncome } - })() - - const printComponentRef = useRef(null) return ( -
+

Aide à la déclaration de revenus au titre de l'année 2019

@@ -197,7 +187,7 @@ export default function() {
- +
@@ -308,6 +298,60 @@ function SimpleField({ dottedName, question, summary }: SimpleFieldProps) { ) } +function Results() { + const results = useEvaluation(simulationConfig.objectifs as Array) + const onGoingComputation = !results.filter(node => node.nodeValue != null) + .length + return ( +
+

+ + Aide à la déclaration + + {emoji('📄')} +

+ {onGoingComputation && ( +

+ + + Calcul en cours... + + +

+ )} + <> + + {results.map(r => ( + +

+ {r.title} {r.summary} +

+ {r.description &&

{r.description}

} +

+ + {r.nodeValue != null ? ( + formatValue({ + nodeValue: r.nodeValue || 0, + language: 'fr', + unit: '€', + precision: 0 + }) + ) : ( + + )} + +

+
+ ))} +
+ +
+ ) +} + const FormBlock = styled.section` max-width: 500px; padding: 0; diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/Home.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/Home.tsx index eccd41a0d..8020d27dd 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/Home.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Gérer/Home.tsx @@ -317,7 +317,7 @@ export const CompanySection = ({ company }: CompanySectionProps) => { -

Êtes-vous dirigeant majoritaire ?

+

Êtes-vous dirigeant majoritaire ?

Si vous êtes administrateur majoritaire ou si vous faites partie d'un conseil d'administration majoritaire, vous n'aurez pas le diff --git a/mon-entreprise/source/utils.ts b/mon-entreprise/source/utils.ts index fc83eba07..0bc483c3c 100644 --- a/mon-entreprise/source/utils.ts +++ b/mon-entreprise/source/utils.ts @@ -33,7 +33,8 @@ export function inIframe(): boolean { // This is different from the process.env.NODE_ENV in that a feature branch may // be build in production mode (with the NODE_ENV) but we may still want to show // or hide some features. -export const productionMode = ['master', 'next'].includes(process.env.HEAD) +export const productionMode = + process.env.HEAD && ['master', 'next'].includes(process.env.HEAD) export function softCatch( fn: (arg: ArgType) => ReturnType diff --git a/yarn.lock b/yarn.lock index bd53894b1..212a45f03 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9673,13 +9673,6 @@ react-test-renderer@^16.0.0-0: react-is "^16.8.6" scheduler "^0.19.1" -react-to-print@^2.5.1: - version "2.7.0" - resolved "https://registry.yarnpkg.com/react-to-print/-/react-to-print-2.7.0.tgz#3afca47ac857c72d9b76f9944b0793d27714bcc5" - integrity sha512-1GdEskOHtQs7EMj9t7OYSiMcAjzGCZyasb1H6kJQf5GaRpoM3Qr4OLbxGQSHK659Sp1PRZMVSD9+DWu4atVOIw== - dependencies: - prop-types "^15.7.2" - react-transition-group@^2.2.1, react-transition-group@^2.5.0: version "2.9.0" resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-2.9.0.tgz#df9cdb025796211151a436c69a8f3b97b5b07c8d"