diff --git a/app/dashboard/[workspaceId]/purchase-plans/[projectId]/page.tsx b/app/dashboard/[workspaceId]/purchase-plans/[projectId]/page.tsx
index f5048a0..724d931 100644
--- a/app/dashboard/[workspaceId]/purchase-plans/[projectId]/page.tsx
+++ b/app/dashboard/[workspaceId]/purchase-plans/[projectId]/page.tsx
@@ -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({
{hasCreative ? (
-
+
📷
{placement.creative_name || "Без названия"}
) : (
@@ -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 }) => {
diff --git a/lib/api/placements.ts b/lib/api/placements.ts
index 58c9277..ac8303d 100644
--- a/lib/api/placements.ts
+++ b/lib/api/placements.ts
@@ -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`
+ ),
};
|