Files
classroomio/apps/dashboard/src/lib/components/Org/Settings/Billing.svelte
T

50 lines
1.6 KiB
Svelte
Raw Normal View History

2024-04-07 06:08:34 +01:00
<script>
import { Grid, Row, Column } from 'carbon-components-svelte';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
import { currentOrgPlan, isFreePlan } from '$lib/utils/store/org';
import SectionTitle from '../SectionTitle.svelte';
2024-04-19 05:45:48 +01:00
import { t } from '$lib/utils/functions/translations';
2024-04-07 06:08:34 +01:00
let isRedirecting = false;
async function onOpenBilling() {
console.log({
plan: $currentOrgPlan
});
if ($currentOrgPlan?.subscriptionId) {
isRedirecting = true;
fetch('/api/lmz/subscriptions?subscriptionId=' + $currentOrgPlan?.subscriptionId)
.then((response) => response.json())
.then((res) => {
isRedirecting = false;
window.open(res.customerPortal, '_blank');
});
}
}
</script>
<Grid class="border-c rounded border-gray-200 dark:border-neutral-600 w-full mt-5">
<Row class="flex lg:flex-row flex-col py-7 border-bottom-c">
2024-04-19 05:45:48 +01:00
<Column sm={4} md={4} lg={4}
><SectionTitle>{$t('settings.billing.sub_title')}</SectionTitle></Column
>
2024-04-07 06:08:34 +01:00
<Column sm={8} md={8} lg={8}>
2024-04-19 05:45:48 +01:00
<h4 class="dark:text-white lg:mt-0">{$t('settings.billing.manage')}</h4>
2024-04-07 06:08:34 +01:00
{#if $isFreePlan}
2024-04-19 05:45:48 +01:00
{$t('settings.billing.active')}
2024-04-07 06:08:34 +01:00
{:else}
2024-04-19 05:45:48 +01:00
<p class="mb-3">{$t('settings.billing.lemonsqueezy')}</p>
2024-04-07 06:08:34 +01:00
<PrimaryButton
2024-04-19 05:45:48 +01:00
label={$t('settings.billing.open_billing')}
2024-04-07 06:08:34 +01:00
variant={VARIANTS.CONTAINED_DARK}
onClick={onOpenBilling}
isLoading={isRedirecting}
/>
{/if}
</Column>
</Row>
</Grid>