mirror of
https://github.com/modrinth/code.git
synced 2026-09-03 13:36:48 +00:00
fix: pix withdrawals (#6128)
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import type { MessageDescriptor } from '@modrinth/ui'
|
|||||||
import { createContext, getCurrencyIcon, paymentMethodMessages, useDebugLogger } from '@modrinth/ui'
|
import { createContext, getCurrencyIcon, paymentMethodMessages, useDebugLogger } from '@modrinth/ui'
|
||||||
import { type Component, computed, type ComputedRef, type Ref, ref } from 'vue'
|
import { type Component, computed, type ComputedRef, type Ref, ref } from 'vue'
|
||||||
|
|
||||||
import { getRailConfig } from '@/utils/muralpay-rails'
|
import { type FieldConfig, getRailConfig } from '@/utils/muralpay-rails'
|
||||||
|
|
||||||
export function getTaxThreshold(thresholds: Record<string, number> | undefined): number {
|
export function getTaxThreshold(thresholds: Record<string, number> | undefined): number {
|
||||||
if (!thresholds || Object.keys(thresholds).length === 0) return 600
|
if (!thresholds || Object.keys(thresholds).length === 0) return 600
|
||||||
@@ -263,6 +263,17 @@ function getRecipientDisplay(data: WithdrawData): string {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isRailFieldVisible(field: FieldConfig, accountDetails: AccountDetails): boolean {
|
||||||
|
if (!field.dependsOn) return true
|
||||||
|
|
||||||
|
const { field: dependsOnField, value: dependsOnValue } = field.dependsOn
|
||||||
|
const currentValue = accountDetails[dependsOnField]
|
||||||
|
|
||||||
|
if (!currentValue) return false
|
||||||
|
if (Array.isArray(dependsOnValue)) return dependsOnValue.includes(currentValue)
|
||||||
|
return currentValue === dependsOnValue
|
||||||
|
}
|
||||||
|
|
||||||
interface PayoutPayload {
|
interface PayoutPayload {
|
||||||
amount: number
|
amount: number
|
||||||
method: 'tremendous' | 'muralpay' | 'paypal' | 'venmo'
|
method: 'tremendous' | 'muralpay' | 'paypal' | 'venmo'
|
||||||
@@ -329,6 +340,8 @@ function buildPayoutPayload(data: WithdrawData): PayoutPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const field of rail.fields) {
|
for (const field of rail.fields) {
|
||||||
|
if (!isRailFieldVisible(field, data.providerData.accountDetails)) continue
|
||||||
|
|
||||||
const value = data.providerData.accountDetails[field.name]
|
const value = data.providerData.accountDetails[field.name]
|
||||||
if (value !== undefined && value !== null && value !== '') {
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
fiatAndRailDetails[field.name] = value
|
fiatAndRailDetails[field.name] = value
|
||||||
@@ -752,7 +765,9 @@ export function createWithdrawContext(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const requiredFields = rail.fields.filter((f) => f.required)
|
const requiredFields = rail.fields.filter(
|
||||||
|
(f) => f.required && isRailFieldVisible(f, accountDetails),
|
||||||
|
)
|
||||||
const allRequiredPresent = requiredFields.every((f) => {
|
const allRequiredPresent = requiredFields.every((f) => {
|
||||||
const value = accountDetails[f.name]
|
const value = accountDetails[f.name]
|
||||||
return value !== undefined && value !== null && value !== ''
|
return value !== undefined && value !== null && value !== ''
|
||||||
|
|||||||
Reference in New Issue
Block a user