diff --git a/frontend/src/api/billing.ts b/frontend/src/api/billing.ts index 96b9e21..f21a335 100644 --- a/frontend/src/api/billing.ts +++ b/frontend/src/api/billing.ts @@ -61,7 +61,7 @@ export async function deleteInvoice(id: string): Promise { } export async function downloadInvoicePdf(id: string): Promise { - const res = await api.get(`/billing/invoices/${id}/pdf`, { responseType: 'blob' }) + const res = await api.get(`/billing/invoices/${id}/pdf`, { responseType: 'blob' }) const url = URL.createObjectURL(res.data) const a = document.createElement('a') a.href = url diff --git a/frontend/src/api/cad.ts b/frontend/src/api/cad.ts index b73e34d..797f6a8 100644 --- a/frontend/src/api/cad.ts +++ b/frontend/src/api/cad.ts @@ -100,6 +100,6 @@ export async function generateGltfProduction(cadFileId: string): Promise { - const res = await api.post(`/cad/${cadFileId}/reset-stuck`) + const res = await api.post<{ status: string; message: string }>(`/cad/${cadFileId}/reset-stuck`) return res.data } diff --git a/frontend/src/api/imports.ts b/frontend/src/api/imports.ts index 10affb8..69dec25 100644 --- a/frontend/src/api/imports.ts +++ b/frontend/src/api/imports.ts @@ -14,7 +14,7 @@ export interface ImportValidation { } export async function getImportValidation(id: string): Promise { - const res = await api.get(`/imports/validation/${id}`) + const res = await api.get(`/imports/validation/${id}`) return res.data } diff --git a/frontend/src/api/materials.ts b/frontend/src/api/materials.ts index 32d84e5..d883cff 100644 --- a/frontend/src/api/materials.ts +++ b/frontend/src/api/materials.ts @@ -47,7 +47,10 @@ export async function saveCadPartMaterials( itemId: string, parts: Array<{ part_name: string; material: string }>, ) { - const res = await api.put(`/orders/${orderId}/items/${itemId}/cad-materials`, { parts }) + const res = await api.put<{ parts: Array<{ part_name: string; material: string }> }>( + `/orders/${orderId}/items/${itemId}/cad-materials`, + { parts }, + ) return res.data } diff --git a/frontend/src/api/notifications.ts b/frontend/src/api/notifications.ts index 1fd0621..fd49ccb 100644 --- a/frontend/src/api/notifications.ts +++ b/frontend/src/api/notifications.ts @@ -25,12 +25,12 @@ export async function getNotifications(params?: { unread_only?: boolean channel?: NotificationChannel }): Promise { - const { data } = await api.get('/notifications', { params }) + const { data } = await api.get('/notifications', { params }) return data } export async function getUnreadCount(): Promise { - const { data } = await api.get('/notifications/unread-count') + const { data } = await api.get<{ unread_count: number }>('/notifications/unread-count') return data.unread_count } diff --git a/frontend/src/api/orders.ts b/frontend/src/api/orders.ts index f0fd55e..abefa20 100644 --- a/frontend/src/api/orders.ts +++ b/frontend/src/api/orders.ts @@ -46,6 +46,8 @@ export interface Order { updated_at: string submitted_at: string | null completed_at: string | null + rejected_at: string | null + rejection_reason: string | null estimated_price: number | null item_count: number line_count: number @@ -239,8 +241,21 @@ export async function generateLinesFromItems( return res.data } +export async function rejectOrder(orderId: string, reason: string, notifyClient: boolean = true): Promise { + const res = await api.post(`/orders/${orderId}/reject`, { + reason, + notify_client: notifyClient, + }) + return res.data +} + +export async function resubmitOrder(orderId: string): Promise { + const res = await api.post(`/orders/${orderId}/resubmit`) + return res.data +} + export async function downloadOrderRenders(orderId: string, orderNumber: string): Promise { - const res = await api.get(`/orders/${orderId}/download-renders`, { responseType: 'blob' }) + const res = await api.get(`/orders/${orderId}/download-renders`, { responseType: 'blob' }) const url = URL.createObjectURL(res.data) const a = document.createElement('a') a.href = url diff --git a/frontend/src/api/products.ts b/frontend/src/api/products.ts index f4dd03d..099cd73 100644 --- a/frontend/src/api/products.ts +++ b/frontend/src/api/products.ts @@ -1,4 +1,5 @@ import api from './client' +import type { Order } from './orders' export interface RenderPosition { id: string @@ -106,10 +107,18 @@ export async function deleteProduct(id: string, hard = false): Promise { await api.delete(`/products/${id}`, { params: hard ? { hard: true } : undefined }) } -export async function uploadProductCad(id: string, file: File) { +export interface ProductCadUploadResponse { + cad_file_id: string + original_name: string + file_hash: string + status: string + product_id: string +} + +export async function uploadProductCad(id: string, file: File): Promise { const form = new FormData() form.append('file', file) - const res = await api.post(`/products/${id}/cad`, form, { + const res = await api.post(`/products/${id}/cad`, form, { headers: { 'Content-Type': 'multipart/form-data' }, }) return res.data @@ -120,13 +129,13 @@ export async function saveProductCadMaterials(id: string, parts: CadPartMaterial return res.data } -export async function regenerateProduct(id: string) { - const res = await api.post(`/products/${id}/regenerate`) +export async function regenerateProduct(id: string): Promise<{ status: string; task_id: string | null }> { + const res = await api.post<{ status: string; task_id: string | null }>(`/products/${id}/regenerate`) return res.data } -export async function reprocessProduct(id: string) { - const res = await api.post(`/products/${id}/reprocess`) +export async function reprocessProduct(id: string): Promise<{ status: string; task_id: string | null }> { + const res = await api.post<{ status: string; task_id: string | null }>(`/products/${id}/reprocess`) return res.data } @@ -174,8 +183,8 @@ export async function downloadProductRenders( URL.revokeObjectURL(url) } -export async function getProductOrders(id: string) { - const res = await api.get(`/products/${id}/orders`) +export async function getProductOrders(id: string): Promise { + const res = await api.get(`/products/${id}/orders`) return res.data } diff --git a/frontend/src/api/renderTemplates.ts b/frontend/src/api/renderTemplates.ts index f5cd4d1..ab948ad 100644 --- a/frontend/src/api/renderTemplates.ts +++ b/frontend/src/api/renderTemplates.ts @@ -28,12 +28,12 @@ export interface MaterialLibraryInfo { } export async function listRenderTemplates(): Promise { - const { data } = await api.get('/render-templates'); + const { data } = await api.get('/render-templates'); return data; } export async function createRenderTemplate(formData: FormData): Promise { - const { data } = await api.post('/render-templates', formData, { + const { data } = await api.post('/render-templates', formData, { headers: { 'Content-Type': 'multipart/form-data' }, }); return data; @@ -43,7 +43,7 @@ export async function updateRenderTemplate( id: string, updates: Partial>, ): Promise { - const { data } = await api.patch(`/render-templates/${id}`, updates); + const { data } = await api.patch(`/render-templates/${id}`, updates); return data; } @@ -54,7 +54,7 @@ export async function deleteRenderTemplate(id: string): Promise { export async function reuploadBlendFile(id: string, file: File): Promise { const fd = new FormData(); fd.append('file', file); - const { data } = await api.post(`/render-templates/${id}/upload`, fd, { + const { data } = await api.post(`/render-templates/${id}/upload`, fd, { headers: { 'Content-Type': 'multipart/form-data' }, }); return data; @@ -63,14 +63,14 @@ export async function reuploadBlendFile(id: string, file: File): Promise { const fd = new FormData(); fd.append('file', file); - const { data } = await api.post('/admin/settings/material-library', fd, { + const { data } = await api.post('/admin/settings/material-library', fd, { headers: { 'Content-Type': 'multipart/form-data' }, }); return data; } export async function getMaterialLibraryInfo(): Promise { - const { data } = await api.get('/admin/settings/material-library'); + const { data } = await api.get('/admin/settings/material-library'); return data; } diff --git a/frontend/src/api/uploads.ts b/frontend/src/api/uploads.ts index ce4f390..b058806 100644 --- a/frontend/src/api/uploads.ts +++ b/frontend/src/api/uploads.ts @@ -93,10 +93,18 @@ export async function finalizeExcelImport(data: ExcelFinalizeRequest): Promise { const form = new FormData() form.append('file', file) - const res = await api.post('/uploads/step', form, { + const res = await api.post('/uploads/step', form, { headers: { 'Content-Type': 'multipart/form-data' }, }) return res.data diff --git a/frontend/src/api/worker.ts b/frontend/src/api/worker.ts index ad085ad..1e48e47 100644 --- a/frontend/src/api/worker.ts +++ b/frontend/src/api/worker.ts @@ -94,7 +94,7 @@ export function renderLogStreamUrl(orderLineId: string): string { export interface QueueTask { task_id: string task_name: string - args: any[] + args: unknown[] argsrepr: string status: 'pending' | 'active' | 'reserved' worker?: string