- 将类型定义从各个模块统一到 type 文件中进行管理 - 移除 auth-session 中不再使用的 AuthSessionInput 和 AuthUser 类型导入 - 移除 game store 中多余的类型导入如 BetSelection、StartAutoHostingInput 等 - 将 i18n 模块中的 AppLanguage 类型改为从 type 文件导入 - 移除 mobile-header 中未使用的 MessageBroadcast 组件导入 - 统一各组件中的类型引用路径,全部指向 type 文件 - 修复 withdraw 组件中 currencies 映射的类型注解问题 - 更新 modal-store 中移除未使用的 ModalKey 类型导入
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { useMutation } from '@tanstack/react-query'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { createWithdraw } from '@/api'
|
|
import { notify } from '@/lib/notify'
|
|
import type { WithdrawCreateRequestDto } from '@/type'
|
|
|
|
export function useWithdrawSubmit() {
|
|
const { i18n, t } = useTranslation()
|
|
const locale = i18n.resolvedLanguage ?? i18n.language ?? 'en-US'
|
|
|
|
return useMutation({
|
|
mutationFn: (payload: WithdrawCreateRequestDto) => createWithdraw(payload),
|
|
onError: (error) => {
|
|
notify.error(
|
|
error instanceof Error
|
|
? error.message
|
|
: t('commonUi.toast.requestFailed'),
|
|
)
|
|
},
|
|
onSuccess: (data) => {
|
|
const formatter = new Intl.NumberFormat(locale, {
|
|
maximumFractionDigits: 2,
|
|
})
|
|
|
|
notify.success(t('gameDesktop.withdraw.submitSuccess'), {
|
|
description: [
|
|
t('gameDesktop.withdraw.success.orderNo', {
|
|
orderNo: data.order_no,
|
|
}),
|
|
t('gameDesktop.withdraw.success.actualArrivalCoin', {
|
|
amount: formatter.format(data.actual_arrival_coin),
|
|
}),
|
|
t('gameDesktop.withdraw.success.feeCoin', {
|
|
amount: formatter.format(data.fee_coin),
|
|
}),
|
|
t('gameDesktop.withdraw.success.reviewRequired', {
|
|
value: data.risk_review_required
|
|
? t('commonUi.dialog.yes')
|
|
: t('commonUi.dialog.no'),
|
|
}),
|
|
].join('\n'),
|
|
})
|
|
},
|
|
})
|
|
}
|