This commit is contained in:
xCyanGrizzly
2026-02-18 14:26:36 +01:00
commit 3a5726e82b
167 changed files with 104081 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import { prisma } from "@/lib/prisma";
export async function getUserSettings(userId: string) {
let settings = await prisma.userSettings.findUnique({
where: { userId },
});
if (!settings) {
settings = await prisma.userSettings.create({
data: {
userId,
lowStockThreshold: 20,
currency: "EUR",
theme: "dark",
units: "metric",
},
});
}
return settings;
}
export async function updateUserSettings(
userId: string,
data: {
lowStockThreshold?: number;
currency?: string;
theme?: string;
units?: string;
}
) {
return prisma.userSettings.upsert({
where: { userId },
update: data,
create: {
userId,
lowStockThreshold: data.lowStockThreshold ?? 20,
currency: data.currency ?? "EUR",
theme: data.theme ?? "dark",
units: data.units ?? "metric",
},
});
}