-
Notifications
You must be signed in to change notification settings - Fork 5
[Refactor] #100 - Refactoring snake_case to camelCase #101
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,60 @@ | ||
| import { Booth, BoothsElement } from "@interfaces/booth"; | ||
| import { BoothStatus, WaitingStatus } from "@linenow-types/status"; | ||
|
|
||
| export interface Image { | ||
| interface Image { | ||
| image: string; | ||
| } | ||
|
|
||
| // Booth ์ธํฐํ์ด์ค ์ ์ | ||
| export interface Booth { | ||
| interface Menu { | ||
| name: string; | ||
| price: string; | ||
| } | ||
|
|
||
| export interface GetBoothResponse { | ||
| id: number; | ||
| name?: string; | ||
| description?: string; | ||
| location?: string; | ||
| caution?: string; | ||
| name: string; | ||
| description: string; | ||
| location: string; | ||
| caution: string; | ||
|
|
||
| is_operated: BoothStatus; | ||
| images?: Image[]; | ||
| menu?: { name: string; price: number }[]; | ||
| images: Image[]; | ||
| menu: Menu[]; | ||
|
|
||
| open_time: string; | ||
| close_time?: string; | ||
| waiting_count?: number; | ||
| is_waiting?: boolean; | ||
| waiting_status?: WaitingStatus; | ||
| close_time: string; | ||
|
|
||
| waiting_count: number; | ||
| total_waiting_teams: number; | ||
| waiting_teams_ahead: number; | ||
|
|
||
| is_waiting: boolean; | ||
| waiting_id?: number; | ||
| total_waiting_teams?: number; | ||
| waiting_teams_ahead?: number; | ||
| waiting_status: WaitingStatus; | ||
| } | ||
|
|
||
| // GetBoothResponse ํจ์ ์ ์ | ||
| export const GetBoothResponse = (response: Booth): Booth => { | ||
| export interface GetBoothsResponse | ||
| extends Array<{ | ||
| id: number; | ||
| name: string; | ||
| description: string; | ||
| location: string; | ||
|
|
||
| is_operated: BoothStatus; | ||
| thumbnail: string; | ||
|
|
||
| waiting_count: number; | ||
| total_waiting_teams: number; | ||
|
|
||
| is_waiting: boolean; | ||
| waiting_status: WaitingStatus | null; | ||
| }> {} | ||
|
|
||
| export const transformGetBoothResponse = ( | ||
| response: GetBoothResponse | ||
| ): Booth => { | ||
| return { | ||
| id: response.id, | ||
| boothID: response.id, | ||
| name: response.name, | ||
| description: response.description, | ||
| location: response.location, | ||
|
|
@@ -38,14 +65,31 @@ export const GetBoothResponse = (response: Booth): Booth => { | |
| name: item.name, | ||
| price: item.price, | ||
| })) || [], | ||
| open_time: response.open_time, | ||
| close_time: response.close_time, | ||
| waiting_count: response.waiting_count, | ||
| is_waiting: response.is_waiting, | ||
| waiting_status: response.waiting_status, | ||
| is_operated: response.is_operated, | ||
| waiting_id: response.waiting_id, | ||
| total_waiting_teams: response.total_waiting_teams, | ||
| waiting_teams_ahead: response.waiting_teams_ahead, | ||
| openTime: response.open_time, | ||
| closeTime: response.close_time, | ||
| waitingCount: response.waiting_count, | ||
| isWaiting: response.is_waiting, | ||
| waitingStatus: response.waiting_status, | ||
| isOperated: response.is_operated, | ||
| waitingID: response.waiting_id, | ||
| totalWaitingTeams: response.total_waiting_teams, | ||
| waitingTeamsAhead: response.waiting_teams_ahead, | ||
|
Comment on lines
+68
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good |
||
| }; | ||
| }; | ||
|
|
||
| export const transformgetBoothsResponse = ( | ||
| response: GetBoothsResponse | ||
| ): BoothsElement[] => { | ||
| return response.map((item) => ({ | ||
| boothID: item.id, | ||
| name: item.name, | ||
| thumbnail: item.thumbnail, | ||
| description: item.description, | ||
| location: item.location, | ||
| isOperated: item.is_operated, | ||
| waitingCount: item.waiting_count, | ||
| totalWaitingTeams: item.total_waiting_teams, | ||
| isWaiting: item.is_waiting, | ||
| waitingStatus: item.waiting_status, | ||
| })); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,41 @@ | ||
| // api method | ||
| import { getResponse } from "@apis/instance"; | ||
| import { Booth, GetBoothResponse } from "./_interfaces"; | ||
|
|
||
| // types | ||
| import { Booth, BoothsElement } from "@interfaces/booth"; | ||
| import { | ||
| GetBoothResponse, | ||
| GetBoothsResponse, | ||
| transformGetBoothResponse, | ||
| transformgetBoothsResponse, | ||
| } from "./_interfaces"; | ||
|
|
||
| // get booth : - ๋ถ์ค ์์ธ | ||
| export interface GetBoothRequest { | ||
| boothId: number; | ||
| boothID: number; | ||
| } | ||
|
|
||
| export const getBooth = async ({ | ||
| boothId, | ||
| ...props | ||
| }: GetBoothRequest): Promise<Booth | null> => { | ||
| const response = await getResponse<Booth>(`/api/v1/booths/${boothId}`); | ||
| const response = await getResponse<GetBoothResponse>( | ||
| `/api/v1/booths/${props.boothID}` | ||
| ); | ||
|
|
||
| return response ? transformGetBoothResponse(response) : null; | ||
| }; | ||
|
|
||
| // get booths : - ๋ถ์ค ๋ฆฌ์คํธ | ||
| export interface GetBoothsRequest { | ||
| ordering: string; | ||
| } | ||
|
|
||
| export const getBoothList = async ({ | ||
| ...props | ||
| }: GetBoothsRequest): Promise<BoothsElement[]> => { | ||
| const response = await getResponse<GetBoothsResponse>( | ||
| `/api/v1/booths?ordering=${props.ordering}` | ||
| ); | ||
|
|
||
| return response ? GetBoothResponse(response) : null; | ||
| return response ? transformgetBoothsResponse(response) : []; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export const BOOTH_QUERY_KEY = { | ||
| BOOTH: "booth", | ||
| BOOTHS: "booths", | ||
| }; |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { postResponse } from "@apis/instance"; | ||
| import { postResponseNew } from "@apis/instance"; | ||
| import { Waiting } from "@interfaces/waiting"; | ||
| import { WaitingStatus } from "@linenow-types/status"; | ||
|
|
||
|
|
@@ -13,6 +13,7 @@ export interface GetWaitingResponse { | |
| // confirmed_at?: string; | ||
| // canceled_at?: string; | ||
| waiting_teams_ahead: number; | ||
| total_waiting_teams: number; | ||
| confirm_due_time: string; | ||
| arrival_due_time: string; | ||
| } | ||
|
|
@@ -34,8 +35,9 @@ export const transformGetWaitingResponse = ( | |
| waitingID: response.id, | ||
| waitingStatus: response.waiting_status, | ||
| waitingTeamsAhead: response.waiting_teams_ahead, | ||
| totalWaitingTeams: response.total_waiting_teams, | ||
|
|
||
| party_size: response.party_size, | ||
| partySize: response.party_size, | ||
|
|
||
| confirmDueTime: response.confirm_due_time, | ||
| arrivalarrivalDueTime: response.arrival_due_time, | ||
|
|
@@ -63,25 +65,32 @@ export const transformGetWaitingsResponse = ( | |
|
|
||
| // ๋๊ธฐ ์ค์๊ธฐ ๋ฑ๋ก ์์ฒญ ์ธํฐํ์ด์ค | ||
| export interface RegisterWaitingRequest { | ||
| boothId: number; | ||
| boothID: number; | ||
| partySize: number; | ||
| } | ||
|
|
||
| interface PostWaitingRegisterBody { | ||
| party_size: number; | ||
| } | ||
|
|
||
| export interface PostWaitingRegisterProps extends Waiting { | ||
| id?: number; | ||
| export interface PostWaitingRegisterResponse { | ||
| id: number; | ||
| } | ||
|
|
||
| // ๋๊ธฐ ์ค์๊ธฐ ๋ฑ๋ก ํจ์ | ||
| export const postWaitingRegister = async ({ | ||
| boothId, | ||
| party_size, | ||
| }: RegisterWaitingRequest): Promise<PostWaitingRegisterProps | null> => { | ||
| const response = await postResponse<PostWaitingRegisterProps>( | ||
| `api/v1/waitings/${boothId}/register`, | ||
| { party_size } | ||
| ); | ||
| ...props | ||
| }: RegisterWaitingRequest): Promise<PostWaitingRegisterResponse | null> => { | ||
| const response = await postResponseNew< | ||
| PostWaitingRegisterBody, | ||
| PostWaitingRegisterResponse | ||
| >(`api/v1/waitings/${props.boothID}/register`, { | ||
| party_size: props.partySize, | ||
| }); | ||
|
Comment on lines
81
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๋ณ๊ฒฝ ๋ฐฉ์ ๋ง์์ ๋๋ค์!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ์ฌ๊ฐ ๋ฉ์ง์๋ค์ |
||
|
|
||
| if (response) { | ||
| return response; | ||
| } else { | ||
| throw new Error("post error"); | ||
| } | ||
| return null; | ||
| }; | ||
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array ํ์ฅํด์ ์ฐ๋ ๋ฐฉ์ ์ข๋ค์!