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

fix: mise a jour de la gestion des filtres quand aucun effectifs sur annee en cours #3965

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion server/src/http/routes/specific.routes/organisme.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ObjectId } from "bson";
import { compact, get } from "lodash-es";
import {
STATUT_APPRENANT,
getAnneeScolaireFromDate,
getAnneesScolaireListFromDate,
getSIFADate,
requiredApprenantAdresseFieldsSifa,
Expand Down Expand Up @@ -207,7 +208,12 @@ export async function getOrganismeEffectifs(
return {
fromDECA: isDeca,
total: data?.total || 0,
filters: data?.filters || {},
filters: {
...data?.filters,
annee_scolaire: Array.from(
new Set([...(data?.filters?.annee_scolaire || []), getAnneeScolaireFromDate(new Date())])
),
},
organismesEffectifs: effectifs || [],
};
}
Expand Down
7 changes: 6 additions & 1 deletion ui/modules/effectifs/EffectifsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,13 @@ function EffectifsPage(props: EffectifsPageProps) {
);

const updatedQuery = { ...router.query, ...queryFilters };

if (!updatedQuery.organismeId) {
updatedQuery.organismeId = router.query.organismeId as string;
}

Object.keys(router.query).forEach((key) => {
if (!queryFilters[key]) {
if (!queryFilters[key] && key !== "organismeId") {
delete updatedQuery[key];
}
});
Expand Down
21 changes: 15 additions & 6 deletions ui/modules/mon-espace/SIFA/SIFAPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ function SIFAPage(props: SIFAPageProps) {
);

useEffect(() => {
const invalidCount = currentEffectifsState
.values()
.toArray()
.filter((effectif) => effectif.requiredSifa.length > 0).length;
const invalidCount = Array.from(currentEffectifsState.values()).filter(
(effectif) => effectif.requiredSifa.length > 0
).length;
setSifaInvalidCount(invalidCount);
}, [currentEffectifsState]);

Expand Down Expand Up @@ -188,13 +187,19 @@ function SIFAPage(props: SIFAPageProps) {
);

const updatedQuery = { ...router.query, ...queryFilters };

if (!updatedQuery.organismeId) {
updatedQuery.organismeId = router.query.organismeId as string;
}

Object.keys(router.query).forEach((key) => {
if (!queryFilters[key]) {
if (!queryFilters[key] && key !== "organismeId") {
delete updatedQuery[key];
}
});

setFilters(mergedFilters);

router.push(
{
pathname: router.pathname,
Expand Down Expand Up @@ -227,10 +232,14 @@ function SIFAPage(props: SIFAPageProps) {
setFilters({});
setSearch("");

const updatedQuery = {
organismeId: router.query.organismeId,
};

router.push(
{
pathname: router.pathname,
query: {},
query: updatedQuery,
},
undefined,
{ shallow: true }
Expand Down
Loading