index.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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, { useMemo, useState, ReactElement } from 'react'
  21. import { Link } from 'react-router-dom'
  22. import { Form } from 'antd'
  23. import { FormComponentProps } from 'antd/lib/form/Form'
  24. import {
  25. GetPassWordType,
  26. IOperateStates,
  27. FindPwStep
  28. } from './types'
  29. import GetCaptcha from './GetCaptcha'
  30. import ResetPassword from './ResetPassword'
  31. const styles = require('./index.less')
  32. const FindPassword: React.FC<FormComponentProps> = React.memo(() => {
  33. const [type, setType] = useState<GetPassWordType>(GetPassWordType.EMAIL)
  34. const [ticket, setTicket] = useState<string>()
  35. const [token, setToken] = useState<string>()
  36. const [step, setStep] = useState<FindPwStep>(FindPwStep.CAPTCHA)
  37. const operate: IOperateStates = useMemo(
  38. () => ({
  39. type,
  40. ticket,
  41. token,
  42. setType,
  43. setTicket,
  44. setToken,
  45. step,
  46. setStep
  47. }),
  48. [type, ticket, token, setType, setTicket, setToken]
  49. )
  50. const StepContent: ReactElement = useMemo(() => {
  51. return step === FindPwStep.CAPTCHA ? (
  52. <GetCaptcha {...operate} />
  53. ) : (
  54. <ResetPassword {...operate} />
  55. )
  56. }, [step, operate])
  57. return (
  58. <div className={styles.container}>
  59. <nav className={styles.header}>
  60. <div className={styles.logoPc}>
  61. <div className={styles.logo}>
  62. <Link to="/login">
  63. <img src={require('assets/images/logo.svg')} />
  64. </Link>
  65. </div>
  66. </div>
  67. <div className={styles.resetPw}>重置密码</div>
  68. </nav>
  69. <div className={styles.content}>
  70. <div className={styles.panel}>{StepContent}</div>
  71. </div>
  72. </div>
  73. )
  74. })
  75. export default Form.create<FormComponentProps>()(FindPassword)