You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
6.0 KiB

10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
11 months ago
10 months ago
9 months ago
11 months ago
10 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
10 months ago
  1. import { Button, Form, Input, Select, notification } from 'antd'
  2. import '../../styles/home.scss'
  3. import { useRef, useState } from 'react'
  4. import { observer } from 'mobx-react'
  5. import store from '../../store'
  6. import { http_send_email, http_transfer } from '../../http/api'
  7. import { useTranslation } from 'react-i18next'
  8. import CountdownTimer, { CountdownTimerRef } from '../../components/CountdownTimer'
  9. const Transfer = () => {
  10. const { userInfo } = store.state
  11. const [form] = Form.useForm()
  12. const { t } = useTranslation()
  13. const options = [
  14. { label: t('Cash Wallet-Asset Account'), value: 1 },
  15. { label: t('Cash Wallet-Other Members'), value: 2 },
  16. { label: t('Asset Account-Cash Wallet'), value: 3 }
  17. ]
  18. const [type, setType] = useState(-1)
  19. const countdownRef = useRef<CountdownTimerRef>(null)
  20. const onSelect = (_type: any) => {
  21. setType(_type)
  22. }
  23. const getVerifyCode = async () => {
  24. try {
  25. if (countdownRef.current?.isActive) return
  26. countdownRef.current?.handleStart()
  27. const res: any = await http_send_email({
  28. email: userInfo.email,
  29. type: 5
  30. })
  31. if (res.code === 0) {
  32. notification.success({
  33. message: t('Verification code sent successfully')
  34. })
  35. } else {
  36. notification.error({
  37. message: t('Failed to send verification code')
  38. })
  39. countdownRef.current?.handleStop()
  40. }
  41. } catch (error) {
  42. countdownRef.current?.handleStop()
  43. }
  44. }
  45. const onFinish = async (values: any) => {
  46. const res: any = await http_transfer({
  47. ...values,
  48. type
  49. })
  50. if (res.code === 0) {
  51. store.getUserInfo()
  52. form.resetFields()
  53. notification.success({
  54. message: t('Submit success')
  55. })
  56. }
  57. }
  58. return (
  59. <div className="deposit">
  60. <div className='text-white fz-22 mb-2'>{t('Assets transfer')}</div>
  61. <div className="flex-1 container">
  62. <div className='p-2'>
  63. <div className='fz-wb-550'>{t('Assets transfer-matters needing attention')}</div>
  64. <div className='text-sub fz-14 mt-1'>
  65. <p>{t('1.Please ensure the safety of the equipment during use,Prevent data from being tampered with or leaked。')}</p>
  66. {/* <p>{t('2.In the process of fund transfer, if there is a delay or other situation,Please handle it later or contact customer service。')}</p> */}
  67. {/* <p>{t('3.After fund transfer operation,There may be delays in the system;If exceeding10Minutes have not yet arrived,Please contact customer service。')}</p> */}
  68. </div>
  69. </div>
  70. <div className='divider' style={{ backgroundColor: '#8492a6' }}></div>
  71. <div className='p-2'>
  72. <Form
  73. layout="vertical"
  74. onFinish={onFinish}
  75. form={form}
  76. >
  77. <Form.Item label={<span className='fz-wb-550'>{t('Assets operations')}</span>}>
  78. <Select style={{ height: 50 }} placeholder={t('Please select an operation type...')} options={options} onSelect={onSelect} />
  79. {
  80. type < 3 ? (
  81. <div>
  82. <span className='fz-12 text-primary'>{t('Wallet balance')}</span>
  83. <span className='fz-12 text-success'>${userInfo.balance}</span>
  84. </div>
  85. ) : (
  86. <div>
  87. <span className='fz-12 text-primary'>{t('Asset account amount')}</span>
  88. <span className='fz-12 text-success'>${userInfo.account_balance}</span>
  89. </div>
  90. )
  91. }
  92. </Form.Item>
  93. {
  94. type === 2 && (
  95. <Form.Item name="email" label={t('Member account')} rules={[{ required: true, message: t('Please enter the other party’s login account (email)') }, { type: 'email', message: t('Email format error') }]}>
  96. <Input style={{ height: 50 }} placeholder={t('Please enter the other party’s login account (email)')} />
  97. </Form.Item>
  98. )
  99. }
  100. {
  101. type === 1 && (
  102. <Form.Item label={<span className='fz-wb-550'>{t('Capital account')}</span>}>
  103. <Input style={{ height: 50 }} placeholder={t('Please enter the transfer amount')} value={`(CFD) ${userInfo.account},${t('Balance')}${userInfo.account_balance}`} disabled />
  104. </Form.Item>
  105. )
  106. }
  107. {
  108. type === 3 && (
  109. <Form.Item label={<span className='fz-wb-550'>{t('Capital account')}</span>}>
  110. <Input style={{ height: 50 }} placeholder={t('Please enter the transfer amount')} value={`(CFD) ${userInfo.account},${t('Balance')}${userInfo.account_balance}`} disabled />
  111. </Form.Item>
  112. )
  113. }
  114. <Form.Item name="amount" rules={[{ required: true, message: t('Please enter the transfer amount') }]} label={<span className='fz-wb-550'>{t('Transfer amount')}</span>}>
  115. <Input style={{ height: 50 }} placeholder={t('Please enter the transfer amount')} />
  116. </Form.Item>
  117. {
  118. type === 2 && (
  119. <Form.Item label={<span className='fz-wb-550'>{t('Verification Code')}</span>} name="code" rules={[{ required: true, message: t('Verification Code') }]}>
  120. <div className='row-items'>
  121. <Input style={{ height: 50, flex: 1 }} className='input' placeholder={t('Verification Code')} />
  122. <Button className='' onClick={getVerifyCode} style={{ height: 50 }} type='primary'>
  123. <CountdownTimer ref={countdownRef} initialSeconds={60} />
  124. </Button>
  125. </div>
  126. </Form.Item>
  127. )
  128. }
  129. <Form.Item>
  130. <div className='row-center'>
  131. <Button type='primary' htmlType='submit' style={{ borderRadius: 30 }}>{t('submit')}</Button>
  132. </div>
  133. </Form.Item>
  134. </Form>
  135. </div>
  136. </div>
  137. </div>
  138. )
  139. }
  140. export default observer(Transfer)