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 ||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { defineSchema, defineTable } from 'convex/server';
|
||||
import { v } from 'convex/values';
|
||||
import { v, VId } from 'convex/values';
|
||||
import { authTables } from '@convex-dev/auth/server';
|
||||
|
||||
// The schema is normally optional, but Convex Auth
|
||||
@@ -13,6 +13,7 @@ export default defineSchema({
|
||||
email: v.optional(v.string()),
|
||||
currentStatusId: v.optional(v.id('statuses')),
|
||||
lunchTime: v.optional(v.string()),
|
||||
automaticLunch: v.optional(v.boolean()),
|
||||
emailVerificationTime: v.optional(v.number()),
|
||||
phone: v.optional(v.string()),
|
||||
phoneVerificationTime: v.optional(v.number()),
|
||||
|
Reference in New Issue
Block a user