Skip to content

Commit

Permalink
Force l'affichage de l'onglet Résultats sil il n'y a pas d'onglet Obj…
Browse files Browse the repository at this point in the history
…ectifs quand on passe d'une source de données à une autre
  • Loading branch information
marc-rutkowski committed May 14, 2024
1 parent e2c66df commit d8e2896
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useEffect} from 'react';
import {Tab, Tabs, useActiveTab} from 'ui/shared/Tabs';
import ToggleButton from 'ui/shared/designSystem/ToggleButton';
import DSTetTooltip from 'ui/shared/floating-ui/DSTetTooltip';
Expand All @@ -24,6 +25,15 @@ export const IndicateurValuesTabs = ({
const {data} = useIndicateurInfoLiees(definition);
const {confidentiel} = data || {};

// force l'affichage de l'onglet Résultats sil il n'y a pas d'onglet Objectifs
// quand on passe d'une source de données à une autre
const avecObjectifs = !importSource || importSource === SOURCE_COLLECTIVITE;
useEffect(() => {
if (activeTab === 1 && !avecObjectifs) {
onChangeTab(0);
}
}, [avecObjectifs, activeTab]);

return (
<>
{!isReadonly && (
Expand Down Expand Up @@ -59,7 +69,7 @@ export const IndicateurValuesTabs = ({
/>
)}
</Tab>
{!importSource || importSource === SOURCE_COLLECTIVITE ? (
{avecObjectifs ? (
<Tab label="Objectifs" icon="calendar-2">
{activeTab === 1 && (
<IndicateurValuesTable
Expand Down

0 comments on commit d8e2896

Please sign in to comment.