|
| 1 | +import * as React from 'react'; |
| 2 | +import { View } from 'react-native'; |
| 3 | + |
| 4 | +import styles from './styles'; |
| 5 | +import { MemberListItemProps } from './types'; |
| 6 | + |
| 7 | +import { I18n } from '~/app/i18n'; |
| 8 | +import theme from '~/app/theme'; |
| 9 | +import { SmallBoldText, SmallText } from '~/framework/components/text'; |
| 10 | + |
| 11 | +const profileMap = { |
| 12 | + guest: { |
| 13 | + color: theme.palette.complementary.pink.regular, |
| 14 | + profileKey: 'guest', |
| 15 | + }, |
| 16 | + personnel: { |
| 17 | + color: theme.palette.complementary.purple.regular, |
| 18 | + profileKey: 'personnel', |
| 19 | + }, |
| 20 | + relative: { |
| 21 | + color: theme.palette.complementary.blue.regular, |
| 22 | + profileKey: 'relative', |
| 23 | + }, |
| 24 | + student: { |
| 25 | + color: theme.palette.complementary.orange.regular, |
| 26 | + profileKey: 'student', |
| 27 | + }, |
| 28 | + teacher: { |
| 29 | + color: theme.palette.complementary.green.regular, |
| 30 | + profileKey: 'teacher', |
| 31 | + }, |
| 32 | +}; |
| 33 | + |
| 34 | +const MemberListItem: React.FC<MemberListItemProps> = ({ name, profileType, role }) => { |
| 35 | + const { color, profileKey } = profileMap[profileType.toLowerCase()] ?? { |
| 36 | + color: theme.palette.grey.black, |
| 37 | + profileKey: '', |
| 38 | + }; |
| 39 | + const profileLabel = profileKey ? I18n.get(`user-profiletypes-${profileKey}`) : ''; |
| 40 | + const roleLabel = role ? I18n.get(`communities-role-${role.toLowerCase()}`) : ''; |
| 41 | + |
| 42 | + return ( |
| 43 | + <View style={styles.container}> |
| 44 | + <SmallBoldText numberOfLines={1}>{name}</SmallBoldText> |
| 45 | + <View style={styles.containerText}> |
| 46 | + <SmallBoldText style={{ color }}>{profileLabel}</SmallBoldText> |
| 47 | + <View style={styles.separator}> |
| 48 | + <SmallBoldText>|</SmallBoldText> |
| 49 | + </View> |
| 50 | + <SmallText>{roleLabel}</SmallText> |
| 51 | + </View> |
| 52 | + </View> |
| 53 | + ); |
| 54 | +}; |
| 55 | + |
| 56 | +export default MemberListItem; |
0 commit comments