mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-06-10 07:16:01 +00:00
feat(preferencias): permite ocultar resumo do lancamento
This commit is contained in:
24
src/shared/lib/preferences/queries.ts
Normal file
24
src/shared/lib/preferences/queries.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db, schema } from "@/shared/lib/db";
|
||||
|
||||
export type AppPreferences = {
|
||||
showTransactionSummary: boolean;
|
||||
};
|
||||
|
||||
const DEFAULT_APP_PREFERENCES: AppPreferences = {
|
||||
showTransactionSummary: true,
|
||||
};
|
||||
|
||||
export async function fetchAppPreferences(
|
||||
userId: string,
|
||||
): Promise<AppPreferences> {
|
||||
const [preferences] = await db
|
||||
.select({
|
||||
showTransactionSummary: schema.userPreferences.showTransactionSummary,
|
||||
})
|
||||
.from(schema.userPreferences)
|
||||
.where(eq(schema.userPreferences.userId, userId))
|
||||
.limit(1);
|
||||
|
||||
return preferences ?? DEFAULT_APP_PREFERENCES;
|
||||
}
|
||||
Reference in New Issue
Block a user