mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fixes to applying coupon
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { FormList, InputChoice, InputNumber } from "$lib/elements/forms";
|
||||
import { toLocaleDate } from "$lib/helpers/date";
|
||||
|
||||
// import { FormList, InputChoice } from "$lib/elements/forms";
|
||||
import { formatCurrency } from "$lib/helpers/numbers";
|
||||
import type { Estimation } from "$lib/sdk/billing";
|
||||
import { organization } from "$lib/stores/organization";
|
||||
import { sdk } from "$lib/stores/sdk";
|
||||
import DiscountsApplied from "./discountsApplied.svelte";
|
||||
|
||||
@@ -13,6 +15,7 @@
|
||||
export let collaborators: string[];
|
||||
export let couponId: string;
|
||||
export let fixedCoupon = false;
|
||||
export let isDowngrade = false;
|
||||
|
||||
export let billingBudget: number;
|
||||
|
||||
@@ -41,7 +44,18 @@
|
||||
|
||||
</script>
|
||||
|
||||
{#if estimation}
|
||||
{#if isDowngrade}
|
||||
<section
|
||||
class="card u-flex u-flex-vertical u-gap-8"
|
||||
style:--p-card-padding="1.5rem"
|
||||
style:--p-card-border-radius="var(--border-radius-small)">
|
||||
<slot />
|
||||
<p class="text u-margin-block-start-16">
|
||||
Your change will take effect once your current billing cycle ends on <span class="u-bold">{toLocaleDate($organization.billingNextInvoiceDate)}</span>.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
{:else if estimation}
|
||||
|
||||
<section
|
||||
class="card u-flex u-flex-vertical u-gap-8"
|
||||
|
||||
@@ -66,17 +66,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
if ($page.url.searchParams.has('coupon')) {
|
||||
const coupon = $page.url.searchParams.get('coupon');
|
||||
try {
|
||||
const response = await sdk.forConsole.billing.getCoupon(coupon);
|
||||
couponData = response;
|
||||
} catch (e) {
|
||||
couponData = {
|
||||
code: null,
|
||||
status: null,
|
||||
credits: null
|
||||
};
|
||||
}
|
||||
couponId = $page.url.searchParams.get('coupon');
|
||||
}
|
||||
if ($page.url.searchParams.has('name')) {
|
||||
name = $page.url.searchParams.get('name');
|
||||
@@ -152,7 +142,7 @@
|
||||
billingPlan,
|
||||
paymentMethodId,
|
||||
null,
|
||||
couponData?.code,
|
||||
couponId,
|
||||
collaborators,
|
||||
billingBudget,
|
||||
taxId
|
||||
|
||||
@@ -360,12 +360,22 @@
|
||||
<svelte:fragment slot="aside">
|
||||
{#if billingPlan !== BillingPlan.FREE && $organization.billingPlan !== billingPlan && $organization.billingPlan !== BillingPlan.CUSTOM && isUpgrade}
|
||||
<EstimatedTotal
|
||||
{isDowngrade}
|
||||
{billingBudget}
|
||||
organizationId={$organization.$id}
|
||||
{billingPlan}
|
||||
{collaborators}
|
||||
{couponId} />
|
||||
{:else if $organization.billingPlan !== BillingPlan.CUSTOM}
|
||||
{#if isDowngrade}
|
||||
<EstimatedTotal
|
||||
{isDowngrade}
|
||||
{billingBudget}
|
||||
organizationId={$organization.$id}
|
||||
{billingPlan}
|
||||
{collaborators}
|
||||
{couponId} />
|
||||
{/if}
|
||||
<PlanComparisonBox downgrade={isDowngrade} />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
||||
Reference in New Issue
Block a user