diff --git a/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx b/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx index fe779901d..3c8557a77 100644 --- a/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx +++ b/site/source/pages/gerer/declaration-revenu-independants/declaration.tsx @@ -1,6 +1,6 @@ import { DottedName } from 'modele-social' import RuleInput from '@/components/conversation/RuleInput' -import Value, { Condition } from '@/components/EngineValue' +import Value, { Condition, WhenApplicable } from '@/components/EngineValue' import ShareOrSaveSimulationBanner from '@/components/ShareSimulationBanner' import { FromTop } from '@/components/ui/animate' import { useEngine } from '@/components/utils/EngineContext' @@ -38,7 +38,7 @@ interface Meta { facultatif?: 'oui' | 'non' section?: 'oui' | 'non' affichage?: string - cases?: string[] | { défaut: string[] } + cases?: string[] | { défaut: string[]; 'sans OGA': string[] } } export function useObjectifs(): Array { @@ -217,9 +217,21 @@ export default function Déclaration() { + + + + + + + + + ) @@ -303,11 +315,13 @@ function useDéclarationRevenuFields() { return fields } -function ResultSection() { - const objectifs = useObjectifs() - const fields = useDéclarationRevenuFields() - const sitePaths = useContext(SitePathsContext) - const engine = useEngine() +const RuleInputWithTitle = ({ + title, + dottedName, +}: { + title?: string + dottedName: string +}) => { const dispatch = useDispatch() const dispatchValue = useCallback( @@ -317,21 +331,54 @@ function ResultSection() { [dispatch] ) + return ( + <> + {title && ( +

+ {title} +

+ )} + + + ) +} + +function ResultSection() { + const objectifs = useObjectifs() + const fields = useDéclarationRevenuFields() + const sitePaths = useContext(SitePathsContext) + const engine = useEngine() + + const caseName = + engine.evaluate('DRI . liasse . OGA').nodeValue === false + ? 'sans OGA' + : 'défaut' + + const getCases = useCallback( + (rule: Rule): string[] => { + const meta = getMeta(rule, {}) + + return ( + (Array.isArray(meta.cases) && meta.cases) || + (typeof meta.cases === 'object' && meta.cases[caseName]) || + [] + ) + }, + [caseName] + ) + const isLiasseFiscaleCompleted = useProgress(objectifs) === 1 if (!isLiasseFiscaleCompleted) { return null } - const getCases = (rule: Rule): string[] => { - const meta = getMeta(rule, {}) - - return ( - (Array.isArray(meta.cases) && meta.cases) || - (typeof meta.cases === 'object' && meta.cases.défaut) || - [] - ) - } - const declarant = engine.evaluate('DRI . déclaration revenus').nodeValue === 'déclarant 2' ? 1 @@ -365,16 +412,9 @@ function ResultSection() { {rule.dottedName.split(' . ').length === 2 ? ( <> -

- {rule.rawNode.question} -

- ) : rule.dottedName.split(' . ').length === 3 ? (