InvitationCard.jsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React from 'react';
  16. import {
  17. Avatar,
  18. Typography,
  19. Card,
  20. Button,
  21. Input,
  22. Badge,
  23. } from '@douyinfe/semi-ui';
  24. import { Copy, Users, BarChart2, TrendingUp, Gift, Zap } from 'lucide-react';
  25. const { Text } = Typography;
  26. const InvitationCard = ({
  27. t,
  28. userState,
  29. renderQuota,
  30. setOpenTransfer,
  31. affLink,
  32. handleAffLinkClick,
  33. }) => {
  34. return (
  35. <Card className="!rounded-2xl shadow-sm border-0">
  36. {/* 卡片头部 */}
  37. <div className="flex items-center mb-4">
  38. <Avatar size="small" color="green" className="mr-3 shadow-md">
  39. <Gift size={16} />
  40. </Avatar>
  41. <div>
  42. <Typography.Text className="text-lg font-medium">{t('邀请奖励')}</Typography.Text>
  43. <div className="text-xs text-gray-600 dark:text-gray-400">{t('邀请好友获得额外奖励')}</div>
  44. </div>
  45. </div>
  46. {/* 收益展示区域 */}
  47. <div className='space-y-4'>
  48. {/* 主要收益卡片 - 待使用收益 */}
  49. <Card className='!rounded-xl with-pastel-balls'>
  50. <div className='flex justify-between items-center mb-3'>
  51. <div className="flex items-center">
  52. <TrendingUp size={16} className="mr-2 text-slate-600 dark:text-slate-300" />
  53. <Text strong className='text-slate-700 dark:text-slate-200'>{t('待使用收益')}</Text>
  54. </div>
  55. <Button
  56. type='primary'
  57. theme='solid'
  58. size='small'
  59. disabled={!userState?.user?.aff_quota || userState?.user?.aff_quota <= 0}
  60. onClick={() => setOpenTransfer(true)}
  61. className='!rounded-lg !bg-slate-600 hover:!bg-slate-700'
  62. >
  63. <Zap size={12} className="mr-1" />
  64. {t('划转到余额')}
  65. </Button>
  66. </div>
  67. <div className='text-2xl sm:text-3xl font-bold text-slate-900 dark:text-slate-100 mb-1'>
  68. {renderQuota(userState?.user?.aff_quota || 0)}
  69. </div>
  70. </Card>
  71. {/* 统计数据网格 */}
  72. <div className='grid grid-cols-2 gap-4'>
  73. <Card className='!rounded-xl bg-slate-50 dark:bg-slate-800'>
  74. <div className='flex items-center mb-2'>
  75. <BarChart2 size={16} className='mr-2 text-slate-600 dark:text-slate-300' />
  76. <Text type='tertiary' className='text-slate-600 dark:text-slate-300'>{t('总收益')}</Text>
  77. </div>
  78. <div className='text-xl font-semibold text-slate-900 dark:text-slate-100'>
  79. {renderQuota(userState?.user?.aff_history_quota || 0)}
  80. </div>
  81. </Card>
  82. <Card className='!rounded-xl bg-slate-50 dark:bg-slate-800'>
  83. <div className='flex items-center mb-2'>
  84. <Users size={16} className='mr-2 text-slate-600 dark:text-slate-300' />
  85. <Text type='tertiary' className='text-slate-600 dark:text-slate-300'>{t('邀请人数')}</Text>
  86. </div>
  87. <div className='text-xl font-semibold text-slate-900 dark:text-slate-100 flex items-center'>
  88. {userState?.user?.aff_count || 0} {t('人')}
  89. </div>
  90. </Card>
  91. </div>
  92. <div className='!mb-4'>
  93. {/* 邀请链接部分 */}
  94. <Input
  95. value={affLink}
  96. readonly
  97. className='!rounded-lg'
  98. prefix={t('邀请链接')}
  99. suffix={
  100. <Button
  101. type='primary'
  102. theme='solid'
  103. onClick={handleAffLinkClick}
  104. icon={<Copy size={14} />}
  105. className='!rounded-lg'
  106. >
  107. {t('复制')}
  108. </Button>
  109. }
  110. />
  111. </div>
  112. {/* 奖励说明 */}
  113. <Card
  114. className='!rounded-xl with-pastel-balls-warm'
  115. title={
  116. <Text strong className='text-slate-700'>
  117. {t('奖励说明')}
  118. </Text>
  119. }
  120. >
  121. <div className='space-y-3'>
  122. <div className='flex items-start gap-2'>
  123. <Badge dot type='success' />
  124. <Text type='tertiary' className='text-sm text-slate-600'>
  125. {t('邀请好友注册,好友充值后您可获得相应奖励')}
  126. </Text>
  127. </div>
  128. <div className='flex items-start gap-2'>
  129. <Badge dot type='success' />
  130. <Text type='tertiary' className='text-sm text-slate-600'>
  131. {t('通过划转功能将奖励额度转入到您的账户余额中')}
  132. </Text>
  133. </div>
  134. <div className='flex items-start gap-2'>
  135. <Badge dot type='success' />
  136. <Text type='tertiary' className='text-sm text-slate-600'>
  137. {t('邀请的好友越多,获得的奖励越多')}
  138. </Text>
  139. </div>
  140. </div>
  141. </Card>
  142. </div>
  143. </Card>
  144. );
  145. };
  146. export default InvitationCard;