I am uncertain how to compare these two types. hive.inspection_date is returning on my console.log like 2022-06-10, when I try to compare it to DateTwo, it's not comparing as my console.log is returning (Tue May 31 2022 17:06:57 GMT-0400 (Eastern Daylight Time)). I am not sure how to convert these so they could compare and I can alert the user. Any suggestions?
import React, { useState } from "react"
import Alert from 'react-bootstrap/Alert'
const DisplayAlert= (props) => {
const [show, setShow] = useState(true);
let dateTwo = new Date();
return (
<>
{console.log(dateTwo)}
{props.hives.map((hive)=> {
if (hive.inspection_date > dateTwo){
return
}
else if (hive.inspection_date <= dateTwo, show){
// if (show) {
{console.log(hive.inspection_date)}
return (
<Alert variant="danger" onClose={() => setShow(false)} dismissible key={hive.id}>
<Alert.Heading >Oh snap! You got are running behind an Inspection for Hive number: {hive.hive_number} Inspection date of: {hive.inspection_date}</Alert.Heading>
</Alert>
);
// }
}
// return <button onClick={() => setShow(true)}>Show Alert</button>;
}
)}
</>
)
}
export default DisplayAlert;