import moment from 'moment';
import React from 'react';
import {Image, StyleSheet, View} from 'react-native';
import {PostType} from '../../types';
import {SCREEN_WIDTH} from '../../utils';
import TaggPostFooter from './TaggPostFooter';

interface TaggPostProps {
  post: PostType;
}
const TaggPost: React.FC<TaggPostProps> = ({post: {socialHandle, data}}) => {
  const parsedDate = moment(data?.timestamp || '');
  const date = parsedDate.isValid() ? parsedDate.format('MMM d') : '';

  return (
    <>
      <View style={styles.image}>
        {data && <Image style={styles.image} source={{uri: data.media_url}} />}
      </View>
      <TaggPostFooter
        // we currently don't have a way to retreive num of likes information
        likes={109}
        handle={socialHandle}
        caption={data?.caption || ''}
        date={date}
      />
    </>
  );
};

const styles = StyleSheet.create({
  image: {
    width: SCREEN_WIDTH,
    height: SCREEN_WIDTH,
    backgroundColor: '#eee',
  },
});

export default TaggPost;
