import React, { useState } from 'react'; import axios from 'axios'; const ResetPasswordForm = ({ showLogin }) => { const [token, setToken] = useState(''); const [newPassword, setNewPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [error, setError] = useState(''); const [success, setSuccess] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); if (newPassword !== confirmPassword) { setError("Passwords don't match."); return; } setLoading(true); setError(''); setSuccess(''); try { // Assuming you have a webhook for resetting the password await axios.post('https://api.karyamanswasta.my.id/webhook/forgot-password/adventure', { token, newPassword }); setSuccess('Password has been sent successfully!'); setTimeout(() => { showLogin(); }, 2000); } catch (err) { setError(err.response?.data?.message || 'Failed to reset password.'); } finally { setLoading(false); } }; return ( <>

Reset Password

Enter the token from your email/WhatsApp and a new password.

setToken(e.target.value)} /> setNewPassword(e.target.value)} /> setConfirmPassword(e.target.value)} /> {error &&

{error}

} {success &&

{success}

}

); }; export default ResetPasswordForm;