@@ -13,7 +13,7 @@ export const useTicketOptions = (ticketId: number) => {
1313
1414// 티켓 옵션 응답 전송
1515export const useCreateTicketOptionAnswers = ( ) => {
16- return useMutation < TicketResponse , Error , TicketOptionAnswerRequest > ( {
16+ return useMutation < TicketResponse , Error , TicketOptionAnswerRequest > ( {
1717 mutationFn : createTicketOptionAnswers ,
1818 onSuccess : ( ) => {
1919 console . log ( "티켓 옵션 응답 전송 성공" ) ;
@@ -26,18 +26,28 @@ export const useCreateTicketOptionAnswers = () => {
2626
2727// 티켓 옵션 응답 전체 조회
2828export const usePurchaserAnswers = ( ticketId : number | null ) => {
29- return useQuery < { isSuccess : boolean ; result : TicketOptionAnswerResponse [ ] } > ( {
30- queryKey : [ 'purchaserAnswers' , ticketId ] ,
31- queryFn : ( ) => readPurchaserAnswers ( ticketId ! ) ,
32- enabled : ! ! ticketId ,
33- } ) ;
29+ return useQuery < { isSuccess : boolean ; result : TicketOptionAnswerResponse [ ] } > ( {
30+ queryKey : [ 'purchaserAnswers' , ticketId ] ,
31+ queryFn : ( ) => {
32+ if ( ticketId === null ) {
33+ throw new Error ( "ticketId is required" ) ;
34+ }
35+ return readPurchaserAnswers ( ticketId ) ;
36+ } ,
37+ enabled : ! ! ticketId ,
38+ } ) ;
3439} ;
3540
3641// 티켓 옵션 응답 개별 조회
3742export const usePersonalTicketOptionAnswers = ( ticketId : number | null ) => {
38- return useQuery < { isSuccess : boolean ; result : PersonalTicketOptionAnswerResponse [ ] } > ( {
39- queryKey : [ 'personalTicketOptionAnswers' , ticketId ] ,
40- queryFn : ( ) => readPersonalTicketOptionAnswers ( ticketId ! ) ,
41- enabled : ! ! ticketId ,
42- } ) ;
43+ return useQuery < { isSuccess : boolean ; result : PersonalTicketOptionAnswerResponse [ ] } > ( {
44+ queryKey : [ 'personalTicketOptionAnswers' , ticketId ] ,
45+ queryFn : ( ) => {
46+ if ( ticketId === null ) {
47+ throw new Error ( "ticketId is required" ) ;
48+ }
49+ return readPersonalTicketOptionAnswers ( ticketId ) ;
50+ } ,
51+ enabled : ! ! ticketId ,
52+ } ) ;
4353} ;
0 commit comments