diff --git a/src/components/IdolCard.jsx b/src/components/IdolCard.jsx index 4b4c700..d63a8fc 100644 --- a/src/components/IdolCard.jsx +++ b/src/components/IdolCard.jsx @@ -1,40 +1,61 @@ -import React, { useState } from 'react'; +import React from 'react'; import checkIcon from '@/assets/images/check.png'; -const IdolCard = ({ idol }) => { - const [isSelected, setIsSelected] = useState(false); +const IdolCard = ({ + children, + idol, + isSelectable = true, + isSelected = false, + isDisabled = false, + sizeClass = 'w-[98px] h-[98px] tablet:w-[128px] tablet:h-[128px]', + onClick, +}) => { const defaultImage = 'https://link24.kr/9iFIhh0'; - console.log('IdolCard 받은 데이터:', idol); - return ( -
+
setIsSelected(!isSelected)} + className={`relative ${sizeClass} p-[2px] flex items-center justify-center rounded-full + ${isDisabled ? 'opacity-50 cursor-not-allowed' : isSelectable ? 'cursor-pointer' : 'cursor-default'} transition-all`} // 비활성화된 경우 투명도 50% + onClick={ + !isDisabled && isSelectable ? () => onClick(idol.id) : undefined + } // 비활성화된 경우 클릭 방지 > -
+ {children} +
-
+
{idol?.name
- {isSelected && ( -
+ {/* 비활성화된 경우 클릭 차단 & 마우스 금지 커서 적용 */} + {isDisabled && ( +
)} - {isSelected && ( - check + {isSelected && isSelectable && ( + <> +
+ check + )}
+ +
+

{idol.name}

+

{idol.group || '그룹 없음'}

+
); }; diff --git a/src/components/IdolImage.jsx b/src/components/IdolImage.jsx deleted file mode 100644 index d2c99bb..0000000 --- a/src/components/IdolImage.jsx +++ /dev/null @@ -1,48 +0,0 @@ -import React, { useState, useEffect } from "react"; - -const ImageWithBorder = ({ borderColor = "#f96868", size = "128px" }) => { - const [imageSrc, setImageSrc] = useState(""); - - useEffect(() => { - - setImageSrc("https://via.placeholder.com/150"); - }, []); - - if (!imageSrc) { - return
Loading...
; - } - - return ( -
-
-
- Profile -
-
- ); -}; - -export default ImageWithBorder; diff --git a/src/pages/myPage/CheckedIdolCard.jsx b/src/pages/myPage/CheckedIdolCard.jsx deleted file mode 100644 index 01b8c3d..0000000 --- a/src/pages/myPage/CheckedIdolCard.jsx +++ /dev/null @@ -1,61 +0,0 @@ -import React from 'react'; -import checkIcon from '@/assets/images/check.png'; - -const CheckedIdolCard = ({ - children, - idol, - isSelectable = true, - isSelected = false, - isDisabled = false, - sizeClass = 'w-[98px] h-[98px] tablet:w-[128px] tablet:h-[128px]', - onClick, -}) => { - const defaultImage = 'https://link24.kr/9iFIhh0'; - - return ( -
-
onClick(idol.id) : undefined} // 비활성화된 경우 클릭 방지 - > - {children} -
- -
- {idol.name} -
- - {/* 비활성화된 경우 클릭 차단 & 마우스 금지 커서 적용 */} - {isDisabled && ( -
- )} - - {isSelected && isSelectable && ( - <> -
- check - - )} -
- -
-

{idol.name}

-

{idol.group || '그룹 없음'}

-
-
- ); -}; - -export default CheckedIdolCard; diff --git a/src/pages/myPage/MyPage.jsx b/src/pages/myPage/MyPage.jsx index 501fb2b..ce8bc8f 100644 --- a/src/pages/myPage/MyPage.jsx +++ b/src/pages/myPage/MyPage.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import Header from '@/components/Header'; -import CheckedIdolCard from '@/pages/myPage/CheckedIdolCard'; +import IdolCard from '@/components/IdolCard'; import nextIcon from '@/assets/icons/nextIcon.svg'; import prevIcon from '@/assets/icons/prevIcon.svg'; import { fetchIdols } from '@/apis/myPageApi.js'; @@ -100,7 +100,7 @@ const MyPage = () => { return (
- { className="absolute -top-0 -right-[0] w-7 h-7 z-50 flex items-center justify-center bg-transparent transition-opacity cursor-pointer" > - Remove + Remove - +
); })}
- +

관심 있는 아이돌을 추가해보세요.

- -
- {/* 아이돌 리스트 */} -
- {idols.slice(currentPage * itemsPerPage, (currentPage + 1) * itemsPerPage).map((idol) => { - const isDisabled = favoriteIdols.includes(idol.id); - - return ( -
- { - if (isDisabled) { - e.preventDefault(); - return; - } - handleToggle(idol.id); - }} - /> -
- ); - })} -
+
+ {idols + .slice(currentPage * itemsPerPage, (currentPage + 1) * itemsPerPage) + .map((idol) => { + const isDisabled = favoriteIdols.includes(idol.id); + return ( +
+ { + if (isDisabled) { + e.preventDefault(); + return; + } + handleToggle(idol.id); + }} + /> +
+ ); + })} +
- + > + Next +
- -