|
|
@ -4,9 +4,7 @@ import { |
|
|
|
FormControl, |
|
|
|
FormLabel, |
|
|
|
Heading, |
|
|
|
Input, |
|
|
|
Select, |
|
|
|
useToast, |
|
|
|
Input, useToast |
|
|
|
} from '@chakra-ui/react'; |
|
|
|
import axios from 'axios'; |
|
|
|
import { useState } from 'react'; |
|
|
@ -14,34 +12,18 @@ import { useDispatch } from 'react-redux'; |
|
|
|
import { useHistory } from 'react-router-dom'; |
|
|
|
import { authLogin } from '../features/auth/authSlice'; |
|
|
|
|
|
|
|
function OrgSelect(props) { |
|
|
|
const orgs = ['MISI: Solidariti', 'UNDI18']; |
|
|
|
const orgOptions = orgs.map(name => { |
|
|
|
return <option value={name}>{name}</option>; |
|
|
|
}); |
|
|
|
|
|
|
|
return ( |
|
|
|
<Select placeholder={props.placeholder} onChange={props.onChange}> |
|
|
|
{orgOptions} |
|
|
|
</Select> |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
function Create() { |
|
|
|
const dispatch = useDispatch(); |
|
|
|
const toast = useToast(); |
|
|
|
const history = useHistory(); |
|
|
|
|
|
|
|
const [name, setName] = useState(null); |
|
|
|
const [email, setEmail] = useState(null); |
|
|
|
const [phoneNumber, setPhoneNumber] = useState(null); |
|
|
|
const [org, setOrg] = useState(null); |
|
|
|
const [telegram, setTelegram] = useState(null); |
|
|
|
const [password, setPassword] = useState(null); |
|
|
|
|
|
|
|
const handleSubmit = e => { |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
if (!name | !email | !phoneNumber | !org | !password) { |
|
|
|
if (!telegram | !password) { |
|
|
|
toast({ |
|
|
|
title: 'Problem!', |
|
|
|
description: 'Please fill in all the fields', |
|
|
@ -56,10 +38,7 @@ function Create() { |
|
|
|
.post( |
|
|
|
`${process.env.REACT_APP_API_URL}/create`, |
|
|
|
{ |
|
|
|
name: name, |
|
|
|
email: email, |
|
|
|
org: org, |
|
|
|
phoneNumber: org, |
|
|
|
telegram: telegram, |
|
|
|
password: password, |
|
|
|
}, |
|
|
|
{ |
|
|
@ -105,23 +84,8 @@ function Create() { |
|
|
|
<Heading mb={6}>Create Account</Heading> |
|
|
|
<form onSubmit={handleSubmit}> |
|
|
|
<FormControl mb={6}> |
|
|
|
<FormLabel>Name:</FormLabel> |
|
|
|
<Input onChange={e => setName(e.target.value)} /> |
|
|
|
</FormControl> |
|
|
|
<FormControl mb={6}> |
|
|
|
<FormLabel>Email:</FormLabel> |
|
|
|
<Input type="email" onChange={e => setEmail(e.target.value)} /> |
|
|
|
</FormControl> |
|
|
|
<FormControl mb={6}> |
|
|
|
<FormLabel>Phone Number:</FormLabel> |
|
|
|
<Input onChange={e => setPhoneNumber(e.target.value)} /> |
|
|
|
</FormControl> |
|
|
|
<FormControl mb={6}> |
|
|
|
<FormLabel>Organization:</FormLabel> |
|
|
|
<OrgSelect |
|
|
|
placeholder="Select Organization" |
|
|
|
onChange={e => setOrg(e.target.value)} |
|
|
|
/> |
|
|
|
<FormLabel>Telegram Username:</FormLabel> |
|
|
|
<Input onChange={e => setTelegram(e.target.value)} /> |
|
|
|
</FormControl> |
|
|
|
<FormControl mb={6}> |
|
|
|
<FormLabel>Password:</FormLabel> |
|
|
|