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:
@@ -47,13 +47,43 @@ export const MonthLocationList:React.FC<MonthLocationListProps > = ({
|
||||
initialMonth ? parseInt(initialMonth as string) : -1 // no month is expanded
|
||||
);
|
||||
|
||||
// Check for profile saved success message
|
||||
// Check for success messages
|
||||
React.useEffect(() => {
|
||||
const params = new URLSearchParams(search.toString());
|
||||
let messageShown = false;
|
||||
|
||||
if (search.get('profileSaved') === 'true') {
|
||||
toast.success(t("profile-saved-message"), { theme: "dark" });
|
||||
// Clean up URL parameter
|
||||
const params = new URLSearchParams(search.toString());
|
||||
params.delete('profileSaved');
|
||||
messageShown = true;
|
||||
}
|
||||
|
||||
if (search.get('billSaved') === 'true') {
|
||||
toast.success(t("bill-saved-message"), { theme: "dark" });
|
||||
params.delete('billSaved');
|
||||
messageShown = true;
|
||||
}
|
||||
|
||||
if (search.get('billDeleted') === 'true') {
|
||||
toast.success(t("bill-deleted-message"), { theme: "dark" });
|
||||
params.delete('billDeleted');
|
||||
messageShown = true;
|
||||
}
|
||||
|
||||
if (search.get('locationSaved') === 'true') {
|
||||
toast.success(t("location-saved-message"), { theme: "dark" });
|
||||
params.delete('locationSaved');
|
||||
messageShown = true;
|
||||
}
|
||||
|
||||
if (search.get('locationDeleted') === 'true') {
|
||||
toast.success(t("location-deleted-message"), { theme: "dark" });
|
||||
params.delete('locationDeleted');
|
||||
messageShown = true;
|
||||
}
|
||||
|
||||
// Clean up URL parameters if any message was shown
|
||||
if (messageShown) {
|
||||
const newSearch = params.toString();
|
||||
router.replace(newSearch ? `?${newSearch}` : '/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user