2020-05-08 17:36:10 +00:00
|
|
|
import React from 'react';
|
2021-09-13 20:41:05 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2020-05-08 17:36:10 +00:00
|
|
|
|
|
|
|
import I18n from '../../i18n';
|
2022-03-03 21:46:53 +00:00
|
|
|
import { useTheme } from '../../theme';
|
2020-05-08 17:36:10 +00:00
|
|
|
import CustomFields from './CustomFields';
|
2023-08-11 20:35:24 +00:00
|
|
|
import Timezone from './Timezone';
|
2020-05-08 17:36:10 +00:00
|
|
|
import styles from './styles';
|
2023-09-26 14:33:53 +00:00
|
|
|
import { IUser } from '../../definitions';
|
2020-05-08 17:36:10 +00:00
|
|
|
|
2022-05-11 18:20:59 +00:00
|
|
|
const Roles = ({ roles }: { roles?: string[] }) => {
|
2023-08-11 20:35:24 +00:00
|
|
|
const { colors } = useTheme();
|
2022-03-03 21:46:53 +00:00
|
|
|
|
2023-08-11 20:35:24 +00:00
|
|
|
if (roles?.length) {
|
|
|
|
return (
|
2023-09-26 14:33:53 +00:00
|
|
|
<View style={styles.item} testID='user-roles'>
|
|
|
|
<Text style={[styles.itemLabel, { color: colors.titleText }]}>{I18n.t('Roles')}</Text>
|
2023-08-11 20:35:24 +00:00
|
|
|
<View style={styles.rolesContainer}>
|
|
|
|
{roles.map(role =>
|
|
|
|
role ? (
|
|
|
|
<View
|
|
|
|
style={[styles.roleBadge, { backgroundColor: colors.chatComponentBackground }]}
|
|
|
|
key={role}
|
2023-09-26 14:33:53 +00:00
|
|
|
testID={`user-role-${role.replace(/ /g, '-')}`}
|
2023-08-11 20:35:24 +00:00
|
|
|
>
|
|
|
|
<Text style={[styles.role, { color: colors.titleText }]}>{role}</Text>
|
|
|
|
</View>
|
|
|
|
) : null
|
|
|
|
)}
|
|
|
|
</View>
|
2021-09-13 20:41:05 +00:00
|
|
|
</View>
|
2023-08-11 20:35:24 +00:00
|
|
|
);
|
2022-03-03 21:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2020-05-08 17:36:10 +00:00
|
|
|
};
|
|
|
|
|
2023-09-26 14:33:53 +00:00
|
|
|
const Direct = ({ roomUser }: { roomUser: IUser }): React.ReactElement => (
|
2020-05-08 17:36:10 +00:00
|
|
|
<>
|
2023-09-26 14:33:53 +00:00
|
|
|
<Roles roles={roomUser.roles} />
|
2022-03-03 21:46:53 +00:00
|
|
|
<Timezone utcOffset={roomUser.utcOffset} />
|
|
|
|
<CustomFields customFields={roomUser.customFields} />
|
2020-05-08 17:36:10 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default Direct;
|