import React, { useState } from 'react'; import { IonContent, IonPage, IonInput, IonButton, IonSpinner, IonIcon, } from '@ionic/react'; import { chevronBackOutline } from 'ionicons/icons'; import { useHistory } from 'react-router-dom'; import { supabase } from '../supabase'; const NewPasswordPage: React.FC = () => { const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [submitting, setSubmitting] = useState(false); const [message, setMessage] = useState(null); const history = useHistory(); const showMessage = (msg: string) => { setMessage(msg); setTimeout(() => setMessage(null), 4000); }; const handleUpdate = async (e: React.FormEvent) => { e.preventDefault(); if (!password || !confirmPassword) { showMessage('Please fill in all fields'); return; } if (password.length < 6) { showMessage('Password must be at least 6 characters'); return; } if (password !== confirmPassword) { showMessage('Passwords do not match'); return; } setSubmitting(true); setMessage(null); try { const { error } = await supabase.auth.updateUser({ password }); if (error) throw error; history.push('/home'); } catch (err: any) { showMessage(err.message || 'An error occurred'); } finally { setSubmitting(false); } }; return (
history.push('/auth')} style={{ position: 'absolute', top: 'calc(var(--ion-safe-area-top, 0px) + 8px)', left: '8px', '--padding-start': '8px', '--padding-end': '8px', zIndex: 10, }} >

Create new password

Set a strong password to protect your account.

setPassword(e.detail.value!)} />
setConfirmPassword(e.detail.value!)} />
{message && (
{message}
)} {submitting ? ( ) : ( 'Update password' )}
); }; export default NewPasswordPage;