Changeset dc30259 for frontend/src
- Timestamp:
- 02/07/26 15:34:33 (5 months ago)
- Branches:
- main
- Children:
- 8a47b30
- Parents:
- ebdd3d4
- Location:
- frontend/src
- Files:
-
- 1 added
- 5 edited
-
App.tsx (modified) (3 diffs)
-
components/LoadingSpinner.tsx (added)
-
pages/AllUsers.tsx (modified) (2 diffs)
-
pages/MusicalCollection.tsx (modified) (2 diffs)
-
pages/Nav.tsx (modified) (1 diff)
-
pages/UserDetail.tsx (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/App.tsx
rebdd3d4 rdc30259 1 import { useState } from "react"; 2 import { createBrowserRouter, Outlet, RouterProvider } from "react-router-dom"; 1 import { useEffect, useState } from "react"; 2 import { 3 createBrowserRouter, 4 Outlet, 5 RouterProvider, 6 useLocation, 7 } from "react-router-dom"; 3 8 import { ToastContainer } from "react-toastify"; 4 9 import "react-toastify/dist/ReactToastify.css"; 10 import LoadingSpinner from "./components/LoadingSpinner"; 5 11 import Sidebar from "./components/Sidebar"; 6 12 import { useAuth } from "./context/authContext"; … … 15 21 const MainLayout = () => { 16 22 const { user } = useAuth(); 17 const [isSidebarOpen, setIsSidebarOpen] = useState(!!user); 23 const location = useLocation(); 24 // show sidebar only if user is logged in and is on the landing page 25 const isLandingPage = location.pathname === "/"; 26 const [isSidebarOpen, setIsSidebarOpen] = useState(!!user && isLandingPage); 27 28 // Open sidebar when user logs in and navigates to landing page 29 useEffect(() => { 30 if (user && isLandingPage) { 31 setIsSidebarOpen(true); 32 } 33 }, [user, isLandingPage]); 18 34 19 35 return ( … … 51 67 52 68 if (isAuthLoading) { 53 return ( 54 <div className="flex h-screen items-center justify-center bg-[#121212]"> 55 <div className="w-12 h-12 border-4 border-white/10 border-t-[#1db954] rounded-full animate-spin"></div> 56 </div> 57 ); 69 return <LoadingSpinner />; 58 70 } 59 71 -
frontend/src/pages/AllUsers.tsx
rebdd3d4 rdc30259 2 2 import { useNavigate } from "react-router-dom"; 3 3 import axiosInstance from "../api/axiosInstance"; 4 import LoadingSpinner from "../components/LoadingSpinner"; 4 5 5 6 interface User { … … 39 40 }; 40 41 41 if (users.length == 0) return <div className="p-6">Loading...</div>; 42 if (users.length == 0) { 43 return <LoadingSpinner />; 44 } 42 45 if (error) { 43 46 return ( -
frontend/src/pages/MusicalCollection.tsx
rebdd3d4 rdc30259 2 2 import { useNavigate, useParams } from "react-router-dom"; 3 3 import axiosInstance from "../api/axiosInstance"; 4 import LoadingSpinner from "../components/LoadingSpinner"; 4 5 import type { Song, Album, Playlist } from "../utils/types"; 5 6 import { handleError } from "../utils/error"; … … 71 72 72 73 if (isLoading) { 73 return < div className="p-6">Loading...</div>;74 return <LoadingSpinner />; 74 75 } 75 76 -
frontend/src/pages/Nav.tsx
rebdd3d4 rdc30259 52 52 > 53 53 <div className="flex items-center gap-4"> 54 {onToggleSidebar && (54 {onToggleSidebar && user && ( 55 55 <button 56 56 onClick={onToggleSidebar} -
frontend/src/pages/UserDetail.tsx
rebdd3d4 rdc30259 2 2 import { useNavigate, useParams } from "react-router-dom"; 3 3 import axiosInstance from "../api/axiosInstance"; 4 import LoadingSpinner from "../components/LoadingSpinner"; 4 5 import ArtistView from "../components/userProfile/ArtistView"; 5 6 import ListenerView from "../components/userProfile/ListenerView"; … … 174 175 } 175 176 176 if (!user) return <div className="p-6">Loading...</div>; 177 if (!user) { 178 return <LoadingSpinner />; 179 } 177 180 178 181 return (
Note:
See TracChangeset
for help on using the changeset viewer.
