"use client";

import React, { createContext, useContext, ReactNode } from "react";
import { Activity } from "../services/workshopService";

interface WorkshopsContextType {
  workshops: Activity[];
}

const WorkshopsContext = createContext<WorkshopsContextType | undefined>(undefined);

export function WorkshopsProvider({
  children,
  workshops,
}: {
  children: ReactNode;
  workshops: Activity[];
}) {
  return (
    <WorkshopsContext.Provider value={{ workshops }}>
      {children}
    </WorkshopsContext.Provider>
  );
}

export function useWorkshops() {
  const context = useContext(WorkshopsContext);
  if (context === undefined) {
    throw new Error("useWorkshops must be used within a WorkshopsProvider");
  }
  return context;
}
