feat: переделал все клиентские запросы на другие endpoint для безопастности
Backend CI / build-and-test (push) Successful in 48s
Frontend CI / build-and-check (push) Failing after 5m13s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 15s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 1m9s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 14s
Backend CI / build-and-test (push) Successful in 48s
Frontend CI / build-and-check (push) Failing after 5m13s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 15s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 1m9s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 14s
This commit is contained in:
@@ -59,6 +59,32 @@ export const lecturesApi = {
|
||||
}
|
||||
|
||||
export const usersApi = {
|
||||
me: () => apiRequest<CurrentUserDto>('/users/me'),
|
||||
updateMe: (payload: { displayName?: string | null; avatarUrl?: string | null }) =>
|
||||
apiRequest<CurrentUserDto>('/users/me', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(payload),
|
||||
}),
|
||||
myStats: () => apiRequest<UserStatsDto>('/users/me/stats'),
|
||||
async myEnrollments() {
|
||||
const payload = await apiRequest<PagedResult<LectureDto> | LectureDto[] | undefined>(
|
||||
'/users/me/enrollments',
|
||||
)
|
||||
return extractItems(payload)
|
||||
},
|
||||
async myAchievements() {
|
||||
const payload = await apiRequest<
|
||||
PagedResult<UserAchievementDto> | UserAchievementDto[] | AchievementDto[]
|
||||
>('/users/me/achievements')
|
||||
if (Array.isArray(payload)) return payload
|
||||
return payload.items ?? []
|
||||
},
|
||||
async myTransactions() {
|
||||
const payload = await apiRequest<PagedResult<CoinTransactionDto> | CoinTransactionDto[]>(
|
||||
'/users/me/transactions',
|
||||
)
|
||||
return extractItems(payload)
|
||||
},
|
||||
get: (id: string | number) => apiRequest<UserDto>(`/users/${id}`),
|
||||
async list(query: UserQuery = {}) {
|
||||
const payload = await apiRequest<PagedResult<UserDto> | UserDto[]>('/users', {
|
||||
|
||||
@@ -33,7 +33,6 @@ function getDefaultActiveRole(roles: UserRole[]): UserRole {
|
||||
export function mapApiUser(user: UserAuthDto | UserDto | CurrentUserDto, stats?: UserStatsDto): User {
|
||||
const roles = mapApiRoles(user.roles)
|
||||
return {
|
||||
id: String(user.id),
|
||||
name: user.displayName || user.email || 'Пользователь UniVerse',
|
||||
email: user.email || '',
|
||||
roles,
|
||||
|
||||
@@ -29,13 +29,13 @@ export interface LoginMicrosoftRequest {
|
||||
}
|
||||
|
||||
export interface UserAuthDto {
|
||||
id: number
|
||||
email: string
|
||||
displayName?: string | null
|
||||
roles: ApiUserRole[]
|
||||
}
|
||||
|
||||
export interface UserDto extends UserAuthDto {
|
||||
id: number
|
||||
avatarUrl?: string | null
|
||||
isActive: boolean
|
||||
xp: number
|
||||
|
||||
Reference in New Issue
Block a user