feat(web): licence banner, settings page and feature gating
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { licence, type LicenseInfo } from "@/lib/api";
|
||||
|
||||
export function useLicense() {
|
||||
const { data, isLoading } = useQuery<LicenseInfo>({
|
||||
queryKey: ["license"],
|
||||
queryFn: licence.get,
|
||||
staleTime: 60_000,
|
||||
});
|
||||
|
||||
return {
|
||||
license: data,
|
||||
isLoading,
|
||||
isActive: data?.state === "valid",
|
||||
// Features render disabled rather than hidden, so treat "unknown while
|
||||
// loading" as available to avoid a flash of disabled controls.
|
||||
hasFeature: (name: string) => (data ? Boolean(data.features?.[name]) : true),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user