Fix more bugs with lunch reminder

This commit is contained in:
2025-09-17 16:40:38 -05:00
parent d4842fdacd
commit 3bff31c07a
3 changed files with 16 additions and 6 deletions

View File

@@ -49,9 +49,9 @@ const RootLayout = async ({
<TVModeProvider>
<Header />
{children}
<Toaster />
<NotificationsPermission />
<LunchReminder />
<Toaster />
</TVModeProvider>
</ConvexClientProvider>
</ThemeProvider>

View File

@@ -1,5 +1,5 @@
'use client';
import { useState } from 'react';
import { useMemo, useState } from 'react';
import { type Preloaded, usePreloadedQuery, useMutation } from 'convex/react';
import { api } from '~/convex/_generated/api';
import { z } from 'zod';
@@ -50,13 +50,17 @@ export const UserInfoForm = ({ preloadedUser }: UserInfoFormProps) => {
const updateUserEmail = useMutation(api.auth.updateUserEmail);
const updateUserLunchtime = useMutation(api.auth.updateUserLunchtime);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
const initialValues = useMemo<z.infer<typeof formSchema>>(
() => ({
name: user?.name ?? '',
email: user?.email ?? '',
lunchTime: user?.lunchTime ?? '',
},
}), [user?.name, user?.email, user?.lunchTime]
);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
values: initialValues,
});
const handleSubmit = async (values: z.infer<typeof formSchema>) => {

View File

@@ -1,5 +1,6 @@
'use client';
import { permission } from 'process';
import { useEffect } from 'react';
import { toast } from 'sonner';
@@ -12,6 +13,11 @@ export const NotificationsPermission = () => {
// Only ask once; tweak logic to your taste.
const prompted = localStorage.getItem(STORAGE_KEY) === '1';
console.log('NotificationsPermission', {
supported: true,
permission: Notification.permission,
prompted,
});
if (prompted) return;
if (Notification.permission === 'default') {