2021-10-01 18:12:19 +00:00
|
|
|
import React, { useContext } from 'react';
|
2022-04-28 18:44:40 +00:00
|
|
|
import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native';
|
2021-10-01 18:12:19 +00:00
|
|
|
|
2022-04-28 18:44:40 +00:00
|
|
|
import { themes } from '../../../lib/constants';
|
2021-10-01 18:12:19 +00:00
|
|
|
import I18n from '../../../i18n';
|
2022-05-30 22:01:25 +00:00
|
|
|
import { CustomIcon } from '../../CustomIcon';
|
2022-04-28 18:44:40 +00:00
|
|
|
import { useTheme } from '../../../theme';
|
|
|
|
import sharedStyles from '../../../views/Styles';
|
2021-10-01 18:12:19 +00:00
|
|
|
import MessageboxContext from '../Context';
|
2022-04-28 18:44:40 +00:00
|
|
|
import styles from '../styles';
|
|
|
|
import { MENTIONS_TRACKING_TYPE_CANNED } from '../constants';
|
|
|
|
|
|
|
|
interface IMentionHeaderList {
|
|
|
|
trackingType: string;
|
|
|
|
hasMentions: boolean;
|
|
|
|
loading: boolean;
|
|
|
|
}
|
2021-10-01 18:12:19 +00:00
|
|
|
|
2022-04-28 18:44:40 +00:00
|
|
|
const MentionHeaderList = ({ trackingType, hasMentions, loading }: IMentionHeaderList) => {
|
|
|
|
const { theme } = useTheme();
|
2021-10-01 18:12:19 +00:00
|
|
|
const context = useContext(MessageboxContext);
|
|
|
|
const { onPressNoMatchCanned } = context;
|
|
|
|
|
|
|
|
if (trackingType === MENTIONS_TRACKING_TYPE_CANNED) {
|
|
|
|
if (loading) {
|
|
|
|
return (
|
|
|
|
<View style={styles.wrapMentionHeaderListRow}>
|
|
|
|
<ActivityIndicator style={styles.loadingPaddingHeader} size='small' />
|
|
|
|
<Text style={[styles.mentionHeaderList, { color: themes[theme].auxiliaryText }]}>{I18n.t('Searching')}</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasMentions) {
|
|
|
|
return (
|
|
|
|
<TouchableOpacity style={[styles.wrapMentionHeaderListRow, styles.mentionNoMatchHeader]} onPress={onPressNoMatchCanned}>
|
|
|
|
<Text style={[styles.mentionHeaderListNoMatchFound, { color: themes[theme].auxiliaryText }]}>
|
|
|
|
{I18n.t('No_match_found')} <Text style={sharedStyles.textSemibold}>{I18n.t('Check_canned_responses')}</Text>
|
|
|
|
</Text>
|
|
|
|
<CustomIcon name='chevron-right' size={24} color={themes[theme].auxiliaryText} />
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default MentionHeaderList;
|