The admin-dashboard.loader file was refactored to use a newly created AdminDashboardService. This service encapsulates the logic for fetching dashboard data. Translations related to account settings, privacy policy, terms of service, and cookie policy were updated for better readability. Changes also include minor reorganizing of code files for clearer structure.
23 lines
559 B
TypeScript
23 lines
559 B
TypeScript
import { notFound } from 'next/navigation';
|
|
|
|
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
|
|
|
import { isSuperAdmin } from './is-super-admin';
|
|
|
|
/**
|
|
* @name adminAction
|
|
* @description Wrap a server action to ensure the user is a super admin.
|
|
* @param fn
|
|
*/
|
|
export function adminAction<Args, Response>(fn: (params: Args) => Response) {
|
|
return async (params: Args) => {
|
|
const isAdmin = await isSuperAdmin(getSupabaseServerActionClient());
|
|
|
|
if (!isAdmin) {
|
|
notFound();
|
|
}
|
|
|
|
return fn(params);
|
|
};
|
|
}
|