-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 결제 페이지 옵션 응답 API 연동 #141
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f6b889f
refact: 결제 로직 변경 및 order api 호출 위치 변경
hyeeuncho 2c562d0
fix: email-edit 페이지 수정
hyeeuncho e174dc0
fix: 로그인 후 모달 닫기
hyeeuncho e70ea28
feat: 결제 페이지 티켓 옵션 조회, 응답 API 연동
hyeeuncho 535a5d6
refact: 코드 수정
hyeeuncho e92528d
fix:충돌수정
hyeeuncho 78027f8
refact: 불필요한 타입 삭제
hyeeuncho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,33 +1,28 @@ | ||
| import { create } from "zustand"; | ||
|
|
||
| export interface TOption { | ||
| type: string; | ||
| optionName: string; | ||
| required: boolean; | ||
| choices: string[]; | ||
| } | ||
|
|
||
| interface TicketOptionState { | ||
| currentPage: number; | ||
| setCurrentPage: (page: number) => void; | ||
|
|
||
| selectedOptions: { [index: number]: { [key: string]: string | string[] } }; | ||
| setOption: (index: number, optionName: string, value: string | string[]) => void; | ||
| selectedOptions: { [page: number]: { [optionId: number]: string | number | number[] } }; | ||
| setOption: (page: number, optionId: number, value: string | number | number[]) => void; | ||
| resetOptions: () => void; | ||
| } | ||
|
|
||
| export const useTicketOptionStore = create<TicketOptionState>((set) => ({ | ||
| currentPage: 1, | ||
| setCurrentPage: (page: number) => set({ currentPage: page }), | ||
|
|
||
| selectedOptions: {}, | ||
| setOption: (index, optionName, value) => { | ||
| setOption: (index, optionId, value) => { | ||
| set((state) => { | ||
| const updatedSelectedOptions = { ...state.selectedOptions }; | ||
| if (!updatedSelectedOptions[index]) { | ||
| updatedSelectedOptions[index] = {}; | ||
| } | ||
| updatedSelectedOptions[index][optionName] = value; | ||
| updatedSelectedOptions[index][optionId] = value; | ||
| return { selectedOptions: updatedSelectedOptions }; | ||
| }); | ||
| }, | ||
| resetOptions: () => set({ selectedOptions: {}, currentPage: 1 }), | ||
| })); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
| import { useMutation, useQuery } from '@tanstack/react-query'; | ||
| import { cancelTickets, orderTickets, readTicket } from '../api/order'; | ||
| import { OrderTicketRequest } from '../model/orderInformation'; | ||
|
|
||
| // 주문 전체 조회 | ||
| export const useTicketOrders = (page: number = 0, size: number = 10) => { | ||
| return useQuery({ | ||
| queryKey: ['ticketOrders', page, size], | ||
| queryFn: () => readTicket.getAll(page, size), | ||
| }); | ||
| }; | ||
|
|
||
| // 주문 상세 조회 | ||
| export const useTicketOrderDetail = (ticketId: number, eventId: number) => { | ||
| return useQuery({ | ||
| queryKey: ['ticketOrderDetail', ticketId, eventId], | ||
| queryFn: () => readTicket.getDetail(ticketId, eventId), | ||
| enabled: !!ticketId && !!eventId, | ||
| }); | ||
| }; | ||
|
|
||
| // 주문 취소 | ||
| export const useCancelTicket = () => { | ||
| return useMutation({ | ||
| mutationFn: (orderId: number) => cancelTickets(orderId), | ||
| onSuccess: () => { | ||
| alert('티켓이 성공적으로 취소되었습니다.'); | ||
| }, | ||
| onError: () => { | ||
| alert('티켓 취소에 실패하였습니다.'); | ||
| }, | ||
| }); | ||
| }; | ||
|
|
||
| // 티켓 구매 | ||
| export const useOrderTicket = () => { | ||
| return useMutation({ | ||
| mutationFn: (data: OrderTicketRequest) => orderTickets(data), | ||
| onError: () => { | ||
| alert("티켓 구매 중 오류가 발생했습니다."); | ||
| }, | ||
hyeeuncho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
| }; | ||
This file contains hidden or 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 hidden or 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,19 @@ | ||
| export interface OrderTicketRequest { | ||
| ticketId: number; | ||
| eventId: number; | ||
| ticketCnt: number; | ||
| } | ||
| export interface TicketConfirm { | ||
| id: number; | ||
| title: string; | ||
| startDate: string; | ||
| ticketName: string; | ||
| hostChannelName: string; | ||
| hostChannelDescription: string; | ||
| organizerEmail: string; | ||
| organizerPhoneNumber: string; | ||
| eventAddress: string; | ||
| locationLat: number; | ||
| locationLng: number; | ||
| orderStatus: "COMPLETED" | "PENDING" | "CANCELLED"; | ||
| }; |
This file contains hidden or 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,59 @@ | ||
| export interface CreateTicketRequest { | ||
| eventId: number; | ||
| ticketType: string; | ||
| ticketName: string; | ||
| ticketDescription: string; | ||
| ticketPrice: number; | ||
| availableQuantity: number; | ||
| startDate: string; | ||
| endDate: string; | ||
| startTime: string; | ||
| endTime: string; | ||
| } | ||
|
|
||
| export interface TicketResponse { | ||
| isSuccess: boolean; | ||
| code: string; | ||
| message: string; | ||
| result: string; // "ticketId: 2" | ||
| } | ||
|
|
||
| export interface ReadTicketResponse { | ||
| ticketId: number; | ||
| ticketName: string; | ||
| ticketDescription: string; | ||
| ticketPrice: number; | ||
| availableQuantity: number; | ||
| } | ||
|
|
||
| export interface TicketOptionChoice { | ||
| id: number; | ||
| name: string; | ||
| } | ||
| export interface TicketOptionResponse { | ||
| id: number; | ||
| name: string; | ||
| description: string; | ||
| type: 'SINGLE' | 'MULTIPLE' | 'TEXT'; | ||
| isMandatory: boolean; | ||
| choices: TicketOptionChoice[]; | ||
| } | ||
|
|
||
| // 텍스트 | ||
| export interface TicketOptionAnswerTextRequest { | ||
| ticketOptionId: number; | ||
| answerText: string; | ||
| } | ||
|
|
||
| // 선택지 | ||
| export interface TicketOptionAnswerChoiceRequest { | ||
| ticketOptionId: number; | ||
| ticketOptionChoiceId: number; | ||
| } | ||
|
|
||
| // 티켓 옵션 응답 | ||
| export interface TicketOptionAnswerRequest { | ||
| ticketOptionId: number; | ||
| answerText?: string; | ||
| ticketOptionChoiceId?: number; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.