mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 16:28:47 +02:00
Proyecciones: clicking a month row opens that month in Budget
The clicked year/month now travel in the navigation state; Budget seeds useBudget with them instead of always defaulting to today. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,17 @@ const MAX_YEAR = 2030;
|
||||
|
||||
export default function Budget() {
|
||||
const currentYear = Math.max(MIN_YEAR, new Date().getFullYear());
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
// Proyecciones row clicks land here with the clicked period in the state.
|
||||
const navState = location.state as
|
||||
| { from?: string; year?: number; month?: number }
|
||||
| null;
|
||||
const cameFromProyecciones = navState?.from === 'proyecciones';
|
||||
const initialYear =
|
||||
navState?.year && navState.year >= MIN_YEAR && navState.year <= MAX_YEAR
|
||||
? navState.year
|
||||
: currentYear;
|
||||
const {
|
||||
year,
|
||||
setYear,
|
||||
@@ -35,12 +46,8 @@ export default function Budget() {
|
||||
updateItem,
|
||||
deleteItem,
|
||||
refresh,
|
||||
} = useBudget(currentYear);
|
||||
} = useBudget(initialYear, navState?.month);
|
||||
const queryClient = useQueryClient();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const cameFromProyecciones =
|
||||
(location.state as { from?: string } | null)?.from === 'proyecciones';
|
||||
|
||||
const [subTab, setSubTab] = useState<'detail' | 'transactions'>('detail');
|
||||
const [txSearch, setTxSearch] = useState('');
|
||||
|
||||
Reference in New Issue
Block a user