Skip to content

Commit

Permalink
fix: 클래스별 매출 페이지 그래프-쿼리 무효화 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
seoyeon08 committed Jul 8, 2024
1 parent e7f74ab commit b4b8124
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pages/mypage/SalesYear.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ import { useNavigate, useParams } from 'react-router-dom';
import { Topbar } from '../../components/common/Topbar';
import { LineChart } from '../../components/molecules/LineChart';
import { Calculator } from '../../components/molecules/Calculator';
import { useQuery } from '@tanstack/react-query';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { ApiClient } from '../../apis/apiClient';
import { useEffect, useMemo } from 'react';

export const SalesYear = () => {
const { year, lesson_id } = useParams<{ year: string; lesson_id: string }>();
const navigate = useNavigate();
const queryClient = useQueryClient();

useEffect(() => {
queryClient.invalidateQueries({ queryKey: ['lessonRevenue', lesson_id] });
}, [year, lesson_id, queryClient]);

// api 호출
const { data: lessonRevenue } = useQuery({
queryKey: ['monthRevenue', lesson_id],
queryKey: ['lessonRevenue', lesson_id],
queryFn: async () => {
const response = await ApiClient.getInstance().getLessonRevenue(
Number(year),
Expand Down

0 comments on commit b4b8124

Please sign in to comment.