-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/SCBJ-7/SCBJ-FE into feat/#163…
…-purchaselist-api
- Loading branch information
Showing
64 changed files
with
899 additions
and
471 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
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,8 @@ | ||
import { END_POINTS } from "@constants/api"; | ||
import { axiosInstance } from "./axiosInstance"; | ||
import { AlarmType } from "@type/alarm"; | ||
|
||
export const fetchAlarm = async (): Promise<AlarmType[]> => { | ||
const { data } = await axiosInstance.get(END_POINTS.ALARM); | ||
return data.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,8 @@ | ||
import { END_POINTS } from "@constants/api"; | ||
import { axiosInstance } from "./axiosInstance"; | ||
import { ReadType } from "@type/alarm"; | ||
|
||
export const fetchHasAlarm = async (): Promise<ReadType> => { | ||
const { data } = await axiosInstance.get(END_POINTS.HASALARM); | ||
return data.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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import { LocaleItemsType, WeekendItem } from "./../types/saleSection"; | ||
import { axiosInstance } from "@apis/axiosInstance"; | ||
import { END_POINTS } from "@/constants/api"; | ||
|
||
// 유저 정보를 불러오는 api입니다. | ||
export const fetchMainItem = async () => { | ||
export const fetchMainItem = async (): Promise< | ||
[LocaleItemsType, WeekendItem[]] | ||
> => { | ||
const { data } = await axiosInstance.get( | ||
END_POINTS.MAIN + | ||
"?cityNames=서울&cityNames=강원&cityNames=부산&cityNames=제주&cityNames=경상&cityNames=전라", | ||
); | ||
console.log(data.data); | ||
return data.data; | ||
const { weekend, ...locale } = data.data; | ||
const temp = weekend.content; | ||
|
||
return [locale, temp]; | ||
}; |
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,7 +1,11 @@ | ||
import { axiosInstance } from "@apis/axiosInstance"; | ||
import { END_POINTS } from "@constants/api"; | ||
import type { ResponseData } from "@type/responseType"; | ||
import type { RoomData } from "@type/room"; | ||
|
||
export const getRoom = async (roomId: string) => { | ||
const { data } = await axiosInstance.get(END_POINTS.ROOM(roomId)); | ||
export const getRoom = async (roomId: string): Promise<RoomData> => { | ||
const { data } = await axiosInstance.get<ResponseData<RoomData>>( | ||
END_POINTS.ROOM(roomId), | ||
); | ||
return data.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 { axiosInstance } from "@apis/axiosInstance"; | ||
import { ACCESS_TOKEN, END_POINTS, REFRESH_TOKEN } from "@/constants/api"; | ||
|
||
export const logout = async () => { | ||
await axiosInstance.post(`${END_POINTS.USER_INFO}/logout`, { | ||
accessToken: localStorage.getItem(ACCESS_TOKEN), | ||
refreshToken: localStorage.getItem(REFRESH_TOKEN), | ||
}); | ||
}; |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import { getRoom } from "@apis/fetchRoom"; | ||
import { calculateDiscount } from "@utils/calculator"; | ||
|
||
import type { RoomData } from "@type/room"; | ||
import type { AxiosError } from "axios"; | ||
|
||
interface RoomQueryData { | ||
rawData: RoomData; | ||
discountRate: string; | ||
} | ||
|
||
export const useRoomQuery = (roomId: string) => { | ||
return useSuspenseQuery<RoomData, AxiosError, RoomQueryData>({ | ||
queryKey: ["room", roomId], | ||
queryFn: () => getRoom(roomId), | ||
select: (data) => { | ||
const discountRate = calculateDiscount( | ||
data.originalPrice, | ||
data.sellingPrice, | ||
); | ||
return { | ||
rawData: data, | ||
discountRate, | ||
}; | ||
}, | ||
}); | ||
}; |
Oops, something went wrong.