Add files via upload

This commit is contained in:
Egor
2026-01-15 19:18:17 +03:00
committed by GitHub
parent b118008cdc
commit 7be6b5c0ae
70 changed files with 21835 additions and 0 deletions

465
src/types/index.ts Normal file
View File

@@ -0,0 +1,465 @@
// User types
export interface User {
id: number
telegram_id: number
username: string | null
first_name: string | null
last_name: string | null
email: string | null
email_verified: boolean
balance_kopeks: number
balance_rubles: number
referral_code: string | null
language: string
created_at: string
}
// Auth types
export interface AuthResponse {
access_token: string
refresh_token: string
token_type: string
expires_in: number
user: User
}
export interface TokenResponse {
access_token: string
refresh_token: string
token_type: string
expires_in: number
}
// Subscription types
export interface ServerInfo {
uuid: string
name: string
country_code: string | null
}
export interface TrafficPurchase {
id: number
traffic_gb: number
expires_at: string
created_at: string
days_remaining: number
progress_percent: number
}
export interface Subscription {
id: number
status: string
is_trial: boolean
start_date: string
end_date: string
days_left: number
hours_left: number
minutes_left: number
time_left_display: string
traffic_limit_gb: number
traffic_used_gb: number
traffic_used_percent: number
device_limit: number
connected_squads: string[]
servers: ServerInfo[]
autopay_enabled: boolean
autopay_days_before: number
subscription_url: string | null
is_active: boolean
is_expired: boolean
traffic_purchases?: TrafficPurchase[]
// Daily tariff fields
is_daily?: boolean
is_daily_paused?: boolean
daily_price_kopeks?: number
next_daily_charge_at?: string // ISO datetime string
// Tariff info
tariff_id?: number
tariff_name?: string
}
// Device types
export interface Device {
hwid: string
platform: string
device_model: string
created_at: string | null
}
export interface DevicesResponse {
devices: Device[]
total: number
device_limit: number
}
// Tariff switch preview
export interface TariffSwitchPreview {
can_switch: boolean
current_tariff_id: number | null
current_tariff_name: string | null
new_tariff_id: number
new_tariff_name: string
remaining_days: number
upgrade_cost_kopeks: number
upgrade_cost_label: string
balance_kopeks: number
balance_label: string
has_enough_balance: boolean
missing_amount_kopeks: number
missing_amount_label: string
is_upgrade: boolean
}
export interface RenewalOption {
period_days: number
price_kopeks: number
price_rubles: number
discount_percent: number
original_price_kopeks: number | null
}
export interface TrafficPackage {
gb: number
price_kopeks: number
price_rubles: number
is_unlimited: boolean
}
export interface TrialInfo {
is_available: boolean
duration_days: number
traffic_limit_gb: number
device_limit: number
requires_payment: boolean
price_kopeks: number
price_rubles: number
reason_unavailable: string | null
}
// Purchase options types
export interface TrafficOption {
value: number
label: string
price_kopeks: number
price_label: string
original_price_kopeks?: number
original_price_label?: string
discount_percent?: number
is_available: boolean
is_default?: boolean
}
export interface ServerOption {
uuid: string
name: string
price_kopeks: number
price_label: string
original_price_kopeks?: number
original_price_label?: string
discount_percent?: number
is_available: boolean
}
export interface DevicesConfig {
min: number
max: number
default: number
current: number
price_per_device_kopeks: number
price_per_device_label: string
price_per_device_original_kopeks?: number
discount_percent?: number
}
export interface TrafficConfig {
selectable: boolean
mode: string
options: TrafficOption[]
default?: number
current?: number
}
export interface ServersConfig {
options: ServerOption[]
min: number
max: number
default: string[]
selected: string[]
}
export interface PeriodOption {
id: string
period_days: number
months: number
label: string
price_kopeks: number
price_label: string
per_month_price_kopeks: number
per_month_price_label: string
discount_percent?: number
original_price_kopeks?: number
original_price_label?: string
is_available: boolean
traffic: TrafficConfig
servers: ServersConfig
devices: DevicesConfig
}
// Tariff types for tariffs mode
export interface TariffPeriod {
days: number
months: number
label: string
price_kopeks: number
price_label: string
price_per_month_kopeks: number
price_per_month_label: string
}
export interface TariffServer {
uuid: string
name: string
}
export interface Tariff {
id: number
name: string
description: string | null
tier_level: number
traffic_limit_gb: number
traffic_limit_label: string
is_unlimited_traffic: boolean
device_limit: number
servers_count: number
servers: TariffServer[]
periods: TariffPeriod[]
is_current: boolean
is_available: boolean
// Custom days options
custom_days_enabled?: boolean
price_per_day_kopeks?: number
min_days?: number
max_days?: number
// Custom traffic options
custom_traffic_enabled?: boolean
traffic_price_per_gb_kopeks?: number
min_traffic_gb?: number
max_traffic_gb?: number
// Device price
device_price_kopeks?: number
// Traffic topup options
traffic_topup_enabled?: boolean
traffic_topup_packages?: number[]
max_topup_traffic_gb?: number
// Daily tariff options
is_daily?: boolean
daily_price_kopeks?: number
}
export interface TariffsPurchaseOptions {
sales_mode: 'tariffs'
tariffs: Tariff[]
current_tariff_id: number | null
balance_kopeks: number
balance_label: string
}
export interface ClassicPurchaseOptions {
sales_mode: 'classic'
currency: string
balance_kopeks: number
balance_label: string
subscription_id: number | null
periods: PeriodOption[]
traffic: TrafficConfig
servers: ServersConfig
devices: DevicesConfig
selection: {
period_id: string
period_days: number
traffic_value: number
servers: string[]
devices: number
}
}
export type PurchaseOptions = TariffsPurchaseOptions | ClassicPurchaseOptions
// Legacy type for backward compatibility
export interface LegacyPurchaseOptions {
currency: string
balance_kopeks: number
balance_label: string
subscription_id: number | null
periods: PeriodOption[]
traffic: TrafficConfig
servers: ServersConfig
devices: DevicesConfig
selection: {
period_id: string
period_days: number
traffic_value: number
servers: string[]
devices: number
}
}
export interface PurchaseSelection {
period_id?: string
period_days?: number
traffic_value?: number
servers?: string[]
devices?: number
}
export interface PurchasePreview {
total_price_kopeks: number
total_price_label: string
original_price_kopeks?: number
original_price_label?: string
discount_percent?: number
discount_label?: string
per_month_price_kopeks: number
per_month_price_label: string
breakdown: { label: string; value: string }[]
balance_kopeks: number
balance_label: string
missing_amount_kopeks: number
missing_amount_label?: string
can_purchase: boolean
status_message?: string
}
// Balance types
export interface Balance {
balance_kopeks: number
balance_rubles: number
}
export interface Transaction {
id: number
type: string
amount_kopeks: number
amount_rubles: number
description: string | null
payment_method: string | null
is_completed: boolean
created_at: string
completed_at: string | null
}
export interface PaymentMethod {
id: string
name: string
description: string | null
min_amount_kopeks: number
max_amount_kopeks: number
is_available: boolean
}
// Referral types
export interface ReferralInfo {
referral_code: string
referral_link: string
total_referrals: number
active_referrals: number
total_earnings_kopeks: number
total_earnings_rubles: number
commission_percent: number
}
export interface ReferralTerms {
is_enabled: boolean
commission_percent: number
minimum_topup_kopeks: number
minimum_topup_rubles: number
first_topup_bonus_kopeks: number
first_topup_bonus_rubles: number
inviter_bonus_kopeks: number
inviter_bonus_rubles: number
}
// Ticket types
export interface TicketMessage {
id: number
message_text: string
is_from_admin: boolean
has_media: boolean
media_type: string | null
media_file_id: string | null
media_caption: string | null
created_at: string
}
export interface Ticket {
id: number
title: string
status: string
priority: string
created_at: string
updated_at: string
closed_at: string | null
messages_count: number
last_message: TicketMessage | null
}
export interface TicketDetail extends Omit<Ticket, 'messages_count' | 'last_message'> {
is_reply_blocked: boolean
messages: TicketMessage[]
}
export interface SupportConfig {
tickets_enabled: boolean
support_type: 'tickets' | 'profile' | 'url'
support_url?: string | null
support_username?: string | null
}
// Paginated response
export interface PaginatedResponse<T> {
items: T[]
total: number
page: number
per_page: number
pages: number
}
// App config types (for connection setup)
export interface LocalizedText {
[key: string]: string
}
export interface AppButton {
buttonLink: string
buttonText: LocalizedText
}
export interface AppStep {
description: LocalizedText
buttons?: AppButton[]
title?: LocalizedText
}
export interface AppInfo {
id: string
name: string
isFeatured: boolean
deepLink?: string | null
installationStep?: AppStep
addSubscriptionStep?: AppStep
connectAndUseStep?: AppStep
additionalBeforeAddSubscriptionStep?: AppStep
additionalAfterAddSubscriptionStep?: AppStep
}
export interface AppConfig {
platforms: Record<string, AppInfo[]>
platformNames: Record<string, LocalizedText>
hasSubscription: boolean
subscriptionUrl: string | null
branding?: {
name?: string
logoUrl?: string
supportUrl?: string
}
}

