mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
refactor: pagina transações e modulariza ações
This commit is contained in:
@@ -22,14 +22,9 @@ export default function MonthNavigation() {
|
||||
const returnTarget = buildHref(defaultPeriod);
|
||||
const isDifferentFromCurrent = period !== defaultPeriod;
|
||||
|
||||
// Prefetch otimizado: apenas meses adjacentes (M-1, M+1) e mês atual
|
||||
// Isso melhora a performance da navegação sem sobrecarregar o cliente
|
||||
useEffect(() => {
|
||||
// Prefetch do mês anterior e próximo para navegação instantânea
|
||||
router.prefetch(prevTarget);
|
||||
router.prefetch(nextTarget);
|
||||
|
||||
// Prefetch do mês atual se não estivermos nele
|
||||
if (isDifferentFromCurrent) {
|
||||
router.prefetch(returnTarget);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ export function useMonthPeriod() {
|
||||
const buildHref = (targetPeriod: string) => {
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.set(PERIOD_PARAM, formatPeriodForUrl(targetPeriod));
|
||||
params.delete("page");
|
||||
|
||||
return `${pathname}?${params.toString()}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user