import { useState } from 'react';
import authService from '../services/authService';

const useValidate = () => {
    const [error, setError] = useState(null);

    const validateEmail = async (TOKEN) => {
        setError(null);
        try {
            const validating = await authService.validateEmail(TOKEN);
            window.location.href = '/login';
        } catch (err) {
            setError(err.message);
        }
    };

    return {
        validateEmail,error
    };
};

export default useValidate;
