diff --git a/src/components/GenerateCourse/AICourseCard.tsx b/src/components/GenerateCourse/AICourseCard.tsx index 4048dd73f..329969ade 100644 --- a/src/components/GenerateCourse/AICourseCard.tsx +++ b/src/components/GenerateCourse/AICourseCard.tsx @@ -1,9 +1,9 @@ -import type { AICourseListItem } from '../../queries/ai-course'; +import type { AICourseWithLessonCount } from '../../queries/ai-course'; import type { DifficultyLevel } from './AICourse'; import { BookOpen } from 'lucide-react'; type AICourseCardProps = { - course: AICourseListItem; + course: AICourseWithLessonCount; }; export function AICourseCard(props: AICourseCardProps) { diff --git a/src/components/GenerateCourse/AICourseSearch.tsx b/src/components/GenerateCourse/AICourseSearch.tsx new file mode 100644 index 000000000..bd0f68a76 --- /dev/null +++ b/src/components/GenerateCourse/AICourseSearch.tsx @@ -0,0 +1,46 @@ +import { SearchIcon } from 'lucide-react'; +import { useEffect, useState } from 'react'; +import { useDebounceValue } from '../../hooks/use-debounce'; + +type AICourseSearchProps = { + value: string; + onChange: (value: string) => void; +}; + +export function AICourseSearch(props: AICourseSearchProps) { + const { value: defaultValue, onChange } = props; + + const [searchTerm, setSearchTerm] = useState(defaultValue); + const debouncedSearchTerm = useDebounceValue(searchTerm, 500); + + useEffect(() => { + setSearchTerm(defaultValue); + }, [defaultValue]); + + useEffect(() => { + if (debouncedSearchTerm && debouncedSearchTerm.length < 3) { + return; + } + + if (debouncedSearchTerm === defaultValue) { + return; + } + + onChange(debouncedSearchTerm); + }, [debouncedSearchTerm]); + + return ( +
- You haven't generated any courses yet. -
-+ You haven't generated any courses yet. +
+No courses match your search. diff --git a/src/components/Pagination/Pagination.tsx b/src/components/Pagination/Pagination.tsx index 86f3ac4de..3f4c8d604 100644 --- a/src/components/Pagination/Pagination.tsx +++ b/src/components/Pagination/Pagination.tsx @@ -11,6 +11,7 @@ type PaginationProps = { totalCount: number; isDisabled?: boolean; onPageChange: (page: number) => void; + className?: string; }; export function Pagination(props: PaginationProps) { @@ -22,6 +23,7 @@ export function Pagination(props: PaginationProps) { currPage, perPage, isDisabled = false, + className, } = props; if (!totalPages || totalPages === 1) { @@ -32,10 +34,14 @@ export function Pagination(props: PaginationProps) { return (