Skip to content

Commit

Permalink
refactor: Type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
DaeHee99 committed Dec 16, 2024
2 parents 778e71a + 028e70a commit a515060
Show file tree
Hide file tree
Showing 102 changed files with 1,501 additions and 896 deletions.
46 changes: 0 additions & 46 deletions src/api/article.js

This file was deleted.

44 changes: 44 additions & 0 deletions src/api/article.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { DELETE, GET, POST, PUT } from "../utils/axios";

export const getArticleList = async (type: string, page: number) =>
await GET(`/article?type=${type}&page=${page}`);

export const getArticleDetail = async (articleId: string) =>
await GET(`/article/${articleId}`, true);

export const getMyArticleList = async (page: number) =>
await GET(`/article/my?page=${page}`, true);

export const getMyCommentList = async (page: number) =>
await GET(`/article/comment/my?page=${page}`, true);

export const postNewArticle = async (body: any) =>
await POST(`/article`, body, true);

export const updateMyArticle = async (articleId: string, body: any) =>
await PUT(`/article/${articleId}`, body, true);

export const deleteMyArticle = async (articleId: number) =>
await DELETE(`/article/${articleId}`, true);

export const postNewComment = async (articleId: string, comment: string) =>
await POST(`/article/comment/${articleId}?content=${comment}`, {}, true);

export const deleteMyComment = async (commentId: number) =>
await DELETE(`/article/comment/${commentId}`, true);

export const postNewReply = async (commentId: number, reply: string) =>
await POST(`/article/reply/${commentId}?content=${reply}`, {}, true);

export const deleteMyReply = async (replyId: number) =>
await DELETE(`/article/reply/${replyId}`, true);

export const searchArticle = async (
keyword: string,
type: string,
page: number
) =>
await GET(
`/article/search?type=${type}&keyword=${keyword}&page=${page}`,
true
);
4 changes: 2 additions & 2 deletions src/api/card.js → src/api/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { GET, POST, DELETE } from "../utils/axios";

export const getCard = async () => await GET("/card", true);

export const postCard = async (body) => await POST("/card", body, true);
export const postCard = async (body: any) => await POST("/card", body, true);

export const deleteCard = async () => await DELETE("/card", true);

export const postPaymentAgain = async (reservationId) =>
export const postPaymentAgain = async (reservationId: number) =>
await POST(`/card/${reservationId}`, {}, true);

export const getMyPaymentList = async () => await GET("/payment/my", true);
18 changes: 9 additions & 9 deletions src/api/chat.js → src/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ import { DELETE, GET, POST } from "../utils/axios";

export const getChatList = async () => await GET("/chat/list", true);

export const getChatRoomData = async (chatRoomId) =>
export const getChatRoomData = async (chatRoomId: number) =>
await GET(`/chat/${chatRoomId}`, true);

export const inviteMemberAPI = async (chatRoomId, userIds) =>
export const inviteMemberAPI = async (chatRoomId: number, userIds: string) =>
await POST(`/chat/invite/${chatRoomId}?userId=${userIds}`, {}, true);

export const leaveChat = async (chatRoomId) =>
export const leaveChat = async (chatRoomId: number) =>
await DELETE(`/chat/leave/${chatRoomId}`, true);

export const makeNewGroupChat = async (userIds, roomName) =>
export const makeNewGroupChat = async (userIds: string, roomName: string) =>
await GET(`/chat/groupChat?userId=${userIds}&roomName=${roomName}`, true);

export const makeNewCoupleChat = async (userId) =>
export const makeNewCoupleChat = async (userId: number) =>
await GET(`/chat/coupleChat?userId=${userId}`, true);

export const getPartyChatId = async (partyId) =>
export const getPartyChatId = async (partyId: number) =>
await GET(`/chat/party/${partyId}`, true);

export const getChatBlockList = async () => await GET("/chat/block", true);

export const blockUser = async (userId) =>
export const blockUser = async (userId: number) =>
await POST(`/chat/block/${userId}`, {}, true);

export const nonBlockUser = async (userId) =>
export const nonBlockUser = async (userId: number) =>
await DELETE(`/chat/block/${userId}`, true);

export const kickPartyChatUser = async (chatRoomId, userId) =>
export const kickPartyChatUser = async (chatRoomId: number, userId: number) =>
await DELETE(`/chat/party/${chatRoomId}?userId=${userId}`, true);
12 changes: 0 additions & 12 deletions src/api/course.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/api/course.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { DELETE, GET, POST, PUT } from "../utils/axios";

export const getCourseDetail = async (courseId: number | string) =>
await GET(`/course/${courseId}`, true);

export const postNewCourse = async (body: any) =>
await POST("/course", body, true);

export const putCourseDetail = async (courseId: string, body: any) =>
await PUT(`/course/${courseId}`, body, true);

export const deleteCourse = async (courseId: string) =>
await DELETE(`/course/${courseId}`, true);
39 changes: 0 additions & 39 deletions src/api/destination.js

This file was deleted.

41 changes: 41 additions & 0 deletions src/api/destination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { GET, POST, PUT, DELETE } from "../utils/axios";

export const getAllMarkers = async () => await GET("/destination/map", true);

export const getSearchInfo = async (searchKeyword: string) =>
await GET(`/destination?keyword=${searchKeyword}`, true);

export const getDestinationDetail = async (destinationId: number) =>
await GET(`/destination/${destinationId}`, true);

export const postDestinationComment = async (
data: any,
destinationId: number
) => await POST(`/destination/review/${destinationId}`, data, true);

