Skip to content

Commit

Permalink
🚧 get challenge status
Browse files Browse the repository at this point in the history
  • Loading branch information
w00khyung committed Dec 15, 2023
1 parent b759c95 commit 0ebf334
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
10 changes: 10 additions & 0 deletions app/(route)/(index)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
'use client'

import Image from 'next/image'

import { useChallengesQuery } from './queries'

export default function HomePage() {
const challengesQuery = useChallengesQuery()

if (!challengesQuery.isSuccess) {
return null
}

return (
<div className='relative h-full px-8 py-4 pt-16'>
<h1 className='text-2xl'>오늘의 도달률</h1>
Expand Down
14 changes: 14 additions & 0 deletions app/(route)/(index)/queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useQuery } from '@tanstack/react-query'

import { getChallenges } from '@/app/_service/challenge'

const QUERY_KEY = {
challenges: ['challenges'],
}

export const useChallengesQuery = () => {
return useQuery({
queryKey: QUERY_KEY.challenges,
queryFn: () => getChallenges(),
})
}
6 changes: 3 additions & 3 deletions app/(route)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import localFont from 'next/font/local'
import type { Metadata } from 'next'

import '@/app/_styles/globals.css'
import Providers from '@/app/_components/providers/QueryClientProvider'

import { cn } from '../_styles/utils'
import CoreProvider from '@/app/_components/providers/CoreProvider'
import { cn } from '@/app/_styles/utils'

const myFont = localFont({
src: '../_assets/fonts/PretendardVariable.woff2',
Expand All @@ -25,7 +25,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<link rel='icon' href='../../favicon.ico' sizes='any' />
</head>
<body className={cn(myFont.className, 'mx-auto max-w-lg text-white')}>
<Providers>{children}</Providers>
<CoreProvider>{children}</CoreProvider>
</body>
</html>
)
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions app/_service/challenge/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import api from '../core/api'

export const getChallenges = () => {
return api.get('/challenges')
}
1 change: 0 additions & 1 deletion app/_service/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getApiEndpoint } from './api.utils'
const createApi = () => {
const _api = axios.create({
baseURL: getApiEndpoint(),
// withCredentials: true,
headers: {
'Content-Type': 'application/json',
},
Expand Down

0 comments on commit 0ebf334

Please sign in to comment.