diff --git a/src/routes/(console)/apply-credit/+page.svelte b/src/routes/(console)/apply-credit/+page.svelte index 95af6175f..2c4137270 100644 --- a/src/routes/(console)/apply-credit/+page.svelte +++ b/src/routes/(console)/apply-credit/+page.svelte @@ -1,33 +1,28 @@ @@ -204,7 +136,7 @@ Apply credits
- + {#if $organizationList?.total && !campaign?.onlyNewOrgs && canSelectOrg} {/if} - {#if selectedOrgId && (selectedOrg?.billingPlan !== BillingPlan.PRO || !selectedOrg?.paymentMethodId)} - {#if selectedOrgId === newOrgId} - - {/if} - - - {/if} - - -
- - {#if !data?.couponData?.code && selectedOrgId} - - - + + {#if campaign?.plan && selectedOrg && selectedOrg.billingPlan !== campaign?.plan} + + This coupon code is only valid when upgrading to Scale plan. + {/if}
+ + {#if campaign?.template === 'card'}
{/if} - {#if selectedOrg?.$id && selectedOrg?.billingPlan !== BillingPlan.FREE && selectedOrg?.billingPlan !== BillingPlan.GITHUB_EDUCATION} -
- {#if couponData?.code && couponData?.status === 'active'} - -

+ +

+ {#if couponData?.code && couponData?.status === 'active'} + {@const dateAvailable = selectedOrg?.billingNextInvoiceDate} + +

+ {#if !dateAvailable} + Credits will automatically be applied to your next invoice. + {:else} Credits will automatically be applied to your next invoice on {toLocaleDate(selectedOrg?.billingNextInvoiceDate)}. -

- {:else} -

Add a coupon code to apply credits to your organization.

- {/if} -
- {:else if selectedOrgId} -
- - {#if campaign?.template === 'review' && (campaign?.cta || campaign?.claimed || campaign?.unclaimed)} -
-

{campaign?.cta}

-

- {#if couponData?.code && couponData?.status === 'active' && campaign?.claimed} - {campaign?.claimed} - {:else if campaign?.unclaimed} - {campaign?.unclaimed} - {/if} -

-
+ >{toLocaleDate(selectedOrg?.billingNextInvoiceDate)}. {/if} -
-
- {/if} +

+ {:else} +

Add a coupon code to apply credits to your organization.

+ {/if} +
@@ -319,18 +206,20 @@ diff --git a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte index d8d1a413b..946cc1083 100644 --- a/src/routes/(console)/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/(console)/organization-[organization]/change-plan/+page.svelte @@ -59,7 +59,7 @@ let formComponent: Form; let isSubmitting = writable(false); let methods: PaymentList; - let billingPlan: Tier = $organization.billingPlan; + let billingPlan: Tier = $currentPlan?.$id as Tier; let paymentMethodId: string; let collaborators: string[] = data?.members?.memberships @@ -100,7 +100,7 @@ billingPlan = plan as BillingPlan; } } - if ($organization?.billingPlan === BillingPlan.SCALE) { + if ($currentPlan?.$id === BillingPlan.SCALE) { billingPlan = BillingPlan.SCALE; } else { billingPlan = BillingPlan.PRO; @@ -141,7 +141,7 @@ 'Content-Type': 'application/json' }, body: JSON.stringify({ - from: tierToPlan($organization.billingPlan).name, + from: tierToPlan($currentPlan?.$id as Tier).name, to: tierToPlan(billingPlan).name, email: $user.email, reason: feedbackDowngradeOptions.find( @@ -239,12 +239,12 @@ } } - $: isUpgrade = billingPlan > $organization.billingPlan; - $: isDowngrade = billingPlan < $organization.billingPlan; + $: isUpgrade = billingPlan > ($currentPlan?.$id as Tier); + $: isDowngrade = billingPlan < ($currentPlan?.$id as Tier); $: if (billingPlan !== BillingPlan.FREE) { loadPaymentMethods(); } - $: isButtonDisabled = $organization.billingPlan === billingPlan; + $: isButtonDisabled = ($currentPlan?.$id as Tier) === billingPlan; @@ -277,7 +277,7 @@ tier={BillingPlan.FREE} class="u-margin-block-start-24" members={data?.members?.total ?? 0} /> - {:else if billingPlan === BillingPlan.PRO && $organization.billingPlan === BillingPlan.SCALE && collaborators?.length > 0} + {:else if billingPlan === BillingPlan.PRO && $currentPlan?.$id === BillingPlan.SCALE && collaborators?.length > 0} {@const extraMembers = collaborators?.length ?? 0} @@ -294,7 +294,7 @@ {/if} {/if} - {#if billingPlan !== BillingPlan.FREE && $organization.billingPlan === BillingPlan.FREE} + {#if billingPlan !== BillingPlan.FREE && $currentPlan?.$id === BillingPlan.FREE} - {#if billingPlan !== BillingPlan.FREE && $organization.billingPlan !== billingPlan && $organization.billingPlan !== BillingPlan.CUSTOM} + {#if billingPlan !== BillingPlan.FREE && $currentPlan?.$id !== billingPlan && $currentPlan?.$id !== BillingPlan.CUSTOM} - {:else if $organization.billingPlan !== BillingPlan.CUSTOM} + {:else if $currentPlan?.$id !== BillingPlan.CUSTOM} {/if}