add flouner stats

This commit is contained in:
Ben Allfree 2024-10-16 19:30:43 -07:00
parent cc74a73b4e
commit 6ef7b73edd
3 changed files with 18 additions and 3 deletions

View File

@ -1,8 +1,10 @@
<script lang="ts"> <script lang="ts">
import { PLAN_NAMES, SubscriptionType } from 'pockethost' import { PLAN_NAMES, SubscriptionType } from 'pockethost'
import { userStore } from '$util/stores' import { stats, userStore } from '$util/stores'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import PricingCard from '$src/routes/(static)/pricing/PricingCard.svelte' import PricingCard from '$src/routes/(static)/pricing/PricingCard.svelte'
import { client } from '$src/pocketbase-client'
import { writable } from 'svelte/store'
export let priceMonthly: [number, string?, number?] = [ export let priceMonthly: [number, string?, number?] = [
359, 359,
@ -21,7 +23,7 @@
<PricingCard <PricingCard
name={`${PLAN_NAMES[SubscriptionType.Flounder]}`} name={`${PLAN_NAMES[SubscriptionType.Flounder]}`}
qtyRemaining={999} qtyRemaining={1000 - $stats.total_flounder_subscribers}
qtyMax={1000} qtyMax={1000}
{comingSoonText} {comingSoonText}
{comingSoon} {comingSoon}

View File

@ -18,7 +18,7 @@
export let fundingGoals: string[] = [] export let fundingGoals: string[] = []
export let startDate: Date | null = null export let startDate: Date | null = null
const qtySold = qtyMax - qtyRemaining $: qtySold = qtyMax - qtyRemaining
let countdown = '' let countdown = ''
let countdownInterval: ReturnType<typeof setInterval> let countdownInterval: ReturnType<typeof setInterval>

View File

@ -34,9 +34,22 @@ export const globalInstancesStore = writable<{
[_: InstanceId]: InstanceFields [_: InstanceId]: InstanceFields
}>({}) }>({})
export const globalInstancesStoreReady = writable(false) export const globalInstancesStoreReady = writable(false)
export const stats = writable<{
total_flounder_subscribers: number
}>({
total_flounder_subscribers: 0,
})
export const init = () => { export const init = () => {
const { onAuthChange } = client() const { onAuthChange } = client()
client()
.client.send(`/api/stats`, {})
.then((res) => {
stats.set(res)
})
.catch(console.error)
onAuthChange((authStoreProps) => { onAuthChange((authStoreProps) => {
const isLoggedIn = authStoreProps.isValid const isLoggedIn = authStoreProps.isValid
isUserLoggedIn.set(isLoggedIn) isUserLoggedIn.set(isLoggedIn)