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

62 lines
2.2 KiB

import React, { FC, FocusEventHandler } from 'react'
import { useDispatch } from 'react-redux'
import { Link } from 'react-router-dom'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUpload, faIdCard } from '@fortawesome/free-solid-svg-icons'
import { checkGroupAvailability } from 'src/actions/registration'
import CheckboxField from './forms/checkbox-field'
import TextField from './forms/text-field'
import SelectField from './forms/select-field'
const CreateGroupForm: FC = () => {
const dispatch = useDispatch()
const checkAvailability = (value: string) => {
if (value.length > 3) {
dispatch(checkGroupAvailability(value))
}
}
const registrationOptions = {
open: 'Anyone can join',
approval: 'Users must be approved',
closed: 'Registration closed',
}
return (
<div className="container">
<TextField name="group-name" label="Community Name" onBlur={e => checkAvailability(e.target.value)} />
<br />
<SelectField name="group-registration" label="Registration" options={registrationOptions} icon={faIdCard} />
<br />
<div className="field">
<label className="label">Community Image</label>
<div className="file is-primary">
<label className="file-label">
<input className="file-input" type="file" name="image" />
<span className="file-cta">
<span className="file-icon">
<FontAwesomeIcon icon={faUpload} />
</span>
<span className="file-label">
Choose an image...
</span>
</span>
</label>
</div>
<p className="help">Image must be smaller than 5 MBs.</p>
</div>
<br />
<CheckboxField name="group-agree">
I agree to the Communities <Link to="/terms/communities">terms and conditions</Link>.
</CheckboxField>
</div>
)
}
export default CreateGroupForm