LoginForm.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.less'
  23. interface ILoginFormProps {
  24. username: string
  25. password: string
  26. loading: boolean
  27. onChangeUsername: (e: ChangeEvent<HTMLInputElement>) => void
  28. onChangePassword: (e: ChangeEvent<HTMLInputElement>) => void
  29. onLogin: (e: FormEvent<HTMLFormElement>) => void
  30. }
  31. const LoginForm: FC<ILoginFormProps> = ({
  32. username,
  33. password,
  34. loading,
  35. onChangeUsername,
  36. onChangePassword,
  37. onLogin
  38. }) => {
  39. return (
  40. <form className={styles.form} onSubmit={onLogin}>
  41. <div className={styles.input}>
  42. <Icon type="user" />
  43. <input
  44. placeholder="用户名"
  45. value={username}
  46. onChange={onChangeUsername}
  47. />
  48. </div>
  49. <div className={styles.input}>
  50. <Icon type="unlock" />
  51. <input
  52. placeholder="密码"
  53. type="password"
  54. value={password}
  55. onChange={onChangePassword}
  56. />
  57. </div>
  58. <button type="submit" className={styles.submit} disabled={loading}>
  59. {loading ? <Icon type="loading" /> : ''}登 录
  60. </button>
  61. </form>
  62. )
  63. }
  64. export default LoginForm