+ This method has a fixed transfer amount of
+ {{ $formatMoney(minWithdrawAmount) }}.
+
+
+
-
+
+
+ This method has a minimum transfer amount of
+ {{ $formatMoney(minWithdrawAmount) }} and a maximum transfer amount of
+ {{ $formatMoney(maxWithdrawAmount) }}.
+
+
+
+ You have entered {{ $formatMoney(parsedAmount) }} to transfer.
+
+
@@ -206,6 +238,36 @@ const fees = computed(() => {
selectedMethod.value.fee.max ?? Number.MAX_VALUE
)
})
+
+const getIntervalRange = (intervalType) => {
+ if (!intervalType) {
+ return []
+ }
+
+ const { min, max, values } = intervalType
+ if (values) {
+ const first = values[0]
+ const last = values.slice(-1)[0]
+ return first === last ? [first] : [first, last]
+ }
+
+ return min === max ? [min] : [min, max]
+}
+
+const getRangeOfMethod = (method) => {
+ return getIntervalRange(method.interval?.fixed || method.interval?.standard)
+}
+
+const maxWithdrawAmount = computed(() => {
+ const interval = selectedMethod.value.interval
+ return interval?.standard ? interval.standard.max : interval?.fixed?.values.slice(-1)[0] ?? 0
+})
+
+const minWithdrawAmount = computed(() => {
+ const interval = selectedMethod.value.interval
+ return interval?.standard ? interval.standard.min : interval?.fixed?.values?.[0] ?? fees.value
+})
+
const withdrawAccount = computed(() => {
if (selectedMethod.value.type === 'paypal') {
return auth.value.user.payout_data.paypal_address
@@ -234,12 +296,15 @@ 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) {
- errors.push(
- `The amount must be no more than ${data.$formatMoney(auth.value.user.payout_data.balance)}`
- )
- } else if (parsedAmount.value <= fees.value) {
- errors.push(`The amount must be at least ${data.$formatMoney(fees.value + 0.01)}`)
+ } else if (
+ parsedAmount.value > auth.value.user.payout_data.balance ||
+ parsedAmount.value > maxWithdrawAmount.value
+ ) {
+ const maxAmount = Math.min(auth.value.user.payout_data.balance, 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)
+ errors.push(`The amount must be at least ${data.$formatMoney(minAmount)}`)
}
return errors
@@ -256,6 +321,18 @@ watch(country, async () => {
}
})
+watch(selectedMethod, () => {
+ if (selectedMethod.value.interval?.fixed) {
+ amount.value = selectedMethod.value.interval.fixed.values[0]
+ }
+ if (maxWithdrawAmount.value === minWithdrawAmount.value) {
+ amount.value = maxWithdrawAmount.value
+ }
+ agreedTransfer.value = false
+ agreedFees.value = false
+ agreedTerms.value = false
+})
+
async function withdraw() {
startLoading()
try {
@@ -353,6 +430,22 @@ async function withdraw() {
display: flex;
justify-content: center;
aspect-ratio: 30 / 19;
+ position: relative;
+
+ .preview-badges {
+ // These will float over the image in the bottom right corner
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ padding: var(--gap-sm) var(--gap-xs);
+
+ .badge {
+ background-color: var(--color-button-bg);
+ border-radius: var(--radius-xs);
+ padding: var(--gap-xs) var(--gap-sm);
+ font-size: var(--font-size-xs);
+ }
+ }
&.show-bg {
background-color: var(--color-bg);