mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-02 18:51:52 +02:00
🧹 Remove legacy user preferences (#1035)
This commit is contained in:
parent
27dda65ca5
commit
44a0d95355
4 changed files with 2 additions and 71 deletions
|
@ -2,14 +2,12 @@ import { mergeRouters, router } from "../trpc";
|
|||
import { auth } from "./auth";
|
||||
import { polls } from "./polls";
|
||||
import { user } from "./user";
|
||||
import { userPreferences } from "./user-preferences";
|
||||
|
||||
export const appRouter = mergeRouters(
|
||||
router({
|
||||
auth,
|
||||
polls,
|
||||
user,
|
||||
userPreferences,
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
import { prisma } from "@rallly/database";
|
||||
import z from "zod";
|
||||
|
||||
import { publicProcedure, router } from "../trpc";
|
||||
|
||||
export const userPreferences = router({
|
||||
get: publicProcedure.query(async ({ ctx }) => {
|
||||
if (ctx.user.isGuest) {
|
||||
return null;
|
||||
} else {
|
||||
return await prisma.userPreferences.findUnique({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
},
|
||||
select: {
|
||||
timeZone: true,
|
||||
weekStart: true,
|
||||
timeFormat: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}),
|
||||
update: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
timeZone: z.string().optional(),
|
||||
weekStart: z.number().min(0).max(6).optional(),
|
||||
timeFormat: z.enum(["hours12", "hours24"]).optional(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
if (ctx.user.isGuest === false) {
|
||||
await prisma.userPreferences.upsert({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
},
|
||||
create: {
|
||||
userId: ctx.user.id,
|
||||
...input,
|
||||
},
|
||||
update: {
|
||||
...input,
|
||||
},
|
||||
});
|
||||
}
|
||||
}),
|
||||
delete: publicProcedure.mutation(async ({ ctx }) => {
|
||||
if (ctx.user.isGuest) {
|
||||
// delete guest preferences
|
||||
} else {
|
||||
await prisma.userPreferences.delete({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}),
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue