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(BO): correction liste message vide #528

Merged
merged 1 commit into from
Oct 2, 2024
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
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
21 changes: 5 additions & 16 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 @@ -202,7 +196,6 @@ import Declaration from "~/components/demandes-sejour/Declaration.vue";
import Multiselect from "@vueform/multiselect";
import "@vueform/multiselect/themes/default.css";
import { defineProps } from "vue";
import messageEtat from "@vao/shared/src/utils/messageUtils";

definePageMeta({
middleware: ["is-connected", "check-role"],
Expand All @@ -221,11 +214,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 +255,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
Loading