From c92bfc66fed6be9cfe64ac48b5917ac3639e5b08 Mon Sep 17 00:00:00 2001
From: Carlos Escalante
Date: Wed, 29 Apr 2026 22:02:46 -0600
Subject: [PATCH] Update pages and components for new module paths
Repoints imports at the relocated lib/api and src/contexts modules,
and refreshes Layout + Login alongside the rest of the migration.
Co-Authored-By: Claude Opus 4.7 (1M context)
---
.../src/components/BillingCycleSelector.tsx | 2 +-
frontend/src/components/Layout.tsx | 105 ++++++++----------
frontend/src/components/PasteImportModal.tsx | 2 +-
.../components/PensionManualEntryModal.tsx | 2 +-
frontend/src/components/TransactionList.tsx | 2 +-
frontend/src/components/TransactionModal.tsx | 2 +-
.../components/budget/RecurringItemDialog.tsx | 2 +-
.../budget/RecurringItemsManager.tsx | 2 +-
.../src/components/budget/YearlyOverview.tsx | 2 +-
.../transactions/transaction-columns.tsx | 2 +-
frontend/src/hooks/useBudget.ts | 2 +-
frontend/src/pages/Analytics.tsx | 4 +-
frontend/src/pages/Login.tsx | 41 ++++---
frontend/src/pages/Pensions.tsx | 2 +-
frontend/src/pages/Salarios.tsx | 2 +-
frontend/src/pages/ServiciosMunicipales.tsx | 2 +-
16 files changed, 80 insertions(+), 96 deletions(-)
diff --git a/frontend/src/components/BillingCycleSelector.tsx b/frontend/src/components/BillingCycleSelector.tsx
index 2022af9..59eaebd 100644
--- a/frontend/src/components/BillingCycleSelector.tsx
+++ b/frontend/src/components/BillingCycleSelector.tsx
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { Calendar } from 'lucide-react';
-import api from '../api';
+import api from '@/lib/api';
import {
Select,
SelectContent,
diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx
index c06cf28..6e6ce3c 100644
--- a/frontend/src/components/Layout.tsx
+++ b/frontend/src/components/Layout.tsx
@@ -1,6 +1,7 @@
-import { NavLink, Outlet, useNavigate } from 'react-router-dom';
+import { useState, useEffect } from "react";
+import { Link, Outlet, useLocation, useNavigate } from "react-router-dom";
import {
- LayoutDashboard,
+ Sparkles,
Calculator,
BarChart3,
Landmark,
@@ -15,24 +16,20 @@ import {
Eye,
EyeOff,
type LucideIcon,
-} from 'lucide-react';
-import { useEffect, useState } from 'react';
-import { useAuth } from '../AuthContext';
-import { useTheme } from '../ThemeContext';
-import { usePrivacy } from '../PrivacyContext';
-import { subscribeToPush } from '../pushNotifications';
-import { Button } from '@/components/ui/button';
+} from "lucide-react";
+import { useTheme } from "@/contexts/theme-context";
+import { usePrivacy } from "@/contexts/privacy-context";
+import { useAuth } from "@/AuthContext";
+import { Button } from "@/components/ui/button";
import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
SheetClose,
-} from '@/components/ui/sheet';
-import { Separator } from '@/components/ui/separator';
-import { cn } from '@/lib/utils';
-
-// ─── Navigation Structure ────────────────────────────────────────────────────
+} from "@/components/ui/sheet";
+import { Separator } from "@/components/ui/separator";
+import { cn } from "@/lib/utils";
interface NavSection {
label: string;
@@ -41,32 +38,32 @@ interface NavSection {
const navSections: NavSection[] = [
{
- label: 'General',
+ label: "General",
+ items: [{ to: "/asistente", icon: Sparkles, label: "Asistente" }],
+ },
+ {
+ label: "Finanzas",
items: [
- { to: '/', icon: LayoutDashboard, label: 'Dashboard' },
+ { to: "/budget", icon: Calculator, label: "Presupuesto" },
+ { to: "/salarios", icon: Landmark, label: "Salarios" },
+ { to: "/pensions", icon: PiggyBank, label: "Pensiones" },
+ { to: "/proyecciones", icon: TrendingUp, label: "Proyecciones" },
+ { to: "/analytics", icon: BarChart3, label: "Analytics" },
],
},
{
- label: 'Finanzas',
+ label: "Servicios",
items: [
- { to: '/budget', icon: Calculator, label: 'Presupuesto' },
- { to: '/salarios', icon: Landmark, label: 'Salarios' },
- { to: '/pensions', icon: PiggyBank, label: 'Pensiones' },
- { to: '/proyecciones', icon: TrendingUp, label: 'Proyecciones' },
- { to: '/analytics', icon: BarChart3, label: 'Analytics' },
- ],
- },
- {
- label: 'Servicios',
- items: [
- { to: '/servicios-municipales', icon: Droplets, label: 'Municipalidad' },
+ { to: "/servicios-municipales", icon: Droplets, label: "Municipalidad" },
],
},
];
-// ─── Shared Nav Renderer ─────────────────────────────────────────────────────
-
function SidebarNav({ onNavigate }: { onNavigate?: () => void }) {
+ const { pathname } = useLocation();
+ const isActive = (to: string) =>
+ pathname === to || pathname.startsWith(`${to}/`);
+
return (
{section.items.map(({ to, icon: Icon, label }) => (
-
- cn(
- 'flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors',
- isActive
- ? 'bg-primary/10 text-primary'
- : 'text-muted-foreground hover:text-foreground hover:bg-muted'
- )
- }
+ className={cn(
+ "flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-colors",
+ isActive(to)
+ ? "bg-primary/10 text-primary"
+ : "text-muted-foreground hover:text-foreground hover:bg-muted",
+ )}
>
{label}
-
+
))}
))}
@@ -99,27 +93,20 @@ function SidebarNav({ onNavigate }: { onNavigate?: () => void }) {
);
}
-// ─── Main Layout ─────────────────────────────────────────────────────────────
-
export default function Layout() {
- const { logout } = useAuth();
const { theme, toggleTheme } = useTheme();
const { privacyMode, togglePrivacy } = usePrivacy();
+ const { logout } = useAuth();
const navigate = useNavigate();
const [mobileOpen, setMobileOpen] = useState(false);
- useEffect(() => {
- subscribeToPush();
- }, []);
-
- const handleLogout = () => {
- logout();
- navigate('/login');
+ const handleLogout = async () => {
+ await logout();
+ navigate("/login", { replace: true });
};
return (
- {/* ── Top bar ───────────────────────────────────────────────────── */}