mirror of
https://github.com/khairul169/github-leaderboard.git
synced 2025-04-28 07:29:32 +07:00
21 lines
509 B
TypeScript
21 lines
509 B
TypeScript
import { useContext } from "react";
|
|
import { AuthContext } from "@client/components/context/auth-context";
|
|
import { API_BASEURL } from "@client/lib/api";
|
|
|
|
export const useAuth = () => {
|
|
const ctx = useContext(AuthContext);
|
|
if (!ctx) {
|
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
}
|
|
|
|
return ctx;
|
|
};
|
|
|
|
export const onLogin = () => {
|
|
window.location.href = API_BASEURL + "/auth/login";
|
|
};
|
|
|
|
export const onLogout = () => {
|
|
window.location.href = API_BASEURL + "/auth/logout";
|
|
};
|