-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds i18n; make timeouts configurable; Refactor code to improve code …
…quality
- Loading branch information
1 parent
fdbb0d1
commit d2498f3
Showing
4 changed files
with
97 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
|
||
export default function RemainingTime({ time }: { time: number }) { | ||
const [remaining, setRemaining] = React.useState(time - new Date().getTime()); | ||
|
||
React.useEffect(() => { | ||
const interval = setInterval(() => { | ||
setRemaining(time - new Date().getTime()); | ||
}, 1000); | ||
|
||
return () => { | ||
clearInterval(interval); | ||
}; | ||
}, [time]); | ||
|
||
const seconds = remaining / 1e3; | ||
|
||
if (seconds < 0) { | ||
return "0 sec."; | ||
} | ||
|
||
return `${seconds.toFixed(0)}s.`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters