Skip to content

Commit 13f25cd

Browse files
committed
feat: add session link sharing
1 parent 4a83cf4 commit 13f25cd

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { IoClose, IoShareSocialOutline } from 'react-icons/io5';
55

66
import { useModal } from '@/features/modal';
77
import { useSessionStore } from '@/features/session';
8+
import { useToastStore } from '@/features/toast';
89

910
import {
1011
Button,
@@ -15,8 +16,16 @@ import QuestionSection from '@/components/qna/QuestionSection';
1516
import SessionSettingsDropdown from '@/components/qna/SessionSettingsDropdown';
1617

1718
function QuestionList() {
18-
const { sessionTitle, expired, isHost, questions, setSelectedQuestionId } =
19-
useSessionStore();
19+
const {
20+
isHost,
21+
expired,
22+
questions,
23+
sessionId,
24+
sessionTitle,
25+
setSelectedQuestionId,
26+
} = useSessionStore();
27+
28+
const { addToast } = useToastStore();
2029

2130
const { Modal: CreateQuestion, openModal: openCreateQuestionModal } =
2231
useModal(<CreateQuestionModal />);
@@ -60,7 +69,24 @@ function QuestionList() {
6069
{
6170
icon: <IoShareSocialOutline />,
6271
label: '공유',
63-
onClick: () => {},
72+
onClick: async () => {
73+
const shareUrl = `${window.location.origin}/session/${sessionId}`;
74+
75+
try {
76+
await navigator.clipboard.writeText(shareUrl);
77+
addToast({
78+
type: 'SUCCESS',
79+
message: '세션 링크가 클립보드에 복사되었습니다',
80+
duration: 3000,
81+
});
82+
} catch (err) {
83+
addToast({
84+
type: 'ERROR',
85+
message: '링크 복사에 실패했습니다',
86+
duration: 3000,
87+
});
88+
}
89+
},
6490
},
6591
{
6692
icon: <GrValidate />,

0 commit comments

Comments
 (0)