-
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.
시니또용 콜백 페이지 api 및 기능 구현
- Loading branch information
Showing
41 changed files
with
518 additions
and
91 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
src/pages/sinitto/call-back/detail/api/accept-call-back.api.ts
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,9 @@ | ||
import { fetchInstance } from '@/shared/api/instance'; | ||
|
||
const getacceptCallbackPath = (callbackId: number) => | ||
`/api/callbacks/accept/${callbackId}`; | ||
|
||
export const acceptCallback = async (callbackId: number) => { | ||
const response = await fetchInstance.put(getacceptCallbackPath(callbackId)); | ||
return response.data; | ||
}; |
9 changes: 9 additions & 0 deletions
9
src/pages/sinitto/call-back/detail/api/cancel-call-back.api.ts
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,9 @@ | ||
import { fetchInstance } from '@/shared/api/instance'; | ||
|
||
const getCancelCallbackPath = (callbackId: number) => | ||
`/api/callbacks/cancel/${callbackId}`; | ||
|
||
export const CancelCallback = async (callbackId: number) => { | ||
const response = await fetchInstance.put(getCancelCallbackPath(callbackId)); | ||
return response.data; | ||
}; |
9 changes: 9 additions & 0 deletions
9
src/pages/sinitto/call-back/detail/api/complete-call-back.api.ts
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,9 @@ | ||
import { fetchInstance } from '@/shared/api/instance'; | ||
|
||
const getCompleteCallbackPath = (callbackId: number) => | ||
`/api/callbacks/complete/${callbackId}`; | ||
|
||
export const CompleteCallback = async (callbackId: number) => { | ||
const response = await fetchInstance.put(getCompleteCallbackPath(callbackId)); | ||
return response.data; | ||
}; |
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,9 @@ | ||
import { fetchInstance } from '@/shared/api/instance'; | ||
import type { CallbackResponse } from '@/shared/types'; | ||
|
||
const getAcceptedPath = () => `/api/callbacks/sinitto/accepted`; | ||
|
||
export const getAccepted = async () => { | ||
const response = await fetchInstance.get<CallbackResponse>(getAcceptedPath()); | ||
return response.data; | ||
}; |
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,4 @@ | ||
export { useAcceptCallback } from './useAcceptCallback'; | ||
export { useCancelCallback } from './useCancelCallback'; | ||
export { useCompleteCallback } from './useCompleteCallback'; | ||
export { useGetAccepted } from './useGetAccepted'; |
14 changes: 14 additions & 0 deletions
14
src/pages/sinitto/call-back/detail/api/hooks/useAcceptCallback.ts
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,14 @@ | ||
import { acceptCallback } from '../accept-call-back.api'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
export const useAcceptCallback = () => { | ||
return useMutation({ | ||
mutationFn: acceptCallback, | ||
onSuccess: () => { | ||
alert('콜백 요청이 수락되었습니다.'); | ||
}, | ||
onError: (error) => { | ||
alert(`콜백 요청 수락 신청 중 오류가 발생했습니다: ${error.message}`); | ||
}, | ||
}); | ||
}; |
14 changes: 14 additions & 0 deletions
14
src/pages/sinitto/call-back/detail/api/hooks/useCancelCallback.ts
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,14 @@ | ||
import { CancelCallback } from '../cancel-call-back.api'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
export const useCancelCallback = () => { | ||
return useMutation({ | ||
mutationFn: CancelCallback, | ||
onSuccess: () => { | ||
alert('진행중인 콜백 서비스가 취소되었습니다.'); | ||
}, | ||
onError: (error) => { | ||
alert(`콜백 서비스 취소 중 오류가 발생했습니다: ${error.message}`); | ||
}, | ||
}); | ||
}; |
14 changes: 14 additions & 0 deletions
14
src/pages/sinitto/call-back/detail/api/hooks/useCompleteCallback.ts
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,14 @@ | ||
import { CompleteCallback } from '../complete-call-back.api'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
export const useCompleteCallback = () => { | ||
return useMutation({ | ||
mutationFn: CompleteCallback, | ||
onSuccess: () => { | ||
alert('진행중인 콜백 서비스가 완료되었습니다.'); | ||
}, | ||
onError: (error) => { | ||
alert(`콜백 서비스 완료 중 오류가 발생했습니다: ${error.message}`); | ||
}, | ||
}); | ||
}; |
10 changes: 10 additions & 0 deletions
10
src/pages/sinitto/call-back/detail/api/hooks/useGetAccepted.ts
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,10 @@ | ||
import { getAccepted } from '../get-accepted.api'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export const useGetAccepted = () => { | ||
return useQuery({ | ||
queryKey: ['acceptedCallback'], | ||
queryFn: getAccepted, | ||
staleTime: 0, | ||
}); | ||
}; |
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,4 @@ | ||
export { acceptCallback } from './accept-call-back.api'; | ||
export { CancelCallback } from './cancel-call-back.api'; | ||
export { CompleteCallback } from './complete-call-back.api'; | ||
export { getAccepted } from './get-accepted.api'; |
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
60 changes: 60 additions & 0 deletions
60
src/pages/sinitto/call-back/detail/components/menu/CallbackMenu.tsx
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,60 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { | ||
useAcceptCallback, | ||
useCancelCallback, | ||
useCompleteCallback, | ||
} from '../../api/hooks'; | ||
import { PostAcceptMenu } from '../../components/menu/post-accept'; | ||
import { PreAcceptMenu } from '../../components/menu/pre-accept'; | ||
import { Spinner } from '@chakra-ui/react'; | ||
|
||
type MenuProps = { | ||
callBackId: number; | ||
accept: boolean; | ||
}; | ||
|
||
export const CallbackMenu = ({ callBackId, accept }: MenuProps) => { | ||
const navigate = useNavigate(); | ||
|
||
const { | ||
mutate: acceptCallback, | ||
isPending: isAcceptLoading, | ||
isSuccess: isAcceptSuccess, | ||
} = useAcceptCallback(); | ||
if (isAcceptSuccess) { | ||
window.location.reload(); | ||
} | ||
|
||
const { | ||
mutate: completeCallback, | ||
isPending: isCompleteLoading, | ||
isSuccess: isCompleteSuccess, | ||
} = useCompleteCallback(); | ||
if (isCompleteSuccess) { | ||
navigate('/call-back'); // TODO: 완료 이후 이동 페이지 지정 필요 | ||
} | ||
|
||
const { | ||
mutate: cancelCallback, | ||
isPending: isCancelLoading, | ||
isSuccess: isCancelSuccess, | ||
} = useCancelCallback(); | ||
if (isCancelSuccess) { | ||
navigate('/call-back'); // TODO: 취소 이후 이동 페이지 지정 필요 | ||
} | ||
|
||
const isLoading = isAcceptLoading || isCancelLoading || isCompleteLoading; | ||
|
||
return isLoading ? ( | ||
<Spinner size='xl' marginTop='30px' /> | ||
) : accept ? ( | ||
<PostAcceptMenu | ||
handleComplete={() => completeCallback(callBackId)} | ||
handleCancle={() => cancelCallback(callBackId)} | ||
phoneNumber='010-1234-5678' // TODO: api로 콜백 조회 시 response에 전화번호 추가 필요 | ||
/> | ||
) : ( | ||
<PreAcceptMenu handleClick={() => acceptCallback(callBackId)} /> | ||
); | ||
}; |
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,2 +1 @@ | ||
export * from './post-accept'; | ||
export * from './pre-accept'; | ||
export { CallbackMenu } from './CallbackMenu'; |
10 changes: 5 additions & 5 deletions
10
src/pages/sinitto/call-back/detail/data/guide-line/guid-line-categories.ts
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,22 +1,22 @@ | ||
export const GUIDE_LINE_CATEGORIES = [ | ||
{ | ||
title: '택시 호출하기', | ||
id: 'taxi', | ||
id: 'TAXI', | ||
backgroundColor: '#81b6ff', | ||
}, | ||
{ | ||
title: '드라마 방영시간 알려주기', | ||
id: 'drama', | ||
title: '음식 배달 주문하기', | ||
id: 'DELIVERY', | ||
backgroundColor: '#b28bff', | ||
}, | ||
{ | ||
title: '서류 제출 도와주기', | ||
id: 'document', | ||
id: null, | ||
backgroundColor: '#ffa7b5', | ||
}, | ||
{ | ||
title: '대중교통 이동 도와주기', | ||
id: 'document', | ||
id: null, | ||
backgroundColor: '#ff4d68', | ||
}, | ||
]; |
Oops, something went wrong.