|
1 | | -import SlideText from "@/components/atoms/common/slideText"; |
| 1 | +import Play from "@/components/atoms/admin/play"; |
2 | 2 | import ControllerStyle from "./controller.style"; |
| 3 | +import ListOption from "@/components/atoms/admin/listOption"; |
| 4 | +import SoundBar from "@/components/atoms/admin/soundBar"; |
| 5 | +import SlideText from "@/components/atoms/common/slideText"; |
3 | 6 | import TrackController from "@/components/atoms/common/trackController"; |
4 | 7 | import { useYoutube } from "@/hooks/useYoutube"; |
| 8 | +import { useParams } from "next/navigation"; |
| 9 | +import { useAlert } from "@/hooks/useAlert"; |
5 | 10 |
|
6 | 11 | const Dump = { |
7 | | - title: "재생 중인 음악이 없습니다.", |
| 12 | + title: "노래를 추가해주세요.", |
8 | 13 | }; |
9 | 14 |
|
10 | 15 | const Controller = () => { |
11 | | - const { current } = useYoutube(); |
| 16 | + const { id } = useParams<{ id: string }>(); |
| 17 | + const { current, loopList } = useYoutube(); |
| 18 | + const { addMessage } = useAlert(); |
12 | 19 |
|
13 | 20 | const playing = current || Dump; |
14 | 21 |
|
| 22 | + const handleCopyLink = () => { |
| 23 | + const textArea = document.createElement("textarea"); |
| 24 | + textArea.value = `${window.location.origin}/client/${id}`; |
| 25 | + |
| 26 | + document.body.prepend(textArea); |
| 27 | + textArea.select(); |
| 28 | + |
| 29 | + try { |
| 30 | + document.execCommand("copy"); |
| 31 | + addMessage({ |
| 32 | + message: "링크가 복사되었습니다.", |
| 33 | + type: "notification", |
| 34 | + onConfirm: () => { |
| 35 | + textArea.remove(); |
| 36 | + }, |
| 37 | + }); |
| 38 | + } catch (error) { |
| 39 | + console.error(error); |
| 40 | + } finally { |
| 41 | + textArea.remove(); |
| 42 | + } |
| 43 | + }; |
| 44 | + |
15 | 45 | return ( |
16 | 46 | <ControllerStyle.Container> |
17 | | - <ControllerStyle.Title> |
18 | | - <SlideText>{playing.title}</SlideText> |
19 | | - </ControllerStyle.Title> |
| 47 | + <ControllerStyle.TopController> |
| 48 | + <TrackController leftTooltip /> |
20 | 49 |
|
21 | | - <TrackController /> |
| 50 | + <ControllerStyle.PlayingBox> |
| 51 | + <ListOption type="link" onClick={handleCopyLink} /> |
| 52 | + <ListOption type="loop" isActive onClick={loopList} /> |
| 53 | + </ControllerStyle.PlayingBox> |
| 54 | + </ControllerStyle.TopController> |
| 55 | + {/* */} |
| 56 | + <ControllerStyle.InfoBox> |
| 57 | + <ControllerStyle.LeftController> |
| 58 | + <ControllerStyle.MusicTitle> |
| 59 | + <SlideText>{playing.title}</SlideText> |
| 60 | + </ControllerStyle.MusicTitle> |
| 61 | + <SoundBar /> |
| 62 | + </ControllerStyle.LeftController> |
| 63 | + {/* */} |
| 64 | + <Play /> |
| 65 | + </ControllerStyle.InfoBox> |
22 | 66 | </ControllerStyle.Container> |
23 | 67 | ); |
24 | 68 | }; |
|
0 commit comments