-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from Kernel360/page-feature-favorite-filter
페이지 기능: 즐겨찾기 페이지 필터 기능 추가
- Loading branch information
Showing
4 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { ComponentType, useEffect } from 'react'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
|
||
import { useAppSelector } from '@stores/hooks'; | ||
|
||
function withAuth<Props = Record<string, never>>( | ||
WrappedComponent: ComponentType<Props>, | ||
) { | ||
return function AuthenticatedComponent(props: Props) { | ||
const router = useRouter(); | ||
const userId = useAppSelector( | ||
(state) => { return state.user.id; }, | ||
(prev, curr) => { return prev === curr; }, | ||
); | ||
|
||
useEffect(() => { | ||
if (userId == null) { | ||
router.push('/login'); | ||
} | ||
}, [userId, router]); | ||
|
||
if (userId == null) { | ||
return null; | ||
} | ||
|
||
return <WrappedComponent {...(props as any)} />; | ||
}; | ||
} | ||
|
||
export default withAuth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { SearchFilterType } from '@/constants/searchByMap'; | ||
|
||
import { ProductListInfoType } from '../../types/home'; | ||
import { getRequest } from '../requests.api'; | ||
|
||
/* ----- like 제품 목록 api ----- */ | ||
export const getFavoriteList = async (pageNum: number, size: number) => { | ||
const response = await getRequest<ProductListInfoType>(`/likes?&page=${pageNum}&size=${size}`); | ||
export const getFavoriteList = async ( | ||
pageNum: number, | ||
size: number, | ||
sortType: SearchFilterType, | ||
) => { | ||
const response = await getRequest<ProductListInfoType>(`/likes?&sortType=${sortType}&page=${pageNum}&size=${size}`); | ||
|
||
return response; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters