From 0d86c8b671ac1d000f7b92c3ddf240068dde2872 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Mon, 30 Sep 2024 14:42:47 +0200 Subject: [PATCH] Use last sent messages batch to generate pno form subscriber list --- .../sent_message_list.spec.ts | 6 +++--- .../components/shared/CardBodyHead/SentMessageList.tsx | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/cypress/e2e/side_window/logbook_prior_notification_form/sent_message_list.spec.ts b/frontend/cypress/e2e/side_window/logbook_prior_notification_form/sent_message_list.spec.ts index 3dd401c3c0..f1f960b854 100644 --- a/frontend/cypress/e2e/side_window/logbook_prior_notification_form/sent_message_list.spec.ts +++ b/frontend/cypress/e2e/side_window/logbook_prior_notification_form/sent_message_list.spec.ts @@ -20,9 +20,9 @@ context('Side Window > Logbook Prior Notification Form > Sent Message List', () cy.get('address').eq(1).contains('ggmaratlan@gendarmerie.defense.gouv.fr') cy.get('address').eq(1).contains('+33987654321') - cy.get('address').eq(2).contains('Unité 5 (DDTM 40)') - cy.get('address').eq(2).contains('unite5@ddtm-40.gouv.fr') - cy.get('address').eq(2).contains('+33000000000') + // The last sent message doesn't include this unit contact details, + // they should not be displayed since they likely were unsubscribed in the meantime. + cy.get('address').contains('Unité 5 (DDTM 40)').should('not.exist') cy.getDataCy('SentMessageList-historyItem') .eq(0) diff --git a/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx b/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx index 669776b484..cbb665e64c 100644 --- a/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx +++ b/frontend/src/features/PriorNotification/components/shared/CardBodyHead/SentMessageList.tsx @@ -14,8 +14,9 @@ type SentMessageListProps = Readonly<{ export function SentMessageList({ detail }: SentMessageListProps) { const { data: sentMessages, isError } = useGetPriorNotificationSentNessagesQuery(detail.reportId) - const subscribers = sentMessages ? getSubscribersFromSentMessages(sentMessages) : undefined const sentMessagesBatches = sentMessages ? getSentMessagesBatches(sentMessages) : undefined + const lastSentMessagesBatch = sentMessagesBatches ? sentMessagesBatches[sentMessagesBatches.length - 1] : undefined + const subscribers = lastSentMessagesBatch ? getSubscribersFromSentMessages(lastSentMessagesBatch.messages) : undefined return ( <>