Skip to content

Commit

Permalink
Corrige l'affichage de l'année dans le message de confirmation avant …
Browse files Browse the repository at this point in the history
…suppression d'une valeur
  • Loading branch information
marc-rutkowski committed Jan 20, 2025
1 parent df655e3 commit 8b33f54
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import classNames from 'classnames';
import { useState } from 'react';
import { SourceType } from '../types';
import { ConfirmDelete } from './confirm-delete';
import { PreparedData } from './prepare-data';
import { IndicateurSourceValeur } from './use-indicateur-valeurs';
import { PreparedData, PreparedValue } from './prepare-data';

type CellAnneeListProps = {
confidentiel?: boolean;
data: PreparedData;
definition: IndicateurDefinition;
readonly?: boolean;
type: SourceType;
onDelete: (valeur: IndicateurSourceValeur) => void;
onDelete: (valeur: PreparedValue) => void;
};

/** Affiche les cellules des années dans l'en-tête du tableau */
Expand All @@ -26,9 +25,7 @@ export const CellAnneeList = ({
onDelete,
}: CellAnneeListProps) => {
const { annees, anneeModePrive, valeursExistantes } = data;
const [toBeDeleted, setToBeDeleted] = useState<IndicateurSourceValeur | null>(
null
);
const [toBeDeleted, setToBeDeleted] = useState<PreparedValue | null>(null);

return annees?.map((annee) => {
const valeur = valeursExistantes.find((v) => v.annee === annee);
Expand Down Expand Up @@ -72,7 +69,6 @@ export const CellAnneeList = ({
</div>
{toBeDeleted && (
<ConfirmDelete
annee={annee}
valeur={toBeDeleted}
unite={definition.unite}
onDismissConfirm={(confirmed) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ import {
} from '@/ui';
import { useState } from 'react';
import { CellValue } from './cell-value';
import { IndicateurSourceValeur } from './use-indicateur-valeurs';
import { PreparedValue } from './prepare-data';

type ConfirmDeleteProps = {
unite: string;
annee: number;
valeur: IndicateurSourceValeur;
valeur: PreparedValue;
onDismissConfirm: (overwrite: boolean) => void;
};

/** Affiche un dialogue de confirmation avant suppression d'une valeur
*/
export const ConfirmDelete = (props: ConfirmDeleteProps) => {
const { annee, valeur, unite, onDismissConfirm } = props;
const { valeur, unite, onDismissConfirm } = props;
const [isOpen, setIsOpen] = useState(true);
const { objectif, objectifCommentaire, resultat, resultatCommentaire } =
valeur;
const {
objectif,
objectifCommentaire,
resultat,
resultatCommentaire,
annee,
} = valeur;

return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ export const prepareData = (
};

export type PreparedData = ReturnType<typeof prepareData>;
export type PreparedValue = PreparedData['sources'][number]['valeurs'][number];
export type PreparedValue = PreparedData['valeursExistantes'][number];

0 comments on commit 8b33f54

Please sign in to comment.