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

[Event] display profile image on participants list #3195

Merged
merged 1 commit into from
Jan 21, 2025
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
3 changes: 2 additions & 1 deletion src/api/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}))
Expand Down
2 changes: 1 addition & 1 deletion src/components/Activists/ActivistList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const ActivistColumnDefinition: CustomTableColumnModel<ActivistModel & { id: str
{
title: '',
minWidth: 50,
render: line => <Avatar src={line.image_url} initials={getInitials(line)} />,
render: line => <Avatar imageUrl={line.image_url} initials={getInitials(line)} />,
},
{
title: 'Militants',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +24,8 @@ type Attendee = {
emailAddress: string
phone: string
subscriptionDate: string
tags: string[]
imageUrl: string | null
tags: Tag[]
}

const Attendees = () => {
Expand Down Expand Up @@ -108,15 +104,9 @@ const Attendees = () => {
<TableCell>
<Stack direction="row" spacing={2} alignItems="center">
<Avatar
sx={{
bgcolor: 'info.lighter',
}}
>
<Typography color="grey.600" fontWeight="600">
{`${attendee.firstName[0]}`.toUpperCase()}
</Typography>
</Avatar>

imageUrl={attendee.imageUrl}
initials={getInitials({ first_name: attendee.firstName, last_name: attendee.lastName })}
/>
<Stack direction="column">
<Typography variant="body2">{`${attendee.firstName} ${attendee.lastName}`.trim()}</Typography>
{attendee.emailAddress && (
Expand All @@ -129,9 +119,9 @@ const Attendees = () => {
</TableCell>
<TableCell>
<Stack direction="row" spacing={2}>
{attendee?.tags?.map((label, i) => (
{attendee?.tags?.map((tag, i) => (
<Label key={i} color={'success'}>
{label}
{tag?.label}
</Label>
))}
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function PersonWithAvatar({ src, firstName, lastName, id, onPerso
return (
<Grid container sx={{ alignItems: 'center' }} spacing={MuiSpacing.normal}>
<Grid item>
<Avatar src={src} initials={getInitials({ first_name: firstName, last_name: lastName })} />
<Avatar imageUrl={src} initials={getInitials({ first_name: firstName, last_name: lastName })} />
</Grid>
<Grid item xs>
<div>
Expand Down
6 changes: 3 additions & 3 deletions src/mui/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<MUIAvatar
sx={{ bgcolor: grey[200], color: grey[600], fontSize: pxToRem(12), fontWeight: 'bold' }}
{...(src && { src })}
src={imageUrl || undefined}
>
{initials}
</MUIAvatar>
Expand Down
Loading