import React, { useState } from 'react'; import { IonButton, IonContent, IonInput, IonItem, IonLabel, IonList, IonPage, useIonLoading, useIonRouter, useIonToast, } from '@ionic/react'; import { supabase } from '../../supabaseClient'; function LoginPage() { const [email, setEmail] = useState('user1@example.com'); const [password, setPassword] = useState('Aa1234567'); const [showLoading, hideLoading] = useIonLoading(); const [showToast] = useIonToast(); const router = useIonRouter(); const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); await showLoading(); try { // // OPT // // await supabase.auth.signIn({ email }); console.log({ email, password }); const { error } = await supabase.auth.signInWithPassword({ email, password, }); if (error) { console.error(error); router.push('/login_error', 'forward', 'replace'); // return redirect('/login?message=Could not authenticate user'); } router.push('/tabs/events', 'forward', 'replace'); // return redirect('/protected'); } catch (e: any) { await showToast({ message: e.error_description || e.message, duration: 5000, }); } finally { await hideLoading(); } }; return (
{'Email'} setEmail(e.detail.value ?? '')} > {'Password'} setPassword(e.detail.value ?? '')} >
{'Login'}
); } export default React.memo(LoginPage);