This commit is contained in:
2025-12-14 02:38:35 +07:00
commit 5343a8f2c3
84 changed files with 7406 additions and 0 deletions

158
frontend/src/types/index.ts Normal file
View File

@@ -0,0 +1,158 @@
// User types
export interface User {
id: number
login: string
nickname: string
avatar_url: string | null
created_at: string
}
export interface TokenResponse {
access_token: string
token_type: string
user: User
}
// Marathon types
export type MarathonStatus = 'preparing' | 'active' | 'finished'
export interface ParticipantInfo {
id: number
total_points: number
current_streak: number
drop_count: number
joined_at: string
}
export interface Marathon {
id: number
title: string
description: string | null
organizer: User
status: MarathonStatus
invite_code: string
start_date: string | null
end_date: string | null
participants_count: number
games_count: number
created_at: string
my_participation: ParticipantInfo | null
}
export interface MarathonListItem {
id: number
title: string
status: MarathonStatus
participants_count: number
start_date: string | null
end_date: string | null
}
export interface LeaderboardEntry {
rank: number
user: User
total_points: number
current_streak: number
completed_count: number
dropped_count: number
}
// Game types
export interface Game {
id: number
title: string
cover_url: string | null
download_url: string
genre: string | null
added_by: User | null
challenges_count: number
created_at: string
}
export interface GameShort {
id: number
title: string
cover_url: string | null
}
// Challenge types
export type ChallengeType =
| 'completion'
| 'no_death'
| 'speedrun'
| 'collection'
| 'achievement'
| 'challenge_run'
| 'score_attack'
| 'time_trial'
export type Difficulty = 'easy' | 'medium' | 'hard'
export type ProofType = 'screenshot' | 'video' | 'steam'
export interface Challenge {
id: number
game: GameShort
title: string
description: string
type: ChallengeType
difficulty: Difficulty
points: number
estimated_time: number | null
proof_type: ProofType
proof_hint: string | null
is_generated: boolean
created_at: string
}
// Assignment types
export type AssignmentStatus = 'active' | 'completed' | 'dropped'
export interface Assignment {
id: number
challenge: Challenge
status: AssignmentStatus
proof_url: string | null
proof_comment: string | null
points_earned: number
streak_at_completion: number | null
started_at: string
completed_at: string | null
}
export interface SpinResult {
assignment_id: number
game: Game
challenge: Challenge
can_drop: boolean
drop_penalty: number
}
export interface CompleteResult {
points_earned: number
streak_bonus: number
total_points: number
new_streak: number
}
export interface DropResult {
penalty: number
total_points: number
new_drop_count: number
}
// Activity types
export type ActivityType = 'join' | 'spin' | 'complete' | 'drop' | 'start_marathon' | 'finish_marathon'
export interface Activity {
id: number
type: ActivityType
user: User
data: Record<string, unknown> | null
created_at: string
}
export interface FeedResponse {
items: Activity[]
total: number
has_more: boolean
}