fix: isFreePlan behaving wrongly

This commit is contained in:
Rotimi Best
2024-09-12 23:54:04 +01:00
parent bb3eb4ceb2
commit eea6ac5147
+11 -6
View File
@@ -32,9 +32,11 @@ export const orgAudience = writable<OrgAudience[]>([]);
export const orgTeam = writable<OrgTeamMember[]>([]); export const orgTeam = writable<OrgTeamMember[]>([]);
export const isOrgAdmin = derived(currentOrg, ($currentOrg) => $currentOrg.role_id === ROLE.ADMIN); export const isOrgAdmin = derived(currentOrg, ($currentOrg) => $currentOrg.role_id === ROLE.ADMIN);
export const currentOrgPlan = derived(currentOrg, ($currentOrg) => const getActivePlan = (org: CurrentOrg) => {
$currentOrg.organization_plan.find((p) => p.is_active) return org.organization_plan.find((p) => p.is_active);
); };
export const currentOrgPlan = derived(currentOrg, ($currentOrg) => getActivePlan($currentOrg));
export const currentOrgPath = derived(currentOrg, ($currentOrg) => export const currentOrgPath = derived(currentOrg, ($currentOrg) =>
$currentOrg.siteName ? `/org/${$currentOrg.siteName}` : '' $currentOrg.siteName ? `/org/${$currentOrg.siteName}` : ''
@@ -51,11 +53,14 @@ export const currentOrgDomain = derived(currentOrg, ($currentOrg) => {
: ''; : '';
}); });
export const isFreePlan = derived(currentOrgPlan, ($plan) => { export const isFreePlan = derived(currentOrg, ($currentOrg) => {
if (!$plan) return false; if (!$currentOrg.id) return false;
return !$plan || $plan.plan_name === PLAN.BASIC; const plan = getActivePlan($currentOrg);
return !plan || plan.plan_name === PLAN.BASIC;
}); });
export const currentOrgMaxAudience = derived(currentOrgPlan, ($plan) => export const currentOrgMaxAudience = derived(currentOrgPlan, ($plan) =>
!$plan !$plan
? 20 ? 20