import moment from 'moment';
import React, {useCallback, useState, useRef} from 'react';
import {
  Image,
  Text,
  View,
  TouchableOpacity,
  Dimensions,
  StyleSheet,
} from 'react-native';
import FastImage from 'react-native-fast-image';
import {GifType} from '../../../values/images';
const windowWidth = Dimensions.get('window').width;
const WishListComponent = ({
  userDetails,
  openView,
  openModalHappyBirthday,
  closeModalHappyBirthday,
  dataBirthday,
}) => {
  return (
    <View style={styles.viewContent}>
      <Text style={[styles.txtTitle, {padding: 10}]}>Lời chúc sinh nhật</Text>

      {dataBirthday.map((item, index) => (
        <View
          key={index}
          style={[
            styles.viewHappyBirthday,
            openView[index].enable
              ? styles.openViewHappyBirthday
              : styles.closeViewHappyBirthday,
          ]}>
          <View style={{flexDirection: 'row'}}>
            <View
              style={{
                flexDirection: 'row',
                flex: openView[index].enable ? 1 : 0,
              }}>
              <Image
                source={{
                  uri: 'https://meu.anawork.com' + item.extend_avatar,
                }}
                style={{width: 40, height: 40}}
              />
              <View style={{paddingLeft: 10}}>
                <Text style={styles.txtTitle}>
                  {item.extend_sender_full_name}
                </Text>
                <Text>{item.position}</Text>
              </View>
            </View>
            {!openView[index].enable && (
              <View style={{alignItems: 'flex-end', flex: 1}}>
                <TouchableOpacity
                  onPress={() => openModalHappyBirthday(index)}
                  style={styles.btnOpenHappyBirthday}>
                  <Text style={{color: 'blue', fontWeight: '500'}}>Xem</Text>
                </TouchableOpacity>
              </View>
            )}
          </View>
          {openView[index].enable && (
            <View>
              <View style={{marginTop: 10}}>
                <Text style={[styles.txtTitle]}>{item?.details}</Text>
                {item.image_path && (
                  <Image
                    source={{
                      uri: 'https://meu.anawork.com' + item.image_path,
                    }}
                    style={{
                      width: 60,
                      height: 60,
                      alignSelf: 'center',
                      marginTop: 10,
                    }}
                  />
                )}
                {!item.image_path && (
                  <FastImage
                    source={GifType.gifBirthdayCake}
                    style={{
                      width: 60,
                      height: 60,
                      alignSelf: 'center',
                      marginTop: 10,
                    }}
                  />
                )}
              </View>
              <TouchableOpacity
                onPress={() => closeModalHappyBirthday(index)}
                style={{alignSelf: 'flex-end'}}>
                <Text style={{color: 'blue', fontWeight: '600'}}> Đóng</Text>
              </TouchableOpacity>
            </View>
          )}
        </View>
      ))}
    </View>
  );
};
const styles = StyleSheet.create({
  viewContent: {
    borderWidth: 1,
    width: windowWidth - 20,
    borderColor: 'white',
    backgroundColor: 'white',
    alignSelf: 'center',
    marginTop: 10,
    marginBottom: 10,
  },
  txtTitle: {
    color: 'black',
    fontSize: 15,
    fontWeight: '500',
  },
  openViewHappyBirthday: {
    borderLeftWidth: 4,
    borderLeftColor: 'blue',
  },
  closeViewHappyBirthday: {
    borderLeftWidth: 1,
  },
  viewHappyBirthday: {
    padding: 20,
    marginVertical: 8,
    marginHorizontal: 16,
    borderWidth: 1,
    borderBottomColor: '#f2f2f2',
    borderTopColor: '#f2f2f2',
    borderRightColor: '#f2f2f2',
    borderTopLeftRadius: 10,
    borderBottomLeftRadius: 10,
    justifyContent: 'space-between',
  },
});
export default WishListComponent;
