'use client'

import * as React from 'react';
import { Box, Button, TextField, Typography } from '@mui/material';

export default function VerifyEmailPage() {

    const [code, setCode] = React.useState('');

    const verify = () => {
        fetch('/api/verifyEmail', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ code: code }),
        }).then((res) => {
            if (res.status === 200) {
                alert('Email vérifié');
            } else {
                alert('Erreur lors de la vérification de l\'email');
            }
        });
    }

    return (
        <Box>
            <Typography variant="h4">Vérification de l&apos;email</Typography>
            <TextField label="Code de vérification" value={code} onChange={(e) => setCode(e.target.value)} fullWidth />
            <Button onClick={verify} margin='dense' fullWidth>Vérifier</Button>
        </Box>
    );
}