Skip to content

Commit

Permalink
feat: 답안 공유 URL 복사 기능
Browse files Browse the repository at this point in the history
[#2]
  • Loading branch information
YuHyun-P authored and flydog98 committed Dec 14, 2023
1 parent e82809b commit 4838fa9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/frontend/src/components/quiz/SolvedModal/SolvedModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRouter } from "next/router";

import { Button, Modal } from "../../../design-system/components/common";
import { Button, Modal, toast } from "../../../design-system/components/common";

import * as styles from "./SolvedModal.css";

Expand All @@ -22,6 +22,15 @@ export function SolvedModal({
router.push(link);
};

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(link);
toast.success("링크를 클립보드에 복사했습니다.");
} catch (error) {
toast.error("링크 복사를 실패했습니다. 잠시 후 다시 시도해 주세요.");
}
};

return (
<Modal onClose={onClose}>
<div className={styles.container}>
Expand All @@ -34,7 +43,11 @@ export function SolvedModal({
defaultValue={link}
readOnly
/>
<button type="button" className={styles.linkCopyButton}>
<button
type="button"
className={styles.linkCopyButton}
onClick={handleCopy}
>
URL 복사
</button>
</div>
Expand Down

0 comments on commit 4838fa9

Please sign in to comment.