Files
silo-server/web/src/hooks/useCanRequest.ts
T

27 lines
848 B
TypeScript
Raw Normal View History

import { useRequestFeatureStatus } from "@/hooks/queries/useRequests";
import { useCurrentProfile } from "@/hooks/useCurrentProfile";
export interface CanRequestState {
discoveryEnabled: boolean;
2026-05-25 22:27:46 -04:00
/**
* True while we cannot yet decide if discovery is on — feature status
* is still loading. Consumers should suppress empty-state UI in this
* window to avoid a flash before the request section appears.
*/
isResolving: boolean;
submitDisabledReason: string | null;
}
export function useCanRequest(): CanRequestState {
const status = useRequestFeatureStatus();
const { profile } = useCurrentProfile();
const discoveryEnabled = Boolean(status.data?.requests_enabled) && Boolean(profile?.id);
2026-05-25 22:27:46 -04:00
const isResolving = status.isLoading;
return {
discoveryEnabled,
2026-05-25 22:27:46 -04:00
isResolving,
submitDisabledReason: null,
};
}