'use client'

import { EventsDate } from "@/lib/types";
import { getEvent } from "@/lib/utils";
import { createContext, useContext } from "react";

interface ThemeEventsContextType {
  event: EventsDate | undefined
}

const ThemeEventsContext = createContext<ThemeEventsContextType | undefined>(undefined);

export const ThemeEventsProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  const eventNow = getEvent();

  return <ThemeEventsContext.Provider value={{ event: eventNow }}>
    {children}
  </ThemeEventsContext.Provider>
}

export const useThemeEvents = () => useContext(ThemeEventsContext);