Changeset 7fbb91c for chapterx-frontend/src/store/authStore.ts
- Timestamp:
- 03/24/26 23:03:39 (3 months ago)
- Branches:
- main
- Children:
- a7550ca
- Parents:
- 73b69b2
- File:
-
- 1 edited
-
chapterx-frontend/src/store/authStore.ts (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
chapterx-frontend/src/store/authStore.ts
r73b69b2 r7fbb91c 19 19 updateUserRole: (userId: number, role: UserRole) => void 20 20 addUser: (user: User) => void 21 fetchAllUsers: () => Promise<void> 21 22 } 22 23 … … 135 136 addUser: (user: User) => 136 137 set(state => ({ allUsers: [...state.allUsers, user] })), 138 139 fetchAllUsers: async () => { 140 try { 141 const res = await axios.get(`${API_BASE}/users`) 142 const data: any[] = res.data?.users ?? res.data ?? [] 143 const users: User[] = data.map((u: any) => ({ 144 user_id: u.id, 145 username: u.username, 146 email: u.email ?? '', 147 name: u.name ?? u.username, 148 surname: u.surname ?? '', 149 role: (u.role ?? 'regular') as UserRole, 150 created_at: u.createdAt ?? new Date().toISOString(), 151 follower_count: 0, 152 following_count: 0, 153 })) 154 set({ allUsers: users }) 155 } catch { 156 // keep existing 157 } 158 }, 137 159 }), 138 160 {
Note:
See TracChangeset
for help on using the changeset viewer.
