import React, { useState } from 'react';
import { createClient } from '@supabase/supabase-js';

const supabase = createClient(
  'https://lecpvgdlklvwvanoscoy.supabase.co',
  'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImxlY3B2Z2Rsa2x2d3Zhbm9zY295Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE2MDE5MDQsImV4cCI6MjA3NzE3NzkwNH0.vJZspH_qbSJXUE058RVpdDuTHGKIGdWCPj_X48r9v5U'
);

function App() {
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  const handleLogin = async () => {
    const { user, error } = await supabase.auth.signIn({
      email,
      password,
    });
    if (error) {
      console.error('Error logging in:', error.message);
    } else {
      console.log('User signed in:', user);
    }
  };

  return (
    <div>
      <h1>Login</h1>
      <input
        type="email"
        placeholder="Email"
        value={email}
        onChange={(e) => setEmail(e.target.value)}
      />
      <input
        type="password"
        placeholder="Password"
        value={password}
        onChange={(e) => setPassword(e.target.value)}
      />
      <button onClick={handleLogin}>Login</button>
    </div>
  );
}

export default App;
