Lunch time reminder is now actually functional

This commit is contained in:
2025-09-17 15:56:59 -05:00
parent 84bfc21877
commit 92854382db
5 changed files with 52 additions and 14 deletions

View File

@@ -33,6 +33,7 @@ export const getUser = query(async (ctx) => {
email: user.email ?? null,
name: user.name ?? null,
image,
lunchTime: user.lunchTime ?? null,
};
});
@@ -43,6 +44,7 @@ export const getAllUsers = query(async (ctx) => {
email: u.email ?? null,
name: u.name ?? null,
image: u.image ?? null,
lunchTime: u.lunchTime ?? null,
}));
});
@@ -96,6 +98,22 @@ export const updateUserImage = mutation({
},
});
export const updateUserLunchtime = mutation({
args: {
lunchTime: v.string(),
},
handler: async (ctx, { lunchTime }) => {
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 (!lunchTime.includes(':'))
throw new ConvexError('Lunch time is invalid.');
await ctx.db.patch(userId, { lunchTime });
return { success: true };
},
});
export const validatePassword = (password: string): boolean => {
if (
password.length < 8 ||

View File

@@ -12,6 +12,7 @@ export default defineSchema({
image: v.optional(v.string()),
email: v.optional(v.string()),
currentStatusId: v.optional(v.id('statuses')),
lunchTime: v.optional(v.string()),
emailVerificationTime: v.optional(v.number()),
phone: v.optional(v.string()),
phoneVerificationTime: v.optional(v.number()),