Skip to content

Commit

Permalink
refactor: 이벤트핸들러 함수 따로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
CheeseB committed Mar 22, 2024
1 parent 4e5cf67 commit 85f0a73
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/components/mypage/MyPosts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const MyPosts = () => {

const pageSize = getPostPageSize(currentDeviceType);

const handleClickPage = (pageNumber: number) => setPage(pageNumber);
const handleSelectFilter = (selectedId: string) => setSelectFilter({ category: selectedId });
const handleOptionChange = (value: string | number) => setSortOption((prev) => ({ ...prev, order: value as Order }));

const { pagedDataList, totalCount } = useProcessedDataList({
initialDataList: MockApiResponse.activities,
selectFilter,
Expand All @@ -72,26 +76,14 @@ const MyPosts = () => {
<span className={cx('selected-game-count')}>{totalCount}</span>
</h2>
<div className={cx('dropdown', 'sm-only')}>
<Dropdown
options={dropdownOptions}
onChange={(value) => setSortOption((prev) => ({ ...prev, order: value as Order }))}
isSmall
/>
<Dropdown options={dropdownOptions} onChange={handleOptionChange} isSmall />
</div>
</div>
<div className={cx('card-area')}>
<div className={cx('filter-sort')}>
<Filter
items={GAME_FILTERS}
selectedFilterId={selectFilter.category}
onChange={(selectedId) => setSelectFilter({ category: selectedId })}
/>
<Filter items={GAME_FILTERS} selectedFilterId={selectFilter.category} onChange={handleSelectFilter} />
<div className={cx('dropdown', 'sm-hidden')}>
<Dropdown
options={dropdownOptions}
onChange={(value) => setSortOption((prev) => ({ ...prev, order: value as Order }))}
isSmall
/>
<Dropdown options={dropdownOptions} onChange={handleOptionChange} isSmall />
</div>
</div>
{totalCount ? (
Expand All @@ -113,12 +105,7 @@ const MyPosts = () => {
<EmptyCard text='No Post' />
)}
</div>
<Pagination
totalCount={totalCount}
pageState={page}
postPerPage={pageSize}
onClick={(pageNumber) => setPage(pageNumber)}
/>
<Pagination totalCount={totalCount} pageState={page} postPerPage={pageSize} onClick={handleClickPage} />
</div>
);
};
Expand Down

0 comments on commit 85f0a73

Please sign in to comment.