diff --git a/backend/internal/api/handlers/import_handler.go b/backend/internal/api/handlers/import_handler.go index b0a0da35..4bc98f0a 100644 --- a/backend/internal/api/handlers/import_handler.go +++ b/backend/internal/api/handlers/import_handler.go @@ -63,7 +63,12 @@ func (h *ImportHandler) GetStatus(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "has_pending": true, - "session": session, + "session": gin.H{ + "id": session.UUID, + "state": session.Status, + "created_at": session.CreatedAt, + "updated_at": session.UpdatedAt, + }, }) } @@ -89,7 +94,15 @@ func (h *ImportHandler) GetPreview(c *gin.Context) { session.Status = "reviewing" h.db.Save(&session) - c.JSON(http.StatusOK, result) + c.JSON(http.StatusOK, gin.H{ + "session": gin.H{ + "id": session.UUID, + "state": session.Status, + "created_at": session.CreatedAt, + "updated_at": session.UpdatedAt, + }, + "preview": result, + }) } // Upload handles manual Caddyfile upload or paste. diff --git a/backend/internal/api/handlers/import_handler_test.go b/backend/internal/api/handlers/import_handler_test.go index c7939d8e..c499ab9f 100644 --- a/backend/internal/api/handlers/import_handler_test.go +++ b/backend/internal/api/handlers/import_handler_test.go @@ -93,7 +93,9 @@ func TestImportHandler_GetPreview(t *testing.T) { assert.Equal(t, http.StatusOK, w.Code) var result map[string]interface{} json.Unmarshal(w.Body.Bytes(), &result) - hosts := result["hosts"].([]interface{}) + + preview := result["preview"].(map[string]interface{}) + hosts := preview["hosts"].([]interface{}) assert.Len(t, hosts, 1) // Verify status changed to reviewing diff --git a/frontend/src/hooks/useImport.ts b/frontend/src/hooks/useImport.ts index 7742824e..d2a16f7b 100644 --- a/frontend/src/hooks/useImport.ts +++ b/frontend/src/hooks/useImport.ts @@ -31,7 +31,7 @@ export function useImport() { const previewQuery = useQuery({ queryKey: ['import-preview'], queryFn: getImportPreview, - enabled: !!statusQuery.data?.has_pending && statusQuery.data?.session?.state === 'reviewing', + enabled: !!statusQuery.data?.has_pending && (statusQuery.data?.session?.state === 'reviewing' || statusQuery.data?.session?.state === 'pending'), }); const uploadMutation = useMutation({