diff --git a/apps/frontend/src/pages/dashboard/index.vue b/apps/frontend/src/pages/dashboard/index.vue index 583bb703e..2b7d63fa7 100644 --- a/apps/frontend/src/pages/dashboard/index.vue +++ b/apps/frontend/src/pages/dashboard/index.vue @@ -88,20 +88,6 @@ > -
-
Current balance
-
- {{ $formatMoney(auth.user.payout_data.balance, true) }} -
- - Withdraw earnings - -
diff --git a/apps/frontend/src/pages/dashboard/revenue/index.vue b/apps/frontend/src/pages/dashboard/revenue/index.vue index 407f9f7bb..dc887c6fd 100644 --- a/apps/frontend/src/pages/dashboard/revenue/index.vue +++ b/apps/frontend/src/pages/dashboard/revenue/index.vue @@ -2,21 +2,24 @@

Revenue

-
+

You have - {{ $formatMoney(auth.user.payout_data.balance) }} - available to withdraw. + {{ $formatMoney(userBalance.available) }} + available to withdraw. {{ $formatMoney(userBalance.pending) }} of your + balance is pending.

You have made - {{ $formatMoney(auth.user.payout_data.balance) }}{{ $formatMoney(userBalance.available) }}, which is under the minimum of ${{ minWithdraw }} to withdraw. + {{ $formatMoney(userBalance.pending) }} of your balance is + pending.

@@ -81,6 +84,10 @@ import { TransferIcon, HistoryIcon, PayPalIcon, SaveIcon, XIcon } from "@modrint const auth = await useAuth(); const minWithdraw = ref(0.01); +const { data: userBalance } = await useAsyncData(`payout/balance`, () => + useBaseFetch(`payout/balance`, { apiVersion: 3 }), +); + async function updateVenmo() { startLoading(); try { diff --git a/apps/frontend/src/pages/dashboard/revenue/withdraw.vue b/apps/frontend/src/pages/dashboard/revenue/withdraw.vue index 3ec3ae965..eec8468c6 100644 --- a/apps/frontend/src/pages/dashboard/revenue/withdraw.vue +++ b/apps/frontend/src/pages/dashboard/revenue/withdraw.vue @@ -88,7 +88,7 @@

You are initiating a transfer of your revenue from Modrinth's Creator Monetization Program. How much of your - {{ $formatMoney(auth.user.payout_data.balance) }} balance would you like to + {{ $formatMoney(userBalance.available) }} balance would you like to transfer transfer to {{ selectedMethod.name }}?

@@ -212,10 +212,13 @@ const country = ref( countries.value.find((x) => x.id === (auth.value.user.payout_data.paypal_region ?? "US")), ); -const { data: payoutMethods, refresh: refreshPayoutMethods } = await useAsyncData( - `payout/methods?country=${country.value.id}`, - () => useBaseFetch(`payout/methods?country=${country.value.id}`, { apiVersion: 3 }), -); +const [{ data: userBalance }, { data: payoutMethods, refresh: refreshPayoutMethods }] = + await Promise.all([ + useAsyncData(`payout/balance`, () => useBaseFetch(`payout/balance`, { apiVersion: 3 })), + useAsyncData(`payout/methods?country=${country.value.id}`, () => + useBaseFetch(`payout/methods?country=${country.value.id}`, { apiVersion: 3 }), + ), + ]); const selectedMethodId = ref(payoutMethods.value[0].id); const selectedMethod = computed(() => @@ -295,10 +298,10 @@ const knownErrors = computed(() => { if (!parsedAmount.value && amount.value.length > 0) { errors.push(`${amount.value} is not a valid amount`); } else if ( - parsedAmount.value > auth.value.user.payout_data.balance || + parsedAmount.value > userBalance.value.available || parsedAmount.value > maxWithdrawAmount.value ) { - const maxAmount = Math.min(auth.value.user.payout_data.balance, maxWithdrawAmount.value); + const maxAmount = Math.min(userBalance.value.available, maxWithdrawAmount.value); errors.push(`The amount must be no more than ${data.$formatMoney(maxAmount)}`); } else if (parsedAmount.value <= fees.value || parsedAmount.value < minWithdrawAmount.value) { const minAmount = Math.max(fees.value + 0.01, minWithdrawAmount.value); diff --git a/apps/frontend/src/public/promo-frame.html b/apps/frontend/src/public/promo-frame.html index 57e35b2e0..226c5de11 100644 --- a/apps/frontend/src/public/promo-frame.html +++ b/apps/frontend/src/public/promo-frame.html @@ -64,9 +64,9 @@ (event) => { if (event.data.modrinthOpenUrl && window.__TAURI_INTERNALS__ && lastUrl !== event.data.modrinthOpenUrl) { lastUrl = event.data.modrinthOpenUrl - window.__TAURI_INTERNALS__.invoke("plugin:shell|open", { - path: event.data.modrinthOpenUrl, - }); + // window.__TAURI_INTERNALS__.invoke("plugin:shell|open", { + // path: event.data.modrinthOpenUrl, + // }); setTimeout(() => { lastUrl = null