fix(FE): resolve conflict pull branch development

This commit is contained in:
randy-ar
2025-12-03 21:21:42 +07:00
28 changed files with 4007 additions and 2126 deletions
+23
View File
@@ -0,0 +1,23 @@
import axios from 'axios';
import { httpClient } from '@/services/http/client';
import { BaseApiResponse, LogoutResponse } from '@/types/api/api-general';
export class AuthApiService {
async logout() {
try {
const logoutRes = await httpClient<LogoutResponse>(`/sso/logout`, {
method: 'POST',
});
return logoutRes;
} catch (error) {
if (axios.isAxiosError<BaseApiResponse>(error)) {
return error.response?.data;
}
return undefined;
}
}
}
export const AuthApi = new AuthApiService();
+477 -1033
View File
File diff suppressed because it is too large Load Diff
+13 -1
View File
@@ -1,10 +1,22 @@
import axios from 'axios';
import type { AxiosRequestConfig } from 'axios';
import type { AxiosError, AxiosRequestConfig } from 'axios';
import { RequestOptions } from '@/services/http/base';
const BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL ?? '';
const axiosClient = axios.create({ baseURL: BASE_URL, timeout: 10_000 });
axiosClient.interceptors.response.use(
(response) => response,
(error: AxiosError) => {
if (error.response?.status === 401) {
const ssoLoginUrl = `${process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string}?redirect_url=${window.location.href}`;
window.location.href = ssoLoginUrl;
}
return Promise.reject(error);
}
);
export async function httpClient<T, B = unknown>(
path: string,
opts: RequestOptions<B> = {}