import {useNavigation} from '@react-navigation/native';
import React from 'react';
import {StyleSheet, Text} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {MomentPostType, ScreenType} from '../../types';
import {normalize} from '../../utils';

interface MomentCommentPreviewProps {
  moment: MomentPostType;
  screenType: ScreenType;
}

const MomentCommentPreview: React.FC<MomentCommentPreviewProps> = ({
  moment,
  screenType,
}) => {
  const navigation = useNavigation();
  const commentCountText =
    moment.comments_count === 0
      ? 'No Comments'
      : moment.comments_count + ' comments';

  return (
    <TouchableOpacity
      style={styles.commentsPreviewContainer}
      onPress={() =>
        navigation.push('MomentCommentsScreen', {
          moment_id: moment.moment_id,
          screenType,
        })
      }>
      <Text style={styles.commentCount}>{commentCountText}</Text>
      <Text>TODO: Add comment preview here</Text>
    </TouchableOpacity>
  );
};

const styles = StyleSheet.create({
  commentsPreviewContainer: {
    flexDirection: 'column',
    marginHorizontal: '5%',
    marginBottom: '2%',
    borderWidth: 1,
  },
  commentCount: {
    fontWeight: '700',
    color: 'white',
    fontSize: normalize(12),
  },
});

export default MomentCommentPreview;
