import { Image, View } from 'react-native';
import store_plannedIcon from '../assets/performics/Planned.svg';
import store_coveredIcon from '../assets/performics/Covered.svg';
import { AntDesign, MaterialCommunityIcons } from '../components/icons';
import ChatbotGreyIcon from '../assets/image/chatbot_grey.svg';
import PpayIcon from '../assets/image/ppay_icon.svg';
import ChatbotGIF from '../assets/image/Gyan_buddy.gif';
import { notify } from '../components/notify';
import Grooming_icon from '../assets/image/grooming_icon.svg';
import { logout } from '../components/logout';

export function getDashBoardConstData(props, customStyle = {}, PageTheme = {}, NB_AskForDownload = () => { }, NB_AskForUpload = () => { },NB_pPAYLink =() => {}) {
  const QuickLinks = [
    {
      text: 'Download Data',
      icon: () => {
        return (
          <View style={customStyle.NB_quickL_IconS}>
            <AntDesign name={'clouddownloado'} color={PageTheme.$primary_color} size={24} />
          </View>
        )
      },
      iconType: 'Icon',
      itemOnPress: () => { NB_AskForDownload() }
    },
    {
      text: 'Daily Route Plan',
      icon: () => {
        return (
          <View style={customStyle.NB_quickL_IconS}>
            <AntDesign name={'fork'} color={PageTheme.$primary_color} size={20} />
          </View>
        )
      },
      iconType: 'Icon',
      itemOnPress: () => { props.navigation.navigate('StoreList'); }
    },

    props.GroomingObj && Object.keys(props.GroomingObj || {}).length > 0 && props.GroomingObj !== undefined
      ? {
        text: props.GroomingObj.MenuName,
        icon: () => (
          <View style={customStyle.NB_quickL_IconS}>
            <Grooming_icon
              width={24}
              height={24}
              color={PageTheme.$primary_color}
            />
          </View>
        ),
        iconType: 'Icon',
        itemOnPress: () =>
          props.navigation.navigate('GroomingPictures', { storeData: {} }),
      }
      : []
    ,
    {
      text: 'Reports',
      icon: () => {
        return (
          <View style={customStyle.NB_quickL_IconS}>
            <MaterialCommunityIcons name={'file-document-outline'} color={PageTheme.$primary_color} size={24} />
          </View>
        )
      },
      iconType: 'Icon',
      itemOnPress: () => { props.navigation.navigate('ReportsMenu'); }

    },
    {
      text: 'Upload Data',
      icon: () => {
        return (
          <View style={customStyle.NB_quickL_IconS}>
            <AntDesign name={'clouduploado'} color={PageTheme.$primary_color} size={24} />
          </View>
        )
      },
      iconType: 'Icon',
      itemOnPress: () => { NB_AskForUpload() }

    },

    {
      text: 'Exit',
      icon: () => {
        return (
          <View style={customStyle.NB_quickL_IconS}>
            <MaterialCommunityIcons name={'exit-to-app'} color={PageTheme.$primary_color} size={24} />
          </View>
        )
      },
      iconType: 'Icon',
      itemOnPress: () => { logout(props) }
    },
  ];

  const storeperformancetext = [
    {
      text: 'MTD Attendance',
      icon: store_plannedIcon,
      value_Key: 'MTDManday',
    },
    {
      text: 'MTD OQAD Score',
      icon: store_coveredIcon,
      value_Key: 'MTD_OQAD',
    },
  ];

  if (props.pPAYObj && Object.keys(props.pPAYObj || {}).length > 0 && props.pPAYObj !== undefined) {
    QuickLinks.unshift({
      text: props?.pPAYObj?.MenuName,
      icon: () => {
        return (
          <View style={customStyle.NB_quickL_IconS}>
            {<PpayIcon width={30} height={30} />}
          </View>
        )
      },
      iconType: 'Icon',
      itemOnPress: () => { NB_pPAYLink(props?.pPAYObj?.Ppay_ExternalLink) }
    },)
  }

  if (props.Chatbot) {
    const now = new Date();
    const hours = now.getHours(); // 0–23
    const isWithinTime = hours >= 8 && hours < 20; // 8 AM to before 8 PM
    QuickLinks.unshift({
      text: 'Gyan Buddy',
      icon: () => {
        return (
          <View style={{}}>
            {isWithinTime ? <Image
              source={ChatbotGIF}
              resizeMode="contain"
              style={{ width: 77, height: 77 }}
            /> : <ChatbotGreyIcon width={45} height={45}/>}

          </View>
        )
      },
      iconType: 'Icon',
      itemOnPress: () => {
        if (isWithinTime) {
          props.navigation.navigate('ChatScreen');
        } else {
          notify("⏰ Gyan Buddy is available between 8:00 AM and 8:00 PM only.")
        }
      }
    },)
  }

  return {
    "QuickLinks": QuickLinks,
    "StorePerformanceText": storeperformancetext,
  }
}
