mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-09-25 00:21:28 +02:00
Add search to my picks
This commit is contained in:
@@ -13,6 +13,7 @@ import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal';
|
|||||||
import { AITutorTallMessage } from './AITutorTallMessage';
|
import { AITutorTallMessage } from './AITutorTallMessage';
|
||||||
import { BookOpen } from 'lucide-react';
|
import { BookOpen } from 'lucide-react';
|
||||||
import { AILoadingState } from './AILoadingState';
|
import { AILoadingState } from './AILoadingState';
|
||||||
|
import { AICourseSearch } from '../GenerateCourse/AICourseSearch';
|
||||||
|
|
||||||
export function AIFeaturedCoursesListing() {
|
export function AIFeaturedCoursesListing() {
|
||||||
const [isInitialLoading, setIsInitialLoading] = useState(true);
|
const [isInitialLoading, setIsInitialLoading] = useState(true);
|
||||||
@@ -21,6 +22,7 @@ export function AIFeaturedCoursesListing() {
|
|||||||
const [pageState, setPageState] = useState<ListUserAiCoursesQuery>({
|
const [pageState, setPageState] = useState<ListUserAiCoursesQuery>({
|
||||||
perPage: '21',
|
perPage: '21',
|
||||||
currPage: '1',
|
currPage: '1',
|
||||||
|
query: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: featuredAiCourses, isFetching: isFeaturedAiCoursesLoading } =
|
const { data: featuredAiCourses, isFetching: isFeaturedAiCoursesLoading } =
|
||||||
@@ -38,16 +40,19 @@ export function AIFeaturedCoursesListing() {
|
|||||||
setPageState({
|
setPageState({
|
||||||
...pageState,
|
...pageState,
|
||||||
currPage: queryParams?.p || '1',
|
currPage: queryParams?.p || '1',
|
||||||
|
query: queryParams?.q || '',
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (pageState?.currPage !== '1') {
|
if (pageState?.currPage !== '1' || pageState?.query !== '') {
|
||||||
setUrlParams({
|
setUrlParams({
|
||||||
p: pageState?.currPage || '1',
|
p: pageState?.currPage || '1',
|
||||||
|
q: pageState?.query || '',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
deleteUrlParam('p');
|
deleteUrlParam('p');
|
||||||
|
deleteUrlParam('q');
|
||||||
}
|
}
|
||||||
}, [pageState]);
|
}, [pageState]);
|
||||||
|
|
||||||
@@ -60,7 +65,18 @@ export function AIFeaturedCoursesListing() {
|
|||||||
<AITutorHeader
|
<AITutorHeader
|
||||||
title="Featured Courses"
|
title="Featured Courses"
|
||||||
onUpgradeClick={() => setShowUpgradePopup(true)}
|
onUpgradeClick={() => setShowUpgradePopup(true)}
|
||||||
/>
|
>
|
||||||
|
<AICourseSearch
|
||||||
|
value={pageState?.query || ''}
|
||||||
|
onChange={(value) => {
|
||||||
|
setPageState({
|
||||||
|
...pageState,
|
||||||
|
query: value,
|
||||||
|
currPage: '1',
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</AITutorHeader>
|
||||||
|
|
||||||
{(isFeaturedAiCoursesLoading || isInitialLoading) && (
|
{(isFeaturedAiCoursesLoading || isInitialLoading) && (
|
||||||
<AILoadingState
|
<AILoadingState
|
||||||
|
Reference in New Issue
Block a user