Implement redirect with toast notification on profile save
- Add gotoHomeWithMessage function to navigationActions - Redirect to home page after successful profile save - Display success message in toast notification instead of in-form - Check for profileSaved URL parameter on home page mount - Clean up URL parameter after showing toast - Move success message translation to home-page section - Remove unused success state and message from AccountForm - Remove useEffect import from AccountForm User experience: After saving profile, users are redirected to the familiar home screen and see a toast notification confirming the save. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,11 @@ export async function gotoHome({year, month}: YearMonth) {
|
||||
await gotoUrl(path);
|
||||
}
|
||||
|
||||
export async function gotoHomeWithMessage(locale: string, message: string) {
|
||||
const path = `/${locale}?${message}=true`;
|
||||
await gotoUrl(path);
|
||||
}
|
||||
|
||||
export async function gotoUrl(path: string) {
|
||||
console.log(path)
|
||||
revalidatePath(path, "page");
|
||||
|
||||
@@ -7,8 +7,9 @@ import { withUser } from '@/app/lib/auth';
|
||||
import { AuthenticatedUser } from '../types/next-auth';
|
||||
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";
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { gotoHomeWithMessage } from './navigationActions';
|
||||
|
||||
export type State = {
|
||||
errors?: {
|
||||
@@ -93,8 +94,7 @@ export const updateUserProfile = withUser(async (user: AuthenticatedUser, prevSt
|
||||
|
||||
revalidatePath('/account');
|
||||
|
||||
return {
|
||||
message: null,
|
||||
success: true,
|
||||
};
|
||||
// Get current locale and redirect to home with success message
|
||||
const locale = await getLocale();
|
||||
await gotoHomeWithMessage(locale, 'profileSaved');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user