improvement for the backend api

This commit is contained in:
ivannoskov
2025-11-19 12:56:04 +03:00
parent b0a9934220
commit d4672ea32b
40 changed files with 2383 additions and 3313 deletions

View File

@@ -1,4 +1,4 @@
import { TargetChannel, TargetChannelDetail } from "@/lib/types/api";
import { TargetChannel } from "@/lib/types/api";
// ============================================================================
// Mock Target Channels Data
@@ -6,74 +6,24 @@ import { TargetChannel, TargetChannelDetail } from "@/lib/types/api";
export const mockTargetChannels: TargetChannel[] = [
{
id: "tc1",
id: "550e8400-e29b-41d4-a716-446655440010",
telegram_id: -1001234567890,
title: "Мой Главный Канал",
username: "my_main_channel",
description: "Основной канал для продвижения продукта",
is_active: true,
created_at: "2024-01-10T10:00:00.000Z",
updated_at: "2024-01-10T10:00:00.000Z",
total_purchases: 15,
total_subscriptions: 1250,
avg_cpf: 45.5,
},
{
id: "tc2",
id: "550e8400-e29b-41d4-a716-446655440011",
telegram_id: -1009876543210,
title: "Тестовый Канал",
username: "test_channel_promo",
description: "Канал для тестирования рекламных креативов",
is_active: true,
created_at: "2024-02-15T12:00:00.000Z",
updated_at: "2024-02-15T12:00:00.000Z",
total_purchases: 8,
total_subscriptions: 450,
avg_cpf: 52.3,
},
{
id: "tc3",
id: "550e8400-e29b-41d4-a716-446655440012",
telegram_id: -1005555555555,
title: "Новости и Обновления",
username: null,
description: "Приватный канал для новостей",
is_active: false,
created_at: "2024-03-01T08:00:00.000Z",
updated_at: "2024-03-20T14:30:00.000Z",
total_purchases: 3,
total_subscriptions: 120,
avg_cpf: 67.8,
},
];
export const getMockTargetChannelDetail = (
id: string
): TargetChannelDetail | null => {
const channel = mockTargetChannels.find((c) => c.id === id);
if (!channel) return null;
return {
...channel,
recent_purchases: [], // Will be populated from purchases mock
stats_by_period: [
{
period: "day",
subscriptions: 25,
cost: 1200,
cpf: 48.0,
},
{
period: "week",
subscriptions: 180,
cost: 8500,
cpf: 47.2,
},
{
period: "month",
subscriptions: 750,
cost: 35000,
cpf: 46.7,
},
],
};
};