Files
evidencija-rezija/app/lib/actions/navigationActions.ts
Knee Cola 5dd7d40edf Update navigation to preserve year/month context in redirects
Modified gotoHomeWithMessage to accept optional yearMonth parameter and
updated location actions to redirect with year/month context after save/delete.

Changes:
- Updated gotoHomeWithMessage to accept yearMonth parameter
- Modified redirect URLs to include year and month query params
- updateOrAddLocation now redirects to /${locale}?year=${year}&month=${month}&locationSaved=true
- deleteLocationById now redirects to /${locale}?year=${year}&month=${month}&locationDeleted=true
- Removed unused gotoHome import from locationActions

This ensures users return to the same month view after location operations,
maintaining context and providing success feedback via URL parameters.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 09:05:25 +01:00

24 lines
689 B
TypeScript

'use server';
import { revalidatePath } from "next/cache";
import { redirect } from 'next/navigation';
import { YearMonth } from "../db-types";
export async function gotoHome({year, month}: YearMonth) {
const path = `/?year=${year}&month=${month}`;
await gotoUrl(path);
}
export async function gotoHomeWithMessage(locale: string, message: string, yearMonth?: YearMonth) {
const path = yearMonth
? `/${locale}?year=${yearMonth.year}&month=${yearMonth.month}&${message}=true`
: `/${locale}?${message}=true`;
await gotoUrl(path);
}
export async function gotoUrl(path: string) {
console.log(path)
revalidatePath(path, "page");
redirect(path);
}