34 lines
992 B
TypeScript
Executable File
34 lines
992 B
TypeScript
Executable File
import PostList from "@web/src/components/models/course/list/PostList";
|
|
import { useMainContext } from "../../layout/MainProvider";
|
|
import PostCard from "@web/src/components/models/post/PostCard";
|
|
import { PostType } from "@nice/common";
|
|
import CourseCard from "@web/src/components/models/post/SubPost/CourseCard";
|
|
import PathCard from "@web/src/components/models/post/SubPost/PathCard";
|
|
const POST_TYPE_COMPONENTS = {
|
|
[PostType.COURSE]: CourseCard,
|
|
[PostType.PATH]: PathCard,
|
|
};
|
|
export default function SearchListContainer() {
|
|
const { searchCondition, termsCondition, searchMode } = useMainContext();
|
|
|
|
return (
|
|
<>
|
|
<PostList
|
|
renderItem={(post) => {
|
|
const Component =
|
|
POST_TYPE_COMPONENTS[post.type] || PostCard;
|
|
return <Component post={post} />;
|
|
}}
|
|
params={{
|
|
pageSize: 12,
|
|
where: {
|
|
type: searchMode === "both" ? undefined : searchMode,
|
|
...termsCondition,
|
|
...searchCondition,
|
|
},
|
|
}}
|
|
cols={4}></PostList>
|
|
</>
|
|
);
|
|
}
|