fix(quick-260610-jlp-01): wire SettingsSheet 'How to enable' to open InstructionSheet
- Add instructionsOpen state to SettingsSheet
- Change broken onClick={onClose} to onClick={() => setInstructionsOpen(true)}
- Render InstructionSheet conditionally when instructionsOpen=true
- Add InstructionSheet.test.tsx: asserts dialog opens + onClose not called (UAT-05-T4)
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { X, Bell, AlertCircle, Loader2 } from 'lucide-react'
|
||||
import { usePushSubscription } from '../hooks/usePushSubscription.js'
|
||||
import { InstructionSheet } from './InstructionSheet.js'
|
||||
|
||||
// CR-04: fetch VAPID key (from sessionStorage cache if available) for the
|
||||
// tap-gated subscribe() path. Same logic as PushPermissionPrompt.
|
||||
@@ -51,6 +52,7 @@ interface SettingsSheetProps {
|
||||
export function SettingsSheet({ isOpen, onClose }: SettingsSheetProps) {
|
||||
const { subscribe, permission, isSubscribed, setEnabled } = usePushSubscription()
|
||||
const [isTogglingOn, setIsTogglingOn] = useState(false)
|
||||
const [instructionsOpen, setInstructionsOpen] = useState(false)
|
||||
// CR-04: pre-fetch the VAPID key into state so the toggle tap handler can call
|
||||
// subscribe(registration, vapidKey) without any network await before pushManager.subscribe().
|
||||
const [vapidKey, setVapidKey] = useState<string | null>(null)
|
||||
@@ -370,7 +372,7 @@ export function SettingsSheet({ isOpen, onClose }: SettingsSheetProps) {
|
||||
Notifications are blocked in your browser settings.{' '}
|
||||
</span>
|
||||
<button
|
||||
onClick={onClose}
|
||||
onClick={() => setInstructionsOpen(true)}
|
||||
style={{
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
@@ -388,6 +390,10 @@ export function SettingsSheet({ isOpen, onClose }: SettingsSheetProps) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{instructionsOpen && (
|
||||
<InstructionSheet onClose={() => setInstructionsOpen(false)} />
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user