feat: small refactor container header, member page plan limit

This commit is contained in:
Arman
2023-07-27 15:49:52 +02:00
parent 5ce7bdbb3d
commit dc71225453
2 changed files with 20 additions and 8 deletions
+15 -2
View File
@@ -9,11 +9,16 @@
import { wizard } from '$lib/stores/wizard';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { limitRates } from '$lib/constants';
import { Button } from '$lib/elements/forms';
export let title: string;
export let serviceId = title.toLocaleLowerCase();
export let totalUse: number = null;
export let buttonText: string = null;
export let buttonMethod: () => void = null;
export let buttonEvent: string = buttonText?.toLocaleLowerCase();
let tooltipContent: HTMLDivElement;
$: limit = limitRates?.[$organization?.billingPlan]?.find((l) => l.id === serviceId)?.amount;
@@ -21,7 +26,7 @@
$: tier = tierToPlan($organization?.billingPlan as Tier)?.name;
</script>
{#if isCloud && totalUse && limit !== 'unlimited' && limit <= totalUse}
{#if isCloud && totalUse && limit !== 'unlimited' && totalUse >= limit}
<Alert type="warning">
<span class="text">
You've reached the maximum number of {title.toLowerCase()} for the {tier} plan.
@@ -57,7 +62,15 @@
{/if}
</div>
<slot />
<slot>
<Button
on:click={buttonMethod}
event={buttonEvent}
disabled={limit !== 'unlimited' && totalUse >= limit}>
<span class="icon-plus" aria-hidden="true" />
<span class="text">{buttonText}</span>
</Button>
</slot>
</div>
{#if isCloud}
@@ -57,12 +57,11 @@
<Container>
{#if data.organizationMembers.total}
<ContainerHeader title="Members" totalUse={data.organizationMembers.total}>
<Button on:click={() => newMemberModal.set(true)} event="invite">
<span class="icon-plus" aria-hidden="true" />
<span class="text">Invite</span>
</Button>
</ContainerHeader>
<ContainerHeader
title="Members"
totalUse={data.organizationMembers.total}
buttonText="Invite"
buttonMethod={() => newMemberModal.set(true)} />
<TableScroll>
<TableHeader>