Skip to content

Commit 9ca890a

Browse files
authored
feat: create searchroom page (#8)
방 검색 페이지 구현 mock data로 구현함
1 parent 149de90 commit 9ca890a

File tree

6 files changed

+402
-1
lines changed

6 files changed

+402
-1
lines changed

src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import RoomSearch from './pages/SearchRoom/RoomSearch';
12
import Router from './router/Router';
23

34
const App = () => {
4-
return <Router />;
5+
return (
6+
<div>
7+
<Router />
8+
<RoomSearch />
9+
</div>
10+
);
511
};
612

713
export default App;

src/pages/SearchRoom/RoomCard.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* RoomCard.css */
2+
.room-card {
3+
background-color: white;
4+
border: 1px solid #ddd;
5+
border-radius: 8px;
6+
padding: 15px;
7+
margin-bottom: 12px;
8+
cursor: pointer;
9+
transition: box-shadow 0.2s;
10+
display: flex;
11+
flex-direction: column;
12+
gap: 8px;
13+
}
14+
15+
.room-card:hover {
16+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
17+
border-color: #aaa;
18+
}
19+
20+
.room-header {
21+
display: flex;
22+
justify-content: space-between;
23+
align-items: center;
24+
}
25+
26+
.room-name {
27+
font-weight: bold;
28+
font-size: 1.1rem;
29+
}
30+
31+
.room-user {
32+
font-size: 0.8rem;
33+
color: #666;
34+
}
35+
36+
.room-route {
37+
display: flex;
38+
align-items: center;
39+
gap: 10px;
40+
background-color: #f9f9f9;
41+
padding: 8px;
42+
border-radius: 4px;
43+
}
44+
45+
.room-details {
46+
display: flex;
47+
justify-content: space-between;
48+
font-size: 0.9rem;
49+
margin-top: 5px;
50+
}
51+
52+
.room-headcount.full {
53+
color: red;
54+
font-weight: bold;
55+
}

src/pages/SearchRoom/RoomCard.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react';
2+
import './RoomCard.css'; // 스타일은 별도 파일 또는 기존 CSS 활용
3+
import { type RoomData } from '../../types'; // 위에서 정의한 타입 import
4+
5+
interface RoomCardProps {
6+
room: RoomData;
7+
onClick: (roomId: number) => void;
8+
}
9+
10+
const RoomCard: React.FC<RoomCardProps> = ({ room, onClick }) => {
11+
// 날짜 포맷팅 (보기 좋게 변환)
12+
const formattedDate = new Date(room.time).toLocaleString('ko-KR', {
13+
month: 'long',
14+
day: 'numeric',
15+
hour: '2-digit',
16+
minute: '2-digit',
17+
});
18+
19+
return (
20+
<div className="room-card" onClick={() => onClick(room.roomId)}>
21+
<div className="room-header">
22+
<span className="room-name">{room.name}</span>
23+
<span className="room-user">방장: {room.user}</span>
24+
</div>
25+
26+
<div className="room-route">
27+
<span className="location">{room.from}</span>
28+
<span className="arrow"></span>
29+
<span className="location">{room.to}</span>
30+
</div>
31+
32+
<div className="room-details">
33+
<span className="room-time">🕒 {formattedDate}</span>
34+
<span
35+
className={`room-headcount ${room.currentHeadcount === room.maxHeadcount ? 'full' : ''}`}
36+
>
37+
👤 {room.currentHeadcount} / {room.maxHeadcount}
38+
</span>
39+
</div>
40+
</div>
41+
);
42+
};
43+
44+
export default RoomCard;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* RoomSearch.css */
2+
.search-filter-card {
3+
background: #fff;
4+
padding: 20px;
5+
border-radius: 10px;
6+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
7+
margin-bottom: 20px;
8+
display: flex;
9+
flex-direction: column;
10+
gap: 15px;
11+
}
12+
13+
.filter-row {
14+
display: flex;
15+
gap: 10px;
16+
align-items: center;
17+
}
18+
19+
.filter-row select,
20+
.filter-row input {
21+
padding: 10px;
22+
border: 1px solid #ccc;
23+
border-radius: 5px;
24+
flex: 1;
25+
}
26+
27+
.search-btn {
28+
background-color: #007bff;
29+
color: white;
30+
border: none;
31+
padding: 10px 20px;
32+
border-radius: 5px;
33+
cursor: pointer;
34+
white-space: nowrap;
35+
}
36+
37+
.room-list {
38+
display: flex;
39+
flex-direction: column;
40+
}
41+
42+
.no-result {
43+
text-align: center;
44+
padding: 40px;
45+
color: #666;
46+
}
47+
48+
.pagination {
49+
display: flex;
50+
justify-content: center;
51+
gap: 5px;
52+
margin-top: 20px;
53+
margin-bottom: 40px;
54+
}
55+
56+
.pagination button {
57+
padding: 8px 12px;
58+
border: 1px solid #ddd;
59+
background: white;
60+
cursor: pointer;
61+
border-radius: 4px;
62+
}
63+
64+
.pagination button.active {
65+
background-color: #007bff;
66+
color: white;
67+
border-color: #007bff;
68+
}
69+
70+
.pagination button:disabled {
71+
background-color: #f0f0f0;
72+
cursor: not-allowed;
73+
color: #aaa;
74+
}

0 commit comments

Comments
 (0)