Changeset b70fbeb for frontend/src
- Timestamp:
- 01/27/26 14:03:17 (6 months ago)
- Branches:
- main
- Children:
- 3238007
- Parents:
- 4e5cf92
- Location:
- frontend/src
- Files:
-
- 4 edited
-
App.tsx (modified) (2 diffs)
-
pages/Login.tsx (modified) (2 diffs)
-
pages/Nav.tsx (modified) (2 diffs)
-
pages/Register.tsx (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/App.tsx
r4e5cf92 rb70fbeb 1 1 import { createBrowserRouter, Outlet, RouterProvider } from "react-router-dom"; 2 import { ToastContainer } from "react-toastify"; 3 import "react-toastify/dist/ReactToastify.css"; 2 4 import AllUsers from "./pages/AllUsers"; 3 5 import LandingPage from "./pages/LandingPage"; … … 11 13 <div className="flex flex-col min-h-screen"> 12 14 <Nav /> 15 <ToastContainer 16 position="top-right" 17 autoClose={2000} 18 hideProgressBar={false} 19 newestOnTop={false} 20 closeOnClick 21 rtl={false} 22 pauseOnFocusLoss 23 draggable 24 pauseOnHover 25 theme="light" 26 /> 13 27 <main className="grow"> 14 28 <Outlet /> -
frontend/src/pages/Login.tsx
r4e5cf92 rb70fbeb 1 1 import { useState } from "react"; 2 2 import { useNavigate } from "react-router-dom"; 3 import { toast } from "react-toastify"; 3 4 import axiosInstance, { scheduleTokenRefresh } from "../api/axiosInstance"; 4 5 import { useAuth } from "../context/authContext"; … … 22 23 setUser(response.data.user); 23 24 navigate("/"); 24 } catch (error) { 25 setError("Login failed. Please check your credentials."); 25 toast.success("Login successful!"); 26 } catch (error: any) { 27 const errorMessage = 28 error.response?.data?.error || 29 "Login failed. Please check your credentials."; 30 setError(errorMessage); 31 toast.error(errorMessage); 26 32 } 27 33 }; -
frontend/src/pages/Nav.tsx
r4e5cf92 rb70fbeb 1 1 import { Link } from "react-router-dom"; 2 import { toast } from "react-toastify"; 2 3 import axiosInstance, { baseURL } from "../api/axiosInstance"; 3 4 import Logo from "../assets/logo-finkwave.png"; … … 12 13 await axiosInstance.post("/auth/logout"); 13 14 setUser(undefined); 15 toast.success("Logout successful!"); 14 16 } catch (error) { 15 17 console.error("Logout failed:", error); 18 toast.error("Logout failed!"); 16 19 } 17 20 }; -
frontend/src/pages/Register.tsx
r4e5cf92 rb70fbeb 1 1 import { useEffect, useState } from "react"; 2 2 import { useNavigate } from "react-router"; 3 import { toast } from "react-toastify"; 3 4 import axiosInstance, { scheduleTokenRefresh } from "../api/axiosInstance"; 4 5 import { useAuth } from "../context/authContext"; … … 15 16 null, 16 17 ); 18 const [error, setError] = useState<string | null>(null); 17 19 18 20 const navigate = useNavigate(); … … 28 30 const handleRegister = async (e: React.FormEvent) => { 29 31 e.preventDefault(); 30 // todo: add proper error handling31 32 if (profilePhotoFile && profilePhotoFile.size > 5 * 1024 * 1024) { 32 33 alert("Max file size is 5MB"); … … 53 54 setUser(response.data.user); 54 55 navigate("/"); 55 } catch (error) { 56 console.error("Registration failed:", error); 56 toast.success("Registration successful!"); 57 } catch (error: any) { 58 const errorMessage = 59 error.response?.data?.error || "Registration failed. Please try again."; 60 setError(errorMessage); 61 toast.error(errorMessage); 57 62 } 58 63 }; … … 62 67 <h2 className="text-2xl mb-4">Register</h2> 63 68 <form className="bg-white p-6 rounded shadow-md w-80"> 69 {error && <p className="text-red-500 mb-4">{error}</p>} 64 70 <div className="mb-4"> 65 71 <label className="block text-gray-700 mb-2" htmlFor="username">
Note:
See TracChangeset
for help on using the changeset viewer.
