Files
AstralRinth/apps/frontend/src/pages/settings/billing/charges.vue
Prospector 1bbb01bd42 devex: migrate to vue-i18n (#4966)
* sample languages refactor

* feat: consistency + dedupe impl of i18n

* fix: broken imports

* fix: intl formatted component

* fix: use relative imports

* fix: imports

* fix: comment out incomplete locales + fix imports

* feat: cleanup

* fix: ui imports

* fix: lint

* fix: admonition import

* make footer a component, fix language reactivity

* make copyright notice untranslatable

---------

Co-authored-by: Calum H. <contact@cal.engineer>
2025-12-27 21:37:37 +00:00

72 lines
2.0 KiB
Vue

<template>
<div>
<section class="card">
<Breadcrumbs
current-title="Past charges"
:link-stack="[{ href: '/settings/billing', label: 'Billing and subscriptions' }]"
/>
<h2>Past charges</h2>
<p>All of your past charges to your Modrinth account will be listed here:</p>
<div
v-for="charge in charges"
:key="charge.id"
class="universal-card recessed flex items-center justify-between gap-4"
>
<div class="flex flex-col gap-1">
<div class="flex items-center gap-1">
<span class="font-bold text-primary">
<template v-if="charge.product?.metadata?.type === 'midas'"> Modrinth Plus </template>
<template v-else-if="charge.product?.metadata?.type === 'pyro'">
Modrinth Hosting
</template>
<template v-else> Medal Server Trial </template>
<template v-if="charge.subscription_interval">
{{ charge.subscription_interval }}
</template>
</span>
<span>{{ formatPrice(vintl.locale, charge.amount, charge.currency_code) }}</span>
</div>
<div class="flex items-center gap-1">
<Badge :color="charge.status === 'succeeded' ? 'green' : 'red'" :type="charge.status" />
{{ $dayjs(charge.due).format('YYYY-MM-DD') }}
</div>
</div>
</div>
</section>
</div>
</template>
<script setup>
import { Badge, Breadcrumbs, useVIntl } from '@modrinth/ui'
import { formatPrice } from '@modrinth/utils'
import { products } from '~/generated/state.json'
definePageMeta({
middleware: 'auth',
})
const vintl = useVIntl()
const { data: charges } = await useAsyncData(
'billing/payments',
() => useBaseFetch('billing/payments', { internal: true }),
{
transform: (charges) => {
return charges
.filter((charge) => charge.status !== 'open' && charge.status !== 'cancelled')
.map((charge) => {
const product = products.find((product) =>
product.prices.some((price) => price.id === charge.price_id),
)
charge.product = product
return charge
})
},
},
)
</script>