export const putDestinationComment = async (data: any, reviewId: number) =>
await PUT(`/destination/review/${reviewId}`, data, true);

export const deleteDestinationComment = async (reviewId: number) =>
await DELETE(`/destination/review/${reviewId}`, true);

export const postLikeDestination = async (destinationId: number) =>
await POST(`/destination/dibs/${destinationId}`, {}, true);

export const deleteUnLikeDestination = async (destinationId: number) =>
await DELETE(`/destination/dibs/${destinationId}`, true);

export const getLikeDestination = async () =>
await GET(`/destination/dibs`, true);

export const postNewDestinationUser = async (body: any) =>
await POST("/destination/by-user", body, true);

export const postNewDestinationAdmin = async (body: any) =>
await POST("/destination", body, true);

export const putDestinationAdmin = async (data: any, destinationId: number) =>
await PUT(`/destination/${destinationId}`, data, true);

export const deleteDestinationAdmin = async (destinationId: number) =>
await DELETE(`/destination/${destinationId}`, true);
26 changes: 16 additions & 10 deletions src/api/driver.js → src/api/driver.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import { POST, GET, PUT, DELETE } from "../utils/axios";

export const getRegionDriver = async (region, member, date) =>
export const getRegionDriver = async (
region: string,
member: number,
date: string
) =>
await GET(
`/driver/search?region=${region}&headcount=${member}&startDate=${date}`,
true
);

export const getDriverInfo = async (driverId) =>
export const getDriverInfo = async (driverId: string | number) =>
await GET(`/driver/${driverId}`, true);

export const postComment = async (data, driverId) =>
export const postComment = async (data: any, driverId: number) =>
await POST(`/driver/review/${driverId}`, data, true);

export const putComment = async (data, reviewId) =>
export const putComment = async (data: any, reviewId: number) =>
await PUT(`/driver/review/${reviewId}`, data, true);

export const deleteComment = async (reviewId) =>
export const deleteComment = async (reviewId: number) =>
await DELETE(`/driver/review/${reviewId}`, true);

export const getDriverMyInfo = async () => await GET("/driver/my", true);

export const putDriverMyInfo = async (data) =>
export const putDriverMyInfo = async (data: any) =>
await PUT("/driver/my", data, true);

export const getDriverApply = async () => await GET("/driver/apply", true);

export const postDriverApply = async (data) =>
export const postDriverApply = async (data: any) =>
await POST("/driver/apply", data, true);

export const putDriverApply = async (data) =>
export const putDriverApply = async (data: any) =>
await PUT("/driver/apply", data, true);

export const deleteDriverApply = async () =>
Expand All @@ -37,5 +41,7 @@ export const deleteDriverApply = async () =>
export const getDriverApplyAdmin = async () =>
await GET("/driver/accept", true);

export const putDriverApplyAcceptAdmin = async (driverId, accept) =>
await PUT(`/driver/accept/${driverId}?accept=${accept}`, {}, true);
export const putDriverApplyAcceptAdmin = async (
driverId: string,
accept: boolean
) => await PUT(`/driver/accept/${driverId}?accept=${accept}`, {}, true);
9 changes: 5 additions & 4 deletions src/api/image.js → src/api/image.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { BASE_SERVER_URL } from "../utils/env";
import axios from "axios";

export const uploadProfileImage = async (image) => {
export const uploadProfileImage = async (image: File) => {
try {
const formData = new FormData();
formData.append("file", image);

const config = {
baseURL: import.meta.env.VITE_BASE_SERVER_URL,
baseURL: BASE_SERVER_URL,
withCredentials: true,
headers: {
"Contest-Type": "multipart/form-data",
Expand All @@ -20,13 +21,13 @@ export const uploadProfileImage = async (image) => {
}
};

export const uploadImage = async (image) => {
export const uploadImage = async (image: File) => {
try {
const formData = new FormData();
formData.append("file", image);

const config = {
baseURL: import.meta.env.VITE_BASE_SERVER_URL,
baseURL: BASE_SERVER_URL,
withCredentials: true,
headers: {
"Contest-Type": "multipart/form-data",
Expand Down
2 changes: 1 addition & 1 deletion src/api/income.js → src/api/income.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GET } from "../utils/axios";

export const getDriverMonthlyIncome = async (month) =>
export const getDriverMonthlyIncome = async (month: string) =>
await GET(`/income/monthly?month=${month}`, true);

export const getCommisionRate = async () =>
Expand Down
10 changes: 5 additions & 5 deletions src/api/notification.js → src/api/notification.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { GET, PUT, DELETE, POST } from "../utils/axios";
import { GET, PUT, DELETE } from "../utils/axios";

export const getNotification = async () => await GET("/notification", true);

export const putNotification = async (notificationId) =>
export const putNotification = async (notificationId: number) =>
await PUT(`/notification/${notificationId}`, {}, true);

export const deleteNotification = async (notificationId) =>
export const deleteNotification = async (notificationId: number) =>
await DELETE(`/notification/${notificationId}`, true);

export const putAllNotification = async () =>
await PUT("/notification/all", {}, true);

export const putFirebaseToken = async (body) =>
export const putFirebaseToken = async (body: any) =>
await PUT("/firebase", body, true);

export const deleteFirebaseToken = async (body) =>
export const deleteFirebaseToken = async (body: any) =>
await DELETE("/firebase", true, body);
Loading

0 comments on commit a515060

Please sign in to comment.