Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve plan info by detail call #1550

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
import { readOnly } from '$lib/stores/billing';
import { GRACE_PERIOD_OVERRIDE } from '$lib/system';
import { isValueOfStringEnum } from '$lib/helpers/types';
import type { PageData } from './$types';

export let data: PageData;

let showDelete = false;

Expand Down Expand Up @@ -397,7 +400,7 @@
</CardGrid>
</Form>

<UpdateMaxFileSize />
<UpdateMaxFileSize currentPlan={data.currentPlan} />

<Form onSubmit={updateAllowedExtensions}>
<CardGrid hideOverflow>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PageLoad } from './$types';
import { sdk } from '$lib/stores/sdk';

export const load: PageLoad = async ({ parent }) => {
const { organization } = await parent();
const currentPlan = await sdk.forConsole.billing.getPlan(organization.$id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're probably going to be using the plan from getPlan() more and more across the console to replace how we've been working with plans before so it might be good to have this as a store. Maybe you can create an issue so we can revisit this later?

return {
currentPlan
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import { Button, Form, FormItem, InputNumber, InputSelect } from '$lib/elements/forms';
import { humanFileSize, sizeToBytes } from '$lib/helpers/sizeConvertion';
import { createByteUnitPair } from '$lib/helpers/unit';
import { getServiceLimit, readOnly, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { readOnly, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
import { bucket } from '../store';
import { updateBucket } from './+page.svelte';
import type { Plan } from '$lib/sdk/billing';
export let currentPlan: Plan;

const service = getServiceLimit('fileSize');
const service = currentPlan['fileSize'];
const { value, unit, baseValue, units } = createByteUnitPair($bucket.maximumFileSize, 1000);
const options = units.map((v) => ({ label: v.name, value: v.name }));

Expand All @@ -35,10 +37,9 @@
<svelte:fragment slot="aside">
{#if isCloud}
{@const size = humanFileSize(sizeToBytes(service, 'MB', 1000))}
{@const plan = tierToPlan($organization?.billingPlan)}
<Alert type="info">
<p class="text">
The {plan.name} plan has a maximum upload file size limit of {Math.floor(
The {currentPlan.name} plan has a maximum upload file size limit of {Math.floor(
parseInt(size.value)
)}{size.unit}.
{#if $organization?.billingPlan === BillingPlan.FREE}
Expand Down
Loading