|
8 | 8 | import { isTabSelected } from '$lib/helpers/load';
|
9 | 9 | import { Cover } from '$lib/layout';
|
10 | 10 | import { daysLeftInTrial, getServiceLimit, plansInfo, readOnly } from '$lib/stores/billing';
|
11 |
| - import { members, newMemberModal, organization } from '$lib/stores/organization'; |
| 11 | + import { members, newMemberModal, type Organization } from '$lib/stores/organization'; |
12 | 12 | import {
|
13 | 13 | canSeeBilling,
|
14 | 14 | canSeeProjects,
|
|
18 | 18 | } from '$lib/stores/roles';
|
19 | 19 | import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
|
20 | 20 | import { IconGithub, IconPlus } from '@appwrite.io/pink-icons-svelte';
|
21 |
| - import { Icon, Tooltip, Typography, Layout, Badge } from '@appwrite.io/pink-svelte'; |
| 21 | + import { Badge, Icon, Layout, Tooltip, Typography } from '@appwrite.io/pink-svelte'; |
22 | 22 |
|
23 | 23 | let areMembersLimited: boolean;
|
24 |
| - $: organization.subscribe(() => { |
| 24 | +
|
| 25 | + $: { |
25 | 26 | const limit = getServiceLimit('members') || Infinity;
|
26 | 27 | const isLimited = limit !== 0 && limit < Infinity;
|
27 | 28 | areMembersLimited =
|
28 | 29 | isCloud &&
|
29 | 30 | (($readOnly && !GRACE_PERIOD_OVERRIDE) || (isLimited && $members?.total >= limit));
|
30 |
| - }); |
| 31 | + } |
31 | 32 |
|
| 33 | + $: organization = page.data.organization as Organization; |
32 | 34 | $: avatars = $members.memberships?.map((m) => m.userName || m.userEmail) ?? [];
|
33 |
| - $: organizationId = $organization?.$id ?? page.params.organization; |
34 |
| - $: path = `${base}/organization-${organizationId}`; |
| 35 | + $: path = `${base}/organization-${organization.$id}`; |
35 | 36 | $: tabs = [
|
36 | 37 | {
|
37 | 38 | href: path,
|
|
75 | 76 | ].filter((tab) => !tab.disabled);
|
76 | 77 | </script>
|
77 | 78 |
|
78 |
| -{#if $organization.$id} |
| 79 | +{#if organization?.$id} |
79 | 80 | <Cover>
|
80 | 81 | <svelte:fragment slot="header">
|
81 | 82 | <span class="u-flex u-cross-center u-gap-8 u-min-width-0">
|
82 | 83 | <Typography.Title color="--fgcolor-neutral-primary" size="xl" truncate>
|
83 |
| - {$organization.name} |
| 84 | + {organization.name} |
84 | 85 | </Typography.Title>
|
85 |
| - {#if isCloud && $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION} |
| 86 | + {#if isCloud && organization?.billingPlan === BillingPlan.GITHUB_EDUCATION} |
86 | 87 | <Badge variant="secondary" content="Education">
|
87 | 88 | <Icon icon={IconGithub} size="s" slot="start" />
|
88 | 89 | </Badge>
|
89 |
| - {:else if isCloud && $organization?.billingPlan === BillingPlan.FREE} |
| 90 | + {:else if isCloud && organization?.billingPlan === BillingPlan.FREE} |
90 | 91 | <Badge variant="secondary" content="Free"></Badge>
|
91 | 92 | {/if}
|
92 |
| - {#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.FREE && $plansInfo.get($organization.billingPlan)?.trialDays} |
| 93 | + {#if isCloud && organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays} |
93 | 94 | <Tooltip>
|
94 | 95 | <Badge variant="secondary" content="Trial" />
|
95 | 96 | <svelte:fragment slot="tooltip">
|
96 | 97 | {`Your trial ends on ${toLocaleDate(
|
97 |
| - $organization.billingStartDate |
| 98 | + organization.billingStartDate |
98 | 99 | )}. ${$daysLeftInTrial} days remaining.`}
|
99 | 100 | </svelte:fragment>
|
100 | 101 | </Tooltip>
|
|
0 commit comments