2021-09-22 17:29:26 +00:00
|
|
|
import React, { useContext } from 'react';
|
2022-03-31 22:39:24 +00:00
|
|
|
import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native';
|
2021-09-22 17:29:26 +00:00
|
|
|
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../../lib/constants';
|
2022-03-31 22:39:24 +00:00
|
|
|
import I18n from '../../../i18n';
|
2022-05-02 19:21:15 +00:00
|
|
|
import { CustomIcon } from '../../CustomIcon';
|
2022-03-31 22:39:24 +00:00
|
|
|
import { useTheme } from '../../../theme';
|
|
|
|
import sharedStyles from '../../../views/Styles';
|
2021-09-22 17:29:26 +00:00
|
|
|
import MessageboxContext from '../Context';
|
2022-03-31 22:39:24 +00:00
|
|
|
import styles from '../styles';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { MENTIONS_TRACKING_TYPE_CANNED } from '../constants';
|
2022-03-31 22:39:24 +00:00
|
|
|
|
|
|
|
interface IMentionHeaderList {
|
|
|
|
trackingType: string;
|
|
|
|
hasMentions: boolean;
|
|
|
|
loading: boolean;
|
|
|
|
}
|
2021-09-22 17:29:26 +00:00
|
|
|
|
2022-03-31 22:39:24 +00:00
|
|
|
const MentionHeaderList = ({ trackingType, hasMentions, loading }: IMentionHeaderList) => {
|
|
|
|
const { theme } = useTheme();
|
2021-09-22 17:29:26 +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;
|