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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | 'use client'; import { useCallback, useState } from 'react'; import Button from 'react-bootstrap/Button'; import Modal from 'react-bootstrap/Modal'; import DatePicker from 'react-datepicker'; import { AudioAction, AudioState } from '@/types/frontend/audio'; import { fNameToDate } from '@/utils/common/strings'; import 'react-datepicker/dist/react-datepicker.css'; export default function CalendarModal({ state, dispatch, }: Readonly<{ state: AudioState, dispatch: React.ActionDispatch<[AudioAction]>; }>) { const [ hour, setHour, ] = useState(0); const [ minute, setMinute, ] = useState(0); const [ newDatetime, setNewDatetime, ] = useState<Date | null>(null); const jumpToTime = useCallback(() => { if (newDatetime === null) { return; } const newDate = new Date(newDatetime.getTime()); newDate.setMilliseconds(0); newDate.setSeconds(0); newDate.setHours(hour); newDate.setMinutes(minute); setHour(0); setMinute(0); setNewDatetime(null); dispatch({ action: 'JumpToTime', f: `00-${Math.floor(newDate.getTime() / 1000).toString() .padStart(10, '0')}_000000000-call_0.m4a`, }); }, [ newDatetime, dispatch, hour, minute, ]); const hourOptions = Array.from(Array(24), (v, idx) => idx); const minuteOptions = [ 0, 15, 30, 45, ]; const currentDatetime = newDatetime !== null ? newDatetime : state.filter.f ? fNameToDate(state.filter.f) : new Date(); return <Modal show={state.calendarModalOpen} onHide={() => dispatch({ action: 'CloseCalendarModal', })} > <Modal.Header closeButton>Jump to Time</Modal.Header> <Modal.Body> <DatePicker selected={currentDatetime} onChange={date => date && setNewDatetime(date)} /> at <select value={hour} onChange={e => setHour(Number(e.target.value))} >{hourOptions.map(h => <option key={h} value={h} >{h.toString().padStart(2, '0')}</option>)}</select> : <select value={minute} onChange={e => setMinute(Number(e.target.value))} >{minuteOptions.map(m => <option key={m} value={m} >{m.toString().padStart(2, '0')}</option>)}</select> </Modal.Body> <Modal.Footer className='justify-content-between'> <Button variant='success' onClick={jumpToTime} disabled={newDatetime === null} >Go to Time</Button> <Button variant='primary' onClick={() => dispatch({ action: 'SetNewFilters', ...state.filter, f: undefined, })} >Go to Present</Button> <Button variant='warning' onClick={() => dispatch({ action: 'CloseCalendarModal', })} >Cancel</Button> </Modal.Footer> </Modal>; } |