2023-06-11 10:18:37 +00:00
|
|
|
|
import { makeRequest } from "@frontend/kitui";
|
2023-05-17 11:20:11 +00:00
|
|
|
|
|
2023-08-30 09:56:14 +00:00
|
|
|
|
import { parseAxiosError } from "@root/utils/parse-error";
|
2023-05-17 11:20:11 +00:00
|
|
|
|
|
2023-08-30 09:56:14 +00:00
|
|
|
|
const apiUrl =
|
|
|
|
|
process.env.NODE_ENV === "production" ? "" : "https://hub.pena.digital";
|
2023-05-17 11:20:11 +00:00
|
|
|
|
|
2023-08-30 09:56:14 +00:00
|
|
|
|
export async function logout(): Promise<[unknown, string?]> {
|
|
|
|
|
try {
|
|
|
|
|
const logoutResponse = await makeRequest<never, void>({
|
|
|
|
|
url: apiUrl + "/auth/logout",
|
|
|
|
|
method: "POST",
|
|
|
|
|
useToken: true,
|
|
|
|
|
withCredentials: true,
|
2023-05-17 11:20:11 +00:00
|
|
|
|
});
|
2023-08-30 09:56:14 +00:00
|
|
|
|
|
|
|
|
|
return [logoutResponse];
|
|
|
|
|
} catch (nativeError) {
|
2023-08-30 11:31:49 +00:00
|
|
|
|
const [error] = parseAxiosError(nativeError);
|
2023-08-30 09:56:14 +00:00
|
|
|
|
|
|
|
|
|
return [null, `Не удалось выйти. ${error}`];
|
|
|
|
|
}
|
|
|
|
|
}
|