Extend toast notifications to all forms (bills and locations)

- Update billActions to redirect with toast messages
  - billSaved: when bill is created or updated
  - billDeleted: when bill is deleted
- Update locationActions to redirect with toast messages
  - locationSaved: when location is created or updated
  - locationDeleted: when location is deleted
- Enhance MonthLocationList to check for all toast parameters
  - Consolidated success message handling for all operations
  - Clean up all URL parameters after showing toast
- Add translations for all success messages (EN and HR)
  - Bill saved/deleted messages
  - Location saved/deleted messages

User experience: All forms now redirect to home with toast
notifications, providing consistent feedback across the app.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2025-11-17 19:06:10 +01:00
parent 5bbf80c2ae
commit fa1d04480f
5 changed files with 60 additions and 26 deletions

View File

@@ -6,8 +6,8 @@ import { Bill, BilledTo, BillAttachment, BillingLocation, YearMonth } from '../d
import { ObjectId } from 'mongodb';
import { withUser } from '@/app/lib/auth';
import { AuthenticatedUser } from '../types/next-auth';
import { gotoHome } from './navigationActions';
import { getTranslations } from "next-intl/server";
import { gotoHome, gotoHomeWithMessage } from './navigationActions';
import { getTranslations, getLocale } from "next-intl/server";
import { IntlTemplateFn } from '@/app/i18n';
export type State = {
@@ -278,8 +278,9 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
}
}
}
if(billYear && billMonth ) {
await gotoHome({ year: billYear, month: billMonth });
if(billYear && billMonth) {
const locale = await getLocale();
await gotoHomeWithMessage(locale, 'billSaved');
}
})
/*
@@ -445,7 +446,7 @@ export const deleteBillById = withUser(async (user:AuthenticatedUser, locationID
}
});
}
await gotoHome({year, month});
return { message: null };
const locale = await getLocale();
await gotoHomeWithMessage(locale, 'billDeleted');
});