Ignore:
Timestamp:
06/23/26 17:20:47 (12 days ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Children:
99c1e45
Parents:
b373fea
Message:

Fixed user profile and reading lists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapterx-frontend/src/store/storyStore.ts

    rb373fea r0b502c2  
    4949  try {
    5050    const token = JSON.parse(localStorage.getItem('chapterx-auth') || '{}')?.state?.token
    51     return token ? { Authorization: `Bearer ${token}` } : {}
     51    if (!token || token === 'mock-token') return {}
     52    return { Authorization: `Bearer ${token}` }
    5253  } catch {
    5354    return {}
     
    145146        created_at: s.createdAt,
    146147        updated_at: s.updatedAt,
    147         total_likes: 0,
    148         total_comments: 0,
    149         total_chapters: 0,
    150         total_views: 0,
     148        total_likes: s.likes?.length ?? 0,
     149        total_comments: s.comments?.length ?? 0,
     150        total_chapters: s.chapters?.length ?? 0,
     151        total_views: s.chapters?.reduce((sum: number, c: any) => sum + (c.viewCount ?? 0), 0) ?? 0,
    151152        genres: (s.hasGenres ?? []).map((hg: any) => hg.genre?.name ?? hg.name).filter(Boolean),
    152153      }))
Note: See TracChangeset for help on using the changeset viewer.