fix: placement send func
This commit is contained in:
@@ -29,6 +29,8 @@ import {
|
|||||||
Trash2,
|
Trash2,
|
||||||
Copy,
|
Copy,
|
||||||
Pencil,
|
Pencil,
|
||||||
|
Send,
|
||||||
|
Check,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { DashboardHeader } from "@/components/layout/dashboard-header";
|
import { DashboardHeader } from "@/components/layout/dashboard-header";
|
||||||
import { useWorkspace } from "@/components/providers/workspace-provider";
|
import { useWorkspace } from "@/components/providers/workspace-provider";
|
||||||
@@ -415,33 +417,35 @@ function CellRenderer({
|
|||||||
<td key={column.id} className="py-2 px-3">
|
<td key={column.id} className="py-2 px-3">
|
||||||
{hasCreative ? (
|
{hasCreative ? (
|
||||||
<div className="flex items-center gap-2">
|
<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>
|
<span className="text-xs">📷</span>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs truncate max-w-[100px]">{placement.creative_name || "Без названия"}</span>
|
<span className="text-xs truncate max-w-[100px]">{placement.creative_name || "Без названия"}</span>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-6 px-2 text-xs"
|
className="h-6 w-6 p-0 text-muted-foreground hover:text-primary"
|
||||||
|
title="Отправить креатив"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (placement.creative_id) {
|
if (placement.creative_id) {
|
||||||
onOpenCreativeSend?.(placement);
|
onOpenCreativeSend?.(placement);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Отправить
|
<Send className="h-3.5 w-3.5" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
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={() => {
|
onClick={() => {
|
||||||
if (placement.creative_id) {
|
if (placement.creative_id) {
|
||||||
onClearCreative?.(placement.id);
|
onClearCreative?.(placement.id);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
✕
|
<X className="h-3.5 w-3.5" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -1218,8 +1222,16 @@ export default function PurchasePlanDetailPage() {
|
|||||||
handleDraftChange(placementId, { creative_id: null, creative_name: null });
|
handleDraftChange(placementId, { creative_id: null, creative_name: null });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenCreativeSend = (placement: PlacementWithStats) => {
|
const handleOpenCreativeSend = async (placement: PlacementWithStats) => {
|
||||||
console.log("Sending creative for placement:", placement.id);
|
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 }) => {
|
const handleSelectCreative = (creative: { id: string; name: string }) => {
|
||||||
|
|||||||
@@ -140,4 +140,17 @@ export const placementsApi = {
|
|||||||
`/workspaces/${workspaceId}/placements/${placementId}/views/history`,
|
`/workspaces/${workspaceId}/placements/${placementId}/views/history`,
|
||||||
{ params }
|
{ 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