Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 2x 2x 14x 14x 14x 14x 14x 14x 11x 4x 1x 4x 14x 4x 4x 4x 14x 1x 14x 1x 1x 14x | import { useEffect, useRef, useState } from 'react';
import { TextInput } from 'react-native';
const MODAL_FOCUS_DELAY = 300;
export const useRejectModal = () => {
const [isModalVisible, setModalVisible] = useState(false);
const [selectedRequestId, setSelectedRequestId] = useState<string>('');
const [note, setNote] = useState<string>('');
const noteInputRef = useRef<TextInput | null>(null);
const isNoteValid = note.trim().length > 0;
// Auto-focus note input when modal opens
useEffect(() => {
if (!isModalVisible) return;
const timeoutId = setTimeout(() => {
noteInputRef.current?.focus();
}, MODAL_FOCUS_DELAY);
return () => clearTimeout(timeoutId);
}, [isModalVisible]);
const openModal = (requestId: string) => {
setSelectedRequestId(requestId);
setNote('');
setModalVisible(true);
};
const closeModal = () => {
setModalVisible(false);
};
const resetModal = () => {
setSelectedRequestId('');
setNote('');
};
return {
isModalVisible,
selectedRequestId,
note,
noteInputRef,
isNoteValid,
setNote,
openModal,
closeModal,
resetModal,
};
};
|