/* eslint-disable no-unused-vars */
/* eslint-disable react/prop-types */
import NavBar from "../components/NavBar/NavBar";
import Footer from "../components/Footer/Footer";
import { Box, ScaleFade, SlideFade } from "@chakra-ui/react";
import { useLocation } from "react-router-dom";
import { useEffect } from "react";
import { useGetDailyDataQuery, useGetDateWiseDataQuery, useGetKPIDetailsQuery, useGetTransAllQuery } from "../Services/api.service";
import { timeZone } from "../Constants/Constants";
import SplashScreen from "../pages/SplashScreen";

const DefaultLayout = ({ children }) => {
  useEffect(() => {
    localStorage.setItem("light", true)
  });
  
  const {
    data,
    isLoading,
  } = useGetKPIDetailsQuery()
  const {
    isLoading: dailyDataLoading,
  } = useGetDailyDataQuery(timeZone === "Asia/Calcutta" ? "Asia/Kolkata" : timeZone);

   // Fetch transactions based on the current page and page size
   const {
    refetch
  } = useGetTransAllQuery({
    pageNumber: 1,
    pageSize: 10,
  });

  // useEffect(() => {
  //   refetch()
  // }, [])
  


  return (
     dailyDataLoading || isLoading  ? <SplashScreen/>: <Box>
    
      <NavBar />
        {children}
      <Footer />
    </Box> 
  );
};

export default DefaultLayout;
