diff --git a/app/auth/forgot-password/page.tsx b/app/auth/forgot-password/page.tsx new file mode 100644 index 0000000..eefe3d8 --- /dev/null +++ b/app/auth/forgot-password/page.tsx @@ -0,0 +1,8 @@ +'use client'; + +import ForgotPasswordForm from "@/components/auth/forgotPassword"; + + +export default function ForgotPassword() { + return ; +} diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 36a1c3e..a70980b 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -36,7 +36,6 @@ export default function Dashboard() { }, [checkDeposits]); useEffect(() => { - // run once immediately checkRef.current(); const id = window.setInterval(() => { diff --git a/components/auth/forgotPassword.tsx b/components/auth/forgotPassword.tsx new file mode 100644 index 0000000..aaabbba --- /dev/null +++ b/components/auth/forgotPassword.tsx @@ -0,0 +1,117 @@ +'use client' + +import React, { useState } from 'react' +import Link from 'next/link' +import { useRouter } from 'next/navigation' +import { Mail, Lock, Eye, EyeOff, ArrowLeft } from 'lucide-react' +import { Input } from '@/components/ui/input' +import { Label } from '@/components/ui/label' +import { Button } from '@/components/ui/buttons' +import { apiClient } from '@/lib/api-client' +import { toast } from 'sonner' + +export default function ForgotPasswordForm() { + const router = useRouter() + const [isLoading, setIsLoading] = useState(false) + const [apiMessage, setApiMessage] = useState(null) + const [formData, setFormData] = useState({ + email: '', + }) + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + setApiMessage(null) + setIsLoading(true) + + try { + const success = await apiClient.ForgotPassword(formData.email) + + if (success) { + toast.success("Reset Password Email sent successfully") + } else { + setApiMessage('failed. Please check your credentials.') + } + } catch (err) { + const message = err instanceof Error ? err.message : String(err) + setApiMessage(message) + } finally { + setIsLoading(false) + } + } + + return ( + + + {/* Back button */} + + + Back to home + + + {/* Header */} + + + Welcome to VELO + + + Reset Your password + + + + {/* Login form */} + + {apiMessage && ( + {apiMessage} + )} + + + {/* Email */} + + Email + + + + setFormData({ ...formData, email: e.target.value }) + } + required + className=" bg-background/50" + /> + + + + + + + + {isLoading ? 'Sending email...' : 'Continue'} + + + + Back to {" "} + + Login + + + + + + ) +} diff --git a/lib/api-client.ts b/lib/api-client.ts index 1be85c9..b6858d4 100644 --- a/lib/api-client.ts +++ b/lib/api-client.ts @@ -20,6 +20,8 @@ import { ResendOtpResponse, // Response types MerchantPaymentStats, + ForgotPasswordCredentials, + ForgotPasswordResponse, } from "./api-types"; import { @@ -197,6 +199,13 @@ class ApiClient { }); } + async ForgotPassword(email: string): Promise { + return this.request("/auth/forgot-password", { + method: "POST", + body: {email}, + }); + } + async verifyOtp( credentials: VerifyOtpCredentials ): Promise { @@ -304,7 +313,7 @@ class ApiClient { method: "GET", }, { - ttl: 30 * 1000, // 30 seconds + ttl: 30 * 1000, backgroundRefresh: true, } ); diff --git a/lib/api-types.ts b/lib/api-types.ts index 7cb9d72..07e54bd 100644 --- a/lib/api-types.ts +++ b/lib/api-types.ts @@ -57,6 +57,10 @@ export interface RegisterCredentials { password: string; } +export interface ForgotPasswordCredentials { + email: string; +} + export interface VerifyOtpCredentials { email: string; otp: string; @@ -81,6 +85,10 @@ export interface ResendOtpResponse { message?: string; } +export interface ForgotPasswordResponse { + success: boolean; + message?: string; +} // API Response wrapper export interface ApiResponse { success: boolean;
+ Reset Your password +
+ Back to {" "} + + Login + +