Skip to content

Commit eef2133

Browse files
committed
YIPPEE
1 parent 715d121 commit eef2133

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

apps/web/src/app/_components/search/search-filter.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use client";
22

3+
import { useCallback } from "react";
4+
import { usePathname, useRouter, useSearchParams } from "next/navigation";
35
import { zodResolver } from "@hookform/resolvers/zod";
46
import { useForm } from "react-hook-form";
57
import { z } from "zod";
@@ -22,10 +24,24 @@ export default function SearchFilter() {
2224
},
2325
});
2426

25-
function onSubmit(values: z.infer<typeof formSchema>) {
26-
//value is user's search info
27+
const searchParams = useSearchParams()!;
28+
const router = useRouter();
29+
const pathName = usePathname();
2730

28-
console.log(values);
31+
const createQueryString = useCallback(
32+
(name: string, value: string) => {
33+
const params = new URLSearchParams(searchParams);
34+
params.set(name, value);
35+
return params.toString();
36+
},
37+
[searchParams],
38+
);
39+
40+
function onSubmit(values: z.infer<typeof formSchema>) {
41+
// console.log(searchParams.get("search")); query the user search info
42+
router.push(
43+
pathName + `/?${createQueryString("search", values.searchText)}`,
44+
);
2945
}
3046

3147
return (

packages/api/src/router/role.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { TRPCRouterRecord } from "@trpc/server";
2+
import Fuse from "fuse.js";
23
import { z } from "zod";
34

45
import { desc, eq } from "@cooper/db";

0 commit comments

Comments
 (0)