[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. // create-user-form.tsx
  2. // Copyright (C) 2020 Dwayne Harris
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (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 General Public License for more details.
  11. // You should have received a copy of the GNU General Public License
  12. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. import React, { FC } from 'react'
  14. import { useDispatch } from 'react-redux'
  15. import { Link } from 'react-router-dom'
  16. import { faEnvelope, faIdCard, faUserShield } from '@fortawesome/free-solid-svg-icons'
  17. import { checkUserAvailability } from '../actions/registration'
  18. import { PRIVACY_OPTIONS } from '../constants'
  19. import { useTheme } from '../hooks'
  20. import CheckboxField from '../components/controls/checkbox-field'
  21. import TextField from '../components/controls/text-field'
  22. import PasswordField from '../components/controls/password-field'
  23. import SelectField from '../components/controls/select-field'
  24. import ImageField from '../components/controls/image-field'
  25. import CoverImageField from '../components/controls/cover-image-field'
  26. import ThemeField from '../components/controls/theme-field'
  27. const CreateUserForm: FC = () => {
  28. const theme = useTheme()
  29. const dispatch = useDispatch()
  30. const checkAvailability = (value: string) => {
  31. if (value.length > 3) {
  32. dispatch(checkUserAvailability(value))
  33. }
  34. }
  35. return (
  36. <div>
  37. <TextField icon={faIdCard} name="user-id" label="Username" placeholder="Your Username/ID" onBlur={e => checkAvailability(e.target.value)} />
  38. <TextField name="user-name" label="Display Name" placeholder="Whatever you want to go by" />
  39. <TextField type="email" icon={faEnvelope} name="user-email" label="Email Address" placeholder="Your email address" />
  40. <PasswordField placeholder="Your new password" />
  41. <ThemeField name="user-theme" label="Color" />
  42. <ImageField name="user-image" label="Avatar" />
  43. <CoverImageField name="user-cover-image" />
  44. <SelectField name="user-privacy" label="Privacy" options={PRIVACY_OPTIONS} icon={faUserShield} />
  45. <CheckboxField name="user-requires-approval">
  46. Approve each Subscription request from other users.
  47. </CheckboxField>
  48. <br />
  49. <CheckboxField name="user-agree">
  50. I agree to the User <Link style={{ color: theme.secondary }} to="/terms">terms and conditions</Link>.
  51. </CheckboxField>
  52. </div>
  53. )
  54. }
  55. export default CreateUserForm