malavikapradeep2001 commited on
Commit
3e95f42
·
1 Parent(s): b531904
frontend/src/components/ResultsPanel.tsx CHANGED
@@ -44,23 +44,8 @@ export function ResultsPanel({ uploadedImage, result, loading }: ResultsPanelPro
44
  }
45
  };
46
 
47
- if (isLoading) {
48
- return (
49
- <div className="bg-white rounded-lg shadow-sm p-6 flex flex-col items-center justify-center">
50
- <Loader2Icon className="w-10 h-10 text-blue-600 animate-spin mb-3" />
51
- <p className="text-teal-700 font-medium">Analysing Image...</p>
52
- </div>
53
- );
54
- }
55
-
56
- if (!result) {
57
- return (
58
- <div className="bg-white rounded-lg shadow-sm p-6 text-center text-gray-500">
59
- No analysis result available yet.
60
- </div>
61
- );
62
- }
63
-
64
  const {
65
  model_used,
66
  detections,
@@ -68,31 +53,40 @@ export function ResultsPanel({ uploadedImage, result, loading }: ResultsPanelPro
68
  summary,
69
  // prediction (not used here)
70
  confidence,
71
- } = result;
72
 
73
 
74
 
75
- return ( <div className="bg-white rounded-lg shadow-sm p-6">
76
- {/* Header */}
77
- <div className="flex items-center justify-between mb-6">
78
- <div>
79
- <h2 className="text-2xl font-bold text-gray-800">
80
- {model_used || "Analysis Result"}
81
- </h2>
82
- <p className="text-sm text-gray-500">Automated Image Analysis</p>
83
- </div>
 
84
 
85
- {/* header actions intentionally empty; Generate Report button moved below analysis details */}
86
- </div>
87
 
88
- {/* Image */}
89
- <div className="relative mb-6 rounded-lg overflow-hidden border border-gray-200">
90
- <ImageWithFallback
91
- src={annotated_image_url || uploadedImage || "/ui.jpg"}
92
- alt="Analysis Result"
93
- className="w-full h-64 object-cover"
94
- />
95
- </div>
 
 
 
 
 
 
 
 
96
 
97
  {/* Summary Section */}
98
  {summary && (
 
44
  }
45
  };
46
 
47
+ // Safely destructure result (keep undefined values when result is null) so we can render
48
+ // a stable panel while loading and avoid early returns that change layout.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  const {
50
  model_used,
51
  detections,
 
53
  summary,
54
  // prediction (not used here)
55
  confidence,
56
+ } = (result || {}) as any;
57
 
58
 
59
 
60
+ return (
61
+ <div className="bg-white rounded-lg shadow-sm p-6">
62
+ {/* Header */}
63
+ <div className="flex items-center justify-between mb-6">
64
+ <div>
65
+ <h2 className="text-2xl font-bold text-gray-800">
66
+ {model_used || "Analysis Result"}
67
+ </h2>
68
+ <p className="text-sm text-gray-500">Automated Image Analysis</p>
69
+ </div>
70
 
71
+ {/* header actions intentionally empty; Generate Report button moved below analysis details */}
72
+ </div>
73
 
74
+ {/* If we're loading, show a centered loader inside the panel */}
75
+ {isLoading ? (
76
+ <div className="bg-white rounded-lg shadow-sm p-6 flex flex-col items-center justify-center">
77
+ <Loader2Icon className="w-10 h-10 text-blue-600 animate-spin mb-3" />
78
+ <p className="text-teal-700 font-medium">Analysing Image...</p>
79
+ </div>
80
+ ) : (
81
+ // Image
82
+ <div className="relative mb-6 rounded-lg overflow-hidden border border-gray-200">
83
+ <ImageWithFallback
84
+ src={annotated_image_url || uploadedImage || "/ui.jpg"}
85
+ alt="Analysis Result"
86
+ className="w-full h-64 object-cover"
87
+ />
88
+ </div>
89
+ )}
90
 
91
  {/* Summary Section */}
92
  {summary && (