diff --git a/frontend/src/Call/CalendarModal.js b/frontend/src/Call/CalendarModal.js index 112f7fe..f733422 100644 --- a/frontend/src/Call/CalendarModal.js +++ b/frontend/src/Call/CalendarModal.js @@ -1,70 +1,64 @@ -import React, { Component } from "react"; +import React, { Component, useState } from "react"; import { Modal, Button, Icon } from "semantic-ui-react"; import "./CalendarModal.css"; +import { setDateFilter } from "../features/callPlayer/callPlayerSlice"; import DatePicker from 'react-datepicker'; -import { subDays } from 'date-fns' +import { useDispatch } from 'react-redux' +import { setDate, subDays } from 'date-fns' import 'react-datepicker/dist/react-datepicker.css'; -class CalendarModal extends Component { - constructor(props) { - super(props) - this.handleDateChange = this.handleDateChange.bind(this); - this.handleDone = this.handleDone.bind(this); - this.handleClose = this.handleClose.bind(this); +function CalendarModal(props) { - this.state = { - open: false, - startDate: new Date() - } -} + const [open, setOpen] = useState(false); + const [startDate, setStartDate] = useState(new Date()); + const dispatch = useDispatch() + const onClose = props.onClose; -handleDateChange = (date) => { - this.setState({ - startDate: date - }); + const handleDateChange = (date) => { + setStartDate(date); } -handleClose = () => this.props.onClose(false); -handleDone(event) { - this.props.callActions.setDateFilter(this.state.startDate.getTime()); - this.props.onClose(true); -} - - - render() { - - return ( - - - Select a Date & Time - - - - - - - - - - - ) + const handleClose = () => this.props.onClose(false); + const handleDone = (onClose) => { + dispatch(setDateFilter(startDate.getTime())); + onClose(true); } + + + + + return ( + + + Select a Date & Time + + + + + + + + + + + ) } + export default CalendarModal; diff --git a/frontend/src/Call/CallInfo.js b/frontend/src/Call/CallInfo.js index 107dab3..9d1543d 100644 --- a/frontend/src/Call/CallInfo.js +++ b/frontend/src/Call/CallInfo.js @@ -11,20 +11,19 @@ import { } from "semantic-ui-react"; // ---------------------------------------------------- -class CallInfo extends React.Component { +function CallInfo(props) { - render() { - var srcList = ""; - var callLength = "-"; - var callFreq = "-"; - var callDate = "-"; - var callTime = "-"; - var talkgroupNum = "-"; - var callDownload = ""; - var callTweet = ""; - if (this.props.call) { - const currentCall = this.props.call; + let srcList = ""; + let callLength = "-"; + let callFreq = "-"; + let callDate = "-"; + let callTime = "-"; + let talkgroupNum = "-"; + let callDownload = ""; + let callTweet = ""; + if (props.call) { + const currentCall = props.call; var time = new Date(currentCall.time); callTime = time.toLocaleTimeString(); callDate = time.toLocaleDateString(); @@ -33,12 +32,11 @@ class CallInfo extends React.Component { callFreq = Math.round(freq * 1000) / 1000; } - srcList = currentCall.srcList.map((source, index) => {source.src} - [{source.pos}]); + srcList = currentCall.srcList.map((source, index) => {source.src}[{source.pos}]); callLength = currentCall.len; talkgroupNum = currentCall.talkgroupNum; callDownload = currentCall.url; - callTweet = "https://twitter.com/intent/tweet?url="+encodeURIComponent(document.location.origin+this.props.link)+"&via="+encodeURIComponent("OpenMHz"); + callTweet = "https://twitter.com/intent/tweet?url="+encodeURIComponent(document.location.origin+props.link)+"&via="+encodeURIComponent("OpenMHz"); } @@ -46,7 +44,7 @@ class CallInfo extends React.Component { return (
-
{this.props.header}
+
{props.header}
{srcList} @@ -84,11 +82,11 @@ class CallInfo extends React.Component { Tweet Download - Link + Link
); - } + } export default CallInfo;