/* eslint-disable */ "use client"; import { useEffect, useState } from "react"; import Spinner from "@/lib/components/ui/Spinner"; import { useAxios } from "@/lib/hooks"; import { UserStats } from "@/lib/types/User"; import { useSupabase } from "@/lib/context/SupabaseProvider"; import { redirectToLogin } from "@/lib/router/redirectToLogin"; import { UserStatistics } from "./components/UserStatistics"; const UserPage = (): JSX.Element => { const [userStats, setUserStats] = useState(); const { session } = useSupabase(); const { axiosInstance } = useAxios(); if (session === null) { redirectToLogin(); } useEffect(() => { const fetchUserStats = async () => { try { console.log( `Fetching user stats from ${process.env.NEXT_PUBLIC_BACKEND_URL}/user` ); const response = await axiosInstance.get( `${process.env.NEXT_PUBLIC_BACKEND_URL}/user`, { headers: { Authorization: `Bearer ${session.access_token}`, }, } ); setUserStats(response.data); } catch (error) { console.error("Error fetching user stats", error); setUserStats(undefined); } }; fetchUserStats(); }, [session.access_token]); return (
{userStats ? ( <> ) : (
Fetching your data...
)}
); }; export default UserPage;