@@ -4,6 +4,10 @@ import { SafeAreaView, View, Text, StyleSheet, ScrollView, TouchableOpacity, Ima
44import { LineChart , PieChart } from 'react-native-chart-kit' ;
55import { router } from 'expo-router' ;
66import { usePersonalBests } from "@/hooks/usePersonalBests" ;
7+ import { getAccessToken } from '@/scripts/auth' ;
8+ import { useEffect } from 'react' ;
9+
10+
711
812const { width } = Dimensions . get ( 'window' ) ;
913//console.log(" 1 HomeScreen about to be rendered rendered");
@@ -17,6 +21,30 @@ const HomeScreen = () => {
1721 return null ;
1822 }
1923 const { name } = user ;
24+ useEffect ( ( ) => {
25+ const fetchAdminDbStructure = async ( ) => {
26+ try {
27+ const token = await getAccessToken ( ) ;
28+ const res = await fetch ( 'http://localhost:8000/api/v1/inspect-db' , {
29+ headers : {
30+ Authorization : `Bearer ${ token } ` ,
31+ } ,
32+ } ) ;
33+
34+ if ( ! res . ok ) {
35+ console . error ( `Failed to fetch admin DB structure: ${ res . status } ` ) ;
36+ return ;
37+ }
38+
39+ const dbStructure = await res . json ( ) ;
40+ console . log ( "🛠 Admin DB Structure:" , dbStructure ) ;
41+ } catch ( err ) {
42+ console . error ( "Error fetching admin DB structure:" , err ) ;
43+ }
44+ } ;
45+
46+ fetchAdminDbStructure ( ) ;
47+ } , [ ] ) ;
2048 const heartRateData = [ 60 , 62 , 65 , 70 , 75 , 78 , 80 , 82 , 79 , 76 ] ;
2149 const waterIntake = '4L' ;
2250 const sleepHours = '8h 20m' ;
@@ -29,7 +57,7 @@ const HomeScreen = () => {
2957 { id : '2' , type : 'Lowerbody Workout' , calories : 200 , duration : '30 minutes' , icon : require ( '../assets/images/lowerbody.png' ) } ,
3058 // ... more workouts
3159 ] ;
32- const { pbs, loading } = usePersonalBests ( ) ;
60+ const { pbs = [ ] , loading } = usePersonalBests ( ) ;
3361 const testPbs = pbs . length === 0 ? [ { metric : "Deadlift" , value : 315 , date : "2025-05-27" } ] : pbs ;
3462
3563 console . log ( 'PBS LOADED:' , pbs ) ;
@@ -224,7 +252,7 @@ const HomeScreen = () => {
224252 ) : pbs . length === 0 ? (
225253 < Text style = { { textAlign : 'center' , color : '#999' , marginBottom : 12 } } > No personal bests yet. Start training to set new records!</ Text >
226254 ) : (
227- testPbs . map ( ( pb ) => (
255+ pbs . map ( ( pb ) => (
228256 < View key = { pb . metric } style = { styles . workoutItem } >
229257 < Image source = { require ( '../assets/images/trophy.png' ) } style = { styles . workoutIcon } />
230258 < View style = { styles . workoutInfo } >
0 commit comments