Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fe): add toggle for hiding expired sessions #246

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/client/src/components/my/SessionRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ function SessionRecord({ session }: SessionRecordProps) {
<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'>
<div className='flex h-fit flex-col items-start justify-center gap-2.5 self-stretch'>
{session.expired ? (
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-green-100 px-2 py-1'>
<div className='text-base font-medium text-green-800'>만료된 세션</div>
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-red-100 px-2 py-1'>
<div className='text-base font-medium text-red-600'>만료된 세션</div>
</div>
) : (
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-blue-100 px-2 py-1'>
<div className='text-base font-medium text-blue-800'>진행 중인 세션</div>
<div className='inline-flex items-center justify-center gap-2.5 rounded bg-green-100 px-2 py-1'>
<div className='text-base font-medium text-green-800'>진행 중인 세션</div>
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/components/qna/ChattingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
return () => {
messageContainer?.removeEventListener('scroll', handleScroll);
};
}, [checkScrollPosition, chatting, isLoading]);

Check warning on line 87 in apps/client/src/components/qna/ChattingList.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'addChattingToFront', 'sessionId', and 'sessionToken'. Either include them or remove the dependency array

useEffect(() => {
if (isBottom && !userScrolling.current) {
Expand All @@ -97,7 +97,7 @@
<div className='inline-flex h-[54px] w-full items-center justify-between border-b border-gray-200 px-4 py-3'>
<div className='shrink grow basis-0 text-lg font-medium text-black'>실시간 채팅</div>
{!expired && (
<div className='max-w-[100px] overflow-x-auto whitespace-nowrap bg-green-100 px-2 py-1 transition-colors duration-150 scrollbar-hide'>
<div className='max-w-[100px] overflow-x-auto whitespace-nowrap bg-green-100 px-2 py-1 scrollbar-hide'>
<p className='text-[10px] font-medium text-green-800'>{participantCount}명 참여중</p>
</div>
)}
Expand Down
9 changes: 8 additions & 1 deletion apps/client/src/components/qna/QuestionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@ function QuestionList() {
<>
<div className='inline-flex h-full w-4/5 flex-grow flex-col items-center justify-start rounded-lg bg-white shadow'>
<div className='inline-flex h-[54px] w-full items-center justify-between border-b border-gray-200 px-8 py-2'>
<div className='text-lg font-medium text-black'>{sessionTitle}</div>
<div className='inline-flex h-full w-fit gap-4'>
<div className='self-center text-lg font-medium text-black'>{sessionTitle}</div>
<div className={`self-center rounded ${expired ? 'bg-red-100' : 'bg-green-100'} px-2 py-1`}>
<p className={`text-xs font-medium ${expired ? 'text-red-600' : 'text-green-800'}`}>
{expired ? '만료된 세션' : '진행 중인 세션'}
</p>
</div>
</div>
{!expired && (
<div className='flex flex-row gap-2'>
<div className='relative'>
Expand Down
21 changes: 18 additions & 3 deletions apps/client/src/pages/MyPage.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
import { useQuery } from '@tanstack/react-query';
import { useMemo, useState } from 'react';

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

import { Button } from '@/components';
import { SessionRecord } from '@/components/my';

function MyPage() {
const [hideExpired, setHideExpired] = useState(true);

const { data } = useQuery({ queryKey: ['/sessions'], queryFn: getSessions });

const sessions = data?.sessionData;
const sessions = useMemo(() => {
if (!data) return [];
if (hideExpired) return data.sessionData.filter((session) => session.expired === false);
return data.sessionData;
}, [data, hideExpired]);

return (
<div className='inline-flex h-full w-full items-center justify-center gap-4 overflow-hidden px-4 py-4 md:max-w-[1194px]'>
<div className='inline-flex shrink grow basis-0 flex-col items-center justify-start self-stretch rounded-lg bg-white shadow'>
<div className='inline-flex h-[54px] items-center justify-between self-stretch border-b border-gray-200 px-8 py-2'>
<div className='text-lg font-medium text-black'>참여한 세션 기록</div>
<div className='rounded-md px-3 py-2' />
<Button
className={`transition-colors duration-200 ${hideExpired ? 'bg-emerald-100' : 'bg-red-100'}`}
onClick={() => setHideExpired((prev) => !prev)}
>
<div className={`rounded-md text-xs font-medium ${hideExpired ? 'text-green-800' : 'text-red-600'}`}>
만료된 세션 {hideExpired ? '보이기' : '숨기기'}
</div>
</Button>
</div>
<div className='flex shrink grow basis-0 flex-col items-start justify-start gap-4 self-stretch overflow-y-auto px-8 py-2'>
{sessions?.map((session) => (
{sessions.map((session) => (
<SessionRecord
key={session.sessionId}
session={{
Expand Down
1 change: 1 addition & 0 deletions apps/client/tests/QnAPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ test.beforeEach(async ({ page }) => {
});

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

Expand Down
Loading