feat(subscription): implement effective plan logic and update free plan features

This commit is contained in:
hamed
2026-07-05 10:46:31 +03:30
parent f3ca6d844f
commit 828e3552c0
10 changed files with 148 additions and 30 deletions
+4 -3
View File
@@ -16,13 +16,14 @@ export function useSubscription() {
});
const sub = data?.data?.subscription ?? null;
const features: Record<string, boolean> = sub?.plan?.features ?? {};
const maxSecretaries: number = sub?.plan?.max_secretaries ?? 1;
const effectivePlan = data?.data?.effective_plan ?? sub?.plan ?? null;
const features: Record<string, boolean> = effectivePlan?.features ?? {};
const maxSecretaries: number = effectivePlan?.max_secretaries ?? 1;
const hasPlan = sub !== null;
return {
subscription: sub,
hasFeature: (key: string) => hasPlan && (features[key] ?? false),
hasFeature: (key: string) => features[key] ?? false,
maxSecretaries,
hasPlan,
isExpiringSoon: (sub?.days_remaining ?? 0) > 0 && (sub?.days_remaining ?? 0) <= 7,