diff --git a/.gitignore b/.gitignore index 7ef3ed6..cedf811 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ next-env.d.ts # customize data/* Budfile +certificates diff --git a/CHANGELOG.md b/CHANGELOG.md index 765a86f..ced7bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## Version 0.1.19 + +### Added + +- PWA support to allow installing app to mobile (#39) +- right click context menu for habits +- Pomodoro clock + +### Fixed + +- disable today's earned SSR (#38) + ## Version 0.1.18 ### Added diff --git a/app/actions/push.ts b/app/actions/push.ts new file mode 100644 index 0000000..3eafff3 --- /dev/null +++ b/app/actions/push.ts @@ -0,0 +1,49 @@ +'use server' + +import webpush from 'web-push' + +webpush.setVapidDetails( + 'mailto:mydohsimpson@gmail.com', + process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY!, + process.env.VAPID_PRIVATE_KEY! +) + +interface PushSubscriptionWithKeys extends PushSubscription { + keys: { + p256dh: string + auth: string + } +} + +let subscription: PushSubscriptionWithKeys | null = null + +export async function subscribeUser(sub: PushSubscriptionWithKeys) { + subscription = sub + return { success: true } +} + +export async function unsubscribeUser() { + subscription = null + return { success: true } +} + +export async function sendNotification(message: string) { + if (!subscription) { + throw new Error('No subscription available') + } + + try { + await webpush.sendNotification( + subscription, + JSON.stringify({ + title: 'HabitTrove', + body: message, + icon: '/icon.png', + }) + ) + return { success: true } + } catch (error) { + console.error('Error sending push notification:', error) + return { success: false, error: 'Failed to send notification' } + } +} diff --git a/app/calendar/page.tsx b/app/calendar/page.tsx index f2b0c21..2b94ace 100644 --- a/app/calendar/page.tsx +++ b/app/calendar/page.tsx @@ -3,9 +3,7 @@ import HabitCalendar from '@/components/HabitCalendar' export default function CalendarPage() { return ( - - - + ) } diff --git a/app/coins/page.tsx b/app/coins/page.tsx index b49f51c..50b8552 100644 --- a/app/coins/page.tsx +++ b/app/coins/page.tsx @@ -3,8 +3,6 @@ import CoinsManager from '@/components/CoinsManager' export default function CoinsPage() { return ( - - - + ) } diff --git a/app/favicon.ico b/app/favicon.ico index 718d6fe..834829d 100644 Binary files a/app/favicon.ico and b/app/favicon.ico differ diff --git a/app/habits/page.tsx b/app/habits/page.tsx index 0bdaad5..05e61af 100644 --- a/app/habits/page.tsx +++ b/app/habits/page.tsx @@ -3,9 +3,7 @@ import HabitList from '@/components/HabitList' export default function HabitsPage() { return ( - - - + ) } diff --git a/app/layout.tsx b/app/layout.tsx index 5dce74b..de119bc 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,17 +1,19 @@ import './globals.css' import { Inter } from 'next/font/google' import { DM_Sans } from 'next/font/google' -import { Toaster } from '@/components/ui/toaster' import { JotaiProvider } from '@/components/jotai-providers' import { Suspense } from 'react' import { JotaiHydrate } from '@/components/jotai-hydrate' import { loadSettings, loadHabitsData, loadCoinsData, loadWishlistData } from './actions/data' +import Layout from '@/components/Layout' +import { Toaster } from '@/components/ui/toaster' + // Inter (clean, modern, excellent readability) -const inter = Inter({ - subsets: ['latin'], - weight: ['400', '500', '600', '700'] -}) -// +// const inter = Inter({ +// subsets: ['latin'], +// weight: ['400', '500', '600', '700'] +// }) + // Clean and contemporary const dmSans = DM_Sans({ subsets: ['latin'], @@ -25,7 +27,7 @@ export const metadata = { description: 'Track your habits and get rewarded', } -export const dynamic = 'force-dynamic' // needed to prevent nextjs from caching the loadSettings function in Layout component +export const dynamic = 'force-dynamic' // needed to prevent nextjs from caching the load... functions in Layout component export default async function RootLayout({ children, @@ -42,6 +44,23 @@ export default async function RootLayout({ return ( +