Skip to content

Commit e45d34e

Browse files
committed
fix hook
1 parent e2f5ae0 commit e45d34e

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

web/api/subject.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import { credFetch } from "../firebase/auth/lib.ts";
99
import { type Hook, useCustomizedSWR } from "../hooks/useCustomizedSWR.ts";
1010
import endpoints from "./internal/endpoints.ts";
1111

12+
const InterestSubjectListSchema = z.array(InterestSubjectSchema);
13+
1214
// 自身の興味分野を取得する
1315
export 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+
// 興味分野を検索
4943
export async function search(q: string): Promise<InterestSubject[]> {
5044
const res = await credFetch("GET", endpoints.subjectsSearch(q));
5145
return await res.json();

web/app/edit/interests/page.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import type { InterestSubject } from "common/types";
44
import { useRouter } from "next/navigation";
55
import { useEffect, useState } from "react";
6-
import { useAboutMe } from "~/api/user";
76
import FullScreenCircularProgress from "~/components/common/FullScreenCircularProgress";
87
import { useAlert } from "~/components/common/alert/AlertProvider";
9-
import { search, update } from "../../../api/subject";
8+
import { search, update, useMyInterests } from "../../../api/subject";
109

1110
export 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

0 commit comments

Comments
 (0)