From 8dd49e680bfea6886839a8841dd829d7f6e71ce8 Mon Sep 17 00:00:00 2001 From: Anita Date: Sun, 19 Apr 2026 19:22:57 +0100 Subject: feat(home): mejora sección estadísticas de uso refs #4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(protected)/(tabs)/home.tsx | 171 ++++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 76 deletions(-) (limited to 'src/app/(protected)/(tabs)') 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() { {/* cabecera de bienvenida */} - Hola{user?.displayName ? `, ${user.displayName}` : ''} 👋 + Hola{user?.displayName ? `, ${user.displayName}` : ""} 👋 - - Bienvenido a la App Oficina - + Bienvenido a la App Oficina {/* seccion de accesos rapidos */} @@ -111,7 +116,7 @@ export default function HomeScreen() { Ver todas - {'>'} + {">"} @@ -122,20 +127,28 @@ export default function HomeScreen() { previewReservations.map((reservation) => ( - - + - - {reservation.officeName} - {'>'} + + {reservation.officeName} + + {">"} - + {formatDate(reservation.date)} @@ -162,11 +175,10 @@ export default function HomeScreen() { : styles.statusTextPending, ]} > - {reservation.checkInAt ? 'Confirmada' : 'Pendiente'} + {reservation.checkInAt ? "Confirmada" : "Pendiente"} - @@ -181,6 +193,10 @@ export default function HomeScreen() { {/* seccion de estadisticas */} + + Estadísticas de uso + + {activeReservations.length} @@ -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 +}); -- cgit v1.2.3-54-g00ecf