import React, { useContext, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import PropTypes from 'prop-types';
import { Button, Card, Container, Text, TextInput, Title } from '@mantine/core';
import { useForm } from 'react-hook-form'
import { ZodError, z } from 'zod';
import { UserDataContext } from '../../context/user-data-context';
let host = import.meta.env.VITE_BACKEND_HOST;
const loginSchema = z.object({
username: z.string().min(5, { message: 'Username should not be less than 5 characters' }).max(15, { message: 'Username should not be more than 15 characters' }),
password: z.string().min(8, { message: 'Password should not be less than 8 characters' }).max(15, { message: 'Password should not be more than 15 characters' })
}).required();
const signupSchema = z.object({
username: z.string().min(5, { message: 'Username should not be less than 5 characters' }).max(15, { message: 'Username should not be more than 15 characters' }),
email: z.string().email({ message: 'Please enter a valid email address' }),
password: z.string().min(8, { message: 'Password should not be less than 8 characters' }).max(15, { message: 'Password should not be more than 15 characters' }),
}).required();
const AuthenticationPage = (props) => {
const navigate = useNavigate();
const { isLogin } = props;
return (
({ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh', backgroundImage: theme.fn.gradient({ from: 'blue', to: 'teal' }) })}>
{isLogin ? 'Login' : 'Sign Up'}
{isLogin ? : }
{/* Toggle between login and signup */}
{isLogin ? 'Don\'t have an account?' : 'Already have an account?'}