Skip to content

Commit 42e0049

Browse files
authored
feat(fe): add toggle for hiding expired sessions (#246)
* feat: add toggle for hiding expired sessions * feat(fe): update session status styling and improve visibility * test: add visibility check for ongoing session in QnAPage test * test: update session visibility checks and add expired session toggle test
1 parent 06caf72 commit 42e0049

File tree

6 files changed

+45
-15
lines changed

6 files changed

+45
-15
lines changed

apps/client/src/components/my/SessionRecord.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ function SessionRecord({ session }: SessionRecordProps) {
1313
<div className='flex h-fit flex-col items-start justify-start gap-4 self-stretch border-b border-gray-200 px-2.5 pb-4 pt-2.5'>
1414
<div className='flex h-fit flex-col items-start justify-center gap-2.5 self-stretch'>
1515
{session.expired ? (
16-
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-green-100 px-2 py-1'>
17-
<div className='text-base font-medium text-green-800'>만료된 세션</div>
16+
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-red-100 px-2 py-1'>
17+
<div className='text-base font-medium text-red-600'>만료된 세션</div>
1818
</div>
1919
) : (
20-
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-blue-100 px-2 py-1'>
21-
<div className='text-base font-medium text-blue-800'>진행 중인 세션</div>
20+
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-green-100 px-2 py-1'>
21+
<div className='text-base font-medium text-green-800'>진행 중인 세션</div>
2222
</div>
2323
)}
2424
</div>

apps/client/src/components/qna/ChattingList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function ChattingList() {
9797
<div className='inline-flex h-[54px] w-full items-center justify-between border-b border-gray-200 px-4 py-3'>
9898
<div className='shrink grow basis-0 text-lg font-medium text-black'>실시간 채팅</div>
9999
{!expired && (
100-
<div className='max-w-[100px] overflow-x-auto whitespace-nowrap bg-green-100 px-2 py-1 transition-colors duration-150 scrollbar-hide'>
100+
<div className='max-w-[100px] overflow-x-auto whitespace-nowrap bg-green-100 px-2 py-1 scrollbar-hide'>
101101
<p className='text-[10px] font-medium text-green-800'>{participantCount}명 참여중</p>
102102
</div>
103103
)}

apps/client/src/components/qna/QuestionList.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,14 @@ function QuestionList() {
144144
<>
145145
<div className='inline-flex h-full w-4/5 flex-grow flex-col items-center justify-start rounded-lg bg-white shadow'>
146146
<div className='inline-flex h-[54px] w-full items-center justify-between border-b border-gray-200 px-8 py-2'>
147-
<div className='text-lg font-medium text-black'>{sessionTitle}</div>
147+
<div className='inline-flex h-full w-fit gap-4'>
148+
<div className='self-center text-lg font-medium text-black'>{sessionTitle}</div>
149+
<div className={`self-center rounded ${expired ? 'bg-red-100' : 'bg-green-100'} px-2 py-1`}>
150+
<p className={`text-xs font-medium ${expired ? 'text-red-600' : 'text-green-800'}`}>
151+
{expired ? '만료된 세션' : '진행 중인 세션'}
152+
</p>
153+
</div>
154+
</div>
148155
{!expired && (
149156
<div className='flex flex-row gap-2'>
150157
<div className='relative'>

apps/client/src/pages/MyPage.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
import { useQuery } from '@tanstack/react-query';
2+
import { useMemo, useState } from 'react';
23

34
import { getSessions } from '@/features/session';
45

6+
import { Button } from '@/components';
57
import { SessionRecord } from '@/components/my';
68

79
function MyPage() {
10+
const [hideExpired, setHideExpired] = useState(true);
11+
812
const { data } = useQuery({ queryKey: ['/sessions'], queryFn: getSessions });
913

10-
const sessions = data?.sessionData;
14+
const sessions = useMemo(() => {
15+
if (!data) return [];
16+
if (hideExpired) return data.sessionData.filter((session) => session.expired === false);
17+
return data.sessionData;
18+
}, [data, hideExpired]);
1119

1220
return (
1321
<div className='inline-flex h-full w-full items-center justify-center gap-4 overflow-hidden px-4 py-4 md:max-w-[1194px]'>
1422
<div className='inline-flex shrink grow basis-0 flex-col items-center justify-start self-stretch rounded-lg bg-white shadow'>
1523
<div className='inline-flex h-[54px] items-center justify-between self-stretch border-b border-gray-200 px-8 py-2'>
1624
<div className='text-lg font-medium text-black'>참여한 세션 기록</div>
17-
<div className='rounded-md px-3 py-2' />
25+
<Button
26+
className={`transition-colors duration-200 ${hideExpired ? 'bg-emerald-100' : 'bg-red-100'}`}
27+
onClick={() => setHideExpired((prev) => !prev)}
28+
>
29+
<div className={`rounded-md text-xs font-medium ${hideExpired ? 'text-green-800' : 'text-red-600'}`}>
30+
만료된 세션 {hideExpired ? '보이기' : '숨기기'}
31+
</div>
32+
</Button>
1833
</div>
1934
<div className='flex shrink grow basis-0 flex-col items-start justify-start gap-4 self-stretch overflow-y-auto px-8 py-2'>
20-
{sessions?.map((session) => (
35+
{sessions.map((session) => (
2136
<SessionRecord
2237
key={session.sessionId}
2338
session={{

apps/client/tests/MyPage.spec.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ test.beforeEach(async ({ page }) => {
6161
test('세션 목록 확인', async ({ page }) => {
6262
await expect(page.locator('text=참여한 세션 기록')).toBeVisible();
6363

64-
const sessionTitles = ['세션 1', '세션 2', '세션 3'];
65-
await Promise.all(
66-
sessionTitles.map(async (title) => {
67-
await expect(page.locator(`text=${title}`)).toBeVisible();
68-
}),
69-
);
64+
await expect(page.locator('text=세션 1')).toBeVisible();
65+
await expect(page.locator('text=세션 2')).toBeHidden();
66+
await expect(page.locator('text=세션 3')).toBeVisible();
67+
});
68+
69+
test('세션 만료 여부 토글', async ({ page }) => {
70+
const toggleButton = page.locator('text=만료된 세션 보이기');
71+
await toggleButton.waitFor();
72+
await toggleButton.click();
73+
74+
await expect(page.locator('text=세션 1')).toBeVisible();
75+
await expect(page.locator('text=세션 2')).toBeVisible();
76+
await expect(page.locator('text=세션 3')).toBeVisible();
7077
});

apps/client/tests/QnAPage.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ test.beforeEach(async ({ page }) => {
173173
});
174174

175175
test('질문 목록이 올바르게 표시되는지 확인', async ({ page }) => {
176+
await expect(page.locator('text=진행 중인 세션')).toBeVisible();
176177
await expect(page.locator('text=테스트 세션 제목')).toBeVisible();
177178
});
178179

0 commit comments

Comments
 (0)