[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.

26 lines
901 B

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. import React, { FC } from 'react'
  2. import { useSelector, useDispatch } from 'react-redux'
  3. import { useTheme } from '../../hooks'
  4. import { setFieldValue } from '../../actions/forms'
  5. import { getFieldValue } from '../../selectors/forms'
  6. import { AppState } from '../../types'
  7. interface Props {
  8. name: string
  9. }
  10. const CheckboxField: FC<Props> = ({ name, children }) => {
  11. const theme = useTheme()
  12. const value = useSelector<AppState, boolean>(state => getFieldValue<boolean>(state, name, false))
  13. const dispatch = useDispatch()
  14. return (
  15. <label className="checkbox">
  16. <input type="checkbox" checked={value} onChange={e => dispatch(setFieldValue(name, e.target.checked))} style={{ color: theme.primary, border: 'none' }} />
  17. &nbsp;&nbsp;
  18. <span style={{ color: theme.text }}>{children}</span>
  19. </label>
  20. )
  21. }
  22. export default CheckboxField