WellNuo/components/ui/ErrorMessage.tsx
Sergei a804a82512 Implement Auth, Patients List, and Dashboard
Features:
- Login screen with API integration (credentials endpoint)
- SecureStore for token management
- Patients list with health data display
- Patient dashboard with stats and quick actions
- AI Chat screen (voice_ask API integration)
- Profile screen with logout
- Full error handling and loading states
- WellNuo brand colors and UI components

API Integration:
- Base URL: eluxnetworks.net/function/well-api/api
- Auth: function=credentials
- Chat: function=voice_ask

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 12:58:15 -08:00

142 lines
3.6 KiB
TypeScript

import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { AppColors, BorderRadius, FontSizes, Spacing } from '@/constants/theme';
interface ErrorMessageProps {
message: string;
onRetry?: () => void;
onDismiss?: () => void;
}
export function ErrorMessage({ message, onRetry, onDismiss }: ErrorMessageProps) {
return (
<View style={styles.container}>
<View style={styles.content}>
<Ionicons name="alert-circle" size={24} color={AppColors.error} />
<Text style={styles.message}>{message}</Text>
</View>
<View style={styles.actions}>
{onRetry && (
<TouchableOpacity onPress={onRetry} style={styles.button}>
<Ionicons name="refresh" size={18} color={AppColors.primary} />
<Text style={styles.buttonText}>Retry</Text>
</TouchableOpacity>
)}
{onDismiss && (
<TouchableOpacity onPress={onDismiss} style={styles.dismissButton}>
<Ionicons name="close" size={18} color={AppColors.textMuted} />
</TouchableOpacity>
)}
</View>
</View>
);
}
interface FullScreenErrorProps {
title?: string;
message: string;
onRetry?: () => void;
}
export function FullScreenError({
title = 'Something went wrong',
message,
onRetry
}: FullScreenErrorProps) {
return (
<View style={styles.fullScreenContainer}>
<Ionicons name="cloud-offline-outline" size={64} color={AppColors.textMuted} />
<Text style={styles.fullScreenTitle}>{title}</Text>
<Text style={styles.fullScreenMessage}>{message}</Text>
{onRetry && (
<TouchableOpacity onPress={onRetry} style={styles.retryButton}>
<Ionicons name="refresh" size={20} color={AppColors.white} />
<Text style={styles.retryButtonText}>Try Again</Text>
</TouchableOpacity>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#FEE2E2',
borderRadius: BorderRadius.lg,
padding: Spacing.md,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginVertical: Spacing.sm,
},
content: {
flexDirection: 'row',
alignItems: 'center',
flex: 1,
},
message: {
color: AppColors.error,
fontSize: FontSizes.sm,
marginLeft: Spacing.sm,
flex: 1,
},
actions: {
flexDirection: 'row',
alignItems: 'center',
},
button: {
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: Spacing.sm,
paddingVertical: Spacing.xs,
},
buttonText: {
color: AppColors.primary,
fontSize: FontSizes.sm,
fontWeight: '500',
marginLeft: Spacing.xs,
},
dismissButton: {
padding: Spacing.xs,
marginLeft: Spacing.xs,
},
// Full Screen Error
fullScreenContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: Spacing.xl,
backgroundColor: AppColors.background,
},
fullScreenTitle: {
fontSize: FontSizes.xl,
fontWeight: '600',
color: AppColors.textPrimary,
marginTop: Spacing.lg,
textAlign: 'center',
},
fullScreenMessage: {
fontSize: FontSizes.base,
color: AppColors.textSecondary,
marginTop: Spacing.sm,
textAlign: 'center',
},
retryButton: {
flexDirection: 'row',
alignItems: 'center',
backgroundColor: AppColors.primary,
paddingVertical: Spacing.sm + 4,
paddingHorizontal: Spacing.lg,
borderRadius: BorderRadius.lg,
marginTop: Spacing.xl,
},
retryButtonText: {
color: AppColors.white,
fontSize: FontSizes.base,
fontWeight: '600',
marginLeft: Spacing.sm,
},
});