fix: isFreePlan behaving wrongly
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user