Gate replays.
This commit is contained in:
1 parent
534af98809
commit
6e1a05f686
8 files changed
+109
-6
No files matched your search
@@ -96,5 +96,6 @@ export * from './usePageParameters';
|
||||
export * from './useRegionNames';
|
||||
export * from './useSlug';
|
||||
export * from './useSticky';
|
||||
export * from './useSubscription';
|
||||
export * from './useTimezone';
|
||||
export * from './useWebsiteNavItems';
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useApp } from '@/store/app';
|
||||
import { useConfig } from './useConfig';
|
||||
|
||||
export interface Subscription {
|
||||
isPro: boolean;
|
||||
isBusiness: boolean;
|
||||
hasSubscription: boolean;
|
||||
}
|
||||
|
||||
const FEATURES = {
|
||||
replays: 'isBusiness',
|
||||
} as const;
|
||||
|
||||
export type FeatureName = keyof typeof FEATURES;
|
||||
|
||||
const defaultSubscription: Subscription = {
|
||||
isPro: false,
|
||||
isBusiness: false,
|
||||
hasSubscription: false,
|
||||
};
|
||||
|
||||
export function useSubscription() {
|
||||
const { user } = useApp();
|
||||
const config = useConfig();
|
||||
|
||||
const subscription: Subscription = user?.subscription || defaultSubscription;
|
||||
const cloudMode = config?.cloudMode || false;
|
||||
|
||||
function hasFeature(feature: FeatureName): boolean {
|
||||
if (!cloudMode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const requiredFlag = FEATURES[feature];
|
||||
return subscription[requiredFlag] || false;
|
||||
}
|
||||
|
||||
return {
|
||||
...subscription,
|
||||
cloudMode,
|
||||
hasFeature,
|
||||
};
|
||||
}
|
||||
@@ -378,6 +378,7 @@ export const labels: Record<string, string> = {
|
||||
retentionDays: 'label.retention-days',
|
||||
duration: 'label.duration',
|
||||
recorded: 'label.recorded',
|
||||
upgrade: 'label.upgrade',
|
||||
};
|
||||
|
||||
export const messages: Record<string, string> = {
|
||||
@@ -427,4 +428,5 @@ export const messages: Record<string, string> = {
|
||||
forbidden: 'message.forbidden',
|
||||
notFound: 'message.not-found',
|
||||
serverError: 'message.sever-error',
|
||||
upgradeRequired: 'message.upgrade-required',
|
||||
};
|
||||
Reference in new issue
Block a user