68
src/types/theme.ts Normal file
View File

@@ -0,0 +1,68 @@
// Theme color settings interface
export interface ThemeColors {
// Main accent color
accent: string
// Dark theme
darkBackground: string
darkSurface: string
darkText: string
darkTextSecondary: string
// Light theme
lightBackground: string
lightSurface: string
lightText: string
lightTextSecondary: string
// Status colors
success: string
warning: string
error: string
}
export interface ThemeSettings extends ThemeColors {
id?: number
updated_at?: string
}
// Enabled themes settings
export interface EnabledThemes {
dark: boolean
light: boolean
}
export const DEFAULT_ENABLED_THEMES: EnabledThemes = {
dark: true,
light: true,
}
// Default theme colors
export const DEFAULT_THEME_COLORS: ThemeColors = {
accent: '#3b82f6',
darkBackground: '#0a0f1a',
darkSurface: '#0f172a',
darkText: '#f1f5f9',
darkTextSecondary: '#94a3b8',
lightBackground: '#F7E7CE',
lightSurface: '#FEF9F0',
lightText: '#1F1A12',
lightTextSecondary: '#7D6B48',
success: '#22c55e',
warning: '#f59e0b',
error: '#ef4444',
}
// Color shade levels for palette generation
export const SHADE_LEVELS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const
// Extended shade levels including 850 for dark palette
export const EXTENDED_SHADE_LEVELS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 850, 900, 950] as const
export type ShadeLevel = (typeof SHADE_LEVELS)[number]
export type ExtendedShadeLevel = (typeof EXTENDED_SHADE_LEVELS)[number]
export type ColorPalette = Record<ShadeLevel | 850, string>