File tree Expand file tree Collapse file tree 2 files changed +7
-15
lines changed
Expand file tree Collapse file tree 2 files changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,14 @@ import { credFetch } from "../firebase/auth/lib.ts";
99import { type Hook , useCustomizedSWR } from "../hooks/useCustomizedSWR.ts" ;
1010import endpoints from "./internal/endpoints.ts" ;
1111
12+ const InterestSubjectListSchema = z . array ( InterestSubjectSchema ) ;
13+
1214// 自身の興味分野を取得する
1315export function useMyInterests ( ) : Hook < InterestSubject [ ] > {
1416 return useCustomizedSWR (
1517 "interests::mine" ,
1618 getMySubjects ,
17- z . array ( InterestSubjectSchema ) ,
19+ InterestSubjectListSchema ,
1820 ) ;
1921}
2022
@@ -37,15 +39,7 @@ export async function get(id: UserID): Promise<InterestSubject[] | null> {
3739 return await res . json ( ) ;
3840}
3941
40- // キーワードで興味分野を検索
41- export function useSearch ( q : string ) : Hook < InterestSubject [ ] > {
42- return useCustomizedSWR (
43- `interests::search::${ q } ` ,
44- ( ) => search ( q ) ,
45- z . array ( InterestSubjectSchema ) ,
46- ) ;
47- }
48-
42+ // 興味分野を検索
4943export async function search ( q : string ) : Promise < InterestSubject [ ] > {
5044 const res = await credFetch ( "GET" , endpoints . subjectsSearch ( q ) ) ;
5145 return await res . json ( ) ;
Original file line number Diff line number Diff line change 33import type { InterestSubject } from "common/types" ;
44import { useRouter } from "next/navigation" ;
55import { useEffect , useState } from "react" ;
6- import { useAboutMe } from "~/api/user" ;
76import FullScreenCircularProgress from "~/components/common/FullScreenCircularProgress" ;
87import { useAlert } from "~/components/common/alert/AlertProvider" ;
9- import { search , update } from "../../../api/subject" ;
8+ import { search , update , useMyInterests } from "../../../api/subject" ;
109
1110export default function EditInterest ( ) {
12- // TODO:
13- const { state } = useAboutMe ( ) ;
14- const data = state . data ?. interestSubjects ;
11+ const { state } = useMyInterests ( ) ;
12+ const data = state . data ;
1513 const error = state . current === "error" ? state . error : null ;
1614 const loading = state . current === "loading" ;
1715
You can’t perform that action at this time.
0 commit comments