consent skip feature

This commit is contained in:
Igor Loskutov
2025-12-19 16:14:28 -05:00
parent a988c3aa92
commit 3929a80665
9 changed files with 158 additions and 66 deletions

View File

@@ -1,5 +1,6 @@
"use client";
import { useState, useEffect } from "react";
import { Box, Button, Text, VStack, HStack } from "@chakra-ui/react";
import { CONSENT_DIALOG_TEXT } from "./constants";
@@ -9,6 +10,15 @@ interface ConsentDialogProps {
}
export function ConsentDialog({ onAccept, onReject }: ConsentDialogProps) {
const [acceptButton, setAcceptButton] = useState<HTMLButtonElement | null>(
null,
);
useEffect(() => {
// Auto-focus accept button so Escape key works (Daily iframe captures keyboard otherwise)
acceptButton?.focus();
}, [acceptButton]);
return (
<Box
p={6}
@@ -26,7 +36,12 @@ export function ConsentDialog({ onAccept, onReject }: ConsentDialogProps) {
<Button variant="ghost" size="sm" onClick={onReject}>
{CONSENT_DIALOG_TEXT.rejectButton}
</Button>
<Button colorPalette="primary" size="sm" onClick={onAccept}>
<Button
ref={setAcceptButton}
colorPalette="primary"
size="sm"
onClick={onAccept}
>
{CONSENT_DIALOG_TEXT.acceptButton}
</Button>
</HStack>

View File

@@ -15,10 +15,10 @@ interface ConsentDialogButtonProps {
}
export function ConsentDialogButton({ meetingId }: ConsentDialogButtonProps) {
const { showConsentModal, consentState, hasConsent, consentLoading } =
const { showConsentModal, consentState, hasAnswered, consentLoading } =
useConsentDialog(meetingId);
if (!consentState.ready || hasConsent(meetingId) || consentLoading) {
if (!consentState.ready || hasAnswered(meetingId) || consentLoading) {
return null;
}

View File

@@ -2,8 +2,9 @@ export interface ConsentDialogResult {
showConsentModal: () => void;
consentState: {
ready: boolean;
consentAnsweredForMeetings?: Set<string>;
consentForMeetings?: Map<string, boolean>;
};
hasConsent: (meetingId: string) => boolean;
hasAnswered: (meetingId: string) => boolean;
hasAccepted: (meetingId: string) => boolean;
consentLoading: boolean;
}

View File

@@ -9,7 +9,12 @@ import { TOAST_CHECK_INTERVAL_MS } from "./constants";
import type { ConsentDialogResult } from "./types";
export function useConsentDialog(meetingId: string): ConsentDialogResult {
const { state: consentState, touch, hasConsent } = useRecordingConsent();
const {
state: consentState,
touch,
hasAnswered,
hasAccepted,
} = useRecordingConsent();
const [modalOpen, setModalOpen] = useState(false);
const audioConsentMutation = useMeetingAudioConsent();
const intervalRef = useRef<NodeJS.Timeout | null>(null);
@@ -42,7 +47,7 @@ export function useConsentDialog(meetingId: string): ConsentDialogResult {
},
});
touch(meetingId);
touch(meetingId, given);
} catch (error) {
console.error("Error submitting consent:", error);
}
@@ -103,7 +108,8 @@ export function useConsentDialog(meetingId: string): ConsentDialogResult {
return {
showConsentModal,
consentState,
hasConsent,
hasAnswered,
hasAccepted,
consentLoading: audioConsentMutation.isPending,
};
}