mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-22 20:08:46 +00:00
refactor: update whitelabeling hooks and API usage for improved access control and consistency
This commit is contained in:
@@ -45,12 +45,12 @@ import {
|
|||||||
import { authClient } from "@/lib/auth-client";
|
import { authClient } from "@/lib/auth-client";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type User = typeof authClient.$Infer.Session.user;
|
type User = typeof authClient.$Infer.Session.user;
|
||||||
|
|
||||||
export const ImpersonationBar = () => {
|
export const ImpersonationBar = () => {
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const [users, setUsers] = useState<User[]>([]);
|
const [users, setUsers] = useState<User[]>([]);
|
||||||
const [selectedUser, setSelectedUser] = useState<User | null>(null);
|
const [selectedUser, setSelectedUser] = useState<User | null>(null);
|
||||||
const [isImpersonating, setIsImpersonating] = useState(false);
|
const [isImpersonating, setIsImpersonating] = useState(false);
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import {
|
|||||||
Loader2,
|
Loader2,
|
||||||
LogIn,
|
LogIn,
|
||||||
type LucideIcon,
|
type LucideIcon,
|
||||||
Palette,
|
|
||||||
Package,
|
Package,
|
||||||
|
Palette,
|
||||||
PieChart,
|
PieChart,
|
||||||
Rocket,
|
Rocket,
|
||||||
Server,
|
Server,
|
||||||
@@ -895,10 +895,10 @@ export default function Page({ children }: Props) {
|
|||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { data: auth } = api.user.get.useQuery();
|
const { data: auth } = api.user.get.useQuery();
|
||||||
const { data: dokployVersion } = api.settings.getDokployVersion.useQuery();
|
const { data: dokployVersion } = api.settings.getDokployVersion.useQuery();
|
||||||
const { data: whitelabeling } = api.whitelabeling.getPublic.useQuery(
|
const { data: whitelabeling } = api.whitelabeling.get.useQuery(undefined, {
|
||||||
undefined,
|
staleTime: 5 * 60 * 1000,
|
||||||
{ staleTime: 5 * 60 * 1000, refetchOnWindowFocus: false },
|
refetchOnWindowFocus: false,
|
||||||
);
|
});
|
||||||
|
|
||||||
const includesProjects = pathname?.includes("/dashboard/project");
|
const includesProjects = pathname?.includes("/dashboard/project");
|
||||||
const { data: isCloud } = api.settings.isCloud.useQuery();
|
const { data: isCloud } = api.settings.isCloud.useQuery();
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ const formSchema = z.object({
|
|||||||
faviconUrl: z.string(),
|
faviconUrl: z.string(),
|
||||||
customCss: z.string(),
|
customCss: z.string(),
|
||||||
loginLogoUrl: z.string(),
|
loginLogoUrl: z.string(),
|
||||||
|
supportUrl: z.string(),
|
||||||
|
docsUrl: z.string(),
|
||||||
errorPageTitle: z.string(),
|
errorPageTitle: z.string(),
|
||||||
errorPageDescription: z.string(),
|
errorPageDescription: z.string(),
|
||||||
metaTitle: z.string(),
|
metaTitle: z.string(),
|
||||||
@@ -173,6 +175,8 @@ export function WhitelabelingSettings() {
|
|||||||
faviconUrl: "",
|
faviconUrl: "",
|
||||||
customCss: "",
|
customCss: "",
|
||||||
loginLogoUrl: "",
|
loginLogoUrl: "",
|
||||||
|
supportUrl: "",
|
||||||
|
docsUrl: "",
|
||||||
errorPageTitle: "",
|
errorPageTitle: "",
|
||||||
errorPageDescription: "",
|
errorPageDescription: "",
|
||||||
metaTitle: "",
|
metaTitle: "",
|
||||||
@@ -190,6 +194,8 @@ export function WhitelabelingSettings() {
|
|||||||
faviconUrl: data.faviconUrl ?? "",
|
faviconUrl: data.faviconUrl ?? "",
|
||||||
customCss: data.customCss ?? "",
|
customCss: data.customCss ?? "",
|
||||||
loginLogoUrl: data.loginLogoUrl ?? "",
|
loginLogoUrl: data.loginLogoUrl ?? "",
|
||||||
|
supportUrl: data.supportUrl ?? "",
|
||||||
|
docsUrl: data.docsUrl ?? "",
|
||||||
errorPageTitle: data.errorPageTitle ?? "",
|
errorPageTitle: data.errorPageTitle ?? "",
|
||||||
errorPageDescription: data.errorPageDescription ?? "",
|
errorPageDescription: data.errorPageDescription ?? "",
|
||||||
metaTitle: data.metaTitle ?? "",
|
metaTitle: data.metaTitle ?? "",
|
||||||
@@ -219,8 +225,8 @@ export function WhitelabelingSettings() {
|
|||||||
primaryColor: null,
|
primaryColor: null,
|
||||||
customCss: values.customCss || null,
|
customCss: values.customCss || null,
|
||||||
loginLogoUrl: values.loginLogoUrl || null,
|
loginLogoUrl: values.loginLogoUrl || null,
|
||||||
supportUrl: null,
|
supportUrl: values.supportUrl || null,
|
||||||
docsUrl: null,
|
docsUrl: values.docsUrl || null,
|
||||||
errorPageTitle: values.errorPageTitle || null,
|
errorPageTitle: values.errorPageTitle || null,
|
||||||
errorPageDescription: values.errorPageDescription || null,
|
errorPageDescription: values.errorPageDescription || null,
|
||||||
metaTitle: values.metaTitle || null,
|
metaTitle: values.metaTitle || null,
|
||||||
@@ -231,6 +237,7 @@ export function WhitelabelingSettings() {
|
|||||||
toast.success("Whitelabeling settings updated");
|
toast.success("Whitelabeling settings updated");
|
||||||
await refetch();
|
await refetch();
|
||||||
await utils.whitelabeling.getPublic.invalidate();
|
await utils.whitelabeling.getPublic.invalidate();
|
||||||
|
await utils.whitelabeling.get.invalidate();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
toast.error(
|
toast.error(
|
||||||
@@ -245,6 +252,7 @@ export function WhitelabelingSettings() {
|
|||||||
toast.success("Whitelabeling settings reset to defaults");
|
toast.success("Whitelabeling settings reset to defaults");
|
||||||
await refetch();
|
await refetch();
|
||||||
await utils.whitelabeling.getPublic.invalidate();
|
await utils.whitelabeling.getPublic.invalidate();
|
||||||
|
await utils.whitelabeling.get.invalidate();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
toast.error(error?.message || "Failed to reset whitelabeling settings");
|
toast.error(error?.message || "Failed to reset whitelabeling settings");
|
||||||
@@ -423,9 +431,9 @@ export function WhitelabelingSettings() {
|
|||||||
{/* Metadata & Links Section */}
|
{/* Metadata & Links Section */}
|
||||||
<Card className="bg-transparent">
|
<Card className="bg-transparent">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Metadata</CardTitle>
|
<CardTitle>Metadata & Links</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
Customize the page title and footer text.
|
Customize the page title, footer text, and sidebar links.
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex flex-col gap-4">
|
<CardContent className="flex flex-col gap-4">
|
||||||
@@ -462,6 +470,46 @@ export function WhitelabelingSettings() {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="supportUrl"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Support URL</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="https://support.example.com"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormDescription>
|
||||||
|
Custom URL for the "Support" link in the sidebar.
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="docsUrl"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Documentation URL</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="https://docs.example.com"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormDescription>
|
||||||
|
Custom URL for the "Documentation" link in the sidebar.
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ import {
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
export type Services = {
|
export type Services = {
|
||||||
serverId?: string | null;
|
serverId?: string | null;
|
||||||
@@ -371,7 +371,7 @@ const EnvironmentPage = (
|
|||||||
{ projectId: selectedTargetProject },
|
{ projectId: selectedTargetProject },
|
||||||
{ enabled: !!selectedTargetProject },
|
{ enabled: !!selectedTargetProject },
|
||||||
);
|
);
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
|
|
||||||
const emptyServices =
|
const emptyServices =
|
||||||
|
|||||||
+2
-2
@@ -56,7 +56,7 @@ import {
|
|||||||
import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type TabState =
|
type TabState =
|
||||||
| "projects"
|
| "projects"
|
||||||
@@ -96,7 +96,7 @@ const Service = (
|
|||||||
const { data: environments } = api.environment.byProjectId.useQuery({
|
const { data: environments } = api.environment.byProjectId.useQuery({
|
||||||
projectId: data?.environment?.project?.projectId || "",
|
projectId: data?.environment?.project?.projectId || "",
|
||||||
});
|
});
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
const environmentDropdownItems =
|
const environmentDropdownItems =
|
||||||
environments?.map((env) => ({
|
environments?.map((env) => ({
|
||||||
|
|||||||
+2
-2
@@ -52,7 +52,7 @@ import {
|
|||||||
import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type TabState =
|
type TabState =
|
||||||
| "projects"
|
| "projects"
|
||||||
@@ -85,7 +85,7 @@ const Service = (
|
|||||||
const { data: environments } = api.environment.byProjectId.useQuery({
|
const { data: environments } = api.environment.byProjectId.useQuery({
|
||||||
projectId: data?.environment?.projectId || "",
|
projectId: data?.environment?.projectId || "",
|
||||||
});
|
});
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
const environmentDropdownItems =
|
const environmentDropdownItems =
|
||||||
environments?.map((env) => ({
|
environments?.map((env) => ({
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ const Mariadb = (
|
|||||||
const { data: environments } = api.environment.byProjectId.useQuery({
|
const { data: environments } = api.environment.byProjectId.useQuery({
|
||||||
projectId: data?.environment?.projectId || "",
|
projectId: data?.environment?.projectId || "",
|
||||||
});
|
});
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
const environmentDropdownItems =
|
const environmentDropdownItems =
|
||||||
environments?.map((env) => ({
|
environments?.map((env) => ({
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ const Mongo = (
|
|||||||
const { data: environments } = api.environment.byProjectId.useQuery({
|
const { data: environments } = api.environment.byProjectId.useQuery({
|
||||||
projectId: data?.environment?.projectId || "",
|
projectId: data?.environment?.projectId || "",
|
||||||
});
|
});
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
const environmentDropdownItems =
|
const environmentDropdownItems =
|
||||||
environments?.map((env) => ({
|
environments?.map((env) => ({
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ const MySql = (
|
|||||||
const { data: environments } = api.environment.byProjectId.useQuery({
|
const { data: environments } = api.environment.byProjectId.useQuery({
|
||||||
projectId: data?.environment?.projectId || "",
|
projectId: data?.environment?.projectId || "",
|
||||||
});
|
});
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
const environmentDropdownItems =
|
const environmentDropdownItems =
|
||||||
environments?.map((env) => ({
|
environments?.map((env) => ({
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
type TabState = "projects" | "monitoring" | "settings" | "backups" | "advanced";
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ const Postgresql = (
|
|||||||
const { data: environments } = api.environment.byProjectId.useQuery({
|
const { data: environments } = api.environment.byProjectId.useQuery({
|
||||||
projectId: data?.environment?.projectId || "",
|
projectId: data?.environment?.projectId || "",
|
||||||
});
|
});
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
const environmentDropdownItems =
|
const environmentDropdownItems =
|
||||||
environments?.map((env) => ({
|
environments?.map((env) => ({
|
||||||
|
|||||||
+2
-2
@@ -44,7 +44,7 @@ import { UseKeyboardNav } from "@/hooks/use-keyboard-nav";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { appRouter } from "@/server/api/root";
|
import { appRouter } from "@/server/api/root";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
|
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
|
||||||
|
|
||||||
type TabState = "projects" | "monitoring" | "settings" | "advanced";
|
type TabState = "projects" | "monitoring" | "settings" | "advanced";
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ const Redis = (
|
|||||||
const { data: environments } = api.environment.byProjectId.useQuery({
|
const { data: environments } = api.environment.byProjectId.useQuery({
|
||||||
projectId: data?.environment?.projectId || "",
|
projectId: data?.environment?.projectId || "",
|
||||||
});
|
});
|
||||||
const { config: whitelabeling } = useWhitelabelingPublic();
|
const { config: whitelabeling } = useWhitelabeling();
|
||||||
const appName = whitelabeling?.appName || "Dokploy";
|
const appName = whitelabeling?.appName || "Dokploy";
|
||||||
const environmentDropdownItems =
|
const environmentDropdownItems =
|
||||||
environments?.map((env) => ({
|
environments?.map((env) => ({
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ import { apiUpdateWhitelabeling } from "@/server/db/schema";
|
|||||||
import {
|
import {
|
||||||
createTRPCRouter,
|
createTRPCRouter,
|
||||||
enterpriseProcedure,
|
enterpriseProcedure,
|
||||||
|
protectedProcedure,
|
||||||
publicProcedure,
|
publicProcedure,
|
||||||
} from "../../trpc";
|
} from "../../trpc";
|
||||||
|
|
||||||
export const whitelabelingRouter = createTRPCRouter({
|
export const whitelabelingRouter = createTRPCRouter({
|
||||||
get: enterpriseProcedure.query(async () => {
|
get: protectedProcedure.query(async () => {
|
||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -80,13 +81,28 @@ export const whitelabelingRouter = createTRPCRouter({
|
|||||||
return { success: true };
|
return { success: true };
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Public endpoint so the whitelabeling config can be applied globally
|
// Public endpoint only for unauthenticated pages (login, register, error)
|
||||||
// (including on the login page before auth)
|
// Returns only the fields needed for public pages
|
||||||
getPublic: publicProcedure.query(async () => {
|
getPublic: publicProcedure.query(async () => {
|
||||||
if (IS_CLOUD) {
|
if (IS_CLOUD) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const settings = await getWebServerSettings();
|
const settings = await getWebServerSettings();
|
||||||
return settings?.whitelabelingConfig ?? null;
|
const config = settings?.whitelabelingConfig;
|
||||||
|
if (!config) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
appName: config.appName,
|
||||||
|
appDescription: config.appDescription,
|
||||||
|
logoUrl: config.logoUrl,
|
||||||
|
loginLogoUrl: config.loginLogoUrl,
|
||||||
|
faviconUrl: config.faviconUrl,
|
||||||
|
primaryColor: config.primaryColor,
|
||||||
|
customCss: config.customCss,
|
||||||
|
metaTitle: config.metaTitle,
|
||||||
|
errorPageTitle: config.errorPageTitle,
|
||||||
|
errorPageDescription: config.errorPageDescription,
|
||||||
|
footerText: config.footerText,
|
||||||
|
};
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook to access whitelabeling config for authenticated pages (dashboard, services, etc.).
|
||||||
|
* Requires the user to be logged in.
|
||||||
|
*/
|
||||||
|
export function useWhitelabeling() {
|
||||||
|
const { data, ...rest } = api.whitelabeling.get.useQuery(undefined, {
|
||||||
|
staleTime: 5 * 60 * 1000,
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
return { config: data ?? null, ...rest };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook to access the public whitelabeling config.
|
* Hook to access the public whitelabeling config.
|
||||||
* Can be used on any page (including login) since it uses the public endpoint.
|
* Only for unauthenticated pages (login, register, error, invitation, password reset).
|
||||||
*/
|
*/
|
||||||
export function useWhitelabelingPublic() {
|
export function useWhitelabelingPublic() {
|
||||||
const { data, ...rest } = api.whitelabeling.getPublic.useQuery(undefined, {
|
const { data, ...rest } = api.whitelabeling.getPublic.useQuery(undefined, {
|
||||||
|
|||||||
Reference in New Issue
Block a user