From 9594fbad35753bb0716eaa09ea795c8fab3f4e16 Mon Sep 17 00:00:00 2001 From: Dimitri Gritsajuk Date: Tue, 21 Jan 2025 12:03:30 +0100 Subject: [PATCH] [Event] display profile image on participants list --- src/api/events.js | 3 +- src/components/Activists/ActivistList.tsx | 2 +- .../detail/components/Attendees/Attendees.tsx | 38 +++++++------------ .../PersonWithAvatar/PersonWithAvatar.tsx | 2 +- src/mui/avatar/Avatar.tsx | 6 +-- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/api/events.js b/src/api/events.js index 95a2e29e0..8342e8a42 100644 --- a/src/api/events.js +++ b/src/api/events.js @@ -26,7 +26,8 @@ export const getEventAttendees = async (id, page) => { lastName: attendee.last_name, phone: attendee.phone, postalCode: attendee.postal_code, - subscriptionDate: attendee?.subscription_date, + subscriptionDate: attendee.created_at, + imageUrl: attendee.image_url, tags: attendee.tags, type: attendee.type, })) diff --git a/src/components/Activists/ActivistList.tsx b/src/components/Activists/ActivistList.tsx index 2b7f7794d..e56484900 100644 --- a/src/components/Activists/ActivistList.tsx +++ b/src/components/Activists/ActivistList.tsx @@ -74,7 +74,7 @@ const ActivistColumnDefinition: CustomTableColumnModel , + render: line => , }, { title: 'Militants', diff --git a/src/components/Events/pages/detail/components/Attendees/Attendees.tsx b/src/components/Events/pages/detail/components/Attendees/Attendees.tsx index b2b68184e..ef04d35ff 100644 --- a/src/components/Events/pages/detail/components/Attendees/Attendees.tsx +++ b/src/components/Events/pages/detail/components/Attendees/Attendees.tsx @@ -4,23 +4,18 @@ import { getNextPageParam, PaginatedResult, usePaginatedData } from '~/api/pagin import { useParams } from 'react-router' import { useErrorHandler } from '~/components/shared/error/hooks' import { Box, Stack } from '@mui/system' -import { - Avatar, - Button, - Card, - CardHeader, - Table, - TableBody, - TableCell, - TableHead, - TableRow, - Typography, -} from '@mui/material' +import { Button, Card, CardHeader, Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@mui/material' import pluralize from '~/components/shared/pluralize/pluralize' import Iconify from '~/mui/iconify' import Label from '~/mui/label' import { InfiniteData } from '@tanstack/react-query' import { useCallback } from 'react' +import { getInitials } from '~/utils/names' +import Avatar from '~/mui/avatar/Avatar' + +type Tag = { + label: string +} type Attendee = { uuid: string @@ -29,7 +24,8 @@ type Attendee = { emailAddress: string phone: string subscriptionDate: string - tags: string[] + imageUrl: string | null + tags: Tag[] } const Attendees = () => { @@ -108,15 +104,9 @@ const Attendees = () => { - - {`${attendee.firstName[0]}`.toUpperCase()} - - - + imageUrl={attendee.imageUrl} + initials={getInitials({ first_name: attendee.firstName, last_name: attendee.lastName })} + /> {`${attendee.firstName} ${attendee.lastName}`.trim()} {attendee.emailAddress && ( @@ -129,9 +119,9 @@ const Attendees = () => { - {attendee?.tags?.map((label, i) => ( + {attendee?.tags?.map((tag, i) => ( ))} diff --git a/src/components/Procurations/Components/PersonWithAvatar/PersonWithAvatar.tsx b/src/components/Procurations/Components/PersonWithAvatar/PersonWithAvatar.tsx index d9d262bdc..4a910dfc9 100644 --- a/src/components/Procurations/Components/PersonWithAvatar/PersonWithAvatar.tsx +++ b/src/components/Procurations/Components/PersonWithAvatar/PersonWithAvatar.tsx @@ -16,7 +16,7 @@ export default function PersonWithAvatar({ src, firstName, lastName, id, onPerso return ( - +
diff --git a/src/mui/avatar/Avatar.tsx b/src/mui/avatar/Avatar.tsx index 8cbae34f4..c3d2d37a7 100644 --- a/src/mui/avatar/Avatar.tsx +++ b/src/mui/avatar/Avatar.tsx @@ -4,14 +4,14 @@ import { Avatar as MUIAvatar } from '@mui/material' interface Props { initials?: string - src?: string | null + imageUrl?: string | null } -export default function Avatar({ initials, src }: Props) { +export default function Avatar({ initials, imageUrl }: Props) { return ( {initials}