improvement for the backend api
This commit is contained in:
@@ -19,15 +19,6 @@ import {
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { purchasesApi } from "@/lib/api";
|
||||
import {
|
||||
formatNumber,
|
||||
@@ -54,7 +45,7 @@ import {
|
||||
Clock,
|
||||
CheckCircle,
|
||||
} from "lucide-react";
|
||||
import type { PurchaseDetail } from "@/lib/types/api";
|
||||
import type { Placement } from "@/lib/types/api";
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ id: string }>;
|
||||
@@ -63,7 +54,7 @@ interface PageProps {
|
||||
export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
const resolvedParams = use(params);
|
||||
const router = useRouter();
|
||||
const [purchase, setPurchase] = useState<PurchaseDetail | null>(null);
|
||||
const [purchase, setPurchase] = useState<Placement | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
@@ -89,9 +80,12 @@ export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
|
||||
try {
|
||||
await purchasesApi.update(purchase.id, {
|
||||
is_archived: !purchase.is_archived,
|
||||
status: purchase.status === "active" ? "archived" : "active",
|
||||
});
|
||||
setPurchase({
|
||||
...purchase,
|
||||
status: purchase.status === "active" ? "archived" : "active",
|
||||
});
|
||||
setPurchase({ ...purchase, is_archived: !purchase.is_archived });
|
||||
} catch (err: any) {
|
||||
alert(err?.error?.message || "Ошибка обновления закупа");
|
||||
}
|
||||
@@ -157,10 +151,8 @@ export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const messageText = purchase.creative.text.replace(
|
||||
"{link}",
|
||||
purchase.invite_link
|
||||
);
|
||||
// Remove message text generation as we don't have creative.text in Placement
|
||||
const messageText = `Текст сообщения с ссылкой: ${purchase.invite_link}`;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -177,19 +169,14 @@ export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<ShoppingCart className="h-6 w-6" />
|
||||
<h1 className="text-3xl font-bold tracking-tight">
|
||||
{purchase.external_channel.title}
|
||||
{purchase.external_channel_title}
|
||||
</h1>
|
||||
{purchase.is_archived ? (
|
||||
{purchase.status === "archived" ? (
|
||||
<Badge variant="secondary">Архив</Badge>
|
||||
) : purchase.actual_date ? (
|
||||
) : (
|
||||
<Badge variant="default">
|
||||
<CheckCircle className="h-3 w-3 mr-1" />
|
||||
Завершено
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="outline">
|
||||
<Clock className="h-3 w-3 mr-1" />
|
||||
Запланировано
|
||||
Активно
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
@@ -197,33 +184,34 @@ export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
<span>
|
||||
Целевой канал:{" "}
|
||||
<Link
|
||||
href={`/channels/${purchase.target_channel.id}`}
|
||||
href={`/channels`}
|
||||
className="hover:underline font-medium"
|
||||
>
|
||||
{purchase.target_channel.title}
|
||||
{purchase.target_channel_title}
|
||||
</Link>
|
||||
</span>
|
||||
<span>•</span>
|
||||
<span>
|
||||
Креатив:{" "}
|
||||
<Link
|
||||
href={`/creatives/${purchase.creative.id}`}
|
||||
href={`/creatives`}
|
||||
className="hover:underline font-medium"
|
||||
>
|
||||
{purchase.creative.name}
|
||||
{purchase.creative_name}
|
||||
</Link>
|
||||
</span>
|
||||
<span>•</span>
|
||||
<span>
|
||||
Дата размещения:{" "}
|
||||
{formatDate(purchase.actual_date || purchase.scheduled_date)}
|
||||
Дата размещения: {formatDate(purchase.placement_date)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" onClick={handleArchive}>
|
||||
<Archive className="mr-2 h-4 w-4" />
|
||||
{purchase.is_archived ? "Разархивировать" : "Архивировать"}
|
||||
{purchase.status === "archived"
|
||||
? "Разархивировать"
|
||||
: "Архивировать"}
|
||||
</Button>
|
||||
<Button variant="destructive" onClick={handleDelete}>
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
@@ -272,27 +260,45 @@ export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">CPF</CardTitle>
|
||||
<CardTitle className="text-sm font-medium">
|
||||
Статус просмотров
|
||||
</CardTitle>
|
||||
<TrendingUp className="h-4 w-4 text-muted-foreground" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">
|
||||
{purchase.cpf ? `₽${formatMetric(purchase.cpf)}` : "—"}
|
||||
<div className="text-lg font-medium">
|
||||
{purchase.views_availability === "available"
|
||||
? "Доступны"
|
||||
: purchase.views_availability === "manual"
|
||||
? "Вручную"
|
||||
: purchase.views_availability === "unavailable"
|
||||
? "Недоступны"
|
||||
: "Неизвестно"}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
{purchase.last_views_fetch_at
|
||||
? `Обновлено: ${formatDate(purchase.last_views_fetch_at)}`
|
||||
: "Еще не обновлялись"}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Конверсия</CardTitle>
|
||||
<CardTitle className="text-sm font-medium">Тип ссылки</CardTitle>
|
||||
<BarChart3 className="h-4 w-4 text-muted-foreground" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">
|
||||
{purchase.conversion_rate
|
||||
? formatPercent(purchase.conversion_rate)
|
||||
: "—"}
|
||||
<div className="text-lg font-medium">
|
||||
{purchase.invite_link_type === "approval"
|
||||
? "С одобрением"
|
||||
: "Публичная"}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
{purchase.invite_link_type === "approval"
|
||||
? "Отслеживание подписчиков"
|
||||
: "Без отслеживания"}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
@@ -318,18 +324,18 @@ export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
{purchase.post_link && (
|
||||
{purchase.ad_post_url && (
|
||||
<div className="pt-2">
|
||||
<Label className="text-sm text-muted-foreground">
|
||||
Ссылка на рекламный пост:
|
||||
</Label>
|
||||
<a
|
||||
href={purchase.post_link}
|
||||
href={purchase.ad_post_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1 text-sm hover:underline mt-1"
|
||||
>
|
||||
{purchase.post_link}
|
||||
{purchase.ad_post_url}
|
||||
<ExternalLinkIcon className="h-3 w-3" />
|
||||
</a>
|
||||
</div>
|
||||
@@ -363,127 +369,21 @@ export default function PurchaseDetailPage({ params }: PageProps) {
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<Tabs defaultValue="subscriptions" className="w-full">
|
||||
<TabsList>
|
||||
<TabsTrigger value="subscriptions">
|
||||
Подписки ({purchase.subscriptions.length})
|
||||
</TabsTrigger>
|
||||
{purchase.views_history && purchase.views_history.length > 0 && (
|
||||
<TabsTrigger value="views">
|
||||
История просмотров ({purchase.views_history.length})
|
||||
</TabsTrigger>
|
||||
)}
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="subscriptions" className="mt-4">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Подписки</CardTitle>
|
||||
<CardDescription>
|
||||
Пользователи, перешедшие по ссылке
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{purchase.subscriptions.length === 0 ? (
|
||||
<p className="text-center text-muted-foreground py-8">
|
||||
Подписок пока нет
|
||||
</p>
|
||||
) : (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Пользователь</TableHead>
|
||||
<TableHead>Username</TableHead>
|
||||
<TableHead>Дата подписки</TableHead>
|
||||
<TableHead>Статус</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{purchase.subscriptions.map((subscription) => (
|
||||
<TableRow key={subscription.id}>
|
||||
<TableCell className="font-medium">
|
||||
{subscription.user_first_name}{" "}
|
||||
{subscription.user_last_name}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{subscription.user_username
|
||||
? formatUsername(subscription.user_username)
|
||||
: "—"}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{formatDate(subscription.subscribed_at)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{subscription.is_active ? (
|
||||
<Badge variant="default">Активен</Badge>
|
||||
) : (
|
||||
<Badge variant="secondary">Отписался</Badge>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
{purchase.views_history && purchase.views_history.length > 0 && (
|
||||
<TabsContent value="views" className="mt-4">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>История просмотров</CardTitle>
|
||||
<CardDescription>
|
||||
Динамика просмотров рекламного поста
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Дата</TableHead>
|
||||
<TableHead className="text-right">Просмотры</TableHead>
|
||||
<TableHead className="text-right">Прирост</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{purchase.views_history.map((item, index) => {
|
||||
const prevViews =
|
||||
index > 0
|
||||
? purchase.views_history![index - 1].views
|
||||
: 0;
|
||||
const growth = item.views - prevViews;
|
||||
|
||||
return (
|
||||
<TableRow key={item.fetched_at}>
|
||||
<TableCell>{formatDate(item.fetched_at)}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatNumber(item.views)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{index > 0 && (
|
||||
<span
|
||||
className={
|
||||
growth > 0
|
||||
? "text-green-600"
|
||||
: "text-muted-foreground"
|
||||
}
|
||||
>
|
||||
+{formatNumber(growth)}
|
||||
</span>
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
)}
|
||||
</Tabs>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Заметка</CardTitle>
|
||||
<CardDescription>
|
||||
Детальная информация о размещении доступна через раздел "Подписки"
|
||||
в главном меню
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Для просмотра списка подписчиков и истории просмотров используйте
|
||||
соответствующие разделы в главном меню.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -60,11 +60,11 @@ export default function CreatePurchasePage() {
|
||||
target_channel_id: "",
|
||||
external_channel_id: "",
|
||||
creative_id: "",
|
||||
scheduled_date: "",
|
||||
placement_date: "",
|
||||
cost: "",
|
||||
comment: "",
|
||||
post_link: "",
|
||||
invite_link_type: "public" as "public" | "private",
|
||||
invite_link_type: "public" as "public" | "approval",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -73,15 +73,24 @@ export default function CreatePurchasePage() {
|
||||
|
||||
const loadData = async () => {
|
||||
try {
|
||||
const [channelsRes, externalChannelsRes, creativesRes] =
|
||||
await Promise.all([
|
||||
channelsApi.list({ is_active: true }),
|
||||
externalChannelsApi.list(),
|
||||
const channelsRes = await channelsApi.list();
|
||||
setChannels(channelsRes.target_channels.filter((c) => c.is_active));
|
||||
|
||||
// Загружаем внешние каналы для первого доступного target channel
|
||||
if (channelsRes.target_channels.length > 0) {
|
||||
const firstTargetChannel = channelsRes.target_channels[0];
|
||||
const [externalChannelsRes, creativesRes] = await Promise.all([
|
||||
externalChannelsApi.list(firstTargetChannel.id),
|
||||
creativesApi.list(),
|
||||
]);
|
||||
setChannels(channelsRes.data);
|
||||
setExternalChannels(externalChannelsRes.data);
|
||||
setCreatives(creativesRes.data.filter((c) => !c.is_archived));
|
||||
setExternalChannels(externalChannelsRes.external_channels);
|
||||
setCreatives(
|
||||
creativesRes.creatives.filter((c) => c.status === "active")
|
||||
);
|
||||
} else {
|
||||
setCreatives([]);
|
||||
setExternalChannels([]);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Error loading data:", err);
|
||||
}
|
||||
@@ -116,7 +125,7 @@ export default function CreatePurchasePage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!formData.scheduled_date) {
|
||||
if (!formData.placement_date) {
|
||||
setError("Укажите дату размещения");
|
||||
return;
|
||||
}
|
||||
@@ -132,10 +141,10 @@ export default function CreatePurchasePage() {
|
||||
target_channel_id: formData.target_channel_id,
|
||||
external_channel_id: formData.external_channel_id,
|
||||
creative_id: formData.creative_id,
|
||||
scheduled_date: formData.scheduled_date,
|
||||
placement_date: formData.placement_date,
|
||||
cost: parseFloat(formData.cost),
|
||||
comment: formData.comment || undefined,
|
||||
post_link: formData.post_link || undefined,
|
||||
ad_post_url: formData.post_link || undefined,
|
||||
invite_link_type: formData.invite_link_type,
|
||||
});
|
||||
|
||||
@@ -247,7 +256,7 @@ export default function CreatePurchasePage() {
|
||||
target_channel_id: "",
|
||||
external_channel_id: "",
|
||||
creative_id: "",
|
||||
scheduled_date: "",
|
||||
placement_date: "",
|
||||
cost: "",
|
||||
comment: "",
|
||||
post_link: "",
|
||||
@@ -394,15 +403,15 @@ export default function CreatePurchasePage() {
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="scheduled_date">Дата размещения *</Label>
|
||||
<Label htmlFor="placement_date">Дата размещения *</Label>
|
||||
<Input
|
||||
id="scheduled_date"
|
||||
type="date"
|
||||
value={formData.scheduled_date}
|
||||
id="placement_date"
|
||||
type="datetime-local"
|
||||
value={formData.placement_date}
|
||||
onChange={(e) =>
|
||||
setFormData({
|
||||
...formData,
|
||||
scheduled_date: e.target.value,
|
||||
placement_date: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
@@ -443,7 +452,7 @@ export default function CreatePurchasePage() {
|
||||
<Label>Тип пригласительной ссылки *</Label>
|
||||
<RadioGroup
|
||||
value={formData.invite_link_type}
|
||||
onValueChange={(value: "public" | "private") =>
|
||||
onValueChange={(value: "public" | "approval") =>
|
||||
setFormData({ ...formData, invite_link_type: value })
|
||||
}
|
||||
>
|
||||
@@ -454,8 +463,8 @@ export default function CreatePurchasePage() {
|
||||
</Label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<RadioGroupItem value="private" id="private" />
|
||||
<Label htmlFor="private" className="font-normal">
|
||||
<RadioGroupItem value="approval" id="approval" />
|
||||
<Label htmlFor="approval" className="font-normal">
|
||||
С одобрением (запрос на вступление через бота)
|
||||
</Label>
|
||||
</div>
|
||||
|
||||
@@ -73,10 +73,10 @@ export default function PurchasesPage() {
|
||||
setLoading(true);
|
||||
const [purchasesRes, channelsRes] = await Promise.all([
|
||||
purchasesApi.list(),
|
||||
channelsApi.list({}),
|
||||
channelsApi.list(),
|
||||
]);
|
||||
setPurchases(purchasesRes.data);
|
||||
setChannels(channelsRes.data);
|
||||
setPurchases(purchasesRes.placements);
|
||||
setChannels(channelsRes.target_channels);
|
||||
} catch (err: any) {
|
||||
setError(err?.error?.message || "Ошибка загрузки данных");
|
||||
} finally {
|
||||
@@ -87,26 +87,24 @@ export default function PurchasesPage() {
|
||||
const filteredPurchases = purchases.filter((purchase) => {
|
||||
// Поиск
|
||||
const matchesSearch =
|
||||
purchase.external_channel.title
|
||||
purchase.external_channel_title
|
||||
.toLowerCase()
|
||||
.includes(searchQuery.toLowerCase()) ||
|
||||
purchase.target_channel.title
|
||||
purchase.target_channel_title
|
||||
.toLowerCase()
|
||||
.includes(searchQuery.toLowerCase()) ||
|
||||
purchase.creative.name.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
purchase.creative_name.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
|
||||
// Фильтр по каналу
|
||||
const matchesChannel =
|
||||
filterChannel === "all" || purchase.target_channel.id === filterChannel;
|
||||
filterChannel === "all" || purchase.target_channel_id === filterChannel;
|
||||
|
||||
// Фильтр по статусу
|
||||
let matchesStatus = true;
|
||||
if (filterStatus === "completed") {
|
||||
matchesStatus = !!purchase.actual_date;
|
||||
} else if (filterStatus === "scheduled") {
|
||||
matchesStatus = !purchase.actual_date;
|
||||
} else if (filterStatus === "archived") {
|
||||
matchesStatus = purchase.is_archived;
|
||||
if (filterStatus === "archived") {
|
||||
matchesStatus = purchase.status === "archived";
|
||||
} else if (filterStatus === "active") {
|
||||
matchesStatus = purchase.status === "active";
|
||||
}
|
||||
|
||||
return matchesSearch && matchesChannel && matchesStatus;
|
||||
@@ -115,17 +113,13 @@ export default function PurchasesPage() {
|
||||
// Статистика
|
||||
const stats = {
|
||||
total: purchases.length,
|
||||
completed: purchases.filter((p) => p.actual_date).length,
|
||||
scheduled: purchases.filter((p) => !p.actual_date).length,
|
||||
active: purchases.filter((p) => p.status === "active").length,
|
||||
archived: purchases.filter((p) => p.status === "archived").length,
|
||||
totalCost: purchases.reduce((sum, p) => sum + (p.cost || 0), 0),
|
||||
totalSubscriptions: purchases.reduce(
|
||||
(sum, p) => sum + p.subscriptions_count,
|
||||
0
|
||||
),
|
||||
avgCpf:
|
||||
purchases.length > 0
|
||||
? purchases.reduce((sum, p) => sum + (p.cpf || 0), 0) / purchases.length
|
||||
: 0,
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -169,7 +163,7 @@ export default function PurchasesPage() {
|
||||
{formatNumber(stats.total)}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
{stats.completed} завершено, {stats.scheduled} запланировано
|
||||
{stats.active} активных, {stats.archived} в архиве
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -203,20 +197,6 @@ export default function PurchasesPage() {
|
||||
<p className="text-xs text-muted-foreground mt-1">Всего</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
||||
<CardTitle className="text-sm font-medium">Средний CPF</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">
|
||||
₽{formatMetric(stats.avgCpf)}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
По всем закупам
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
@@ -308,9 +288,8 @@ export default function PurchasesPage() {
|
||||
<TableHead>Креатив</TableHead>
|
||||
<TableHead>Дата</TableHead>
|
||||
<TableHead className="text-right">Стоимость</TableHead>
|
||||
<TableHead className="text-right">Подписчики</TableHead>
|
||||
<TableHead className="text-right">CPF</TableHead>
|
||||
<TableHead className="text-right">Конверсия</TableHead>
|
||||
<TableHead className="text-right">Подписки</TableHead>
|
||||
<TableHead className="text-right">Просмотры</TableHead>
|
||||
<TableHead></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -318,34 +297,27 @@ export default function PurchasesPage() {
|
||||
{filteredPurchases.map((purchase) => (
|
||||
<TableRow key={purchase.id}>
|
||||
<TableCell>
|
||||
{purchase.is_archived ? (
|
||||
{purchase.status === "archived" ? (
|
||||
<Badge variant="secondary">
|
||||
<Archive className="h-3 w-3 mr-1" />
|
||||
Архив
|
||||
</Badge>
|
||||
) : purchase.actual_date ? (
|
||||
) : (
|
||||
<Badge variant="default">
|
||||
<CheckCircle className="h-3 w-3 mr-1" />
|
||||
Завершено
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="outline">
|
||||
<Clock className="h-3 w-3 mr-1" />
|
||||
Запланировано
|
||||
Активно
|
||||
</Badge>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
{purchase.target_channel.title}
|
||||
{purchase.target_channel_title}
|
||||
</TableCell>
|
||||
<TableCell>{purchase.external_channel.title}</TableCell>
|
||||
<TableCell>{purchase.external_channel_title}</TableCell>
|
||||
<TableCell className="max-w-[200px] truncate">
|
||||
{purchase.creative.name}
|
||||
{purchase.creative_name}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{formatDate(
|
||||
purchase.actual_date || purchase.scheduled_date
|
||||
)}
|
||||
{formatDate(purchase.placement_date)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatCurrency(purchase.cost)}
|
||||
@@ -354,11 +326,8 @@ export default function PurchasesPage() {
|
||||
{formatNumber(purchase.subscriptions_count)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{purchase.cpf ? `₽${formatMetric(purchase.cpf)}` : "—"}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{purchase.conversion_rate
|
||||
? formatPercent(purchase.conversion_rate)
|
||||
{purchase.views_count
|
||||
? formatNumber(purchase.views_count)
|
||||
: "—"}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
|
||||
Reference in New Issue
Block a user