diff --git a/src/components/SectionTimer.tsx b/src/components/SectionTimer.tsx new file mode 100644 index 0000000..ffe696e --- /dev/null +++ b/src/components/SectionTimer.tsx @@ -0,0 +1,27 @@ +import { useMemo } from 'react' +import { calculateDifference } from '../utils/calculateTimeLeft' +import Countdown from './Countdown.jsx' + +const SectionTimer = () => { + const timeLeft = useMemo( + () => calculateDifference('2023-07-21T20:00:00+02:00'), [] + ) + + return ( + timeLeft > 0 ? +
+

Quedan

+ +

+ Para el AforShow +

+
+ : + + ) +} + +export default SectionTimer diff --git a/src/pages/index.astro b/src/pages/index.astro index d700b3e..6baa74f 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,5 +1,5 @@ --- -import Countdown from '../components/Countdown.jsx' +import SectionTimer from '../components/SectionTimer.jsx' import Header from '../components/Header.astro' import Ticket from '../components/Ticket/Ticket' import Faq from '../components/Faq.jsx' @@ -51,19 +51,7 @@ const ogTitle = >
-
-

Quedan

- -

- Para el AforShow -

-
+ diff --git a/src/utils/calculateTimeLeft.js b/src/utils/calculateTimeLeft.js index a2fdcf1..33694eb 100644 --- a/src/utils/calculateTimeLeft.js +++ b/src/utils/calculateTimeLeft.js @@ -1,6 +1,6 @@ import { getLocalTime } from './getLocalTime' -export function calculateTimeLeft(time) { +export function calculateTimeLeft (time) { const { fulltime } = getLocalTime(time) const difference = new Date(fulltime) - new Date() @@ -37,3 +37,8 @@ export function calculateTimeLeft(time) { return timeLeft } + +export function calculateDifference (time) { + const { fulltime } = getLocalTime(time) + return new Date(fulltime) - new Date() +}