Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 20 additions & 36 deletions src/pages/ListPage/components/MonthChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function MonthChart({ openModal }) {
const [chartIdolData, setChartIdolData] = useState([]);
const [nextCursorValue, setNextCursorValue] = useState(0);
const [moreButtonDisabled, setMoreButtonDisabled] = useState(false);
const [allButtonDisabled, setAllButtonDisabled] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [dataReload, setDataReload] = useState(true);

Expand Down Expand Up @@ -74,10 +73,8 @@ export default function MonthChart({ openModal }) {
setChartIdolData(idols);
setNextCursorValue(nextCursor);
setIsLoading(false);
setAllButtonDisabled(true);
} catch (error) {
console.error(error);
setAllButtonDisabled(false);
} finally {
setIsLoading(false);
}
Expand All @@ -99,15 +96,6 @@ export default function MonthChart({ openModal }) {
}
}, [nextCursorValue]);

// 페이지 처음 로드할 때 불러온 차트내용이 전부이면 더보기 버튼 안보이게 하기
useEffect(() => {
if (nextCursorValue === null) {
setAllButtonDisabled(false);
} else {
setAllButtonDisabled(true);
}
}, []);

if (isLoading) {
return (
<LoadingSpinner
Expand Down Expand Up @@ -142,30 +130,26 @@ export default function MonthChart({ openModal }) {
chartIdolData={chartIdolData}
handleClickDataReload={() => handleClickDataReload()}
/>
{allButtonDisabled ? (
<ChartMoreButton>
<button
type="button"
onClick={() => {
handleClickMoreButton();
}}
className={moreButtonDisabled ? 'none' : ''}
>
더보기
</button>
<button
type="button"
onClick={() => {
handleClickShortButton();
}}
className={moreButtonDisabled ? '' : 'none'}
>
접기
</button>
</ChartMoreButton>
) : (
''
)}
<ChartMoreButton>
<button
type="button"
onClick={() => {
handleClickMoreButton();
}}
className={moreButtonDisabled ? 'none' : ''}
>
더보기
</button>
<button
type="button"
onClick={() => {
handleClickShortButton();
}}
className={moreButtonDisabled ? '' : 'none'}
>
접기
</button>
</ChartMoreButton>
</MyCreditWrap>
);
}
Expand Down