Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/components/auth/redeem-verify-email.tsx
Views: 687
import apiPost from "lib/api/post";1import { useEffect, useState } from "react";2import { Icon } from "@cocalc/frontend/components/icon";3import { Alert } from "antd";4import Contact from "components/landing/contact";56import AuthPageContainer from "./fragments/auth-page-container";78interface Props {9token: string;10email_address: string;11}1213export default function RedeemVerifyEmail({ token, email_address }: Props) {14const [redeeming, setRedeeming] = useState<boolean>(false);15const [error, setError] = useState<string>("");16const [success, setSuccess] = useState<string>("");1718async function redeem(): Promise<void> {19setRedeeming(true);20setError("");21setSuccess("");22try {23await apiPost("/auth/redeem-verify-email", {24email_address,25token,26});27setSuccess("Successfully verified your email address. Thanks!");28} catch (err) {29setError(`${err}`);30} finally {31setRedeeming(false);32}33}3435useEffect(() => {36redeem();37return;38}, []);3940function Body() {41if (redeeming) {42return (43<div>44<Icon name="spinner" spin /> Verifying your email address...45</div>46);47}48if (error) {49return (50<div>51We weren't able to validate your e-mail address. ):52</div>53);54}55return (56<div>57{success && (58<Alert59style={{ marginTop: "20px" }}60message={<b>Success</b>}61description={<div style={{ fontSize: "12pt" }}>{success}</div>}62type="success"63showIcon64/>65)}66</div>67);68}6970function renderError() {71return error && (72<div style={{ fontSize: "12pt" }}>73<b>{error}</b>74<br/>75If you are stuck, please <Contact lower/>.76</div>77);78}7980function renderTitle() {81return `${success ? "Successfully " : ""}Verif${success ? "ied" : "y"} Your Email Address`;82}8384return (85<AuthPageContainer86error={renderError()}87title={renderTitle()}88>89<div style={{ marginTop: "8px" }}>90<Body/>91</div>92</AuthPageContainer>93);94}959697