diff --git a/src/App.tsx b/src/App.tsx index 49119d0..d21a606 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -38,6 +38,7 @@ import JoiningLetter from './pages/joiningLetter/JoiningLetter'; import Celebration from './pages/celebration/Celebration'; import SignaturePhoto from './pages/joiningLetter/SignaturePhoto'; import TechinicalInterviewResults from './pages/technicalInterview/TechinicalInterviewResults'; +import CountdownTimer from './components/CountDownTimer/CountdownTimer'; @@ -104,11 +105,10 @@ const App: React.FC = () => ( - - + diff --git a/src/components/CountDownTimer/CountdownTimer.module.scss b/src/components/CountDownTimer/CountdownTimer.module.scss new file mode 100644 index 0000000..5bad81e --- /dev/null +++ b/src/components/CountDownTimer/CountdownTimer.module.scss @@ -0,0 +1,18 @@ +.CountdownTimerHolder { + .time { + font-size: 3.6rem; + font-weight: 600; + color: #363636; + letter-spacing: 0.036rem; + } + .days { + font-size: 1.3rem; + color: #9F9F9F; + display: flex; + justify-content: space-between; + align-items: center; + // width: 95%; + margin: 0 auto; + text-align: center; + } +} diff --git a/src/components/CountDownTimer/CountdownTimer.tsx b/src/components/CountDownTimer/CountdownTimer.tsx new file mode 100644 index 0000000..b8bf8e1 --- /dev/null +++ b/src/components/CountDownTimer/CountdownTimer.tsx @@ -0,0 +1,32 @@ +import styles from "./CountdownTimer.module.scss"; + +interface OwnProp { + days: number; + hours: number; + minutes: number; + seconds: number; +} + +const CountdownTimer: React.FC = (props) => { + + return ( +
+

+ { + `${props.days < 10 ? "0" : ""}${props.days} : + ${props.hours < 10 ? "0" : ""}${props.hours} : + ${props.minutes < 10 ? "0" : ""}${props.minutes} : + ${props.seconds < 10 ? "0" : ""}${props.seconds}` + } +

+
+
Days
+
Hrs
+
Mins
+
Secs
+
+
+ ); +} + +export default CountdownTimer; \ No newline at end of file diff --git a/src/components/CountDownTimer/useCountdown.tsx b/src/components/CountDownTimer/useCountdown.tsx new file mode 100644 index 0000000..df20f22 --- /dev/null +++ b/src/components/CountDownTimer/useCountdown.tsx @@ -0,0 +1,27 @@ +import { useEffect, useState } from 'react'; + +const useCountdown = (targetDate: Date) => { + + const countDownDate = new Date(targetDate).getTime(); + + const [countDown, setCountDown] = useState( + countDownDate - new Date().getTime() + ); + + useEffect(() => { + const interval = setInterval(() => { + setCountDown(countDownDate - new Date().getTime()); + }, 1000); + + return () => clearInterval(interval); + }, []); + + const days = Math.floor(countDown / (1000 * 60 * 60 * 24)); + const hours = Math.floor((countDown % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + const minutes = Math.floor((countDown % (1000 * 60 * 60)) / (1000 * 60)); + const seconds = Math.floor((countDown % (1000 * 60)) / 1000); + + return [days, hours, minutes, seconds]; +}; + +export { useCountdown }; \ No newline at end of file diff --git a/src/components/timeSlot/TimeSlot.tsx b/src/components/timeSlot/TimeSlot.tsx index e58c4c3..7148ad6 100644 --- a/src/components/timeSlot/TimeSlot.tsx +++ b/src/components/timeSlot/TimeSlot.tsx @@ -3,7 +3,7 @@ import styles from "./TimeSlot.module.scss"; import { chevronBack, key } from 'ionicons/icons' import { Link } from "react-router-dom"; import { useState } from "react"; -import { addDays } from "date-fns"; +import { addDays, format } from "date-fns"; // singular interface dates { @@ -24,18 +24,10 @@ const TimeSlot: React.FC = (props) => { const [highlightedDate, setHighlightedDate] = useState(); const [highlightedTime, setHighlightedTime] = useState(""); - // use object insted of map - const daysMap = new Map([[0, "Sun"], [1, "Mon"], [2, "Tue"], [3, "Wed"], [4, "Thu"], [5, "Fri"], [6, "Sat"]]); - const dates = props.dates.map((date, key) => { const currentDate = new Date(); let day = addDays(currentDate, key + 1); - // if (daysMap.get(day) === "Thu") { // sat - // day = addDays(currentDate, key + 3).getDay(); - // } else if (daysMap.get(day) === "Fri") { - // day = addDays(currentDate, key + 3).getDay(); - // } - console.log(highlightedDate); + return (
= (props) => { onClick={() => setHighlightedDate(date)}>
- {daysMap.get(day.getDay())} + {format(day, 'eee')}
- {day.getDate()} + {format(day, 'e')}
diff --git a/src/pages/preliminaryRound/PreliminaryRound.tsx b/src/pages/preliminaryRound/PreliminaryRound.tsx index 84065ec..13d6371 100644 --- a/src/pages/preliminaryRound/PreliminaryRound.tsx +++ b/src/pages/preliminaryRound/PreliminaryRound.tsx @@ -39,7 +39,7 @@ const PreliminaryRound: React.FC = () => { - + Start quiz diff --git a/src/pages/technicalInterview/TechnicalInterview.module.scss b/src/pages/technicalInterview/TechnicalInterview.module.scss index 1c771c3..56e6d32 100644 --- a/src/pages/technicalInterview/TechnicalInterview.module.scss +++ b/src/pages/technicalInterview/TechnicalInterview.module.scss @@ -46,22 +46,22 @@ letter-spacing: 0.024rem; } .timeLeft { - .time { - font-size: 3.6rem; - font-weight: 600; - color: #363636; - letter-spacing: 0.036rem; - } - .days { - font-size: 1.3rem; - color: #9F9F9F; - display: flex; - justify-content: space-between; - align-items: center; - width: 95%; - margin: 0 auto; - text-align: center; - } + // .time { + // font-size: 3.6rem; + // font-weight: 600; + // color: #363636; + // letter-spacing: 0.036rem; + // } + // .days { + // font-size: 1.3rem; + // color: #9F9F9F; + // display: flex; + // justify-content: space-between; + // align-items: center; + // width: 95%; + // margin: 0 auto; + // text-align: center; + // } } .icon { width: 6rem; diff --git a/src/pages/technicalInterview/TechnicalInterview.tsx b/src/pages/technicalInterview/TechnicalInterview.tsx index d0f6631..59549c7 100644 --- a/src/pages/technicalInterview/TechnicalInterview.tsx +++ b/src/pages/technicalInterview/TechnicalInterview.tsx @@ -5,8 +5,11 @@ import StepHeader from "../../components/stepsHeader/StepHeader"; import techinicalInterview from "../../assets/icons/Technical_Interview.svg"; import linkIcon from "../../assets/icons/link.svg"; import { Link } from "react-router-dom"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import TimeSlot from "../../components/timeSlot/TimeSlot"; +import { useCountdown } from "../../components/CountDownTimer/useCountdown"; +import { addDays, min } from "date-fns"; +import CountdownTimer from "../../components/CountDownTimer/CountdownTimer"; interface dates { date: string; @@ -18,6 +21,14 @@ const TechnicalInterview: React.FC = () => { const [isDateSet, setDate] = useState(false); const [isTimeSlot, setTimeSlot] = useState(false); + const [days, hours, minutes, seconds] = useCountdown(addDays(new Date(), 2)); + + console.log(days, hours, minutes, seconds); + + // useEffect(() => { + // console.log("render"); + // }, [seconds]); + const timeSlots = ["11:00 AM - 1:00 pm", "1:00 PM - 3:00 pm", "3:00 PM - 5:00 pm"]; const dates: dates[] = [ @@ -40,7 +51,6 @@ const TechnicalInterview: React.FC = () => { ]; const getDate = (date: string) => { - console.log(date); setTimeSlot(false); setDate(true); } @@ -64,13 +74,18 @@ const TechnicalInterview: React.FC = () => {

Let's Meet in:

-

02 : 04 : 25 : 53

-
+ {/*

{`${days} : ${hours} : ${minutes} : ${seconds}`}

*/} + + {/*
Days
Hrs
Mins
Secs
-
+
*/}

Join us on Google Meet

@@ -98,7 +113,7 @@ const TechnicalInterview: React.FC = () => { { isTimeSlot &&