fix: placement send func
This commit is contained in:
@@ -29,6 +29,8 @@ import {
|
||||
Trash2,
|
||||
Copy,
|
||||
Pencil,
|
||||
Send,
|
||||
Check,
|
||||
} from "lucide-react";
|
||||
import { DashboardHeader } from "@/components/layout/dashboard-header";
|
||||
import { useWorkspace } from "@/components/providers/workspace-provider";
|
||||
@@ -415,33 +417,35 @@ function CellRenderer({
|
||||
<td key={column.id} className="py-2 px-3">
|
||||
{hasCreative ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-8 h-8 rounded bg-muted flex items-center justify-center overflow-hidden">
|
||||
<div className="w-8 h-8 rounded bg-muted flex items-center justify-center overflow-hidden shrink-0">
|
||||
<span className="text-xs">📷</span>
|
||||
</div>
|
||||
<span className="text-xs truncate max-w-[100px]">{placement.creative_name || "Без названия"}</span>
|
||||
<Button
|
||||
variant="outline"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 px-2 text-xs"
|
||||
className="h-6 w-6 p-0 text-muted-foreground hover:text-primary"
|
||||
title="Отправить креатив"
|
||||
onClick={() => {
|
||||
if (placement.creative_id) {
|
||||
onOpenCreativeSend?.(placement);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Отправить
|
||||
<Send className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 px-1 text-xs text-muted-foreground hover:text-destructive"
|
||||
className="h-6 w-6 p-0 text-muted-foreground hover:text-destructive"
|
||||
title="Очистить креатив"
|
||||
onClick={() => {
|
||||
if (placement.creative_id) {
|
||||
onClearCreative?.(placement.id);
|
||||
}
|
||||
}}
|
||||
>
|
||||
✕
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
@@ -1218,8 +1222,16 @@ export default function PurchasePlanDetailPage() {
|
||||
handleDraftChange(placementId, { creative_id: null, creative_name: null });
|
||||
};
|
||||
|
||||
const handleOpenCreativeSend = (placement: PlacementWithStats) => {
|
||||
console.log("Sending creative for placement:", placement.id);
|
||||
const handleOpenCreativeSend = async (placement: PlacementWithStats) => {
|
||||
if (!placement.creative_id || isDemoMode) return;
|
||||
|
||||
try {
|
||||
await placementsApi.sendCreative(workspaceId, projectId, placement.id);
|
||||
alert("Креатив успешно отправлен");
|
||||
} catch (err) {
|
||||
console.error("Failed to send creative:", err);
|
||||
alert("Не удалось отправить креатив");
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectCreative = (creative: { id: string; name: string }) => {
|
||||
|
||||
@@ -140,4 +140,17 @@ export const placementsApi = {
|
||||
`/workspaces/${workspaceId}/placements/${placementId}/views/history`,
|
||||
{ params }
|
||||
),
|
||||
|
||||
/**
|
||||
* Build creative for placement (generate invite link and send to user via bot)
|
||||
* POST /workspaces/{workspace_id}/projects/{project_id}/placements/{placement_id}/creative
|
||||
*/
|
||||
sendCreative: (
|
||||
workspaceId: string,
|
||||
projectId: string,
|
||||
placementId: string
|
||||
) =>
|
||||
api.post<{ id: string; name: string; text: string }>(
|
||||
`/workspaces/${workspaceId}/projects/${projectId}/placements/${placementId}/creative`
|
||||
),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user