@@ -15,58 +15,6 @@ import { profileService } from '@/services/profileService';
1515import { Volunteer } from '@/types/api/volunteer' ;
1616import { Event } from '@/types/api/event' ;
1717
18- // Calculate level from experience (same logic as useProfile)
19- function calculateLevel ( experience : number ) : number {
20- if ( experience < 100 ) return 1 ;
21-
22- let level = 1 ;
23- let totalXPNeeded = 0 ;
24-
25- while ( totalXPNeeded <= experience ) {
26- const xpForNextLevel = level * 100 + ( level - 1 ) * 50 ;
27- totalXPNeeded += xpForNextLevel ;
28- if ( totalXPNeeded <= experience ) {
29- level ++ ;
30- } else {
31- break ;
32- }
33- }
34-
35- return level ;
36- }
37-
38- function getXPForLevel ( level : number ) : number {
39- let totalXP = 0 ;
40- for ( let i = 1 ; i < level ; i ++ ) {
41- totalXP += i * 100 + ( i - 1 ) * 50 ;
42- }
43- return totalXP ;
44- }
45-
46- function getXPForNextLevel ( currentLevel : number ) : number {
47- return currentLevel * 100 + ( currentLevel - 1 ) * 50 ;
48- }
49-
50- function calculateLevelProgress ( experience : number ) : {
51- level : number ;
52- progress : number ;
53- currentLevelXP : number ;
54- nextLevelXP : number ;
55- } {
56- const level = calculateLevel ( experience ) ;
57- const xpForCurrentLevel = getXPForLevel ( level ) ;
58- const xpForNextLevel = getXPForNextLevel ( level ) ;
59- const currentLevelXP = experience - xpForCurrentLevel ;
60- const progress = ( currentLevelXP / xpForNextLevel ) * 100 ;
61-
62- return {
63- level,
64- progress : Math . min ( Math . max ( progress , 0 ) , 100 ) ,
65- currentLevelXP,
66- nextLevelXP : xpForNextLevel ,
67- } ;
68- }
69-
7018function calculateTotalHours ( completedEvents : Event [ ] ) : number {
7119 return completedEvents . reduce ( ( sum , event ) => {
7220 const start = new Date ( event . startDateTime ) ;
@@ -84,7 +32,6 @@ export default function UserProfileScreen() {
8432 const [ stats , setStats ] = useState < {
8533 totalHours : number ;
8634 level : number ;
87- levelProgress : number ;
8835 } | null > ( null ) ;
8936
9037 useEffect ( ( ) => {
@@ -110,13 +57,11 @@ export default function UserProfileScreen() {
11057 const pastEventsData = await profileService . getPastEvents ( volunteerId ) ;
11158
11259 // Calculate stats
113- const levelData = calculateLevelProgress ( volunteerData . experience ) ;
11460 const totalHours = calculateTotalHours ( pastEventsData ) ;
11561
11662 setStats ( {
11763 totalHours,
118- level : levelData . level ,
119- levelProgress : levelData . progress ,
64+ level : volunteerData . currentLevel ,
12065 } ) ;
12166 } catch ( error ) {
12267 console . error ( 'Error loading profile data:' , error ) ;
@@ -164,15 +109,9 @@ export default function UserProfileScreen() {
164109
165110 < FishTank volunteerId = { volunteer . id } />
166111
167- < LevelProgress
168- level = { stats . level }
169- progress = { stats . levelProgress }
170- motivationalText = "Keep volunteering to level up!"
171- />
172-
173112 < View style = { styles . statsContainer } >
174113 < StatCard
175- title = "Total Volunteering Hours"
114+ title = "Total Hours"
176115 value = { `${ Math . round ( stats . totalHours ) } hours` }
177116 />
178117 < StatCard title = "Level" value = { `${ stats . level } ` } />
0 commit comments