File tree Expand file tree Collapse file tree 8 files changed +31
-28
lines changed
Expand file tree Collapse file tree 8 files changed +31
-28
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import TreeStatusCard from '@pages/level/components/TreeStatusCard';
66import { getTreeLevel } from '@shared/utils/treeLevel' ;
77import { TreeLevel } from '@pages/level/types/treeLevelType' ;
88import { Badge } from '@pinback/design-system/ui' ;
9- import { useGetArcons } from '. /apis/queries' ;
9+ import { useGetArcons } from '@shared /apis/queries' ;
1010
1111export default function Level ( ) {
1212 const { data, isPending, isError } = useGetArcons ( ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import apiRequest from '@shared/apis/setting/axiosInstance' ;
2+ import { formatLocalDateTime } from '@shared/utils/formatDateTime' ;
23
34export const getDashboardCategories = async ( ) => {
45 const { data } = await apiRequest . get ( '/api/v1/categories/dashboard' ) ;
@@ -11,3 +12,11 @@ export const postCategory = async (categoryName: string) => {
1112 } ) ;
1213 return response ;
1314} ;
15+
16+ export const getAcorns = async ( ) => {
17+ const now = formatLocalDateTime ( new Date ( ) ) ;
18+ const { data } = await apiRequest . get ( '/api/v1/users/acorns?now=' , {
19+ params : { now } ,
20+ } ) ;
21+ return data . data ;
22+ } ;
Original file line number Diff line number Diff line change 11import { useMutation , useQuery , UseQueryResult } from '@tanstack/react-query' ;
22import { getDashboardCategories , postCategory } from '@shared/apis/axios' ;
33import { AxiosError } from 'axios' ;
4- import { DashboardCategoriesResponse } from '@shared/types/api' ;
4+ import { DashboardCategoriesResponse , AcornsResponse } from '@shared/types/api' ;
5+ import { getAcorns } from './axios' ;
56
67export const useGetDashboardCategories = ( ) : UseQueryResult <
78 DashboardCategoriesResponse ,
@@ -18,3 +19,10 @@ export const usePostCategory = () => {
1819 mutationFn : ( categoryName : string ) => postCategory ( categoryName ) ,
1920 } ) ;
2021} ;
22+
23+ export const useGetArcons = ( ) : UseQueryResult < AcornsResponse , AxiosError > => {
24+ return useQuery ( {
25+ queryKey : [ 'arcons' ] ,
26+ queryFn : ( ) => getAcorns ( ) ,
27+ } ) ;
28+ } ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import PopupPortal from './PopupPortal';
1313import {
1414 useGetDashboardCategories ,
1515 usePostCategory ,
16+ useGetArcons ,
1617} from '@shared/apis/queries' ;
1718import { useState } from 'react' ;
1819import { useQueryClient } from '@tanstack/react-query' ;
@@ -23,6 +24,7 @@ export function Sidebar() {
2324
2425 const { data : categories } = useGetDashboardCategories ( ) ;
2526 const { mutate : createCategory } = usePostCategory ( ) ;
27+ const { data, isPending, isError } = useGetArcons ( ) ;
2628
2729 const {
2830 activeTab,
@@ -65,6 +67,10 @@ export function Sidebar() {
6567 } ) ;
6668 } ;
6769
70+ if ( isPending ) return console . log ( '로딩중...' ) ;
71+ if ( isError ) return console . log ( '에러...' ) ;
72+ const acornCount = data . acornCount ;
73+
6874 return (
6975 < aside className = "bg-white-bg sticky top-0 h-screen w-[24rem] border-r border-gray-300" >
7076 < div className = "flex h-full flex-col px-[0.8rem]" >
@@ -134,7 +140,7 @@ export function Sidebar() {
134140
135141 < footer className = "pb-[2.8rem] pt-[1.2rem]" >
136142 < MyLevelItem
137- acorns = { 0 }
143+ acorns = { acornCount }
138144 isActive = { activeTab === 'level' }
139145 onClick = { ( ) => {
140146 setSelectedCategoryId ( null ) ;
Original file line number Diff line number Diff line change @@ -7,3 +7,8 @@ export interface Category {
77export interface DashboardCategoriesResponse {
88 categories : Category [ ] ;
99}
10+
11+ export type AcornsResponse = {
12+ acornCount : number ;
13+ remindDateTime : string ;
14+ } ;
You can’t perform that action at this time.
0 commit comments