Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appliquer les données de l'open data #3211

Merged
merged 22 commits into from
May 21, 2024
Merged

Conversation

marc-rutkowski
Copy link
Collaborator

No description provided.

@marc-rutkowski marc-rutkowski requested review from farnoux and removed request for derfurth May 17, 2024 08:04

export type IndicateurImportSource = {
id: string;
libelle: string;
type?: SourceType;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi optionnel ?
Dans quel cas une source peut ne pas avoir de type ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parce que ce champ n'existe pas encore (pour l'instant on a que des sources de type "resultat").
Je te propose de changer ça quand le nouveau modèle sera disponible et que je ferai les changements dans le front.

/** données à appliquer */
openData: TIndicateurValeurEtCommentaires[]
) => {
if (!openData?.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Au vu du type array non null et non undefined de openData, pourquoi pas simplement openData.length (sans la protection ?) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

setCurrentSource,
}: {
definition: TIndicateurDefinition;
sources?: IndicateurImportSource[] | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je vois beaucoup de props et de variables gérées en type undefined ou null qui ajoutent ensuite pas mal de petites syntaxes polluantes dans le code pour vérifier cet état non défini.

Autant parfois c'est nécessaire, autant ici, et dès qu'on peut, il me semble plus simple de gérer un array vide s'il n'y a pas de sources plutôt que de vérifier le null et undefined à chaque fois.

Quand bien même ça tire le fil de cette logique sur useIndicateurImportSources et useImportSources.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

useIndexedSources(sources);

// source sélectionnée
const s = sources?.find(s => s.id === currentSource);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas possible d'utiliser un "return early" dans le cas ou s n'est pas défini, i.e que il n'y a pas de source sélectionnée ?

Ça éviterait pas mal de gestion du undefined ou null dans la suite du code, et permettrait de simplifier la lecture.

@marc-rutkowski marc-rutkowski merged commit af66e04 into upcoming_develop May 21, 2024
16 of 21 checks passed
@marc-rutkowski marc-rutkowski deleted the apply-open-data branch May 21, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants