import React, { Component } from 'react' import profileIcon from "../../images/profileicon.png"; import "./RegisterFormComponent.css" import ErrorIcon from '@mui/icons-material/Error'; import CheckBoxIcon from '@mui/icons-material/CheckBox'; import InputFormComponent from './InputFormComponent'; import { Input } from '@mui/material'; import axios from 'axios'; export class RegisterFormComponent extends Component { constructor(props) { super(props) this.state = { firstName: '', lastName: '', email: '', password: '', confirmPassword:'', serverResponse: '' } } submitHandler = (e) => { e.preventDefault() let dataToSend = JSON.stringify({ "firstName": this.state.firstName, "lastName": this.state.lastName, "email": this.state.email, "password": this.state.password }); let config = { method: 'post', url: '/registration', headers: { 'Content-Type': 'application/json' }, data : dataToSend }; axios(config) .then((response) => { this.setState({ serverResponse: response.data }) }) .catch((error) => { this.setState({ serverResponse: error.response.data }) }); } setValue = (e) => { this.setState({ [e.target.name]: e.target.value }) } render() { const {firstName,lastName,email,password,confirmPassword} = this.state return (
{(() => { if(this.state.serverResponse == '') { return <> } if(this.state.serverResponse != '' && this.state.serverResponse.includes('Error')) { return
{this.state.serverResponse.split(':')[1]}
} if(this.state.serverResponse != '' && this.state.serverResponse.includes('token')) { return
Вашата регистрација е во тек. Потврдете на вашата е-маил адреса!
} })()}
profile

Регистрација

); } } export default RegisterFormComponent