EmailBindModal.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 { Button, Input, Modal } from '@douyinfe/semi-ui';
  17. import { IconMail, IconKey } from '@douyinfe/semi-icons';
  18. import Turnstile from 'react-turnstile';
  19. const EmailBindModal = ({
  20. t,
  21. showEmailBindModal,
  22. setShowEmailBindModal,
  23. inputs,
  24. handleInputChange,
  25. sendVerificationCode,
  26. bindEmail,
  27. disableButton,
  28. loading,
  29. countdown,
  30. turnstileEnabled,
  31. turnstileSiteKey,
  32. setTurnstileToken
  33. }) => {
  34. return (
  35. <Modal
  36. title={
  37. <div className="flex items-center">
  38. <IconMail className="mr-2 text-blue-500" />
  39. {t('绑定邮箱地址')}
  40. </div>
  41. }
  42. visible={showEmailBindModal}
  43. onCancel={() => setShowEmailBindModal(false)}
  44. onOk={bindEmail}
  45. size={'small'}
  46. centered={true}
  47. maskClosable={false}
  48. className="modern-modal"
  49. >
  50. <div className="space-y-4 py-4">
  51. <div className="flex gap-3">
  52. <Input
  53. placeholder={t('输入邮箱地址')}
  54. onChange={(value) => handleInputChange('email', value)}
  55. name='email'
  56. type='email'
  57. size="large"
  58. className="!rounded-lg flex-1"
  59. prefix={<IconMail />}
  60. />
  61. <Button
  62. onClick={sendVerificationCode}
  63. disabled={disableButton || loading}
  64. className="!rounded-lg"
  65. type="primary"
  66. theme="outline"
  67. size='large'
  68. >
  69. {disableButton ? `${t('重新发送')} (${countdown})` : t('获取验证码')}
  70. </Button>
  71. </div>
  72. <Input
  73. placeholder={t('验证码')}
  74. name='email_verification_code'
  75. value={inputs.email_verification_code}
  76. onChange={(value) =>
  77. handleInputChange('email_verification_code', value)
  78. }
  79. size="large"
  80. className="!rounded-lg"
  81. prefix={<IconKey />}
  82. />
  83. {turnstileEnabled && (
  84. <div className="flex justify-center">
  85. <Turnstile
  86. sitekey={turnstileSiteKey}
  87. onVerify={(token) => {
  88. setTurnstileToken(token);
  89. }}
  90. />
  91. </div>
  92. )}
  93. </div>
  94. </Modal>
  95. );
  96. };
  97. export default EmailBindModal;