2023-03-08 10:22:10 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2023-03-09 08:55:35 -08:00
|
|
|
import { Link } from 'react-router-dom';
|
2023-03-08 10:22:10 -08:00
|
|
|
|
2023-03-14 11:44:48 -07:00
|
|
|
import GroupAvatar from 'soapbox/components/groups/group-avatar';
|
2023-03-28 08:52:25 -07:00
|
|
|
import { HStack, Icon, Stack, Text } from 'soapbox/components/ui';
|
|
|
|
import GroupActionButton from 'soapbox/features/group/components/group-action-button';
|
2023-03-08 10:22:10 -08:00
|
|
|
import { Group as GroupEntity } from 'soapbox/types/entities';
|
|
|
|
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
|
|
|
|
2023-06-08 06:00:49 -07:00
|
|
|
interface IGroupListItem {
|
2023-03-08 10:22:10 -08:00
|
|
|
group: GroupEntity
|
|
|
|
withJoinAction?: boolean
|
|
|
|
}
|
|
|
|
|
2023-06-08 06:00:49 -07:00
|
|
|
const GroupListItem = (props: IGroupListItem) => {
|
2023-03-08 10:22:10 -08:00
|
|
|
const { group, withJoinAction = true } = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HStack
|
|
|
|
alignItems='center'
|
|
|
|
justifyContent='between'
|
2023-05-01 09:01:39 -07:00
|
|
|
data-testid='group-list-item'
|
2023-03-08 10:22:10 -08:00
|
|
|
>
|
2023-05-23 09:32:55 -07:00
|
|
|
<Link key={group.id} to={`/group/${group.slug}`} className='overflow-hidden'>
|
2023-03-09 08:55:35 -08:00
|
|
|
<HStack alignItems='center' space={2}>
|
2023-03-14 11:44:48 -07:00
|
|
|
<GroupAvatar
|
|
|
|
group={group}
|
2023-03-09 08:55:35 -08:00
|
|
|
size={44}
|
2023-03-08 10:22:10 -08:00
|
|
|
/>
|
|
|
|
|
2023-05-23 09:32:55 -07:00
|
|
|
<Stack className='overflow-hidden'>
|
2023-03-09 08:55:35 -08:00
|
|
|
<Text
|
|
|
|
weight='bold'
|
|
|
|
dangerouslySetInnerHTML={{ __html: group.display_name_html }}
|
2023-05-23 09:32:55 -07:00
|
|
|
truncate
|
2023-03-08 10:22:10 -08:00
|
|
|
/>
|
|
|
|
|
2023-03-09 08:55:35 -08:00
|
|
|
<HStack className='text-gray-700 dark:text-gray-600' space={1} alignItems='center'>
|
|
|
|
<Icon
|
|
|
|
className='h-4.5 w-4.5'
|
|
|
|
src={group.locked ? require('@tabler/icons/lock.svg') : require('@tabler/icons/world.svg')}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Text theme='inherit' tag='span' size='sm' weight='medium'>
|
|
|
|
{group.locked ? (
|
|
|
|
<FormattedMessage id='group.privacy.locked' defaultMessage='Private' />
|
|
|
|
) : (
|
|
|
|
<FormattedMessage id='group.privacy.public' defaultMessage='Public' />
|
|
|
|
)}
|
|
|
|
</Text>
|
2023-03-08 10:22:10 -08:00
|
|
|
|
2023-03-09 08:55:35 -08:00
|
|
|
{typeof group.members_count !== 'undefined' && (
|
|
|
|
<>
|
|
|
|
<span>•</span>
|
|
|
|
<Text theme='inherit' tag='span' size='sm' weight='medium'>
|
|
|
|
{shortNumberFormat(group.members_count)}
|
|
|
|
{' '}
|
|
|
|
<FormattedMessage
|
|
|
|
id='groups.discover.search.results.member_count'
|
|
|
|
defaultMessage='{members, plural, one {member} other {members}}'
|
|
|
|
values={{
|
|
|
|
members: group.members_count,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Text>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</HStack>
|
|
|
|
</Stack>
|
|
|
|
</HStack>
|
|
|
|
</Link>
|
2023-03-08 10:22:10 -08:00
|
|
|
|
|
|
|
{withJoinAction && (
|
2023-03-28 08:52:25 -07:00
|
|
|
<GroupActionButton group={group} />
|
2023-03-08 10:22:10 -08:00
|
|
|
)}
|
|
|
|
</HStack>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default GroupListItem;
|