add
This commit is contained in:
parent
e704df40c9
commit
208953c5b6
|
@ -21,8 +21,21 @@ export default function CoursesPage() {
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
let coursesData = [];
|
let coursesData = [];
|
||||||
let isCourseLoading = false;
|
let isCourseLoading = false;
|
||||||
|
const searchValue = searchParams.get("searchValue");
|
||||||
|
|
||||||
if (!searchParams.get("searchValue")) {
|
if (!searchParams.get("searchValue")) {
|
||||||
console.log("no category");
|
console.log("no category");
|
||||||
|
const { data, isLoading } = api.post.findManyWithPagination.useQuery({
|
||||||
|
where: {
|
||||||
|
type: PostType.COURSE,
|
||||||
|
},
|
||||||
|
select: courseDetailSelect,
|
||||||
|
});
|
||||||
|
coursesData = data?.items;
|
||||||
|
isCourseLoading = isLoading;
|
||||||
|
} else {
|
||||||
|
console.log("searchValue:" + searchParams.get("searchValue"));
|
||||||
|
const searchValue = searchParams.get("searchValue");
|
||||||
const { data, isLoading } = api.post.findManyWithPagination.useQuery({
|
const { data, isLoading } = api.post.findManyWithPagination.useQuery({
|
||||||
where: {
|
where: {
|
||||||
type: PostType.COURSE,
|
type: PostType.COURSE,
|
||||||
|
@ -40,17 +53,6 @@ export default function CoursesPage() {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
select: courseDetailSelect,
|
|
||||||
});
|
|
||||||
coursesData = data?.items;
|
|
||||||
isCourseLoading = isLoading;
|
|
||||||
} else {
|
|
||||||
console.log("searchValue:" + searchParams.get("searchValue"));
|
|
||||||
const searchValue = searchParams.get("searchValue");
|
|
||||||
const { data, isLoading } = api.post.findManyWithPagination.useQuery({
|
|
||||||
where: {
|
|
||||||
type: PostType.COURSE,
|
|
||||||
OR: [
|
OR: [
|
||||||
{ title: { contains: searchValue, mode: "insensitive" } },
|
{ title: { contains: searchValue, mode: "insensitive" } },
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue