Skip to content

Commit

Permalink
fix(BO): correction liste message vide
Browse files Browse the repository at this point in the history
  • Loading branch information
l-scherer committed Oct 1, 2024
1 parent 51a88c8 commit de32c39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 12 additions & 2 deletions packages/backend/src/services/DemandeSejour.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,18 @@ SELECT
COUNT(CASE WHEN statut = 'ABANDONNEE' THEN 1 END)::integer AS "abandonnee",
COUNT(CASE WHEN statut = 'REFUSEE' THEN 1 END)::integer AS "refusee",
COUNT(CASE WHEN statut = 'REFUSEE 8J' THEN 1 END)::integer AS "refuse8J",
COUNT(CASE WHEN statut <> 'BROUILLON' THEN 1 END)::integer AS "global"
COUNT(CASE WHEN statut <> 'BROUILLON' THEN 1 END)::integer AS "global",
COUNT(CASE WHEN (dsm.message is not null AND dsm.read_at IS NULL AND dsm.back_user_id IS NULL) THEN 1 END)::integer AS "nonlu",
COUNT(CASE WHEN (dsm.message is not null AND dsm.read_at IS NOT NULL AND dsm.back_user_id IS NULL) THEN 1 END)::integer AS "lu",
COUNT(CASE WHEN (dsm.message is not null AND dsm.front_user_id IS NULL) THEN 1 END)::integer AS "repondu"
FROM
front.demande_sejour ds
JOIN front.organismes o ON o.id = ds.organisme_id
LEFT JOIN front.agrements a ON a.organisme_id = ds.organisme_id
LEFT JOIN front.demande_sejour_message dsm ON dsm.declaration_id = ds.id AND dsm.id = (
SELECT MAX(dsmax.id)
FROM front.demande_sejour_message dsmax
WHERE dsmax.declaration_id = ds.id)
WHERE
jsonb_path_query_array(hebergement, '$.hebergements[*].coordonnees.adresse.departement') ?| ($1)::text[]
OR a.region_obtention = '${territoireCode}'
Expand Down Expand Up @@ -345,6 +352,7 @@ SELECT COUNT(DISTINCT ds.id)
FROM front.demande_sejour ds
JOIN front.organismes o ON o.id = ds.organisme_id
LEFT JOIN front.agrements a ON a.organisme_id = ds.organisme_id
LEFT JOIN front.demande_sejour_message dsm ON dsm.declaration_id = ds.id
WHERE
statut <> 'BROUILLON'
AND ((${departementQuery})
Expand Down Expand Up @@ -961,6 +969,9 @@ module.exports.getByDepartementCodes = async (
`statut in ('${dsStatus.statuts.EN_COURS}', '${dsStatus.statuts.EN_COURS_8J}', '${dsStatus.statuts.TRANSMISE}', '${dsStatus.statuts.TRANSMISE_8J}')`,
);
}
if (search?.message) {
searchQuery.push(`dsm.message is not null`);
}

/*
* Cette Partie du code soit toujours etre appelé juste avant la fonction query.getByDepartementCodes
Expand All @@ -975,7 +986,6 @@ module.exports.getByDepartementCodes = async (
departementQuery,
params,
);

const stats = await pool.query(
...query.getAdminStats(departementCodes, territoireCode),
);
Expand Down
20 changes: 5 additions & 15 deletions packages/frontend-bo/src/components/demandes-sejour/liste.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,15 @@
:values="[
{
title: 'Messages non lus',
value: filteredDemandes.filter(
(d) => d.messageEtat === messageEtat.etat.NON_LU,
).length,
value: sejourStore.stats?.nonlu || 0,
},
{
title: 'Messages lus',
value: filteredDemandes.filter(
(d) => d.messageEtat === messageEtat.etat.LU,
).length,
value: sejourStore.stats?.lu || 0,
},
{
title: 'Messages répondus',
value: filteredDemandes.filter(
(d) => d.messageEtat === messageEtat.etat.REPONDU,
).length,
value: sejourStore.stats?.repondu || 0,
},
]"
/>
Expand Down Expand Up @@ -162,7 +156,7 @@
</div>
<TableWithBackendPagination
:headers="headers"
:data="filteredDemandes"
:data="sejourStore.demandes"
:total-items="sejourStore.total"
:current-page="currentPageState"
:sort-by="sortState.sortBy"
Expand Down Expand Up @@ -221,11 +215,6 @@ const toaster = useToaster();
const sejourStore = useDemandeSejourStore();
const demandeSejour = useDemandeSejourStore();
const userStore = useUserStore();
const filteredDemandes = computed(() =>
props.display === displayType.Messagerie
? sejourStore.demandes.filter((d) => d.message)
: sejourStore.demandes,
);
const defaultSort = [];
const defaultLimit = 10;
const defaultOffset = 0;
Expand Down Expand Up @@ -267,6 +256,7 @@ const searchState = reactive({
.filter((statut) => Object.values(status.value).includes(statut))
: null,
action: parseBoolean(route.query.action),
message: props.display === displayType.Messagerie,
});
watch(
Expand Down

0 comments on commit de32c39

Please sign in to comment.