-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: queryClient, interestMutation 추가
- Loading branch information
1 parent
dcd38a6
commit 543bbaa
Showing
11 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
import axios from 'axios'; | ||
|
||
export const axiosInstance = axios.create({ | ||
withCredentials: true, | ||
}); |
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,21 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { axiosInstance } from '@/api/axiosInstance'; | ||
import { AxiosError, AxiosResponse } from 'axios'; | ||
|
||
interface postMutationParams { | ||
interestList: string[]; | ||
} | ||
|
||
export const postMutation = ({ interestList }: postMutationParams) => { | ||
return axiosInstance.post('/inbox/interests', { | ||
interests: interestList.map(data => { | ||
return { category: data }; | ||
}), | ||
}); | ||
}; | ||
|
||
export const useInterestMutation = () => { | ||
return useMutation<AxiosResponse, AxiosError, postMutationParams>({ | ||
mutationFn: postMutation, | ||
}); | ||
}; |
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,25 @@ | ||
'use client'; | ||
import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; | ||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; | ||
import { useState } from 'react'; | ||
|
||
export default function ReactQueryProviders({ children }: React.PropsWithChildren) { | ||
const [client] = useState( | ||
new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
refetchOnWindowFocus: false, | ||
refetchOnMount: false, | ||
retry: 1, | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
return ( | ||
<QueryClientProvider client={client}> | ||
{children} | ||
<ReactQueryDevtools initialIsOpen={false} /> | ||
</QueryClientProvider> | ||
); | ||
} |
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,19 +1,19 @@ | ||
import type { Metadata } from 'next'; | ||
import type { PropsWithChildren } from 'react'; | ||
import ReactQueryProviders from '@/api/queryClient'; | ||
import '@/styles/tailwind.css'; | ||
|
||
export const metadata: Metadata = { | ||
title: 'InspoMailClub', | ||
description: 'Your Daily Insight Source', | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
export default function RootLayout({ children }: Readonly<PropsWithChildren>) { | ||
return ( | ||
<html lang='ko'> | ||
<body className='flex flex-col items-center w-full'>{children}</body> | ||
<body className='flex flex-col items-center w-full'> | ||
<ReactQueryProviders>{children}</ReactQueryProviders> | ||
</body> | ||
</html> | ||
); | ||
} |
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