Skip to content

Commit 6d3168b

Browse files
authored
Merge branch 'main' into memo
2 parents e048be4 + 3d751bc commit 6d3168b

File tree

5 files changed

+50
-54
lines changed

5 files changed

+50
-54
lines changed

web/app/friends/page.tsx

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,52 @@
11
"use client";
2-
3-
import { Tab, Tabs } from "@mui/material";
42
import { useState } from "react";
5-
import { NavigateByAuthState } from "~/components/common/NavigateByAuthState";
6-
import Matchings from "~/components/match/matching";
7-
import Requests from "~/components/match/requests";
83

9-
export default function Friends() {
10-
const [open, setOpen] = useState(0);
4+
// https://nextjs.org/docs/messages/react-hydration-error#solution-2-disabling-ssr-on-specific-components
5+
import dynamic from "next/dynamic";
6+
const NoSSRMatchings = dynamic(() => import("~/components/match/matching"), {
7+
ssr: false,
8+
});
9+
const NoSSRRequests = dynamic(() => import("~/components/match/requests"), {
10+
ssr: false,
11+
});
1112

12-
const handleChange = (_event: React.SyntheticEvent, newOpen: number) => {
13-
setOpen(newOpen);
14-
};
13+
export default function Friends() {
14+
const [activeTab, setActiveTab] = useState("matching");
1515

1616
return (
17-
<NavigateByAuthState type="toLoginForUnauthenticated">
18-
<div className="fixed z-50 w-full border-gray-200 border-b-[1px] bg-white">
19-
<Tabs value={open} onChange={handleChange} variant="fullWidth">
20-
<Tab label="マッチ中" {...a11yProps(0)} sx={{ width: "50%" }} />
21-
<Tab label="リクエスト" {...a11yProps(1)} sx={{ width: "50%" }} />
22-
</Tabs>
23-
</div>
24-
<div className="absolute top-9 right-0 left-0 overflow-y-auto">
25-
<TabPanel open={open}>
26-
{open === 0 ? <Matchings /> : open === 1 ? <Requests /> : null}
27-
</TabPanel>
17+
<div className="w-full">
18+
<div className="flex w-full border-gray-200 border-b">
19+
<button
20+
type="button"
21+
className={`relative flex-1 py-2 text-center ${
22+
activeTab === "matching" ? "text-primary" : "text-gray-600"
23+
}`}
24+
onClick={() => setActiveTab("matching")}
25+
>
26+
<span>マッチ中</span>
27+
{activeTab === "matching" && (
28+
<span className="absolute bottom-0 left-0 h-1 w-full bg-primary" />
29+
)}
30+
</button>
31+
32+
<button
33+
type="button"
34+
className={`relative flex-1 py-2 text-center ${
35+
activeTab === "request" ? "text-primary" : "text-gray-600"
36+
}`}
37+
onClick={() => setActiveTab("request")}
38+
>
39+
<span>リクエスト</span>
40+
{activeTab === "request" && (
41+
<span className="absolute bottom-0 left-0 h-1 w-full bg-primary" />
42+
)}
43+
</button>
2844
</div>
29-
</NavigateByAuthState>
30-
);
31-
}
3245

33-
function TabPanel({
34-
open,
35-
children,
36-
}: {
37-
open: number;
38-
children: React.ReactNode;
39-
}) {
40-
return (
41-
<div
42-
// role="tabpanel" // FIXME: biome says it should not be a div, but I couldn't find a proper html elem
43-
id={`tabpanel-${open}`}
44-
aria-labelledby={`tab-${open}`}
45-
>
46-
<div>{children}</div>
46+
{/* コンテンツ部分 */}
47+
<div className="mt-4 text-center text-gray-700 text-lg">
48+
{activeTab === "matching" ? <NoSSRMatchings /> : <NoSSRRequests />}
49+
</div>
4750
</div>
4851
);
4952
}
50-
51-
function a11yProps(index: number) {
52-
return {
53-
id: `tab-${index}`,
54-
"aria-controls": `tabpanel-${index}`,
55-
};
56-
}

web/components/match/matching.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import { deleteMatch } from "~/api/match";
23
import { useMatched } from "~/api/user";
34
import FullScreenCircularProgress from "../common/FullScreenCircularProgress";
@@ -13,15 +14,11 @@ export default function Matchings() {
1314

1415
return (
1516
<div className="p-4">
16-
<p className="mr-10 ml-10 text-lg">
17-
{data && data.length === 0 && (
18-
<>
19-
誰ともマッチングしていません。
20-
<br />
21-
リクエストを送りましょう!
22-
</>
23-
)}
24-
</p>
17+
{data && data.length === 0 && (
18+
<p className="mr-10 ml-10 text-lg">
19+
誰ともマッチングしていません。 リクエストを送りましょう!
20+
</p>
21+
)}
2522
{current === "loading" ? (
2623
<FullScreenCircularProgress />
2724
) : error ? (

web/components/match/myRequests.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import * as request from "~/api/request";
23
import { usePendingFromMe } from "~/api/user";
34
import FullScreenCircularProgress from "../common/FullScreenCircularProgress";

web/components/match/othersRequests.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import request from "~/api/request";
23
import { usePendingToMe } from "~/api/user";
34
import FullScreenCircularProgress from "../common/FullScreenCircularProgress";

web/components/match/requests.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import MyReq from "./myRequests";
23
import OthersReq from "./othersRequests";
34

0 commit comments

Comments
 (0)