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

Add check to which plan the org is changing when applying the credits #1574

Merged
merged 6 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/lib/components/billing/estimatedTotalBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</span>

<p class="text u-margin-block-start-16">
You'll pay <span class="u-bold">{formatCurrency(estimatedTotal)}</span> now, with our first
You'll pay <span class="u-bold">{formatCurrency(estimatedTotal)}</span> now, with your first
billing cycle starting on
<span class="u-bold"
>{!currentPlan.trialDays
Expand Down
14 changes: 13 additions & 1 deletion src/routes/(console)/apply-credit/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@
$: selectedOrg = $organizationList?.teams?.find(
(team) => team.$id === selectedOrgId
) as Organization;

function getNewBillingPlan(organization: Organization): BillingPlan {
if (organization?.billingPlan === BillingPlan.SCALE) {
return BillingPlan.SCALE;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still a bit hesitant to hardcode stuff here. For example, enterprise plans will run into a problem with this logic.

Maybe we can rely on the plan order (after it gets fixed for the education plan)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah definitely! However atm we don't have a plan order in code afaik?

Copy link
Member

@ItzNotABug ItzNotABug Dec 23, 2024

Choose a reason for hiding this comment

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

@ernstmul We don't have an exact order [there's tier-* format though] but possibly we could check via getNextTier, not 100% sure as it doesn't include anything about enterprise/custom tiers atm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tier-* doesn't hold up anymore, since we now also have auto-1 and cont-1! getNextTier would definitely work, but perhaps its nice get this info from BE?

} else if (campaign?.plan) {
return campaign.plan;
} else {
return BillingPlan.PRO;
}
}

$: billingPlan = getNewBillingPlan(selectedOrg);
Copy link
Contributor

Choose a reason for hiding this comment

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

@ArmanNik and @TorstenDittmann might now more on Svelte best practices, but I don't think we need to create a new function for this. You can put an if statement directly here like:

$: if (execution?.errors) {
selectedResponse = 'errors';
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now I've changed it to a ternary operation. The if statement way didn't seem to do the trick correctly (perhaps @TorstenDittmann or @ArmanNik can point out later on what I'm doing wrong there haha).

</script>

<svelte:head>
Expand Down Expand Up @@ -268,7 +280,7 @@
</div>
</div>
{/if}
{#if selectedOrg?.$id && selectedOrg?.billingPlan !== BillingPlan.FREE}
{#if selectedOrg?.$id && selectedOrg?.billingPlan !== BillingPlan.FREE && selectedOrg?.billingPlan !== BillingPlan.GITHUB_EDUCATION}
<section
class="card u-margin-block-start-24"
style:--p-card-padding="1.5rem"
Expand Down
Loading