From f417556ef412a23429bf16c42be51ad6657af1f0 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 11 Jun 2024 17:39:33 +0200 Subject: [PATCH] feat: new coupon input --- src/routes/console/apply-credit/+page.svelte | 37 ++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/routes/console/apply-credit/+page.svelte b/src/routes/console/apply-credit/+page.svelte index 3ac88c5ca..fe385bf48 100644 --- a/src/routes/console/apply-credit/+page.svelte +++ b/src/routes/console/apply-credit/+page.svelte @@ -8,7 +8,6 @@ EstimatedTotalBox, SelectPaymentMethod } from '$lib/components/billing'; - import ValidateCreditModal from '$lib/components/billing/validateCreditModal.svelte'; import { BillingPlan, Dependencies } from '$lib/constants'; import { Button, Form, FormList, InputSelect, InputTags, InputText } from '$lib/elements/forms'; import { toLocaleDate } from '$lib/helpers/date'; @@ -66,7 +65,7 @@ } ]; let name: string; - let showCreditModal = false; + let coupon: string; let couponData = data?.couponData; onMount(async () => { @@ -159,6 +158,23 @@ } } + async function addCoupon() { + try { + const response = await sdk.forConsole.billing.getCoupon(coupon); + couponData = response; + coupon = null; + addNotification({ + type: 'success', + message: 'Credits applied successfully' + }); + } catch (e) { + addNotification({ + type: 'error', + message: e.message + }); + } + } + $: selectedOrg = $organizationList?.teams?.find( (team) => team.$id === selectedOrgId ) as Organization; @@ -219,13 +235,16 @@ {/if} {#if !data?.couponData?.code && selectedOrgId} - + bind:value={coupon} + placeholder="Enter coupon code" + id="code" + label="Coupon code"> + + {/if} @@ -296,8 +315,6 @@ - -