diff options
| author | Anita <ana.tqtc@gmail.com> | 2026-04-19 19:22:57 +0100 |
|---|---|---|
| committer | Anita <ana.tqtc@gmail.com> | 2026-04-19 19:22:57 +0100 |
| commit | 8dd49e680bfea6886839a8841dd829d7f6e71ce8 (patch) | |
| tree | 8186a7fded9beec34c6849baa0ff796b03f8649d /src/app | |
| parent | e8914f03cce7db31485ec26912ac7c20ec3165ce (diff) | |
feat(home): mejora sección estadísticas de uso refs #4
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/(protected)/(tabs)/home.tsx | 171 |
1 files changed, 95 insertions, 76 deletions
diff --git a/src/app/(protected)/(tabs)/home.tsx b/src/app/(protected)/(tabs)/home.tsx index e3458ab..ea6c5cc 100644 --- a/src/app/(protected)/(tabs)/home.tsx +++ b/src/app/(protected)/(tabs)/home.tsx @@ -1,31 +1,38 @@ -import { useReservations } from '@/features/reservations/hooks/useReservations'; -import { useAuthSession } from '@/providers/AuthProvider'; -import theme from '@/theme'; -import { Feather, MaterialIcons } from '@expo/vector-icons'; -import { Link } from 'expo-router'; -import { useMemo } from 'react'; -import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native'; +import { useReservations } from "@/features/reservations/hooks/useReservations"; +import { useAuthSession } from "@/providers/AuthProvider"; +import theme from "@/theme"; +import { Feather, MaterialIcons } from "@expo/vector-icons"; +import { Link } from "expo-router"; +import { useMemo } from "react"; +import { + ActivityIndicator, + Pressable, + StyleSheet, + Text, + View, +} from "react-native"; function formatDate(date: string): string { const parsedDate = new Date(date); - // formato fecha - return parsedDate.toLocaleDateString('es-ES', { - day: '2-digit', - month: 'short', - year: 'numeric', - }); - } + // formato fecha + return parsedDate.toLocaleDateString("es-ES", { + day: "2-digit", + month: "short", + year: "numeric", + }); +} // creacion de acceso rapidos al theme de estilos -const { colors, spacing, radius, typography, fontWeight, layout, shadows } = theme; +const { colors, spacing, radius, typography, fontWeight, layout, shadows } = + theme; export default function HomeScreen() { const { user } = useAuthSession(); - const { reservations, activeReservations, loading, error } = useReservations(); - + const { reservations, activeReservations, loading, error } = + useReservations(); // crea el contador de reservas en el mes actual - const currentMonthReservationsCount = useMemo(() => { + const currentMonthReservationsCount = useMemo(() => { const now = new Date(); const currentMonth = now.getMonth(); const currentYear = now.getFullYear(); @@ -42,7 +49,7 @@ export default function HomeScreen() { // crea una lista con las 2 primeras reservas activas const previewReservations = useMemo( () => activeReservations.slice(0, 2), - [activeReservations] + [activeReservations], ); if (loading) { @@ -66,12 +73,10 @@ export default function HomeScreen() { <View style={styles.container}> {/* cabecera de bienvenida */} <Text style={styles.title}> - Hola{user?.displayName ? `, ${user.displayName}` : ''} 👋 + Hola{user?.displayName ? `, ${user.displayName}` : ""} 👋 </Text> - <Text style={styles.subtitle}> - Bienvenido a la App Oficina - </Text> + <Text style={styles.subtitle}>Bienvenido a la App Oficina</Text> <View style={styles.divider} /> {/* seccion de accesos rapidos */} @@ -111,7 +116,7 @@ export default function HomeScreen() { <Pressable> <View style={styles.linkRow}> <Text style={styles.linkText}>Ver todas</Text> - <Text style={styles.chevronSmall}>{'>'}</Text> + <Text style={styles.chevronSmall}>{">"}</Text> </View> </Pressable> </Link> @@ -122,20 +127,28 @@ export default function HomeScreen() { previewReservations.map((reservation) => ( <View key={reservation.id} style={styles.reservationCard}> <View style={styles.reservationContent}> - <View style={styles.reservationIconContainer}> - <MaterialIcons name="business" size={22} color={colors.primary} /> + <MaterialIcons + name="business" + size={22} + color={colors.primary} + /> </View> <View style={styles.reservationInfo}> - <View style={styles.reservationHeader}> - <Text style={styles.reservationOffice}>{reservation.officeName}</Text> - <Text style={styles.chevron}>{'>'}</Text> + <Text style={styles.reservationOffice}> + {reservation.officeName} + </Text> + <Text style={styles.chevron}>{">"}</Text> </View> <View style={styles.reservationMetaRow}> - <MaterialIcons name="access-time" size={14} color={colors.textSecondary} /> + <MaterialIcons + name="access-time" + size={14} + color={colors.textSecondary} + /> <Text style={styles.reservationMeta}> {formatDate(reservation.date)} </Text> @@ -162,11 +175,10 @@ export default function HomeScreen() { : styles.statusTextPending, ]} > - {reservation.checkInAt ? 'Confirmada' : 'Pendiente'} + {reservation.checkInAt ? "Confirmada" : "Pendiente"} </Text> </View> </View> - </View> </View> </View> @@ -181,6 +193,10 @@ export default function HomeScreen() { </View> {/* seccion de estadisticas */} + <View style={styles.statsHeader}> + <Text style={styles.sectionTitle}>Estadísticas de uso</Text> + </View> + <View style={styles.statsGrid}> <View style={styles.statCard}> <Text style={styles.statValue}>{activeReservations.length}</Text> @@ -210,14 +226,14 @@ const styles = StyleSheet.create({ paddingBottom: spacing.xl, gap: 18, maxWidth: layout.contentWidth, - width: '100%', - alignSelf: 'center', + width: "100%", + alignSelf: "center", backgroundColor: colors.background, }, center: { flex: 1, - alignItems: 'center', - justifyContent: 'center', + alignItems: "center", + justifyContent: "center", padding: spacing.xxxl, backgroundColor: colors.background, }, @@ -248,7 +264,7 @@ const styles = StyleSheet.create({ gap: spacing.lg, }, quickAccessRow: { - flexDirection: 'row', + flexDirection: "row", gap: spacing.lg, }, quickAccessButton: { @@ -256,8 +272,8 @@ const styles = StyleSheet.create({ backgroundColor: colors.primary, paddingVertical: spacing.xxxl, borderRadius: radius.xl, - alignItems: 'center', - justifyContent: 'center', + alignItems: "center", + justifyContent: "center", gap: spacing.md, minHeight: 120, }, @@ -266,8 +282,8 @@ const styles = StyleSheet.create({ backgroundColor: colors.primaryDark, paddingVertical: spacing.xxxl, borderRadius: radius.xl, - alignItems: 'center', - justifyContent: 'center', + alignItems: "center", + justifyContent: "center", gap: spacing.md, minHeight: 112, }, @@ -277,7 +293,7 @@ const styles = StyleSheet.create({ color: colors.white, fontWeight: fontWeight.regular, fontSize: typography.md, - textAlign: 'center', + textAlign: "center", lineHeight: 16, }, //---------------------------------- @@ -286,28 +302,28 @@ const styles = StyleSheet.create({ width: 40, height: 40, borderRadius: radius.md, - backgroundColor: '#3b82f6', - alignItems: 'center', - justifyContent: 'center', + backgroundColor: "#3b82f6", + alignItems: "center", + justifyContent: "center", }, quickAccessIconContainerDark: { width: 40, height: 40, borderRadius: radius.md, - backgroundColor: '#334e68', - alignItems: 'center', - justifyContent: 'center', + backgroundColor: "#334e68", + alignItems: "center", + justifyContent: "center", }, // estilos de reservas activas reservationsHeader: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", }, linkRow: { - flexDirection: 'row', - alignItems: 'center', + flexDirection: "row", + alignItems: "center", gap: spacing.xs, }, chevronSmall: { @@ -333,7 +349,7 @@ const styles = StyleSheet.create({ ...shadows.card, }, reservationContent: { - flexDirection: 'row', + flexDirection: "row", gap: spacing.lg, }, reservationIconContainer: { @@ -341,17 +357,17 @@ const styles = StyleSheet.create({ height: 48, borderRadius: radius.lg, backgroundColor: colors.primarySoft, - alignItems: 'center', - justifyContent: 'center', + alignItems: "center", + justifyContent: "center", }, reservationInfo: { flex: 1, gap: spacing.sm, }, reservationHeader: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", }, reservationOffice: { fontSize: 18, @@ -364,8 +380,8 @@ const styles = StyleSheet.create({ fontWeight: fontWeight.semibold, }, reservationMetaRow: { - flexDirection: 'row', - alignItems: 'center', + flexDirection: "row", + alignItems: "center", gap: spacing.sm, }, reservationMeta: { @@ -373,9 +389,9 @@ const styles = StyleSheet.create({ fontSize: typography.md, }, reservationRow: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", }, reservationTime: { color: colors.text, @@ -383,13 +399,13 @@ const styles = StyleSheet.create({ flex: 1, }, statusBadge: { - alignSelf: 'flex-start', + alignSelf: "flex-start", backgroundColor: colors.successBg, paddingHorizontal: 10, paddingVertical: spacing.xs, borderRadius: radius.sm, }, - // estado confirmada (verde) + // estado confirmada (verde) statusConfirmed: { backgroundColor: colors.successBg, }, @@ -399,12 +415,12 @@ const styles = StyleSheet.create({ }, // estado pendiente (gris neutro) statusPending: { - backgroundColor: '#EEF2F6', + backgroundColor: "#EEF2F6", }, statusTextPending: { - color: '#475569', + color: "#475569", }, - + statusText: { color: colors.successText, fontWeight: fontWeight.semibold, @@ -419,12 +435,15 @@ const styles = StyleSheet.create({ }, emptyReservationText: { color: colors.textSecondary, - textAlign: 'center', + textAlign: "center", }, //estilos estadisticas + statsHeader: { + marginBottom: spacing.md, + }, statsGrid: { - flexDirection: 'row', + flexDirection: "row", gap: spacing.lg, }, statCard: { @@ -437,8 +456,8 @@ const styles = StyleSheet.create({ minHeight: 115, backgroundColor: colors.surface, gap: spacing.sm, - alignItems: 'center', - justifyContent: 'space-between', + alignItems: "center", + justifyContent: "space-between", }, // --- estilos textos estadisticas @@ -451,12 +470,12 @@ const styles = StyleSheet.create({ color: colors.textSecondary, fontSize: typography.sm, fontWeight: fontWeight.regular, - textAlign: 'center', + textAlign: "center", }, //-------------------------------- error: { color: colors.error, - textAlign: 'center', + textAlign: "center", }, -});
\ No newline at end of file +}); |