Implemented theme through user preferences
This commit is contained in:
1 parent
36b258f4b7
commit
5206fb4f88
10 files changed
+161
-98
No files matched your search
+11
-13
@@ -1,6 +1,6 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getSession } from 'next-auth/client';
|
||||
import prisma from '../../../lib/prisma';
|
||||
import prisma, {whereAndSelect} from '@lib/prisma';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const session = await getSession({req: req});
|
||||
@@ -11,15 +11,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
|
||||
// Get user
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
email: session.user.email,
|
||||
const user = await whereAndSelect(prisma.user.findUnique, {
|
||||
id: session.user.id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
password: true
|
||||
}
|
||||
});
|
||||
[ "id", "password" ]
|
||||
);
|
||||
|
||||
if (!user) { res.status(404).json({message: 'User not found'}); return; }
|
||||
|
||||
@@ -42,6 +38,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
const timeZone = req.body.timeZone;
|
||||
const weekStart = req.body.weekStart;
|
||||
const hideBranding = req.body.hideBranding;
|
||||
const theme = req.body.theme;
|
||||
|
||||
const updateUser = await prisma.user.update({
|
||||
where: {
|
||||
@@ -52,11 +49,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
name,
|
||||
avatar,
|
||||
bio: description,
|
||||
timeZone: timeZone,
|
||||
weekStart: weekStart,
|
||||
hideBranding: hideBranding,
|
||||
timeZone,
|
||||
weekStart,
|
||||
hideBranding,
|
||||
theme,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json({message: 'Profile updated successfully'});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user