-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathErrorWidgetCard.tsx
More file actions
71 lines (65 loc) · 1.85 KB
/
ErrorWidgetCard.tsx
File metadata and controls
71 lines (65 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { ToolWidget } from '../types';
interface ErrorWidgetCardProps {
widget: ToolWidget;
}
/**
* Error card per tool widgets falliti in voice chat
* Mostra messaggio di errore con icona rossa
*/
const ErrorWidgetCard: React.FC<ErrorWidgetCardProps> = React.memo(({ widget }) => {
const errorMessage = widget.errorMessage || 'Errore durante l\'esecuzione';
// Determina il messaggio specifico in base al tool
let specificMessage = errorMessage;
if (widget.toolName === 'show_tasks_to_user') {
specificMessage = 'Impossibile recuperare le task';
} else if (widget.toolName === 'show_categories_to_user') {
specificMessage = 'Impossibile recuperare le categorie';
}
return (
<View style={styles.container}>
<View style={styles.iconContainer}>
<Ionicons name="alert-circle" size={24} color="#FF3B30" />
</View>
<View style={styles.textContainer}>
<Text style={styles.errorTitle}>{specificMessage}</Text>
{widget.errorMessage && widget.errorMessage !== specificMessage && (
<Text style={styles.errorDetail}>{widget.errorMessage}</Text>
)}
</View>
</View>
);
});
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#FFFFFF',
borderRadius: 12,
padding: 12,
marginVertical: 8,
borderWidth: 1.5,
borderColor: '#E1E5E9',
borderLeftWidth: 4,
borderLeftColor: '#FF3B30',
},
iconContainer: {
marginRight: 12,
},
textContainer: {
flex: 1,
},
errorTitle: {
fontSize: 14,
fontWeight: '600',
color: '#FF3B30',
marginBottom: 2,
},
errorDetail: {
fontSize: 12,
color: '#CC0000',
},
});
export default ErrorWidgetCard;