mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-11 18:09:05 +00:00
standardize and fix branding on new resources auth pages
This commit is contained in:
31
src/lib/loadOrgLoginPageBranding.ts
Normal file
31
src/lib/loadOrgLoginPageBranding.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { priv } from "@app/lib/api";
|
||||
import { isOrgSubscribed } from "@app/lib/api/isOrgSubscribed";
|
||||
import { build } from "@server/build";
|
||||
import { LoadLoginPageBrandingResponse } from "@server/routers/loginPage/types";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
export async function loadOrgLoginPageBranding(orgId: string): Promise<{
|
||||
primaryColor: string | null;
|
||||
}> {
|
||||
if (build === "oss") {
|
||||
return { primaryColor: null };
|
||||
}
|
||||
|
||||
const subscribed = await isOrgSubscribed(orgId);
|
||||
if (!subscribed) {
|
||||
return { primaryColor: null };
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await priv.get<
|
||||
AxiosResponse<LoadLoginPageBrandingResponse>
|
||||
>(`/login-page-branding?orgId=${orgId}`);
|
||||
if (res.status === 200) {
|
||||
return { primaryColor: res.data.data.primaryColor ?? null };
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return { primaryColor: null };
|
||||
}
|
||||
Reference in New Issue
Block a user