RegisterForm.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React, { FC, ChangeEvent, FormEvent } from 'react'
  21. import { Icon } from 'antd'
  22. import styles from '../Login/Login.less'
  23. interface IRegisterFormProps {
  24. username: string
  25. email: string
  26. password: string
  27. password2: string
  28. loading: boolean
  29. onChangeUsername: (e: ChangeEvent<HTMLInputElement>) => void
  30. onChangeEmail: (e: ChangeEvent<HTMLInputElement>) => void
  31. onChangePassword: (e: ChangeEvent<HTMLInputElement>) => void
  32. onChangePassword2: (e: ChangeEvent<HTMLInputElement>) => void
  33. onSignup: (e: FormEvent<HTMLFormElement>) => void
  34. onCheckName: (
  35. id: number,
  36. name: string,
  37. type: string,
  38. resolve?: (res: any) => any,
  39. reject?: (error: any) => any
  40. ) => any
  41. }
  42. const RegisterForm: FC<IRegisterFormProps> = ({
  43. username,
  44. email,
  45. password,
  46. password2,
  47. loading,
  48. onChangeUsername,
  49. onChangeEmail,
  50. onChangePassword,
  51. onChangePassword2,
  52. onSignup
  53. }) => {
  54. return (
  55. <form className={styles.form} onSubmit={onSignup}>
  56. <div className={styles.input}>
  57. <Icon type="user" />
  58. <input
  59. placeholder="用户名"
  60. value={username}
  61. onChange={onChangeUsername}
  62. />
  63. </div>
  64. <div className={styles.input}>
  65. <Icon type="mail" />
  66. <input placeholder="邮箱" value={email} onChange={onChangeEmail} />
  67. </div>
  68. <div className={styles.input}>
  69. <Icon type="unlock" />
  70. <input
  71. placeholder="密码"
  72. type="password"
  73. value={password}
  74. onChange={onChangePassword}
  75. />
  76. </div>
  77. <div className={styles.input}>
  78. <Icon type="unlock" />
  79. <input
  80. placeholder="确认密码"
  81. type="password"
  82. value={password2}
  83. onChange={onChangePassword2}
  84. />
  85. </div>
  86. <button type="submit" className={styles.submit} disabled={loading}>
  87. {loading ? <Icon type="loading" /> : ''}
  88. 注册
  89. </button>
  90. </form>
  91. )
  92. }
  93. export default RegisterForm