mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
24 lines
636 B
TypeScript
24 lines
636 B
TypeScript
import { eq } from "drizzle-orm";
|
|
import type { WidgetPreferences } from "@/features/dashboard/widgets/actions";
|
|
import { db, schema } from "@/shared/lib/db";
|
|
|
|
export interface UserDashboardPreferences {
|
|
dashboardWidgets: WidgetPreferences | null;
|
|
}
|
|
|
|
export async function fetchUserDashboardPreferences(
|
|
userId: string,
|
|
): Promise<UserDashboardPreferences> {
|
|
const result = await db
|
|
.select({
|
|
dashboardWidgets: schema.userPreferences.dashboardWidgets,
|
|
})
|
|
.from(schema.userPreferences)
|
|
.where(eq(schema.userPreferences.userId, userId))
|
|
.limit(1);
|
|
|
|
return {
|
|
dashboardWidgets: result[0]?.dashboardWidgets ?? null,
|
|
};
|
|
}
|