2026-05-25 18:10:58 -04:00
|
|
|
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;
|
2026-05-25 18:10:58 -04:00
|
|
|
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;
|
2026-05-25 18:10:58 -04:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
discoveryEnabled,
|
2026-05-25 22:27:46 -04:00
|
|
|
isResolving,
|
2026-05-25 18:10:58 -04:00
|
|
|
submitDisabledReason: null,
|
|
|
|
|
};
|
|
|
|
|
}
|