From 82955c3b976657251cd6ad45c801a1166bb2930e Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Tue, 20 Jun 2023 17:14:48 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20la=20section=20r=C3=A9mun=C3=A9ration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../choix-du-statut/rémunération.tsx | 128 +++++++++++++++++- .../assistants/choix-du-statut/statuts.tsx | 11 +- 2 files changed, 128 insertions(+), 11 deletions(-) diff --git a/site/source/pages/assistants/choix-du-statut/rémunération.tsx b/site/source/pages/assistants/choix-du-statut/rémunération.tsx index 6dbdba1da..bb20a8251 100644 --- a/site/source/pages/assistants/choix-du-statut/rémunération.tsx +++ b/site/source/pages/assistants/choix-du-statut/rémunération.tsx @@ -1,11 +1,135 @@ -import { H1 } from '@/design-system/typography/heading' +import { useEffect } from 'react' +import { Trans, useTranslation } from 'react-i18next' +import { useDispatch } from 'react-redux' +import { useEngine } from '@/components/utils/EngineContext' +import { usePersistingState } from '@/components/utils/persistState' +import { NumberField } from '@/design-system' +import { HelpButtonWithPopover } from '@/design-system/buttons' +import { Strong } from '@/design-system/typography' +import { H3 } from '@/design-system/typography/heading' +import { Body } from '@/design-system/typography/paragraphs' +import { batchUpdateSituation } from '@/store/actions/actions' + +import Layout from './_components/Layout' import Navigation from './_components/Navigation' +type State = { CA: number | undefined; charges: number | undefined } + export default function Rémunération() { + const { t } = useTranslation() + const [{ CA, charges }, setState, reset, isComplete] = useRémunérationState() + return ( <> -

Rémunération

+ + La première année, j'estime mon chiffre d'affaires à... + + + Le chiffre d’affaires est la{' '} + somme des montants des ventes réalisées pendant{' '} + votre exercice comptable (un an) :{' '} +
CA = prix de vente × quantités vendues
. + +
+ + } + > + setState({ CA: value })} + label={t( + 'choix-statut.rémunération.CA.label', + "Montant du chiffre d'affaires HT" + )} + displayedUnit="€/an" + /> + +

+ J'estime mes charges professionnelles à... + + + Ce sont{' '} + + toutes les dépenses nécessaires au bon fonctionnement de votre + entreprise + {' '} + : expertise-comptable, abonnement téléphonique, abonnement + internet, mutuelle, prévoyance, outils de travail, etc. + + +

+
+ setState({ charges: value })} + /> + + +
) } + +function useRémunérationState(): [ + state: State, + setState: (value: Partial) => void, + reset: () => void, + isComplete: boolean +] { + const defaultState = { CA: undefined, charges: undefined } + const [state, setState] = usePersistingState( + 'choix-statut:associés', + defaultState + ) + + const dispatch = useDispatch() + + const handleChange = (value: Partial) => { + const newState = { ...state, ...value } + setState(newState) + dispatch( + batchUpdateSituation({ + "entreprise . chiffre d'affaires": { + valeur: newState.CA, + unité: '€/an', + }, + 'entreprise . charges': { valeur: newState.charges, unité: '€/an' }, + }) + ) + } + + useEffect(() => { + handleChange(state) + }, []) + const reset = () => { + handleChange(defaultState) + } + + const engine = useEngine() + const isComplete = + engine.evaluate("entreprise . chiffre d'affaires").nodeValue !== + undefined && + engine.evaluate('entreprise . charges').nodeValue !== undefined + + return [state, handleChange, reset, isComplete] +} diff --git a/site/source/pages/assistants/choix-du-statut/statuts.tsx b/site/source/pages/assistants/choix-du-statut/statuts.tsx index 21595db45..3dd9002c1 100644 --- a/site/source/pages/assistants/choix-du-statut/statuts.tsx +++ b/site/source/pages/assistants/choix-du-statut/statuts.tsx @@ -1,12 +1,5 @@ -import { H1 } from '@/design-system/typography/heading' - -import Navigation from './_components/Navigation' +import ComparateurStatuts from '@/pages/simulateurs/comparaison-statuts' export default function Statuts() { - return ( - <> -

Statuts

- - - ) + return }