mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
more logs, copy, credit fix, trial days fix
This commit is contained in:
1 parent
95b88842a6
commit
9cf0ebccb8
10 files changed
+28
-30
No files matched your search
@@ -12,7 +12,6 @@ export const paymentMethods = derived(page, ($page) => $page.data.paymentMethods
|
||||
export const addressList = derived(page, ($page) => $page.data.addressList as AddressesList);
|
||||
export const plansInfo = derived(page, ($page) => $page.data.plansInfo as PlansInfo);
|
||||
export const daysLeftInTrial = writable<number>(0);
|
||||
export const trialEndDate = writable<Date>();
|
||||
export const readOnly = writable<boolean>(false);
|
||||
|
||||
// export type ReadOnlyData = {
|
||||
|
||||
@@ -14,6 +14,7 @@ export type Organization = Models.Team<Record<string, unknown>> & {
|
||||
billingCurrentInvoiceDate: string;
|
||||
billingNextInvoiceDate: string;
|
||||
billingTrialStartDate?: string;
|
||||
billingTrialEndDate?: string;
|
||||
billingTrialDays?: number;
|
||||
billingAddressId?: string;
|
||||
amount: number;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
failedInvoice,
|
||||
daysLeftInTrial,
|
||||
tierToPlan,
|
||||
trialEndDate,
|
||||
readOnly,
|
||||
showUsageRatesModal
|
||||
} from '$lib/stores/billing';
|
||||
@@ -252,6 +251,10 @@
|
||||
console.log('Environment is Cloud and Stripe public key deteted');
|
||||
$stripe = await loadStripe(VARS.STRIPE_PUBLIC_KEY);
|
||||
console.log('Stripe should have been loading', $stripe);
|
||||
} else {
|
||||
console.log('Environment is not Cloud or Stripe public key not deteted');
|
||||
console.log('isCloud:', isCloud);
|
||||
console.log('hasStripePublicKey:', hasStripePublicKey);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -276,9 +279,8 @@
|
||||
if (isCloud) {
|
||||
if (org?.billingPlan === 'tier-0') {
|
||||
$daysLeftInTrial = 0;
|
||||
$trialEndDate = null;
|
||||
} else {
|
||||
calculateTrialDay(new Date(org?.billingTrialStartDate), org?.billingTrialDays);
|
||||
calculateTrialDay(new Date(org?.billingTrialEndDate));
|
||||
}
|
||||
|
||||
checkForTrialEnding();
|
||||
@@ -287,11 +289,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
function calculateTrialDay(startDate: Date, trialDays: number) {
|
||||
function calculateTrialDay(endDate: Date) {
|
||||
const today = new Date();
|
||||
const days = diffDays(startDate, today);
|
||||
$daysLeftInTrial = trialDays - days;
|
||||
$trialEndDate = new Date(startDate.getTime() + trialDays * 24 * 60 * 60 * 1000);
|
||||
const days = diffDays(today, endDate);
|
||||
$daysLeftInTrial = days;
|
||||
}
|
||||
|
||||
function checkForTrialEnding() {
|
||||
@@ -304,7 +305,7 @@
|
||||
tierToPlan($organization.billingPlan).name
|
||||
} plan.</b>
|
||||
You will be billed on a recurring 30 day cycle after your trial period ends on <b>${toLocaleDate(
|
||||
$trialEndDate?.toString()
|
||||
$organization.billingTrialEndDate
|
||||
)}</b>`
|
||||
});
|
||||
localStorage.setItem('trialEndingNotification', 'true');
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
import { isCloud } from '$lib/system';
|
||||
import { Pill } from '$lib/elements';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Organization } from '$lib/stores/organization';
|
||||
import { daysLeftInTrial, trialEndDate } from '$lib/stores/billing';
|
||||
import { organization, type Organization } from '$lib/stores/organization';
|
||||
import { daysLeftInTrial } from '$lib/stores/billing';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
@@ -86,7 +86,7 @@
|
||||
class="u-flex u-cross-center"
|
||||
use:tooltip={{
|
||||
content: `Your trial ends on ${toLocaleDate(
|
||||
$trialEndDate.toString()
|
||||
$organization.billingTrialEndDate
|
||||
)}. ${$daysLeftInTrial} days remaining.`
|
||||
}}>
|
||||
<Pill>FREE TRIAL</Pill>
|
||||
|
||||
@@ -38,13 +38,14 @@
|
||||
await initializeStripe();
|
||||
}
|
||||
console.log('test');
|
||||
console.log($page.url.searchParams.get('invoice'));
|
||||
try {
|
||||
const invoiceId = $page.url.searchParams.get('invoice');
|
||||
console.log(invoiceId);
|
||||
const invoice = await sdk.forConsole.billing.getInvoice(
|
||||
$page.params.organization,
|
||||
invoiceId
|
||||
);
|
||||
console.log(invoice);
|
||||
const { setupIntent, error } = await $stripe.confirmCardSetup(
|
||||
invoice.clientSecret,
|
||||
{
|
||||
@@ -52,7 +53,7 @@
|
||||
return_url: `${base}/console/organization-${$organization.$id}/billing`
|
||||
}
|
||||
);
|
||||
console.log(setupIntent);
|
||||
console.log('error', error);
|
||||
if (error) {
|
||||
console.log('Something went wrong');
|
||||
}
|
||||
@@ -75,6 +76,7 @@
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
addNotification({
|
||||
title: 'Error',
|
||||
message:
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
async function redeem() {
|
||||
try {
|
||||
await sdk.forConsole.billing.addCredit($organization.$id, coupon);
|
||||
show = false;
|
||||
await invalidate(Dependencies.CREDIT);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Credit has been added to ${$organization.name}`
|
||||
});
|
||||
await invalidate(Dependencies.CREDIT);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
trackEvent(Submit.CreditRedeem, {
|
||||
coupon
|
||||
});
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
$organization?.billingPlan === 'tier-2'
|
||||
? tierScale
|
||||
: $organization?.billingPlan === 'tier-1'
|
||||
? tierPro
|
||||
: tierFree;
|
||||
? tierPro
|
||||
: tierFree;
|
||||
|
||||
$: aggregation = $aggregationList.aggregations[0];
|
||||
</script>
|
||||
@@ -46,8 +46,8 @@
|
||||
</div>
|
||||
|
||||
<p class="text">
|
||||
{#if $organization?.billingPlan !== 'tier-0' && !$daysLeftInTrial}
|
||||
<span class="u-color-text-gray"> Esimated total (in USD): </span>
|
||||
{#if $organization?.billingPlan !== 'tier-0'}
|
||||
<span class="u-color-text-gray"> Total to date (in USD): </span>
|
||||
{/if}
|
||||
${aggregation?.amount}
|
||||
</p>
|
||||
|
||||
@@ -8,13 +8,7 @@
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { isTabSelected } from '$lib/helpers/load';
|
||||
import { Cover } from '$lib/layout';
|
||||
import {
|
||||
daysLeftInTrial,
|
||||
getServiceLimit,
|
||||
readOnly,
|
||||
tierToPlan,
|
||||
trialEndDate
|
||||
} from '$lib/stores/billing';
|
||||
import { daysLeftInTrial, getServiceLimit, readOnly, tierToPlan } from '$lib/stores/billing';
|
||||
import {
|
||||
members,
|
||||
newMemberModal,
|
||||
@@ -95,7 +89,7 @@
|
||||
class="u-flex u-cross-center"
|
||||
use:tooltip={{
|
||||
content: `Your trial ends on ${toLocaleDate(
|
||||
$trialEndDate.toString()
|
||||
$organization.billingTrialEndDate
|
||||
)}. ${$daysLeftInTrial} days remaining.`
|
||||
}}>
|
||||
<Pill>FREE TRIAL</Pill>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
{#if $createOrganization.billingPlan !== 'tier-0'}
|
||||
<div class="u-margin-block-start-32">
|
||||
<p class="body-text-1 u-bold">Organization members</p>
|
||||
<p class="text u-margin-block-start-8">{collaboratorsNumber} members invited</p>
|
||||
<p class="text u-margin-block-start-8">{collaboratorsNumber} members</p>
|
||||
</div>
|
||||
<div class="u-margin-block-start-32">
|
||||
<p class="body-text-1 u-bold">Payment</p>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
{#if $changeOrganizationTier.billingPlan !== 'tier-0'}
|
||||
<div class="u-margin-block-start-32">
|
||||
<p class="body-text-1 u-bold">Organization members</p>
|
||||
<p class="text u-margin-block-start-8">{collaboratorsNumber} members invited</p>
|
||||
<p class="text u-margin-block-start-8">{collaboratorsNumber} members</p>
|
||||
</div>
|
||||
<div class="u-margin-block-start-32">
|
||||
<p class="body-text-1 u-bold">Payment</p>
|
||||
|
||||
Reference in new issue
Block a user