Some checks failed
Deploy to Cloudflare Workers / deploy (push) Has been cancelled
21 lines
786 B
TypeScript
21 lines
786 B
TypeScript
import type { PortalRole } from "@/lib/auth/roles";
|
|
import { PORTAL_ROUTES, loginPathForRole } from "@/lib/auth/roles";
|
|
|
|
export function pathForRole(role: PortalRole | null | undefined) {
|
|
if (role === "league_master") return PORTAL_ROUTES.league_master;
|
|
if (role === "manager") return PORTAL_ROUTES.manager;
|
|
return "/";
|
|
}
|
|
|
|
export function loginForPath(pathname: string) {
|
|
if (pathname.startsWith("/master")) return loginPathForRole("league_master");
|
|
if (pathname.startsWith("/manager")) return loginPathForRole("manager");
|
|
return "/login/manager";
|
|
}
|
|
|
|
export function roleForPath(pathname: string): PortalRole | null {
|
|
if (pathname.startsWith("/master")) return "league_master";
|
|
if (pathname.startsWith("/manager")) return "manager";
|
|
return null;
|
|
}
|