import React, { useState, createContext, useEffect } from 'react'; import { Course, Group } from '../types'; interface courseContext { courses: Array; choosenGroups: Array; addCourse: (courses: Course) => void; addGroup: (group: Group) => void; } export const coursesContext = createContext(null); interface CoursesProviderProps { children: React.ReactNode; } export const CoursesProvider = ({ children }: CoursesProviderProps) => { const [courses, setCourses] = useState>([]); const [choosenGroups, setChoosenGroups] = useState>([]); const addCourse = (course: Course) => { setCourses([...courses, course]); }; const addGroup = (group: Group) => { setChoosenGroups([...choosenGroups, group]); }; return ( {children} ); };