Skip to content

Commit f9942ff

Browse files
committed
vibe-coded frontend changes
1 parent cdbc540 commit f9942ff

File tree

2 files changed

+63
-17
lines changed

2 files changed

+63
-17
lines changed

apps/frontend/src/components/ui/dashboard/WithdrawFeeBreakdown.vue

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
<template v-if="isGiftCard && shouldShowExchangeRate">
1212
<div class="flex items-center justify-between">
1313
<span class="text-primary">{{ formatMessage(messages.feeBreakdownGiftCardValue) }}</span>
14-
<span class="font-semibold text-contrast"
15-
>{{ formatMoney(amount || 0) }} ({{ formattedLocalCurrency }})</span
16-
>
14+
<span class="font-semibold text-contrast">{{ formatMoney(amountInUsd) }} ({{ formattedLocalCurrencyAmount }})</span>
1715
</div>
1816
</template>
1917
<template v-else>
2018
<div class="flex items-center justify-between">
2119
<span class="text-primary">{{ formatMessage(messages.feeBreakdownAmount) }}</span>
22-
<span class="font-semibold text-contrast">{{ formatMoney(amount || 0) }}</span>
20+
<span class="font-semibold text-contrast">{{ formatMoney(amountInUsd) }}</span>
2321
</div>
2422
</template>
2523

@@ -29,7 +27,7 @@
2927
<template v-if="feeLoading">
3028
<LoaderCircleIcon class="size-5 animate-spin !text-secondary" />
3129
</template>
32-
<template v-else>-{{ formatMoney(fee || 0) }}</template>
30+
<template v-else>-{{ formatMoney(feeInUsd) }}</template>
3331
</span>
3432
</div>
3533

