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:
@@ -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');
|
||||
});
|
||||
@@ -6,10 +6,10 @@ import { BillingLocation, YearMonth } from '../db-types';
|
||||
import { ObjectId } from 'mongodb';
|
||||
import { withUser } from '@/app/lib/auth';
|
||||
import { AuthenticatedUser } from '../types/next-auth';
|
||||
import { gotoHome } from './navigationActions';
|
||||
import { gotoHome, gotoHomeWithMessage } from './navigationActions';
|
||||
import { unstable_noStore as noStore } from 'next/cache';
|
||||
import { IntlTemplateFn } from '@/app/i18n';
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { getTranslations, getLocale } from "next-intl/server";
|
||||
|
||||
export type State = {
|
||||
errors?: {
|
||||
@@ -221,12 +221,10 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
||||
}
|
||||
}
|
||||
|
||||
if(yearMonth) await gotoHome(yearMonth);
|
||||
|
||||
return {
|
||||
message: null,
|
||||
errors: undefined,
|
||||
};
|
||||
if(yearMonth) {
|
||||
const locale = await getLocale();
|
||||
await gotoHomeWithMessage(locale, 'locationSaved');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -402,10 +400,7 @@ export const deleteLocationById = withUser(async (user:AuthenticatedUser, locati
|
||||
// Delete only the specific location (current behavior)
|
||||
await dbClient.collection<BillingLocation>("lokacije").deleteOne({ _id: locationID, userId });
|
||||
}
|
||||
|
||||
await gotoHome(yearMonth);
|
||||
|
||||
return {
|
||||
message: null
|
||||
};
|
||||
|
||||
const locale = await getLocale();
|
||||
await gotoHomeWithMessage(locale, 'locationDeleted');
|
||||
})
|
||||
Reference in New Issue
Block a user