Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
669 changes: 669 additions & 0 deletions apps/web/src/apis/.bruno-cache/hashes.json

Large diffs are not rendered by default.

30 changes: 14 additions & 16 deletions apps/web/src/apis/Admin/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,34 +143,32 @@ export interface GpaListResponse {
}

export const adminApi = {
putVerifyLanguageTest: async (params: {
languageTestScoreId: string | number;
data?: VerifyLanguageTestRequest;
}): Promise<VerifyLanguageTestResponse> => {
putVerifyLanguageTest: async (params: { languageTestScoreId: string | number, data?: VerifyLanguageTestRequest }): Promise<VerifyLanguageTestResponse> => {
const res = await axiosInstance.put<VerifyLanguageTestResponse>(
`/admin/scores/language-tests/${params.languageTestScoreId}`,
params?.data,
`/admin/scores/language-tests/${params.languageTestScoreId}`, params?.data
);
return res.data;
},

getLanguageTestList: async (params: { params?: Record<string, any> }): Promise<LanguageTestListResponse> => {
const res = await axiosInstance.get<LanguageTestListResponse>(`/admin/scores/language-tests?page=1&size=10`, {
params: params?.params,
});
const res = await axiosInstance.get<LanguageTestListResponse>(
`/admin/scores/language-tests?page=1&size=10`, { params: params?.params }
);
return res.data;
},

putVerifyGpa: async (params: {
gpaScoreId: string | number;
data?: VerifyGpaRequest;
}): Promise<VerifyGpaResponse> => {
const res = await axiosInstance.put<VerifyGpaResponse>(`/admin/scores/gpas/${params.gpaScoreId}`, params?.data);
putVerifyGpa: async (params: { gpaScoreId: string | number, data?: VerifyGpaRequest }): Promise<VerifyGpaResponse> => {
const res = await axiosInstance.put<VerifyGpaResponse>(
`/admin/scores/gpas/${params.gpaScoreId}`, params?.data
);
return res.data;
},

getGpaList: async (params: { params?: Record<string, any> }): Promise<GpaListResponse> => {
const res = await axiosInstance.get<GpaListResponse>(`/admin/scores/gpas`, { params: params?.params });
const res = await axiosInstance.get<GpaListResponse>(
`/admin/scores/gpas`, { params: params?.params }
);
return res.data;
},
};

};
6 changes: 3 additions & 3 deletions apps/web/src/apis/Admin/getGpaList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AxiosError } from "axios";
import { useQuery } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { adminApi, GpaListResponse } from "./api";
import { QueryKeys } from "../queryKeys";
import { adminApi, type GpaListResponse } from "./api";

const useGetGpaList = (params?: Record<string, any>) => {
return useQuery<GpaListResponse, AxiosError>({
Expand All @@ -10,4 +10,4 @@ const useGetGpaList = (params?: Record<string, any>) => {
});
};

export default useGetGpaList;
export default useGetGpaList;
6 changes: 3 additions & 3 deletions apps/web/src/apis/Admin/getLanguageTestList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AxiosError } from "axios";
import { useQuery } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { adminApi, LanguageTestListResponse } from "./api";
import { QueryKeys } from "../queryKeys";
import { adminApi, type LanguageTestListResponse } from "./api";

const useGetLanguageTestList = (params?: Record<string, any>) => {
return useQuery<LanguageTestListResponse, AxiosError>({
Expand All @@ -10,4 +10,4 @@ const useGetLanguageTestList = (params?: Record<string, any>) => {
});
};

export default useGetLanguageTestList;
export default useGetLanguageTestList;
10 changes: 5 additions & 5 deletions apps/web/src/apis/Admin/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { adminApi } from "./api";
export { default as getGpaList } from "./getGpaList";
export { default as getLanguageTestList } from "./getLanguageTestList";
export { default as putVerifyGpa } from "./putVerifyGpa";
export { default as putVerifyLanguageTest } from "./putVerifyLanguageTest";
export { adminApi } from './api';
export { default as getGpaList } from './getGpaList';
export { default as getLanguageTestList } from './getLanguageTestList';
export { default as putVerifyGpa } from './putVerifyGpa';
export { default as putVerifyLanguageTest } from './putVerifyLanguageTest';
6 changes: 3 additions & 3 deletions apps/web/src/apis/Admin/putVerifyGpa.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AxiosError } from "axios";
import { useMutation } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { adminApi, type VerifyGpaRequest, type VerifyGpaResponse } from "./api";
import { adminApi, VerifyGpaResponse, VerifyGpaRequest } from "./api";

const usePutVerifyGpa = () => {
return useMutation<VerifyGpaResponse, AxiosError, { gpaScoreId: string | number; data: VerifyGpaRequest }>({
mutationFn: (variables) => adminApi.putVerifyGpa(variables),
});
};

export default usePutVerifyGpa;
export default usePutVerifyGpa;
12 changes: 4 additions & 8 deletions apps/web/src/apis/Admin/putVerifyLanguageTest.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { AxiosError } from "axios";
import { useMutation } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { adminApi, type VerifyLanguageTestRequest, type VerifyLanguageTestResponse } from "./api";
import { adminApi, VerifyLanguageTestResponse, VerifyLanguageTestRequest } from "./api";

