feat: add colorscheme to user in db (#987)
This commit is contained in:
@@ -30,6 +30,7 @@ const defaultSession = {
|
||||
user: {
|
||||
id: defaultCreatorId,
|
||||
permissions: [],
|
||||
colorScheme: "light",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
} satisfies Session;
|
||||
@@ -87,6 +88,7 @@ describe("getAllBoards should return all boards accessable to the current user",
|
||||
user: {
|
||||
id: defaultCreatorId,
|
||||
permissions: ["board-view-all"],
|
||||
colorScheme: "light",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
},
|
||||
|
||||
@@ -29,6 +29,7 @@ const createSessionWithPermissions = (...permissions: GroupPermissionKey[]) =>
|
||||
user: {
|
||||
id: "1",
|
||||
permissions,
|
||||
colorScheme: "light",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
}) satisfies Session;
|
||||
|
||||
@@ -12,6 +12,7 @@ const defaultSession = {
|
||||
user: {
|
||||
id: defaultOwnerId,
|
||||
permissions: [],
|
||||
colorScheme: "light",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
} satisfies Session;
|
||||
|
||||
@@ -17,6 +17,7 @@ const defaultSessionWithPermissions = (permissions: GroupPermissionKey[] = []) =
|
||||
user: {
|
||||
id: defaultUserId,
|
||||
permissions,
|
||||
colorScheme: "light",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
}) satisfies Session;
|
||||
|
||||
@@ -12,6 +12,7 @@ const defaultSession = {
|
||||
user: {
|
||||
id: createId(),
|
||||
permissions: [],
|
||||
colorScheme: "light",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
} satisfies Session;
|
||||
|
||||
@@ -16,6 +16,7 @@ const defaultSession = {
|
||||
user: {
|
||||
id: createId(),
|
||||
permissions: [],
|
||||
colorScheme: "light",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
} satisfies Session;
|
||||
|
||||
@@ -246,6 +246,7 @@ describe("editProfile shoud update user", () => {
|
||||
image: null,
|
||||
homeBoardId: null,
|
||||
provider: "credentials",
|
||||
colorScheme: "auto",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -287,6 +288,7 @@ describe("editProfile shoud update user", () => {
|
||||
image: null,
|
||||
homeBoardId: null,
|
||||
provider: "credentials",
|
||||
colorScheme: "auto",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -312,6 +314,7 @@ describe("delete should delete user", () => {
|
||||
salt: null,
|
||||
homeBoardId: null,
|
||||
provider: "ldap" as const,
|
||||
colorScheme: "auto" as const,
|
||||
},
|
||||
{
|
||||
id: userToDelete,
|
||||
@@ -322,6 +325,7 @@ describe("delete should delete user", () => {
|
||||
password: null,
|
||||
salt: null,
|
||||
homeBoardId: null,
|
||||
colorScheme: "auto" as const,
|
||||
},
|
||||
{
|
||||
id: createId(),
|
||||
@@ -333,6 +337,7 @@ describe("delete should delete user", () => {
|
||||
salt: null,
|
||||
homeBoardId: null,
|
||||
provider: "oidc" as const,
|
||||
colorScheme: "auto" as const,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -317,6 +317,14 @@ export const userRouter = createTRPCRouter({
|
||||
})
|
||||
.where(eq(users.id, input.userId));
|
||||
}),
|
||||
changeColorScheme: protectedProcedure.input(validation.user.changeColorScheme).mutation(async ({ input, ctx }) => {
|
||||
await ctx.db
|
||||
.update(users)
|
||||
.set({
|
||||
colorScheme: input.colorScheme,
|
||||
})
|
||||
.where(eq(users.id, ctx.session.user.id));
|
||||
}),
|
||||
});
|
||||
|
||||
const createUserAsync = async (db: Database, input: z.infer<typeof validation.user.create>) => {
|
||||
|
||||
Reference in New Issue
Block a user