import { useFormState } from "react-use-form-state"; import React, { FC, useState } from "react"; import { Flex } from "rebass"; import axios from "axios"; import { getAxiosConfig } from "../../utils"; import { useMessage } from "../../hooks"; import { APIv2 } from "../../consts"; import { TextInput } from "../Input"; import Text, { H2 } from "../Text"; import { Button } from "../Button"; import { Col } from "../Layout"; import Icon from "../Icon"; const SettingsChangeEmail: FC = () => { const [loading, setLoading] = useState(false); const [message, setMessage] = useMessage(5000); const [formState, { password, email, label }] = useFormState<{ changeemailpass: string; changeemailaddress: string; }>(null, { withIds: true }); const onSubmit = async (e) => { e.preventDefault(); if (loading) return; setLoading(true); try { const res = await axios.post( APIv2.AuthChangeEmail, { password: formState.values.changeemailpass, email: formState.values.changeemailaddress }, getAxiosConfig() ); setMessage(res.data.message, "green"); } catch (error) { setMessage(error?.response?.data?.error || "Couldn't send email."); } setLoading(false); }; return (

Change email address

Password: New email address: {message.text} ); }; export default SettingsChangeEmail;