Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

콜백 서비스 완료대기 -> 완료 시 콜백 내역 refetch 되지 않던 문제 해결 #213

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/common/register/hooks/useRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useNavigate } from 'react-router-dom';

import { AxiosError } from 'axios';

import { registerUser } from '../api';
import { registerUser } from '../apis';
import { SignupApiResponse } from '../types';
import { RouterPath } from '@/app/routes/path';
import { authStorage } from '@/shared/utils/storage';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/common/register/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export * from './data';
export * from './components';
export * from './types';
export * from './hooks';
export * from './api';
export * from './apis';
5 changes: 0 additions & 5 deletions src/pages/guard/guide-line/api/index.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/pages/guard/guide-line/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './view-specific-guideline.api';
export * from './view-senior-all-guideline.api';
export * from './modify-guideline.api';
export * from './add-guideline.api';
export * from './delete-guideline.api';
2 changes: 1 addition & 1 deletion src/pages/guard/guide-line/hooks/useAddGuideline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addGuideline } from '../api/add-guideline.api';
import { addGuideline } from '../apis/';
import { AddGuidelineRequest } from '../types';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/guide-line/hooks/useDeleteGuideline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deleteGuideline } from '../api';
import { deleteGuideline } from '../apis';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

export const useDeleteGuideline = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
getSeniorAllGuidelines,
getSeniorAllGuidelinesQueryKey,
} from '../api/view-senior-all-guideline.api';
} from '../apis';
import { SeniorAllGuideLineResponse } from '../types';
import { useQuery } from '@tanstack/react-query';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
getViewSpecificGuideline,
getViewSpecificGuidelineQueryKey,
} from '../api/view-specific-guideline.api';
getViewSpecificGuideline,
} from '../apis';
import { ViewSpecificGuidelineResponse } from '../types';
import { useQuery } from '@tanstack/react-query';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/guide-line/hooks/useModifyGuideline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { modifyGuideline } from '../api/modify-guideline.api';
import { modifyGuideline } from '../apis';
import { ModifyGuidelineRequest } from '../types';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/guide-line/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { GuideLinePage } from './ui';

export * from './api';
export * from './apis';
export * from './components';
export * from './data';
export * from './hooks';
Expand Down
1 change: 0 additions & 1 deletion src/pages/guard/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './guide-line';
export * from './mypage';
// export * from './point';
export * from './hello-call-apply';
export * from './register';
export * from './review';
Expand Down
5 changes: 0 additions & 5 deletions src/pages/guard/mypage/api/index.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/pages/guard/mypage/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './guard-information.api';
export * from './all-senior-info.api';
5 changes: 1 addition & 4 deletions src/pages/guard/mypage/hooks/useGetAllSeniorInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
allSeniorInfoPath,
getAllSeniorInfo,
} from '../api/all-senior-info.api';
import { allSeniorInfoPath, getAllSeniorInfo } from '../apis';
import { AllSeniorInfoResponse } from '../types';
import { useQuery } from '@tanstack/react-query';

Expand Down
3 changes: 1 addition & 2 deletions src/pages/guard/mypage/hooks/useGetGuardInformation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getGuardInformation } from '../api';
import { guardInformationPath } from '../api/guard-information.api';
import { getGuardInformation, guardInformationPath } from '../apis';
import { GuardInformationResponse } from '../types';
import { useQuery } from '@tanstack/react-query';

Expand Down
3 changes: 2 additions & 1 deletion src/pages/guard/mypage/hooks/useModifyGuardInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GuardInformationRequest, modifyGuardInformation } from '../';
import { modifyGuardInformation } from '../apis';
import { GuardInformationRequest } from '../types';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

// 본인 정보 수정
Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/mypage/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './ui';
export * from './components';
export * from './api';
export * from './apis';
export * from './hooks';
export * from './types';
5 changes: 0 additions & 5 deletions src/pages/guard/register/api/index.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/pages/guard/register/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './senior-info.api';
2 changes: 1 addition & 1 deletion src/pages/guard/register/hooks/useAddSeniorInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AxiosError } from 'axios';

import { addSeniorInfo } from '../api';
import { addSeniorInfo } from '../apis';
import { SeniorRegisterRequest } from '../types';
import { useMutation } from '@tanstack/react-query';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/register/hooks/useDeleteSeniorInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deleteSeniorInfo } from '../api';
import { deleteSeniorInfo } from '../apis';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

// 시니어 삭제 훅
Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/register/hooks/useEditSeniorInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { editSeniorInfo } from '../api';
import { editSeniorInfo } from '../apis';
import { SeniorRegisterRequest } from '../types';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/register/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './ui';
export * from './components';
export * from './data';
export * from './api';
export * from './apis';
export * from './hooks';
2 changes: 1 addition & 1 deletion src/pages/guard/review/hooks/usePostReview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { postReview } from '../api';
import { postReview } from '../apis';
import { ReviewRequest } from '../types';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/guard/review/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './ui';
export * from './api';
export * from './apis';
export * from './hooks';
17 changes: 6 additions & 11 deletions src/pages/guard/service-history/hooks/useCompleteCallback.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { completeCallback, getCallbackHistoryQueryKey } from '../apis';
import { queryClient } from '@/shared';
import { completeCallback } from '../apis';
import { useMutation, UseMutationResult } from '@tanstack/react-query';

export const useCompleteCallback = (): UseMutationResult<
string,
Error,
number
> => {
export const useCompleteCallback = (
refetch: () => void
): UseMutationResult<string, Error, number> => {
return useMutation({
mutationFn: (callbackId: number) => completeCallback(callbackId),
onSuccess: () => {
onSuccess: async () => {
alert('콜백 서비스를 완료 처리하였습니다.');
queryClient.invalidateQueries({
queryKey: getCallbackHistoryQueryKey(1),
});
refetch();
},
onError: (error: Error) => {
console.error(error);
Expand Down
7 changes: 3 additions & 4 deletions src/pages/guard/service-history/hooks/useHistoryData.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { useGetCallbackHistory, useGetHelloHistoryList } from '../hooks';

export const useHistoryData = (currentPage: number, pageSize: number) => {
const { data: callbackHistory } = useGetCallbackHistory(
currentPage,
pageSize
);
const { data: callbackHistory, refetch: refetchCallback } =
useGetCallbackHistory(currentPage, pageSize);
const { data: helloCallHistory, refetch } = useGetHelloHistoryList();

return {
callbackHistory,
helloCallHistory,
refetch,
refetchCallback,
};
};
5 changes: 3 additions & 2 deletions src/pages/guard/service-history/hooks/useServiceStatus.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useCompleteCallback } from '../hooks';
import { useCompleteCallback, useHistoryData } from '../hooks';
import { CallbackHistory } from '../types';

export const useServiceStatus = (historyData: CallbackHistory) => {
const completeCallbackMutation = useCompleteCallback();
const { refetchCallback } = useHistoryData(0, 20);
const completeCallbackMutation = useCompleteCallback(refetchCallback);

const serviceStatus = () => {
if (historyData.status === 'COMPLETE') {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/sinitto/mypage/hooks/useSinittoInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
modifySinittoBankInformation,
modifySinittoInformation,
registerSinittoBankInformation,
} from '../api/sinitto-information.api';
} from '../apis';
import {
SinittoBankInfo,
SinittoInfoRequest,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/sinitto/mypage/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './components';
export * from './api';
export * from './apis';
export * from './data';
export * from './hooks';
export * from './ui';
Empty file removed src/pages/sinitto/point/.gitkeep
Empty file.