|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | | -import React from 'react'; |
| 3 | +import React, { useState, useEffect } from 'react'; |
4 | 4 | import PreferencesPanel from '@/components/Notifications/PreferencesPanel'; |
5 | 5 | import { useNotifications } from '@/hooks/useNotifications'; |
6 | | -import { useToast } from '@/hooks/useToast'; |
7 | | -import { Bell, Shield, Info } from 'lucide-react'; |
| 6 | +import { Bell, Shield, Info, Keyboard } from 'lucide-react'; |
| 7 | +import { getShortcuts, getEnabledKeys, setEnabledKeys, type Shortcut } from '@/lib/shortcutRegistry'; |
8 | 8 |
|
9 | 9 | export default function NotificationSettingsPage() { |
10 | | - // Using a hardcoded userId for demo purposes. |
11 | | - // In a real app, this would come from an auth context. |
12 | | - const { |
13 | | - preferences, |
14 | | - updatePreferences, |
15 | | - isLoading, |
16 | | - subscribeToPushNotifications, |
17 | | - } = useNotifications('user-123'); |
18 | | - const toast = useToast(); |
| 10 | + // Using a hardcoded userId for demo purposes. |
| 11 | + // In a real app, this would come from an auth context. |
| 12 | + const { preferences, updatePreferences, isLoading, subscribeToPushNotifications } = useNotifications('user-123'); |
| 13 | + const [shortcutsEnabled, setShortcutsEnabled] = useState(getEnabledKeys()); |
| 14 | + const [shortcuts] = useState<Shortcut[]>(getShortcuts()); |
19 | 15 |
|
20 | 16 | const handleUpdatePreferences = async ( |
21 | 17 | prefs: Parameters<typeof updatePreferences>[0] |
@@ -46,15 +42,60 @@ export default function NotificationSettingsPage() { |
46 | 42 | </p> |
47 | 43 | </div> |
48 | 44 |
|
49 | | - <div className="grid grid-cols-1 md:grid-cols-3 gap-8"> |
50 | | - {/* Main Content */} |
51 | | - <div className="md:col-span-2 space-y-8"> |
52 | | - <section className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden"> |
53 | | - <PreferencesPanel |
54 | | - preferences={preferences} |
55 | | - onUpdatePreferences={handleUpdatePreferences} |
56 | | - /> |
57 | | - </section> |
| 45 | + {/* Device Settings */} |
| 46 | + <section className="bg-white rounded-xl shadow-sm border border-gray-200 p-6"> |
| 47 | + <div className="flex items-center gap-3 mb-4"> |
| 48 | + <Shield size={22} className="text-blue-600" /> |
| 49 | + <h2 className="text-xl font-semibold text-gray-900">Push Notifications</h2> |
| 50 | + </div> |
| 51 | + <p className="text-gray-600 mb-6"> |
| 52 | + Enable push notifications to stay updated even when you're not on the site. |
| 53 | + </p> |
| 54 | + <button |
| 55 | + onClick={handlePushSubscription} |
| 56 | + className="px-6 py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors flex items-center gap-2" |
| 57 | + > |
| 58 | + <Bell size={18} /> |
| 59 | + Enable Browser Push |
| 60 | + </button> |
| 61 | + </section> |
| 62 | + |
| 63 | + {/* Keyboard Shortcuts */} |
| 64 | + <section className="bg-white rounded-xl shadow-sm border border-gray-200 p-6"> |
| 65 | + <div className="flex items-center gap-3 mb-4"> |
| 66 | + <Keyboard size={22} className="text-blue-600" /> |
| 67 | + <h2 className="text-xl font-semibold text-gray-900">Keyboard Shortcuts</h2> |
| 68 | + </div> |
| 69 | + <div className="flex items-center justify-between mb-6"> |
| 70 | + <div> |
| 71 | + <p className="text-gray-600">Enable keyboard shortcuts</p> |
| 72 | + <p className="text-sm text-gray-400"> |
| 73 | + Press <kbd className="px-1 py-0.5 bg-gray-100 rounded text-xs font-mono">Ctrl+K</kbd> to open the command palette |
| 74 | + </p> |
| 75 | + </div> |
| 76 | + <button |
| 77 | + onClick={() => { |
| 78 | + const next = !shortcutsEnabled; |
| 79 | + setShortcutsEnabled(next); |
| 80 | + setEnabledKeys(next); |
| 81 | + }} |
| 82 | + className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${shortcutsEnabled ? 'bg-blue-600' : 'bg-gray-300'}`} |
| 83 | + > |
| 84 | + <span className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${shortcutsEnabled ? 'translate-x-6' : 'translate-x-1'}`} /> |
| 85 | + </button> |
| 86 | + </div> |
| 87 | + <div className="space-y-2"> |
| 88 | + {shortcuts.map((s) => ( |
| 89 | + <div key={s.keys} className="flex items-center justify-between py-1.5"> |
| 90 | + <span className="text-sm text-gray-700">{s.description}</span> |
| 91 | + <kbd className="text-xs font-mono text-gray-500 bg-gray-100 px-2 py-0.5 rounded"> |
| 92 | + {s.keys} |
| 93 | + </kbd> |
| 94 | + </div> |
| 95 | + ))} |
| 96 | + </div> |
| 97 | + </section> |
| 98 | + </div> |
58 | 99 |
|
59 | 100 | {/* Device Settings */} |
60 | 101 | <section className="bg-white rounded-xl shadow-sm border border-gray-200 p-6"> |
|
0 commit comments