1- import React from 'react'
1+ import React , { useState } from 'react'
2+ import { useNavigate } from 'react-router-dom'
23
34import styled , { useTheme } from 'styled-components'
45
@@ -7,6 +8,7 @@ import type { CdMetaResponse } from '@/entities/playlist'
78import { useLike } from '@/features/like'
89import { getNextId } from '@/shared/lib'
910import { myCdButton } from '@/shared/styles/mixins'
11+ import { Modal } from '@/shared/ui'
1012import SvgButton from '@/shared/ui/SvgButton'
1113
1214interface LikeButtonProps {
@@ -23,13 +25,16 @@ const ICON_STYLE = {
2325} as const
2426
2527const LikeButton = ( { playlistId, type = 'HOME' , playlistData, activeIndex } : LikeButtonProps ) => {
28+ const [ isModalOpen , setIsModalOpen ] = useState ( false )
2629 const theme = useTheme ( )
30+ const navigate = useNavigate ( )
2731 const { liked, toggleLike } = useLike ( playlistId , {
2832 shouldNavigate : type === 'MY' ,
2933 getNextId : ( ) => {
3034 if ( ! playlistData || activeIndex === undefined ) return undefined
3135 return getNextId ( activeIndex , playlistData )
3236 } ,
37+ openLoginModal : ( ) => setIsModalOpen ( true ) ,
3338 } )
3439
3540 const handleClick = ( e : React . MouseEvent < HTMLButtonElement > ) => {
@@ -41,25 +46,45 @@ const LikeButton = ({ playlistId, type = 'HOME', playlistData, activeIndex }: Li
4146 const opacity = type === 'HOME' ? ( liked ? 1 : 0.2 ) : 1
4247
4348 return (
44- < Wrapper $opacity = { opacity } $isMy = { type === 'MY' } >
45- < SvgButton
46- icon = { Icon }
47- onClick = { handleClick }
48- width = { size }
49- height = { size }
50- fill = {
51- type === 'HOME'
52- ? liked
53- ? theme . COLOR [ 'primary-normal' ]
54- : theme . COLOR [ 'gray-200' ]
55- : liked
56- ? theme . COLOR [ 'primary-normal' ]
57- : 'none'
58- }
59- stroke = { liked ? theme . COLOR [ 'primary-normal' ] : theme . COLOR [ 'gray-200' ] }
60- />
61- { type === 'MY' && < p > μ’μμ</ p > }
62- </ Wrapper >
49+ < >
50+ < Wrapper $opacity = { opacity } $isMy = { type === 'MY' } >
51+ < SvgButton
52+ icon = { Icon }
53+ onClick = { handleClick }
54+ width = { size }
55+ height = { size }
56+ fill = {
57+ type === 'HOME'
58+ ? liked
59+ ? theme . COLOR [ 'primary-normal' ]
60+ : theme . COLOR [ 'gray-200' ]
61+ : liked
62+ ? theme . COLOR [ 'primary-normal' ]
63+ : 'none'
64+ }
65+ stroke = { liked ? theme . COLOR [ 'primary-normal' ] : theme . COLOR [ 'gray-200' ] }
66+ />
67+ { type === 'MY' && < p > μ’μμ</ p > }
68+ </ Wrapper >
69+
70+ { isModalOpen && (
71+ < Modal
72+ isOpen = { isModalOpen }
73+ title = "λ‘κ·ΈμΈ ν μ΄μ©ν μ μμ΄μ"
74+ ctaType = "double"
75+ onConfirm = { ( ) => {
76+ navigate ( '/login' )
77+ setIsModalOpen ( false )
78+ } }
79+ onCancel = { ( ) => {
80+ setIsModalOpen ( false )
81+ } }
82+ onClose = { ( ) => setIsModalOpen ( false ) }
83+ confirmText = "λ‘κ·ΈμΈνκΈ°"
84+ cancelText = "λ€μμ νκΈ°"
85+ />
86+ ) }
87+ </ >
6388 )
6489}
6590
0 commit comments