优化提现功能,更新提现审核逻辑以处理API响应,确保在操作失败时提供用户反馈。同时,调整页面数据加载逻辑,提升用户体验和代码可读性。
This commit is contained in:
@@ -221,21 +221,28 @@ export function DistributionPage() {
|
||||
}
|
||||
}
|
||||
|
||||
function refreshCurrentTab() {
|
||||
async function refreshCurrentTab() {
|
||||
setLoadedTabs((prev) => {
|
||||
const next = new Set(prev)
|
||||
next.delete(activeTab)
|
||||
return next
|
||||
})
|
||||
if (activeTab === 'overview') loadInitialData()
|
||||
loadTabData(activeTab, true)
|
||||
await loadTabData(activeTab, true)
|
||||
}
|
||||
|
||||
async function handleApproveWithdrawal(id: string) {
|
||||
if (!confirm('确认审核通过并打款?')) return
|
||||
try {
|
||||
await put('/api/admin/withdrawals', { id, action: 'approve' })
|
||||
refreshCurrentTab()
|
||||
const res = await put<{ success?: boolean; error?: string }>('/api/admin/withdrawals', {
|
||||
id,
|
||||
action: 'approve',
|
||||
})
|
||||
if (!res?.success) {
|
||||
alert(res?.error || '操作失败')
|
||||
return
|
||||
}
|
||||
await refreshCurrentTab()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
alert('操作失败')
|
||||
@@ -246,8 +253,15 @@ export function DistributionPage() {
|
||||
const reason = prompt('请输入拒绝原因:')
|
||||
if (!reason) return
|
||||
try {
|
||||
await put('/api/admin/withdrawals', { id, action: 'reject', errorMessage: reason })
|
||||
refreshCurrentTab()
|
||||
const res = await put<{ success?: boolean; error?: string }>(
|
||||
'/api/admin/withdrawals',
|
||||
{ id, action: 'reject', errorMessage: reason },
|
||||
)
|
||||
if (!res?.success) {
|
||||
alert(res?.error || '操作失败')
|
||||
return
|
||||
}
|
||||
await refreshCurrentTab()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
alert('操作失败')
|
||||
|
||||
Reference in New Issue
Block a user