Skip to content

Commit b125d65

Browse files
committed
page.tsxをbottomBar.tsxの内容にしてしまったため修復
1 parent 499d24d commit b125d65

File tree

5 files changed

+160
-182
lines changed

5 files changed

+160
-182
lines changed

web/app/chat/page.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import RoomList from "~/components/chat/RoomList";
88
import { RoomWindow } from "~/components/chat/RoomWindow";
99
import FullScreenCircularProgress from "~/components/common/FullScreenCircularProgress";
1010

11+
export default function Chat() {
12+
return (
13+
<Suspense fallback={<FullScreenCircularProgress />}>
14+
<ChatListContent />
15+
</Suspense>
16+
);
17+
}
18+
1119
function ChatListContent() {
1220
const searchParams = useSearchParams();
1321

@@ -28,11 +36,3 @@ function ChatListContent() {
2836
<RoomList roomsData={state.data} />
2937
);
3038
}
31-
32-
export default function Chat() {
33-
return (
34-
<Suspense fallback={<FullScreenCircularProgress />}>
35-
<ChatListContent />
36-
</Suspense>
37-
);
38-
}

web/app/search/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function HomePageLayout({
88
}) {
99
return (
1010
<>
11-
<Header title="ホーム/Home" />
11+
<Header title="検索/Search" />
1212
<div className="absolute top-14 right-0 bottom-14 left-0 overflow-y-auto sm:top-16">
1313
{children}
1414
</div>

web/app/search/page.tsx

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,82 @@
1-
import Link from "next/link";
2-
import { MdHome } from "react-icons/md";
3-
import { MdPeople } from "react-icons/md";
4-
import { MdChat } from "react-icons/md";
5-
import { MdSettings } from "react-icons/md";
1+
"use client";
62

7-
type Props = {
8-
activeTab: "0_home" | "1_friends" | "2_chat" | "3_settings" | "4_search";
9-
};
3+
import type React from "react";
4+
import { useEffect, useState } from "react";
5+
import { useRecommended } from "~/api/user";
106

11-
function BottomBarCell({
12-
label,
13-
href,
14-
iconComponent,
15-
isActive,
16-
}: {
17-
label: string;
18-
href: string;
19-
iconComponent: React.ReactNode;
20-
isActive: boolean;
21-
}) {
22-
return (
23-
<Link
24-
href={href}
25-
className={`focus:bg-gray-300 ${isActive ? "active text-primary" : "text-secondary"}`}
26-
>
27-
{iconComponent}
28-
<span
29-
className={`text-xs ${isActive ? "text-primary" : "text-gray-500"}`}
30-
>
31-
{label}
32-
</span>
33-
</Link>
34-
);
35-
}
7+
import { useModal } from "~/components/common/modal/ModalProvider";
8+
import { HumanListItem } from "~/components/human/humanListItem";
9+
10+
const SearchPage: React.FC = () => {
11+
const [searchWord, setSearchWord] = useState("");
12+
const { data: recommended } = useRecommended();
13+
const { openModal } = useModal();
14+
const [users, setUsers] = useState<
15+
| {
16+
id: number;
17+
guid: string;
18+
name: string;
19+
gender: string;
20+
grade: string;
21+
faculty: string;
22+
department: string;
23+
intro: string;
24+
pictureUrl: string;
25+
}[]
26+
| null
27+
>(null);
28+
29+
useEffect(() => {
30+
if (recommended) {
31+
setUsers(recommended);
32+
}
33+
}, [recommended]);
34+
35+
function searchByUserName() {
36+
const filteredUsers = recommended?.filter((user) =>
37+
user.name.toLowerCase().includes(searchWord.toLowerCase()),
38+
);
39+
setUsers(filteredUsers || null);
40+
}
3641

37-
export default function BottomBar(props: Props) {
38-
const { activeTab } = props;
3942
return (
40-
<div className="btm-nav flex max-h-14 w-full flex-row">
41-
<BottomBarCell
42-
label="Home"
43-
href="/home"
44-
isActive={activeTab === "0_home"}
45-
iconComponent={<MdHome className="text-2xl" />}
46-
/>
47-
<BottomBarCell
48-
label="Friends"
49-
href="/friends"
50-
isActive={activeTab === "1_friends"}
51-
iconComponent={<MdPeople className="text-2xl" />}
52-
/>
53-
<BottomBarCell
54-
label="Chat"
55-
href="/chat"
56-
isActive={activeTab === "2_chat"}
57-
iconComponent={<MdChat className="text-2xl" />}
58-
/>
59-
<BottomBarCell
60-
label="Settings"
61-
href="/settings"
62-
isActive={activeTab === "3_settings"}
63-
iconComponent={<MdSettings className="text-2xl" />}
64-
/>
65-
<BottomBarCell
66-
label="Search"
67-
href="/search"
68-
isActive={activeTab === "4_search"}
69-
iconComponent={<MdSettings className="text-2xl" />}
70-
/>
43+
<div className="flex min-h-screen items-center justify-center bg-gray-100">
44+
<div className="card w-96 bg-white p-6 shadow-md">
45+
<h2 className="mb-4 font-bold text-2xl">Search</h2>
46+
47+
<div className="form-control mb-4">
48+
<label htmlFor="searchInput" className="label">
49+
<span className="label-text">Enter search term</span>
50+
</label>
51+
<input
52+
type="text"
53+
value={searchWord}
54+
onChange={(e) => setSearchWord(e.target.value)}
55+
placeholder="Type here"
56+
className="input input-bordered w-full"
57+
/>
58+
</div>
59+
60+
<button
61+
type="button"
62+
onClick={searchByUserName}
63+
className="btn btn-primary w-full"
64+
>
65+
Search
66+
</button>
67+
{users?.map((user) => (
68+
<HumanListItem
69+
key={user.id}
70+
id={user.id}
71+
name={user.name}
72+
pictureUrl={user.pictureUrl}
73+
onOpen={() => openModal(user)}
74+
hasDots
75+
/>
76+
))}
77+
</div>
7178
</div>
7279
);
73-
}
80+
};
81+
82+
export default SearchPage;

web/components/BottomBar.tsx

Lines changed: 62 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,73 @@
1-
import ChatIcon from "@mui/icons-material/Chat";
2-
import HomeIcon from "@mui/icons-material/Home";
3-
import PeopleIcon from "@mui/icons-material/People";
4-
import SearchIcon from "@mui/icons-material/Search";
5-
import SettingsIcon from "@mui/icons-material/Settings";
6-
import { BottomNavigation, BottomNavigationAction, Box } from "@mui/material";
71
import Link from "next/link";
2+
import { MdHome } from "react-icons/md";
3+
import { MdPeople } from "react-icons/md";
4+
import { MdChat } from "react-icons/md";
5+
import { MdSettings } from "react-icons/md";
86

97
type Props = {
108
activeTab: "0_home" | "1_friends" | "2_chat" | "3_settings" | "4_search";
119
};
1210

11+
function BottomBarCell({
12+
label,
13+
href,
14+
iconComponent,
15+
isActive,
16+
}: {
17+
label: string;
18+
href: string;
19+
iconComponent: React.ReactNode;
20+
isActive: boolean;
21+
}) {
22+
return (
23+
<Link
24+
href={href}
25+
className={`focus:bg-gray-300 ${isActive ? "active text-primary" : "text-secondary"}`}
26+
>
27+
{iconComponent}
28+
<span
29+
className={`text-xs ${isActive ? "text-primary" : "text-gray-500"}`}
30+
>
31+
{label}
32+
</span>
33+
</Link>
34+
);
35+
}
36+
1337
export default function BottomBar(props: Props) {
1438
const { activeTab } = props;
1539
return (
16-
<Box sx={{ position: "fixed", bottom: 0, left: 0, right: 0 }}>
17-
{/* TODO: 単に Viewer として BottomNavigation を使用しているので Box 等で置き換える */}
18-
<BottomNavigation
19-
showLabels
20-
value={activeTab}
21-
sx={{
22-
width: "100%",
23-
bottom: 0,
24-
borderTop: "1px solid",
25-
borderColor: "primary.main",
26-
}}
27-
>
28-
<BottomNavigationAction
29-
component={Link}
30-
href="/home"
31-
label="Home"
32-
icon={
33-
<HomeIcon
34-
sx={{
35-
color:
36-
activeTab === "0_home" ? "primary.main" : "secondary.main",
37-
}}
38-
/>
39-
}
40-
/>
41-
<BottomNavigationAction
42-
component={Link}
43-
href="/friends"
44-
label="Friends"
45-
icon={
46-
<PeopleIcon
47-
sx={{
48-
color:
49-
activeTab === "1_friends" ? "primary.main" : "secondary.main",
50-
}}
51-
/>
52-
}
53-
/>
54-
<BottomNavigationAction
55-
component={Link}
56-
href="/chat"
57-
label="Chat"
58-
icon={
59-
<ChatIcon
60-
sx={{
61-
color:
62-
activeTab === "2_chat" ? "#primary.main" : "secondary.main",
63-
}}
64-
/>
65-
}
66-
/>
67-
<BottomNavigationAction
68-
component={Link}
69-
href="/settings"
70-
label="Settings"
71-
icon={
72-
<SettingsIcon
73-
sx={{
74-
color:
75-
activeTab === "3_settings"
76-
? "primary.main"
77-
: "secondary.main",
78-
}}
79-
/>
80-
}
81-
/>
82-
<BottomNavigationAction
83-
component={Link}
84-
href="/search"
85-
label="Search"
86-
icon={
87-
<SearchIcon
88-
sx={{
89-
color:
90-
activeTab === "4_search" ? "primary.main" : "secondary.main",
91-
}}
92-
/>
93-
}
94-
/>
95-
</BottomNavigation>
96-
</Box>
40+
<div className="btm-nav flex max-h-14 w-full flex-row">
41+
<BottomBarCell
42+
label="Home"
43+
href="/home"
44+
isActive={activeTab === "0_home"}
45+
iconComponent={<MdHome className="text-2xl" />}
46+
/>
47+
<BottomBarCell
48+
label="Friends"
49+
href="/friends"
50+
isActive={activeTab === "1_friends"}
51+
iconComponent={<MdPeople className="text-2xl" />}
52+
/>
53+
<BottomBarCell
54+
label="Chat"
55+
href="/chat"
56+
isActive={activeTab === "2_chat"}
57+
iconComponent={<MdChat className="text-2xl" />}
58+
/>
59+
<BottomBarCell
60+
label="Settings"
61+
href="/settings"
62+
isActive={activeTab === "3_settings"}
63+
iconComponent={<MdSettings className="text-2xl" />}
64+
/>
65+
<BottomBarCell
66+
label="Search"
67+
href="/search"
68+
isActive={activeTab === "4_search"}
69+
iconComponent={<MdSettings className="text-2xl" />}
70+
/>
71+
</div>
9772
);
9873
}

0 commit comments

Comments
 (0)