import { useDispatch, useSelector } from 'react-redux'; import { setCourses } from '@/app/slices/courses'; import { RootState } from '@/app/store'; function useCourses() { const dispatch = useDispatch(); const courses = useSelector( (state: RootState) => state.courses?.courses ) as T; const categories = useSelector( (state: RootState) => state.courses?.categories ) as string[]; const set = (courses: Course[]) => { dispatch(setCourses(courses)); }; return { setCourses: set, courses, categories }; } export default useCourses;