Skip to content

Commit 081a846

Browse files
committed
feat: enhance SearchLoading component with additional messages and error handling for extended wait times
1 parent ebdbc77 commit 081a846

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

ichub-frontend/src/features/part-discovery/components/search/SearchLoading.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ const SearchLoading = ({ isLoading, isCompleted = false, onCancel }: SearchLoadi
3939
// Base rotating messages (shown after first message)
4040
const rotatingMessages = [
4141
'Searching through the dataspace for available data...',
42+
'Discovering Partner endpoints...',
43+
'Discovering Digital Twin Registries...',
4244
'Negotiating contracts with data providers...',
4345
'Connecting to digital twin registries...',
4446
'Establishing secure connections to data sources...',
4547
'Retrieving digital twin information...',
46-
'Almost there, gathering results...'
4748
];
4849

4950
// Extended wait message for long operations
50-
const extendedWaitMessage = "It's taking a bit more than expected, probably the negotiation is being retried (approx 10s)";
51+
const extendedWaitMessage = "It's taking a bit more than expected, probably the access negotiation is still going (approx 10s)";
52+
53+
// Error message for very long operations
54+
const errorMessage = "This is taking much longer than expected. There may be an error in the initial connection/negotiation process. Please contact your administrator.";
5155

5256
// Reset component state when loading starts
5357
useEffect(() => {
@@ -99,6 +103,11 @@ const SearchLoading = ({ isLoading, isCompleted = false, onCancel }: SearchLoadi
99103

100104
const elapsed = Date.now() - startTime;
101105

106+
// Show error message after 30 seconds
107+
if (elapsed > 30000) {
108+
return errorMessage;
109+
}
110+
102111
// Show extended wait message after 12 seconds
103112
if (elapsed > 12000) {
104113
return extendedWaitMessage;
@@ -108,7 +117,10 @@ const SearchLoading = ({ isLoading, isCompleted = false, onCancel }: SearchLoadi
108117
};
109118

110119
const progressValue = calculateProgress();
111-
const progressColor = isCompleted ? 'success' : 'primary';
120+
const elapsed = Date.now() - startTime;
121+
const isExtendedWait = elapsed > 12000 && elapsed <= 30000 && isLoading && !isCompleted;
122+
const isErrorState = elapsed > 30000 && isLoading && !isCompleted;
123+
const progressColor = isCompleted ? 'success' : (isErrorState ? 'error' : (isExtendedWait ? 'warning' : 'primary'));
112124

113125
return (
114126
<Box sx={{ width: '100%', position: 'relative' }}>
@@ -197,15 +209,20 @@ const SearchLoading = ({ isLoading, isCompleted = false, onCancel }: SearchLoadi
197209
'& .MuiLinearProgress-bar': {
198210
background: isCompleted
199211
? 'linear-gradient(45deg, #4caf50 30%, #66bb6a 90%)' // Green when completed
200-
: 'linear-gradient(45deg, #1976d2 30%, #42a5f5 90%)', // Blue when loading
212+
: isExtendedWait
213+
? 'linear-gradient(45deg, #ff9800 30%, #ffb74d 90%)' // Orange/Yellow when taking longer
214+
: 'linear-gradient(45deg, #1976d2 30%, #42a5f5 90%)', // Blue when loading normally
201215
borderRadius: 4,
202216
transition: isCompleted
203217
? 'all 0.8s cubic-bezier(0.4, 0, 0.2, 1)' // Smooth elastic transition to completion
204-
: 'transform 0.4s ease-in-out', // Smooth transition for normal progress
205-
// Add a subtle glow effect when completed
218+
: 'all 0.4s ease-in-out', // Smooth transition for normal progress and color changes
219+
// Add a subtle glow effect when completed or extended wait
206220
...(isCompleted && {
207221
boxShadow: '0 0 15px rgba(76, 175, 80, 0.6)',
208222
transform: 'scaleY(1.1)' // Slightly expand when complete
223+
}),
224+
...(isExtendedWait && !isCompleted && {
225+
boxShadow: '0 0 12px rgba(255, 152, 0, 0.4)',
209226
})
210227
}
211228
}}

0 commit comments

Comments
 (0)