24 lines
698 B
TypeScript
24 lines
698 B
TypeScript
'use server';
|
|
|
|
import { getUserPreferences, updateUserPreference, UserPreferences } from '@/lib/preferences';
|
|
import { revalidatePath } from 'next/cache';
|
|
|
|
/**
|
|
* Server action to get user preferences
|
|
*/
|
|
export async function fetchUserPreferencesAction() {
|
|
return await getUserPreferences();
|
|
}
|
|
|
|
/**
|
|
* Server action to update user preferences and revalidate the dashboard
|
|
*/
|
|
export async function updateUserPreferencesAction(update: Partial<UserPreferences>) {
|
|
const success = await updateUserPreference(update);
|
|
if (success) {
|
|
// Revalidate all dashboard pages to reflect UI changes immediately
|
|
revalidatePath('/dashboard', 'layout');
|
|
}
|
|
return { success };
|
|
}
|