diff --git a/client/src/pages/last-mails-sent/components/item.tsx b/client/src/pages/last-mails-sent/components/item.tsx index d5a0696..876cbcd 100644 --- a/client/src/pages/last-mails-sent/components/item.tsx +++ b/client/src/pages/last-mails-sent/components/item.tsx @@ -17,82 +17,87 @@ const LastMailsSentItem: React.FC = ({ data }) => { return ( <> - {data.emails.map((email, index) => { - const link = generateLink( - email.collectionName, - email.fromApplication, - email.contributionId - ); + {data.emails + .slice() + .sort( + (a, b) => new Date(b.sentAt).getTime() - new Date(a.sentAt).getTime() + ) + .map((email, index) => { + const link = generateLink( + email.collectionName, + email.fromApplication, + email.contributionId + ); - const sentDate = new Date(email.sentAt); - const formattedDate = sentDate.toLocaleDateString("fr-FR"); - const formattedTime = sentDate.toLocaleTimeString("fr-FR", { - hour: "2-digit", - minute: "2-digit", - }); + const sentDate = new Date(email.sentAt); + const formattedDate = sentDate.toLocaleDateString("fr-FR"); + const formattedTime = sentDate.toLocaleTimeString("fr-FR", { + hour: "2-digit", + minute: "2-digit", + }); - return ( - -
- - {collectionNameMapping[email.collectionName]} - - - {email.fromApplication && ( + return ( + +
- {email.fromApplication} + {collectionNameMapping[email.collectionName]} - )} -
-
- - Réponse de{" "} - - {email.selectedProfile} - {" "} - à{" "} - + {email.fromApplication && ( + + {email.fromApplication} + + )} +
+ +
+ + Réponse de{" "} + + {email.selectedProfile} + {" "} + à{" "} + + + {email?.name} ({email?.to}) + + + + + + Voir la contribution {email?.contributionId} + + + + - {email?.name} ({email?.to}) + Envoyé le {formattedDate} à {formattedTime} - - - - - Voir la contribution {email?.contributionId} - - - - - - Envoyé le {formattedDate} à {formattedTime} - - - {email.userResponse} -
- - ); - })} + + {email.userResponse} +
+ + ); + })} ); }; diff --git a/client/src/pages/last-mails-sent/components/utils.tsx b/client/src/pages/last-mails-sent/components/utils.tsx index 7c12841..6e86269 100644 --- a/client/src/pages/last-mails-sent/components/utils.tsx +++ b/client/src/pages/last-mails-sent/components/utils.tsx @@ -7,7 +7,6 @@ const collectionNameMapping: { [key: string]: string } = { }; export default collectionNameMapping; -// utils/generateLink.ts export function generateLink( collectionName: string, fromApplication?: string,