mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-06 20:51:48 +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,
|
||||
},
|
||||
});
|
||||
}
|
||||
}),
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
-- DropTable
|
||||
DROP TABLE "user_preferences";
|
|
@ -99,17 +99,6 @@ model Subscription {
|
|||
@@map("subscriptions")
|
||||
}
|
||||
|
||||
// @deprecated
|
||||
model UserPreferences {
|
||||
userId String @id @map("user_id")
|
||||
timeZone String? @map("time_zone")
|
||||
weekStart Int? @map("week_start")
|
||||
timeFormat TimeFormat? @map("time_format")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@map("user_preferences")
|
||||
}
|
||||
|
||||
enum ParticipantVisibility {
|
||||
full
|
||||
scoresOnly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue