-
Notifications
You must be signed in to change notification settings - Fork 1
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 #122 from kakao-tech-campus-2nd-step3/Weekly11
Master<-Weekly11
- Loading branch information
Showing
19 changed files
with
218 additions
and
82 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,40 @@ | ||
import { APIResponse, SearchProductsResponse } from '@/types'; | ||
import { useSuspenseInfiniteQuery } from '@tanstack/react-query'; | ||
import fetchInstance from '../instance'; | ||
import QueryKeys from '../queryKeys'; | ||
|
||
async function getWishes({ | ||
pageParam = 0, | ||
}: { | ||
pageParam: number; | ||
}): Promise<APIResponse<SearchProductsResponse>> { | ||
const size = 20; | ||
const response = await fetchInstance().get('/wishes', { | ||
params: { | ||
size, | ||
page: pageParam, | ||
}, | ||
}); | ||
return response.data; | ||
} | ||
|
||
const useGetWishes = () => { | ||
const queryResult = useSuspenseInfiniteQuery< | ||
APIResponse<SearchProductsResponse>, | ||
Error, | ||
APIResponse<SearchProductsResponse>, | ||
[string], | ||
number | ||
>({ | ||
queryKey: [QueryKeys.WISH_LIST], | ||
queryFn: ({ pageParam }) => getWishes({ pageParam }), | ||
initialPageParam: 0, | ||
getNextPageParam: (lastPage, allPages) => { | ||
return lastPage.data.hasNext ? allPages.length : undefined; | ||
}, | ||
}); | ||
|
||
return queryResult; | ||
}; | ||
|
||
export default useGetWishes; |
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,36 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
const LoaderWrapper = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
`; | ||
|
||
const Spinner = styled.div` | ||
border: 4px solid #f3f3f3; | ||
border-top: 4px solid #3498db; | ||
border-radius: 50%; | ||
width: 50px; | ||
height: 50px; | ||
animation: spin 1.5s linear infinite; | ||
@keyframes spin { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
`; | ||
|
||
const Loader = () => { | ||
return ( | ||
<LoaderWrapper> | ||
<Spinner /> | ||
</LoaderWrapper> | ||
); | ||
}; | ||
|
||
export default Loader; |
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
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
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
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
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
Oops, something went wrong.