Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
import {useGetMe} from "../../../queries/useGetMe.ts";
import {useIsFeatureEnabled} from "../../../hooks/useIsFeatureEnabled.ts";
import {FeatureFlagKey} from "../../../constants/featureFlags.ts";
export interface LicensedFeatureAccess {
isEnabled: boolean;
isUnlicensed: boolean;
isSetupLocked: boolean;
isLocked: boolean;
isVisible: boolean;
}
export const useLicensedFeature = (feature: FeatureFlagKey): LicensedFeatureAccess => {
const {data: me} = useGetMe();
const isEnabled = useIsFeatureEnabled(feature);
const licence = me?.licence;
const isUnlicensed = !!licence && !licence.unlocked_features?.includes(feature);
const isSetupLocked = !isEnabled && isUnlicensed;
const isLocked = isSetupLocked && !!licence?.features_in_use?.includes(feature);
return {isEnabled, isUnlicensed, isSetupLocked, isLocked, isVisible: isEnabled || isLocked};
};