mattermost-mobile/app/components/chips/user_chip.tsx
Daniel Espino García a5d7bf7db4
Add select user screen to select owner and task assignee (#9089)
* Add select user screen to select owner and task assignee

* Fix i18n

* Add tests

* Address feedback

* Fix test

* Address UX feedback

* Fix test

* Put the no assignee button inline with the search
2025-09-12 12:13:25 +02:00

58 lines
1.5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useCallback, useMemo} from 'react';
import {useIntl} from 'react-intl';
import ProfilePicture from '@components/profile_picture';
import {displayUsername} from '@utils/user';
import BaseChip from './base_chip';
import type UserModel from '@typings/database/models/servers/user';
type SelectedChipProps = {
user: UserModel | UserProfile;
onPress: (id: string) => void;
testID?: string;
teammateNameDisplay: string;
actionIcon?: 'remove' | 'downArrow';
showAnimation?: boolean;
}
export default function UserChip({
testID,
user,
teammateNameDisplay,
onPress: receivedOnPress,
actionIcon,
showAnimation,
}: SelectedChipProps) {
const intl = useIntl();
const onPress = useCallback(() => {
receivedOnPress(user.id);
}, [receivedOnPress, user.id]);
const name = displayUsername(user, intl.locale, teammateNameDisplay);
const picture = useMemo(() => (
<ProfilePicture
author={user}
size={20}
iconSize={20}
testID={`${testID}.profile_picture`}
showStatus={false}
/>
), [testID, user]);
return (
<BaseChip
testID={testID}
onPress={onPress}
actionIcon={actionIcon}
showAnimation={showAnimation}
label={name}
prefix={picture}
/>
);
}