feat: purchase-plans global update

This commit is contained in:
ivannoskov
2026-02-02 21:01:11 +03:00
parent f9c334ba22
commit 735077e707
11 changed files with 2575 additions and 534 deletions

View File

@@ -12,20 +12,9 @@ import type {
ViewsHistoryItem,
ViewsHistoryQueryParams,
PaginatedResponse,
UpdatePlacementInProjectRequest,
} from "@/lib/types/api";
type UpdatePlacementInProjectRequest = Partial<{
status: string;
comment: string | null;
creative_id: string | null;
placement_at: string | null;
payment_at: string | null;
cost: { type: "fixed"; value: number } | null;
cost_before_bargain: number | null;
placement_type: string | null;
format: string | null;
}>;
export const placementsApi = {
/**
* Get list of placements for workspace
@@ -40,15 +29,22 @@ export const placementsApi = {
* Get placements for a specific project (grouped by channel UI)
*/
getByProject: (workspaceId: string, projectId: string) =>
api.get<{ placements: Placement[] }>(`/workspaces/${workspaceId}/projects/${projectId}/placements`)
.then((response) => response.placements),
api.get<PaginatedResponse<Placement>>(`/workspaces/${workspaceId}/projects/${projectId}/placements`)
.then((response) => response.items),
/**
* Get single placement
* Get single placement (deprecated - use getInProject for project-specific data)
*/
get: (workspaceId: string, placementId: string) =>
api.get<Placement>(`/workspaces/${workspaceId}/placements/${placementId}`),
/**
* Get single placement within project
* GET /workspaces/{workspace_id}/projects/{project_id}/placements/{placement_id}
*/
getInProject: (workspaceId: string, projectId: string, placementId: string) =>
api.get<PlacementWithStats>(`/workspaces/${workspaceId}/projects/${projectId}/placements/${placementId}`),
/**
* Create new placement
*/
@@ -124,10 +120,13 @@ export const placementsApi = {
),
/**
* Delete (archive) placement
* Delete placement within project
* DELETE /workspaces/{workspace_id}/projects/{project_id}/placements/{placement_id}
*/
delete: (workspaceId: string, placementId: string) =>
api.delete<void>(`/workspaces/${workspaceId}/placements/${placementId}`),
deleteInProject: (workspaceId: string, projectId: string, placementId: string) =>
api.delete<void>(
`/workspaces/${workspaceId}/projects/${projectId}/placements/${placementId}`
),
/**
* Get views history for placement