summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib/api.ts
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
-rw-r--r--makima/frontend/src/lib/api.ts84
1 files changed, 84 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 4923c1d..7968583 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -3387,6 +3387,85 @@ export async function pickUpOrders(directiveId: string): Promise<PickUpOrdersRes
}
// =============================================================================
+// Directive Order Groups (DOGs) API
+// =============================================================================
+
+export type DOGStatus = "open" | "in_progress" | "done" | "archived";
+
+export interface DirectiveOrderGroup {
+ id: string;
+ directiveId: string;
+ ownerId: string;
+ name: string;
+ description: string | null;
+ status: DOGStatus;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface DOGListResponse {
+ dogs: DirectiveOrderGroup[];
+}
+
+export interface CreateDOGRequest {
+ name: string;
+ description?: string | null;
+}
+
+export interface UpdateDOGRequest {
+ name?: string;
+ description?: string | null;
+ status?: DOGStatus;
+}
+
+export async function listDogs(directiveId: string): Promise<DOGListResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/dogs`);
+ if (!res.ok) throw new Error(`Failed to list DOGs: ${res.statusText}`);
+ return res.json();
+}
+
+export async function createDog(directiveId: string, req: CreateDOGRequest): Promise<DirectiveOrderGroup> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/dogs`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(req),
+ });
+ if (!res.ok) throw new Error(`Failed to create DOG: ${res.statusText}`);
+ return res.json();
+}
+
+export async function getDog(directiveId: string, dogId: string): Promise<DirectiveOrderGroup> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/dogs/${dogId}`);
+ if (!res.ok) throw new Error(`Failed to get DOG: ${res.statusText}`);
+ return res.json();
+}
+
+export async function updateDog(directiveId: string, dogId: string, req: UpdateDOGRequest): Promise<DirectiveOrderGroup> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/dogs/${dogId}`, {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(req),
+ });
+ if (!res.ok) throw new Error(`Failed to update DOG: ${res.statusText}`);
+ return res.json();
+}
+
+export async function deleteDog(directiveId: string, dogId: string): Promise<void> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/dogs/${dogId}`, {
+ method: "DELETE",
+ });
+ if (!res.ok) throw new Error(`Failed to delete DOG: ${res.statusText}`);
+}
+
+export async function pickUpDogOrders(directiveId: string, dogId: string): Promise<PickUpOrdersResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/directives/${directiveId}/dogs/${dogId}/pick-up-orders`, {
+ method: "POST",
+ });
+ if (!res.ok) throw new Error(`Failed to pick up DOG orders: ${res.statusText}`);
+ return res.json();
+}
+
+// =============================================================================
// Orders API
// =============================================================================
@@ -3406,6 +3485,7 @@ export interface Order {
directiveId: string | null;
directiveStepId: string | null;
directiveName: string | null;
+ dogId: string | null;
repositoryUrl: string | null;
createdAt: string;
updatedAt: string;
@@ -3424,6 +3504,7 @@ export interface CreateOrderRequest {
orderType?: OrderType;
labels?: string[];
directiveId: string;
+ dogId?: string | null;
repositoryUrl?: string | null;
}
@@ -3436,6 +3517,7 @@ export interface UpdateOrderRequest {
labels?: string[];
directiveId?: string | null;
directiveStepId?: string | null;
+ dogId?: string | null;
repositoryUrl?: string | null;
}
@@ -3445,6 +3527,7 @@ export async function listOrders(
priority?: OrderPriority,
directiveId?: string,
search?: string,
+ dogId?: string,
): Promise<OrderListResponse> {
const params = new URLSearchParams();
if (status) params.set("status", status);
@@ -3452,6 +3535,7 @@ export async function listOrders(
if (priority) params.set("priority", priority);
if (directiveId) params.set("directiveId", directiveId);
if (search) params.set("search", search);
+ if (dogId) params.set("dogId", dogId);
const qs = params.toString();
const res = await authFetch(`${API_BASE}/api/v1/orders${qs ? `?${qs}` : ""}`);
if (!res.ok) throw new Error(`Failed to list orders: ${res.statusText}`);