Update form to look better & add automatic lunch toggle
This commit is contained in:
@@ -34,6 +34,7 @@ export const getUser = query(async (ctx) => {
|
||||
name: user.name ?? null,
|
||||
image,
|
||||
lunchTime: user.lunchTime ?? null,
|
||||
automaticLunch: user.automaticLunch ?? false as boolean,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -45,6 +46,7 @@ export const getAllUsers = query(async (ctx) => {
|
||||
name: u.name ?? null,
|
||||
image: u.image ?? null,
|
||||
lunchTime: u.lunchTime ?? null,
|
||||
automaticLUnch: u.automaticLunch ?? false as boolean,
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -114,6 +116,20 @@ export const updateUserLunchtime = mutation({
|
||||
},
|
||||
});
|
||||
|
||||
export const updateUserAutomaticLunch = mutation({
|
||||
args: { automaticLunch: v.boolean() },
|
||||
handler: async (ctx, { automaticLunch }) => {
|
||||
const userId = await getAuthUserId(ctx);
|
||||
if (!userId) throw new ConvexError('Not authenticated.');
|
||||
const user = await ctx.db.get(userId);
|
||||
if (!user) throw new ConvexError('User not found.');
|
||||
if (user.automaticLunch === automaticLunch)
|
||||
return { success: true };
|
||||
await ctx.db.patch(userId, { automaticLunch });
|
||||
return { success: true };
|
||||
},
|
||||
})
|
||||
|
||||
export const validatePassword = (password: string): boolean => {
|
||||
if (
|
||||
password.length < 8 ||
|
||||
|
||||
Reference in New Issue
Block a user