const usePutVerifyLanguageTest = () => {
return useMutation<
VerifyLanguageTestResponse,
AxiosError,
{ languageTestScoreId: string | number; data: VerifyLanguageTestRequest }
>({
return useMutation<VerifyLanguageTestResponse, AxiosError, { languageTestScoreId: string | number; data: VerifyLanguageTestRequest }>({
mutationFn: (variables) => adminApi.putVerifyLanguageTest(variables),
});
};

export default usePutVerifyLanguageTest;
export default usePutVerifyLanguageTest;
121 changes: 44 additions & 77 deletions apps/web/src/apis/Auth/api.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { axiosInstance, publicAxiosInstance } from "@/utils/axiosInstance";
import { axiosInstance } from "@/utils/axiosInstance";

export type SignOutResponse = Record<string, never>;

export type SignOutRequest = Record<string, never>;

// Apple Auth Types
export interface RegisteredAppleAuthResponse {
isRegistered: true;
accessToken: string;
refreshToken: string;
}

export interface UnregisteredAppleAuthResponse {
isRegistered: false;
export interface AppleAuthResponse {
isRegistered: boolean;
nickname: null;
email: string;
profileImageUrl: null;
signUpToken: string;
}

export type AppleAuthResponse = RegisteredAppleAuthResponse | UnregisteredAppleAuthResponse;

export interface AppleAuthRequest {
code: string;
}
export type AppleAuthRequest = Record<string, never>;

export interface RefreshTokenResponse {
accessToken: string;
Expand All @@ -36,110 +25,88 @@ export interface EmailLoginResponse {
refreshToken: string;
}

export interface EmailLoginRequest {
email: string;
password: string;
}
export type EmailLoginRequest = Record<string, never>;

export interface EmailVerificationResponse {
signUpToken: string;
}

export interface EmailVerificationRequest {
email: string;
verificationCode: string;
}

// Kakao Auth Types
export interface RegisteredKakaoAuthResponse {
isRegistered: true;
accessToken: string;
refreshToken: string;
}
export type EmailVerificationRequest = Record<string, never>;

export interface UnregisteredKakaoAuthResponse {
isRegistered: false;
export interface KakaoAuthResponse {
isRegistered: boolean;
nickname: string;
email: string;
profileImageUrl: string;
signUpToken: string;
}

export type KakaoAuthResponse = RegisteredKakaoAuthResponse | UnregisteredKakaoAuthResponse;
export type KakaoAuthRequest = Record<string, never>;

export interface KakaoAuthRequest {
code: string;
}

export type AccountResponse = undefined;
export type AccountResponse = void;

export interface SignUpResponse {
accessToken: string;
refreshToken: string;
}

export interface SignUpRequest {
signUpToken: string;
nickname: string;
profileImageUrl: string;
preparationStatus: string;
interestedRegions: string[];
interestedCountries: string[];
}

export interface EmailSignUpRequest {
email: string;
password: string;
}

export interface EmailSignUpResponse {
signUpToken: string;
}
export type SignUpRequest = Record<string, never>;

export const authApi = {
postSignOut: async (): Promise<SignOutResponse> => {
const res = await axiosInstance.post<SignOutResponse>(`/auth/sign-out`);
postSignOut: async (params: { data?: SignOutRequest }): Promise<SignOutResponse> => {
const res = await axiosInstance.post<SignOutResponse>(
`/auth/sign-out`, params?.data
);
return res.data;
},

postAppleAuth: async (data: AppleAuthRequest): Promise<AppleAuthResponse> => {
const res = await publicAxiosInstance.post<AppleAuthResponse>(`/auth/apple`, data);
postAppleAuth: async (params: { data?: AppleAuthRequest }): Promise<AppleAuthResponse> => {
const res = await axiosInstance.post<AppleAuthResponse>(
`/auth/apple`, params?.data
);
return res.data;
},

postRefreshToken: async (): Promise<RefreshTokenResponse> => {
const res = await publicAxiosInstance.post<RefreshTokenResponse>(`/auth/reissue`);
postRefreshToken: async (params: { data?: RefreshTokenRequest }): Promise<RefreshTokenResponse> => {
const res = await axiosInstance.post<RefreshTokenResponse>(
`/auth/reissue`, params?.data
);
return res.data;
},

postEmailLogin: async (data: EmailLoginRequest): Promise<EmailLoginResponse> => {
const res = await publicAxiosInstance.post<EmailLoginResponse>(`/auth/email/sign-in`, data);
postEmailLogin: async (params: { data?: EmailLoginRequest }): Promise<EmailLoginResponse> => {
const res = await axiosInstance.post<EmailLoginResponse>(
`/auth/email/sign-in`, params?.data
);
return res.data;
},

postEmailSignUp: async (data: EmailSignUpRequest): Promise<EmailSignUpResponse> => {
const res = await publicAxiosInstance.post<EmailSignUpResponse>(`/auth/email/sign-up`, data);
postEmailVerification: async (params: { data?: EmailVerificationRequest }): Promise<EmailVerificationResponse> => {
const res = await axiosInstance.post<EmailVerificationResponse>(
`/auth/email/sign-up`, params?.data
);
return res.data;
},

postKakaoAuth: async (data: KakaoAuthRequest): Promise<KakaoAuthResponse> => {
const res = await publicAxiosInstance.post<KakaoAuthResponse>(`/auth/kakao`, data);
postKakaoAuth: async (params: { data?: KakaoAuthRequest }): Promise<KakaoAuthResponse> => {
const res = await axiosInstance.post<KakaoAuthResponse>(
`/auth/kakao`, params?.data
);
return res.data;
},

deleteAccount: async (): Promise<AccountResponse> => {
const res = await axiosInstance.delete<AccountResponse>(`/auth/quit`);
const res = await axiosInstance.delete<AccountResponse>(
`/auth/quit`
);
return res.data;
},

postSignUp: async (data: SignUpRequest): Promise<SignUpResponse> => {
// ์ž„์‹œ ์„ฑ๋ณ„, ์ƒ๋…„์›”์ผ ์ถ”๊ฐ€. API ๋ณ€๊ฒฝ ์‹œ ์‚ญ์ œ
const payload = {
...data,
birth: "2000-01-01",
gender: "PREFER_NOT_TO_SAY",
};
const res = await publicAxiosInstance.post<SignUpResponse>(`/auth/sign-up`, payload);
postSignUp: async (params: { data?: SignUpRequest }): Promise<SignUpResponse> => {
const res = await axiosInstance.post<SignUpResponse>(
`/auth/sign-up`, params?.data
);
return res.data;
},
};

};
38 changes: 7 additions & 31 deletions apps/web/src/apis/Auth/deleteAccount.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { AxiosError } from "axios";
import { useMutation } from "@tanstack/react-query";
import { authApi, AccountResponse, AccountRequest } from "./api";

import type { AxiosError } from "axios";
import { useRouter } from "next/navigation";

import useAuthStore from "@/lib/zustand/useAuthStore";
import { toast } from "@/lib/zustand/useToastStore";
import { type AccountResponse, authApi } from "./api";

/**
* @description ํšŒ์›ํƒˆํ‡ด๋ฅผ ์œ„ํ•œ useMutation ์ปค์Šคํ…€ ํ›…
*/
const useDeleteUserAccount = () => {
const router = useRouter();
const { clearAccessToken } = useAuthStore();
const queryClient = useQueryClient();

return useMutation<AccountResponse, AxiosError, void>({
mutationFn: () => authApi.deleteAccount(),
onMutate: () => {
// ๋‚™๊ด€์  ์—…๋ฐ์ดํŠธ: ์š”์ฒญ์ด ์‹œ์ž‘๋˜๋ฉด ๋ฐ”๋กœ ํ™ˆ์œผ๋กœ ์ด๋™
router.replace("/");
},
onSuccess: () => {
// Zustand persist๊ฐ€ ์ž๋™์œผ๋กœ localStorage์—์„œ ์ œ๊ฑฐ
clearAccessToken();
queryClient.clear();
},
onError: () => {
toast.error("ํšŒ์›ํƒˆํ‡ด์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ์ž ์‹œ ํ›„ ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.");
},
const useDeleteAccount = () => {
return useMutation<AccountResponse, AxiosError, AccountRequest>({
mutationFn: (data) => authApi.deleteAccount({ data }),
});
};

export default useDeleteUserAccount;
export default useDeleteAccount;
34 changes: 9 additions & 25 deletions apps/web/src/apis/Auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
export type {
AppleAuthRequest,
AppleAuthResponse,
EmailLoginRequest,
EmailLoginResponse,
EmailSignUpRequest,
EmailSignUpResponse,
KakaoAuthRequest,
KakaoAuthResponse,
SignUpRequest,
SignUpResponse,
} from "./api";
export { authApi } from "./api";

// Client-side hooks
export { default as useDeleteUserAccount } from "./deleteAccount";
export { default as usePostAppleAuth } from "./postAppleAuth";
export { default as usePostEmailAuth } from "./postEmailLogin";
export { default as usePostEmailSignUp } from "./postEmailVerification";
export { default as usePostKakaoAuth } from "./postKakaoAuth";
export { default as usePostLogout } from "./postSignOut";
export { default as usePostSignUp } from "./postSignUp";

// Server-side functions
export { postReissueToken } from "./server";
export { authApi } from './api';
export { default as deleteAccount } from './deleteAccount';
export { default as postAppleAuth } from './postAppleAuth';
export { default as postEmailLogin } from './postEmailLogin';
export { default as postEmailVerification } from './postEmailVerification';
export { default as postKakaoAuth } from './postKakaoAuth';
export { default as postRefreshToken } from './postRefreshToken';
export { default as postSignOut } from './postSignOut';
export { default as postSignUp } from './postSignUp';
Loading
Loading