Add 3 roles, settings for marathons

This commit is contained in:
2025-12-14 20:21:56 +07:00
parent bb9e9a6e1d
commit d0b8eca600
28 changed files with 1679 additions and 290 deletions

View File

@@ -1,9 +1,12 @@
// User types
export type UserRole = 'user' | 'admin'
export interface User {
id: number
login: string
nickname: string
avatar_url: string | null
role: UserRole
created_at: string
}
@@ -15,22 +18,31 @@ export interface TokenResponse {
// Marathon types
export type MarathonStatus = 'preparing' | 'active' | 'finished'
export type ParticipantRole = 'participant' | 'organizer'
export type GameProposalMode = 'all_participants' | 'organizer_only'
export interface ParticipantInfo {
id: number
role: ParticipantRole
total_points: number
current_streak: number
drop_count: number
joined_at: string
}
export interface ParticipantWithUser extends ParticipantInfo {
user: User
}
export interface Marathon {
id: number
title: string
description: string | null
organizer: User
creator: User
status: MarathonStatus
invite_code: string
is_public: boolean
game_proposal_mode: GameProposalMode
start_date: string | null
end_date: string | null
participants_count: number
@@ -43,11 +55,21 @@ export interface MarathonListItem {
id: number
title: string
status: MarathonStatus
is_public: boolean
participants_count: number
start_date: string | null
end_date: string | null
}
export interface MarathonCreate {
title: string
description?: string
start_date: string
duration_days: number
is_public: boolean
game_proposal_mode: GameProposalMode
}
export interface LeaderboardEntry {
rank: number
user: User
@@ -58,13 +80,17 @@ export interface LeaderboardEntry {
}
// Game types
export type GameStatus = 'pending' | 'approved' | 'rejected'
export interface Game {
id: number
title: string
cover_url: string | null
download_url: string
genre: string | null
added_by: User | null
status: GameStatus
proposed_by: User | null
approved_by: User | null
challenges_count: number
created_at: string
}
@@ -158,7 +184,16 @@ export interface DropResult {
}
// Activity types
export type ActivityType = 'join' | 'spin' | 'complete' | 'drop' | 'start_marathon' | 'finish_marathon'
export type ActivityType =
| 'join'
| 'spin'
| 'complete'
| 'drop'
| 'start_marathon'
| 'finish_marathon'
| 'add_game'
| 'approve_game'
| 'reject_game'
export interface Activity {
id: number
@@ -173,3 +208,35 @@ export interface FeedResponse {
total: number
has_more: boolean
}
// Admin types
export interface AdminUser {
id: number
login: string
nickname: string
role: UserRole
avatar_url: string | null
telegram_id: number | null
telegram_username: string | null
marathons_count: number
created_at: string
}
export interface AdminMarathon {
id: number
title: string
status: MarathonStatus
creator: User
participants_count: number
games_count: number
start_date: string | null
end_date: string | null
created_at: string
}
export interface PlatformStats {
users_count: number
marathons_count: number
games_count: number
total_participations: number
}