You've already forked AstralRinth
forked from didirus/AstralRinth
* fix tauri config * fix package patch * regen pnpm lock * use new workflow * New GH actions * Update lockfile * update scripts * Fix build script * Fix missing deps * Fix assets eslint * Update libraries lint * Fix all lint configs * update lockfile * add fmt + clippy fails * Separate App Tauri portion * fix app features * Fix lints * install tauri cli * update lockfile * corepack, fix lints * add store path * fix unused import * Fix tests * Issue templates + port over tauri release * fix actions * fix before build command * Add X86 target * Update build matrix * finalize actions * make debug build smaller * Use debug build to make cache smaller * dummy commit * change proj name * update file name * Use release builds for less space use * Remove rust cache * Readd for app build * add merge queue trigger
227 lines
6.6 KiB
Vue
227 lines
6.6 KiB
Vue
<template>
|
|
<div>
|
|
<section class="universal-card payout-history">
|
|
<Breadcrumbs
|
|
current-title="Transfer history"
|
|
:link-stack="[{ href: '/dashboard/revenue', label: 'Revenue' }]"
|
|
/>
|
|
<h2>Transfer history</h2>
|
|
<p>All of your withdrawals from your Modrinth balance will be listed here:</p>
|
|
<div class="input-group">
|
|
<DropdownSelect
|
|
v-model="selectedYear"
|
|
:options="years"
|
|
:display-name="(x) => (x === 'all' ? 'All years' : x)"
|
|
name="Year filter"
|
|
/>
|
|
<DropdownSelect
|
|
v-model="selectedMethod"
|
|
:options="methods"
|
|
:display-name="
|
|
(x) => (x === 'all' ? 'Any method' : x === 'paypal' ? 'PayPal' : capitalizeString(x))
|
|
"
|
|
name="Method filter"
|
|
/>
|
|
</div>
|
|
<p>
|
|
{{
|
|
selectedYear !== "all"
|
|
? selectedMethod !== "all"
|
|
? formatMessage(messages.transfersTotalYearMethod, {
|
|
amount: $formatMoney(totalAmount),
|
|
year: selectedYear,
|
|
method: selectedMethod,
|
|
})
|
|
: formatMessage(messages.transfersTotalYear, {
|
|
amount: $formatMoney(totalAmount),
|
|
year: selectedYear,
|
|
})
|
|
: selectedMethod !== "all"
|
|
? formatMessage(messages.transfersTotalMethod, {
|
|
amount: $formatMoney(totalAmount),
|
|
method: selectedMethod,
|
|
})
|
|
: formatMessage(messages.transfersTotal, { amount: $formatMoney(totalAmount) })
|
|
}}
|
|
</p>
|
|
<div
|
|
v-for="payout in filteredPayouts"
|
|
:key="payout.id"
|
|
class="universal-card recessed payout"
|
|
>
|
|
<div class="platform">
|
|
<PayPalIcon v-if="payout.method === 'paypal'" />
|
|
<TremendousIcon v-else-if="payout.method === 'tremendous'" />
|
|
<VenmoIcon v-else-if="payout.method === 'venmo'" />
|
|
<UnknownIcon v-else />
|
|
</div>
|
|
<div class="payout-info">
|
|
<div>
|
|
<strong>
|
|
{{ $dayjs(payout.created).format("MMMM D, YYYY [at] h:mm A") }}
|
|
</strong>
|
|
</div>
|
|
<div>
|
|
<span class="amount">{{ $formatMoney(payout.amount) }}</span>
|
|
<template v-if="payout.fee">⋅ Fee {{ $formatMoney(payout.fee) }}</template>
|
|
</div>
|
|
<div class="payout-status">
|
|
<span>
|
|
<Badge v-if="payout.status === 'success'" color="green" type="Success" />
|
|
<Badge v-else-if="payout.status === 'cancelling'" color="yellow" type="Cancelling" />
|
|
<Badge v-else-if="payout.status === 'cancelled'" color="red" type="Cancelled" />
|
|
<Badge v-else-if="payout.status === 'failed'" color="red" type="Failed" />
|
|
<Badge v-else-if="payout.status === 'in-transit'" color="yellow" type="In transit" />
|
|
<Badge v-else :type="payout.status" />
|
|
</span>
|
|
<template v-if="payout.method">
|
|
<span>⋅</span>
|
|
<span>{{ $formatWallet(payout.method) }} ({{ payout.method_address }})</span>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
<div class="input-group">
|
|
<button
|
|
v-if="payout.status === 'in-transit'"
|
|
class="iconified-button raised-button"
|
|
@click="cancelPayout(payout.id)"
|
|
>
|
|
<XIcon /> Cancel payment
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</template>
|
|
<script setup>
|
|
import { XIcon, PayPalIcon, UnknownIcon } from "@modrinth/assets";
|
|
import { capitalizeString } from "@modrinth/utils";
|
|
import { Badge, Breadcrumbs, DropdownSelect } from "@modrinth/ui";
|
|
import dayjs from "dayjs";
|
|
import TremendousIcon from "~/assets/images/external/tremendous.svg?component";
|
|
import VenmoIcon from "~/assets/images/external/venmo-small.svg?component";
|
|
|
|
const vintl = useVIntl();
|
|
const { formatMessage } = vintl;
|
|
|
|
useHead({
|
|
title: "Transfer history - Modrinth",
|
|
});
|
|
|
|
const data = await useNuxtApp();
|
|
const auth = await useAuth();
|
|
|
|
const { data: payouts, refresh } = await useAsyncData(`payout`, () =>
|
|
useBaseFetch(`payout`, {
|
|
apiVersion: 3,
|
|
}),
|
|
);
|
|
|
|
const sortedPayouts = computed(() =>
|
|
payouts.value.sort((a, b) => dayjs(b.created) - dayjs(a.created)),
|
|
);
|
|
|
|
const years = computed(() => {
|
|
const values = sortedPayouts.value.map((x) => dayjs(x.created).year());
|
|
return ["all", ...new Set(values)];
|
|
});
|
|
|
|
const selectedYear = ref("all");
|
|
|
|
const methods = computed(() => {
|
|
const values = sortedPayouts.value.filter((x) => x.method).map((x) => x.method);
|
|
return ["all", ...new Set(values)];
|
|
});
|
|
|
|
const selectedMethod = ref("all");
|
|
|
|
const filteredPayouts = computed(() =>
|
|
sortedPayouts.value
|
|
.filter((x) => selectedYear.value === "all" || dayjs(x.created).year() === selectedYear.value)
|
|
.filter((x) => selectedMethod.value === "all" || x.method === selectedMethod.value),
|
|
);
|
|
|
|
const totalAmount = computed(() =>
|
|
filteredPayouts.value.reduce((sum, payout) => sum + payout.amount, 0),
|
|
);
|
|
|
|
async function cancelPayout(id) {
|
|
startLoading();
|
|
try {
|
|
await useBaseFetch(`payout/${id}`, {
|
|
method: "DELETE",
|
|
apiVersion: 3,
|
|
});
|
|
await refresh();
|
|
await useAuth(auth.value.token);
|
|
} catch (err) {
|
|
data.$notify({
|
|
group: "main",
|
|
title: "An error occurred",
|
|
text: err.data.description,
|
|
type: "error",
|
|
});
|
|
}
|
|
stopLoading();
|
|
}
|
|
|
|
const messages = defineMessages({
|
|
transfersTotal: {
|
|
id: "revenue.transfers.total",
|
|
defaultMessage: "You have withdrawn {amount} in total.",
|
|
},
|
|
transfersTotalYear: {
|
|
id: "revenue.transfers.total.year",
|
|
defaultMessage: "You have withdrawn {amount} in {year}.",
|
|
},
|
|
transfersTotalMethod: {
|
|
id: "revenue.transfers.total.method",
|
|
defaultMessage: "You have withdrawn {amount} through {method}.",
|
|
},
|
|
transfersTotalYearMethod: {
|
|
id: "revenue.transfers.total.year_method",
|
|
defaultMessage: "You have withdrawn {amount} in {year} through {method}.",
|
|
},
|
|
});
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.payout {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
|
|
.platform {
|
|
display: flex;
|
|
padding: 0.75rem;
|
|
background-color: var(--color-raised-bg);
|
|
width: fit-content;
|
|
height: fit-content;
|
|
border-radius: 20rem;
|
|
|
|
svg {
|
|
width: 2rem;
|
|
height: 2rem;
|
|
}
|
|
}
|
|
|
|
.payout-status {
|
|
display: flex;
|
|
gap: 0.5ch;
|
|
}
|
|
|
|
.amount {
|
|
color: var(--color-heading);
|
|
font-weight: 500;
|
|
}
|
|
|
|
@media screen and (min-width: 800px) {
|
|
flex-direction: row;
|
|
align-items: center;
|
|
|
|
.input-group {
|
|
margin-left: auto;
|
|
}
|
|
}
|
|
}
|
|
</style>
|