Skip to content

Commit

Permalink
fix: isFreePlan behaving wrongly
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi-best committed Sep 12, 2024
1 parent bb3eb4c commit eea6ac5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions apps/dashboard/src/lib/utils/store/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ export const orgAudience = writable<OrgAudience[]>([]);
export const orgTeam = writable<OrgTeamMember[]>([]);
export const isOrgAdmin = derived(currentOrg, ($currentOrg) => $currentOrg.role_id === ROLE.ADMIN);

export const currentOrgPlan = derived(currentOrg, ($currentOrg) =>
$currentOrg.organization_plan.find((p) => p.is_active)
);
const getActivePlan = (org: CurrentOrg) => {
return org.organization_plan.find((p) => p.is_active);
};

export const currentOrgPlan = derived(currentOrg, ($currentOrg) => getActivePlan($currentOrg));

export const currentOrgPath = derived(currentOrg, ($currentOrg) =>
$currentOrg.siteName ? `/org/${$currentOrg.siteName}` : ''
Expand All @@ -51,11 +53,14 @@ export const currentOrgDomain = derived(currentOrg, ($currentOrg) => {
: '';
});

export const isFreePlan = derived(currentOrgPlan, ($plan) => {
if (!$plan) return false;
export const isFreePlan = derived(currentOrg, ($currentOrg) => {
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) =>
!$plan
? 20
Expand Down

0 comments on commit eea6ac5

Please sign in to comment.