import React from 'react';
import {
  View,
  Text,
  TouchableOpacity,
  StyleSheet,
  TouchableOpacityProps,
} from 'react-native';
import {ProfilePreviewType} from 'src/types';
import SearchResults from './SearchResults';

interface RecentSearchesProps extends TouchableOpacityProps {
  sectionTitle: string;
  sectionButtonTitle: string;
  recents: Array<ProfilePreviewType>;
}
/**
 * An image component that returns the <Image> of the icon for a specific social media platform.
 */
const RecentSearches: React.FC<RecentSearchesProps> = (props) => {
  return (
    <>
      <View style={styles.container}>
        <Text style={styles.title}>{props.sectionTitle}</Text>
        {props.sectionButtonTitle && (
          <TouchableOpacity {...props}>
            <Text style={styles.clear}>Clear all</Text>
          </TouchableOpacity>
        )}
      </View>
      <SearchResults results={props.recents} />
    </>
  );
};

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
  },
  title: {
    fontSize: 17,
    fontWeight: 'bold',
    flexGrow: 1,
  },
  clear: {
    fontSize: 17,
    fontWeight: 'bold',
    color: '#698DD3',
  },
});

export default RecentSearches;
