feat: add functional data for donation page

This commit is contained in:
mrjvs
2026-08-12 20:06:01 +02:00
parent 42782367ba
commit 8a8c84756d
2 changed files with 54 additions and 1 deletions

View File

@@ -108,7 +108,7 @@ Miscellanous tasks:
- [x] Discourse SSO
- [x] HCaptcha
- [x] RSS feed
- [ ] Stripe checkout
- [x] Stripe checkout
- [ ] Stripe donation progress
- [ ] Stripe webhooks (+ mailing)
- [x] Forgot password flow

View File

@@ -0,0 +1,53 @@
<script setup lang="ts">
import type { ApiAccountCheckoutRequest } from '~~/shared/api-types';
definePageMeta({
needsAuth: true
});
const { data: tierData } = await useApiFetch('/api/account/tiers');
const sortedTiers = computed(() => [...tierData.value?.tiers ?? []].sort((a, b) => a.tierLevel - b.tierLevel));
async function checkout(priceId: string) {
try {
const result = await apiFetch('/api/account/checkout', {
method: 'POST',
body: {
priceId
} satisfies ApiAccountCheckoutRequest
});
await navigateTo(result.url, { external: true });
} catch (error: unknown) {
const err = getApiError(error);
alert(err.code);
}
}
</script>
<template>
<div>
<h1>Tiers</h1>
<div
v-for="tier of sortedTiers"
:key="tier.priceId"
:style="{ border: '1px solid white'}"
>
<h2>{{ tier.name }}</h2>
<p>{{ tier.description }}</p>
<p v-if="tier.perks.beta">
Perk: Beta access
</p>
<p v-if="tier.perks.discordRead">
Perk: Read discord channels
</p>
<img
v-if="tier.thumbnailUrl"
:src="tier.thumbnailUrl"
>
<p>Cost: {{ tier.priceCents }} cents</p>
<button @click="checkout(tier.priceId)">
Checkout
</button>
</div>
</div>
</template>