Skip to content

Commit

Permalink
Merge pull request #10 from atapas/countdown-fix
Browse files Browse the repository at this point in the history
Countdown fix
  • Loading branch information
atapas committed Jan 31, 2022
2 parents 591d056 + 1b3dda8 commit e82d38d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/plays/date-time-counter/CdTimerComp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import { useState } from "react";
import CountDownTimer from "./CountDownTimer";

const CdTimerComp = () => {
const dateTimeAfterThreeDays = new Date().getTime() + 3 * 24 * 60 * 60 * 1000;
const THREE_DAYS_IN_MS = 3 * 24 * 60 * 60 * 1000;
const NOW_IN_MS = new Date().getTime();

const dateTimeAfterThreeDays = NOW_IN_MS + THREE_DAYS_IN_MS;
const [targetDate, setTargetDate] = useState(
new Date(dateTimeAfterThreeDays)
);

const handleChange = (event) => {
event.preventDefault();
setTargetDate(new Date(event.target.value));
if (event.target.value) {
setTargetDate(new Date(event.target.value));
} else {
setTargetDate(new Date(dateTimeAfterThreeDays));
}
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/plays/date-time-counter/CountDownTimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ShowCounter = ({ days, hours, minutes, seconds }) => {
const CountDownTimer = ({ targetDate }) => {
const [days, hours, minutes, seconds] = useCountDown(targetDate);

if (days < 0) {
if (days + hours + minutes + seconds <= 0) {
return <ExpiredNotice />;
} else {
return (
Expand Down
4 changes: 4 additions & 0 deletions src/plays/movies/movies.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ li {
border: 1px solid #ccc;
border-radius: 5px;
background-color: #fff;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
}

.movie img {
Expand Down

1 comment on commit e82d38d

@vercel
Copy link

@vercel vercel bot commented on e82d38d Jan 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.