@@ -79,9 +77,23 @@ const props = withDefaults(
7977
8078
const { formatMessage } = useVIntl()
8179
80+
const amountInUsd = computed(() => {
81+
if (props.isGiftCard && shouldShowExchangeRate.value) {
82+
return (props.amount || 0) / (props.exchangeRate || 1)
83+
}
84+
return props.amount || 0
85+
})
86+
87+
const feeInUsd = computed(() => {
88+
if (props.isGiftCard && shouldShowExchangeRate.value) {
89+
return (props.fee || 0) / (props.exchangeRate || 1)
90+
}
91+
return props.fee || 0
92+
})
93+
8294
const netAmount = computed(() => {
83-
const amount = props.amount || 0
84-
const fee = props.fee || 0
95+
const amount = amountInUsd.value
96+
const fee = feeInUsd.value
8597
return Math.max(0, amount - fee)
8698
})
8799
@@ -96,6 +108,11 @@ const netAmountInLocalCurrency = computed(() => {
96108
return netAmount.value * (props.exchangeRate || 0)
97109
})
98110
111+
const localCurrencyAmount = computed(() => {
112+
if (!shouldShowExchangeRate.value) return null
113+
return (props.amount || 0)
114+
})
115+
99116
const formattedLocalCurrency = computed(() => {
100117
if (!shouldShowExchangeRate.value || !netAmountInLocalCurrency.value || !props.localCurrency)
101118
return ''
@@ -112,6 +129,22 @@ const formattedLocalCurrency = computed(() => {
112129
}
113130
})
114131
132+
const formattedLocalCurrencyAmount = computed(() => {
133+
if (!shouldShowExchangeRate.value || !localCurrencyAmount.value || !props.localCurrency)
134+
return ''
135+
136+
try {
137+
return new Intl.NumberFormat('en-US', {
138+
style: 'currency',
139+
currency: props.localCurrency,
140+
minimumFractionDigits: 2,
141+
maximumFractionDigits: 2,
142+
}).format(localCurrencyAmount.value)
143+
} catch {
144+
return `${props.localCurrency} ${localCurrencyAmount.value.toFixed(2)}`
145+
}
146+
})
147+
115148
const messages = defineMessages({
116149
feeBreakdownAmount: {
117150
id: 'dashboard.creator-withdraw-modal.fee-breakdown-amount',

apps/frontend/src/components/ui/dashboard/withdraw-stages/TremendousDetailsStage.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@
111111
</Combobox>
112112
</div>
113113
<span v-if="selectedMethodDetails" class="text-secondary">
114-
{{ formatMoney(fixedDenominationMin ?? effectiveMinAmount)
114+
{{
115+
formatMoney(
116+
selectedMethodCurrencyCode && selectedMethodCurrencyCode !== 'USD' && selectedMethodExchangeRate
117+
? (fixedDenominationMin ?? effectiveMinAmount) / selectedMethodExchangeRate
118+
: (fixedDenominationMin ?? effectiveMinAmount),
119+
)
115120
}}<template v-if="selectedMethodCurrencyCode && selectedMethodCurrencyCode !== 'USD'">
116121
({{
117122
formatAmountForDisplay(
@@ -124,9 +129,13 @@
124129
min,
125130
{{
126131
formatMoney(
127-
fixedDenominationMax ??
128-
selectedMethodDetails.interval?.standard?.max ??
129-
effectiveMaxAmount,
132+
selectedMethodCurrencyCode && selectedMethodCurrencyCode !== 'USD' && selectedMethodExchangeRate
133+
? (fixedDenominationMax ??
134+
selectedMethodDetails.interval?.standard?.max ??
135+
effectiveMaxAmount) / selectedMethodExchangeRate
136+
: (fixedDenominationMax ??
137+
selectedMethodDetails.interval?.standard?.max ??
138+
effectiveMaxAmount),
130139
)
131140
}}<template v-if="selectedMethodCurrencyCode && selectedMethodCurrencyCode !== 'USD'">
132141
({{
@@ -145,7 +154,12 @@
145154
v-if="selectedMethodDetails && effectiveMinAmount > roundedMaxAmount"
146155
class="text-sm text-red"
147156
>
148-
You need at least {{ formatMoney(effectiveMinAmount)
157+
You need at least {{
158+
formatMoney(
159+
selectedMethodCurrencyCode && selectedMethodCurrencyCode !== 'USD' && selectedMethodExchangeRate
160+
? effectiveMinAmount / selectedMethodExchangeRate
161+
: effectiveMinAmount,
162+
)
149163
}}<template v-if="selectedMethodCurrencyCode && selectedMethodCurrencyCode !== 'USD'">
150164
({{
151165
formatAmountForDisplay(
@@ -207,7 +221,7 @@
207221
formatMessage(messages.balanceWorthHint, {
208222
usdBalance: formatMoney(roundedMaxAmount),
209223
localBalance: formatAmountForDisplay(
210-
roundedMaxAmount,
224+
roundedMaxAmount * selectedMethodExchangeRate,
211225
selectedMethodCurrencyCode,
212226
selectedMethodExchangeRate,
213227
),
@@ -273,7 +287,7 @@
273287
formatMessage(messages.balanceWorthHint, {
274288
usdBalance: formatMoney(roundedMaxAmount),
275289
localBalance: formatAmountForDisplay(
276-
roundedMaxAmount,
290+
roundedMaxAmount * selectedMethodExchangeRate,
277291
selectedMethodCurrencyCode,
278292
selectedMethodExchangeRate,
279293
),
@@ -608,14 +622,13 @@ const giftCardExchangeRate = computed(() => {
608622
})
609623
610624
function formatAmountForDisplay(
611-
usdAmount: number,
625+
localAmount: number,
612626
currencyCode: string | null | undefined,
613627
rate: number | null | undefined,
614628
): string {
615629
if (!currencyCode || currencyCode === 'USD' || !rate) {
616-
return formatMoney(usdAmount)
630+
return formatMoney(localAmount)
617631
}
618-
const localAmount = usdAmount * rate
619632
try {
620633
return new Intl.NumberFormat('en-US', {
621634
style: 'currency',

0 commit comments

Comments
 (0)