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
|
|
|
|
2023-08-11 20:35:24 +00:00
|
|
|
import { IUserParsed } from '.';
|
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';
|
|
|
|
|
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 (
|
|
|
|
<View style={styles.item}>
|
|
|
|
<Text testID='user-roles' style={[styles.itemLabel, { color: colors.titleText }]}>
|
|
|
|
{I18n.t('Roles')}
|
|
|
|
</Text>
|
|
|
|
<View style={styles.rolesContainer}>
|
|
|
|
{roles.map(role =>
|
|
|
|
role ? (
|
|
|
|
<View
|
|
|
|
testID={`user-role-${role.replace(/ /g, '-')}`}
|
|
|
|
style={[styles.roleBadge, { backgroundColor: colors.chatComponentBackground }]}
|
|
|
|
key={role}
|
|
|
|
>
|
|
|
|
<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-08-11 20:35:24 +00:00
|
|
|
const Direct = ({ roomUser }: { roomUser: IUserParsed }): React.ReactElement => (
|
2020-05-08 17:36:10 +00:00
|
|
|
<>
|
2022-03-03 21:46:53 +00:00
|
|
|
<Roles roles={roomUser.parsedRoles} />
|
|
|
|
<Timezone utcOffset={roomUser.utcOffset} />
|
|
|
|
<CustomFields customFields={roomUser.customFields} />
|
2020-05-08 17:36:10 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default Direct;
|