@@ -1,7 +1,7 @@ | |||||
import { useEffect, useState } from 'react'; | import { useEffect, useState } from 'react'; | ||||
const useCountdown = (targetDate: Date) => { | const useCountdown = (targetDate: Date) => { | ||||
console.log(targetDate); | |||||
const countDownDate = new Date(targetDate).getTime(); | const countDownDate = new Date(targetDate).getTime(); | ||||
const [countDown, setCountDown] = useState( | const [countDown, setCountDown] = useState( | ||||
@@ -14,13 +14,14 @@ const useCountdown = (targetDate: Date) => { | |||||
}, 1000); | }, 1000); | ||||
return () => clearInterval(interval); | return () => clearInterval(interval); | ||||
}, []); | |||||
}, [targetDate]); | |||||
const days = Math.floor(countDown / (1000 * 60 * 60 * 24)); | const days = Math.floor(countDown / (1000 * 60 * 60 * 24)); | ||||
const hours = Math.floor((countDown % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | const hours = Math.floor((countDown % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||||
const minutes = Math.floor((countDown % (1000 * 60 * 60)) / (1000 * 60)); | const minutes = Math.floor((countDown % (1000 * 60 * 60)) / (1000 * 60)); | ||||
const seconds = Math.floor((countDown % (1000 * 60)) / 1000); | const seconds = Math.floor((countDown % (1000 * 60)) / 1000); | ||||
return [days, hours, minutes, seconds]; | return [days, hours, minutes, seconds]; | ||||
}; | }; | ||||
@@ -9,6 +9,7 @@ interface OwnProps { | |||||
month: string; | month: string; | ||||
getDate: () => void; | getDate: () => void; | ||||
HideTimeSlot: () => void; | HideTimeSlot: () => void; | ||||
getTimeSlot: (date: any, time: string) => void; | |||||
} | } | ||||
const TimeSlot: React.FC<OwnProps> = (props) => { | const TimeSlot: React.FC<OwnProps> = (props) => { | ||||
@@ -16,6 +17,14 @@ const TimeSlot: React.FC<OwnProps> = (props) => { | |||||
const [highlightedDate, setHighlightedDate] = useState<Date>(); | const [highlightedDate, setHighlightedDate] = useState<Date>(); | ||||
const [highlightedTime, setHighlightedTime] = useState<string>(""); | const [highlightedTime, setHighlightedTime] = useState<string>(""); | ||||
const setTimeSlot = () => { | |||||
if (highlightedDate && highlightedTime !== "") { | |||||
props.getDate(); | |||||
props.getTimeSlot(highlightedDate, highlightedTime); | |||||
} else { | |||||
return undefined; | |||||
} | |||||
} | |||||
const dates = Dates.map((date, key) => { | const dates = Dates.map((date, key) => { | ||||
return ( | return ( | ||||
<div | <div | ||||
@@ -27,7 +36,7 @@ const TimeSlot: React.FC<OwnProps> = (props) => { | |||||
{format(date, 'eee')} | {format(date, 'eee')} | ||||
</div> | </div> | ||||
<div> | <div> | ||||
{format(date, 'e')} | |||||
{format(date, 'd')} | |||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -68,7 +77,7 @@ const TimeSlot: React.FC<OwnProps> = (props) => { | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div onClick={(highlightedDate && highlightedTime !== "") ? () => props.getDate() : undefined} | |||||
<div onClick={setTimeSlot} | |||||
className={styles.timeSlotButton + " " + (highlightedDate && highlightedTime !== "" ? styles.buttonActive : "")}> | className={styles.timeSlotButton + " " + (highlightedDate && highlightedTime !== "" ? styles.buttonActive : "")}> | ||||
<IonButton shape="round" expand='block' >Confirm slot</IonButton> | <IonButton shape="round" expand='block' >Confirm slot</IonButton> | ||||
</div> | </div> | ||||
@@ -8,23 +8,28 @@ import { Link } from "react-router-dom"; | |||||
import { useState } from "react"; | import { useState } from "react"; | ||||
import TimeSlot from "../../components/timeSlot/TimeSlot"; | import TimeSlot from "../../components/timeSlot/TimeSlot"; | ||||
import { useCountdown } from "../../components/CountDownTimer/useCountdown"; | import { useCountdown } from "../../components/CountDownTimer/useCountdown"; | ||||
import { addDays } from "date-fns"; | |||||
import CountdownTimer from "../../components/CountDownTimer/CountdownTimer"; | import CountdownTimer from "../../components/CountDownTimer/CountdownTimer"; | ||||
import { format } from "date-fns"; | |||||
const FinalInterview: React.FC = () => { | const FinalInterview: React.FC = () => { | ||||
const [isDateSet, setDate] = useState<boolean>(false); | |||||
const [isTimeSlot, setTimeSlot] = useState<boolean>(false); | |||||
const [isDateSet, setIsDate] = useState<boolean>(false); | |||||
const [isTimeSlot, setIsTimeSlot] = useState<boolean>(false); | |||||
const [date, setDate] = useState<Date>(new Date()); | |||||
const [days, hours, minutes, seconds] = useCountdown(new Date('may 6, 2022 07:00:00')); | |||||
const [days, hours, minutes, seconds] = useCountdown(date); | |||||
const getDate = () => { | const getDate = () => { | ||||
setTimeSlot(false); | |||||
setDate(true); | |||||
setIsTimeSlot(false); | |||||
setIsDate(true); | |||||
} | } | ||||
const HideTimeSlot = () => { | const HideTimeSlot = () => { | ||||
setTimeSlot(false); | |||||
setIsTimeSlot(false); | |||||
} | |||||
const getTimeSlot = (date: any, time: string) => { | |||||
setDate(new Date(`${format(date, "LLL")} ${format(date, "d")} ${format(date, "y")} ${time.substring(0, 8)}`)); | |||||
} | } | ||||
return ( | return ( | ||||
@@ -46,13 +51,6 @@ const FinalInterview: React.FC = () => { | |||||
<h4>Let's Meet in:</h4> | <h4>Let's Meet in:</h4> | ||||
<div className={styles.timeLeft}> | <div className={styles.timeLeft}> | ||||
{/* <h4 className={styles.time}>02 : 04 : 25 : 53</h4> | |||||
<div className={styles.days}> | |||||
<div>Days</div> | |||||
<div>Hrs</div> | |||||
<div>Mins</div> | |||||
<div>Secs</div> | |||||
</div> */} | |||||
<CountdownTimer | <CountdownTimer | ||||
days={days} | days={days} | ||||
hours={hours} | hours={hours} | ||||
@@ -68,7 +66,7 @@ const FinalInterview: React.FC = () => { | |||||
</div> | </div> | ||||
{ | { | ||||
!isDateSet ? | !isDateSet ? | ||||
<div className={styles.techinicalInterviewBtn} onClick={() => setTimeSlot(true)}> | |||||
<div className={styles.techinicalInterviewBtn} onClick={() => setIsTimeSlot(true)}> | |||||
<IonButton shape="round" expand='block'>Find a slot</IonButton> | <IonButton shape="round" expand='block'>Find a slot</IonButton> | ||||
</div> | </div> | ||||
: | : | ||||
@@ -87,7 +85,8 @@ const FinalInterview: React.FC = () => { | |||||
<TimeSlot | <TimeSlot | ||||
month="April-May" | month="April-May" | ||||
getDate={getDate} | getDate={getDate} | ||||
HideTimeSlot={HideTimeSlot} /> | |||||
HideTimeSlot={HideTimeSlot} | |||||
getTimeSlot={getTimeSlot} /> | |||||
} | } | ||||
</IonContent> | </IonContent> | ||||
@@ -58,11 +58,12 @@ const Options: React.FC<OwnProps> = (props) => { | |||||
setTextInput(inputRef.current?.value!) | setTextInput(inputRef.current?.value!) | ||||
} | } | ||||
if (props.lastQuestion) { | |||||
const setAnswer = () => { | |||||
localStorage.setItem("answer", answers.toString()); | localStorage.setItem("answer", answers.toString()); | ||||
} | } | ||||
const options = props.options!.map((option, key) => { | const options = props.options!.map((option, key) => { | ||||
return ( | return ( | ||||
<IonItem lines='none' key={key} className={(option === selected) ? styles.highlighted : ""}> | <IonItem lines='none' key={key} className={(option === selected) ? styles.highlighted : ""}> | ||||
@@ -122,7 +123,7 @@ const Options: React.FC<OwnProps> = (props) => { | |||||
} | } | ||||
{props.lastQuestion && | {props.lastQuestion && | ||||
< Link to="/preliminaryRoundResults" className={styles.button + " " + ((selected || selectedOptions.length > 0 || textInput) ? styles.active : "")}> | |||||
< Link to="/preliminaryRoundResults" onClick={setAnswer} className={styles.button + " " + ((selected || selectedOptions.length > 0 || textInput) ? styles.active : "")}> | |||||
<IonButton shape="round" expand='block'>Next Step</IonButton> | <IonButton shape="round" expand='block'>Next Step</IonButton> | ||||
</Link> | </Link> | ||||
} | } | ||||
@@ -5,27 +5,34 @@ import StepHeader from "../../components/stepsHeader/StepHeader"; | |||||
import techinicalInterview from "../../assets/icons/Technical_Interview.svg"; | import techinicalInterview from "../../assets/icons/Technical_Interview.svg"; | ||||
import linkIcon from "../../assets/icons/link.svg"; | import linkIcon from "../../assets/icons/link.svg"; | ||||
import { Link } from "react-router-dom"; | import { Link } from "react-router-dom"; | ||||
import { useState } from "react"; | |||||
import { useEffect, useState } from "react"; | |||||
import TimeSlot from "../../components/timeSlot/TimeSlot"; | import TimeSlot from "../../components/timeSlot/TimeSlot"; | ||||
import { useCountdown } from "../../components/CountDownTimer/useCountdown"; | import { useCountdown } from "../../components/CountDownTimer/useCountdown"; | ||||
import CountdownTimer from "../../components/CountDownTimer/CountdownTimer"; | import CountdownTimer from "../../components/CountDownTimer/CountdownTimer"; | ||||
import { format } from "date-fns"; | |||||
const TechnicalInterview: React.FC = () => { | const TechnicalInterview: React.FC = () => { | ||||
const [isDateSet, setDate] = useState<boolean>(false); | |||||
const [isTimeSlot, setTimeSlot] = useState<boolean>(false); | |||||
const [isDateSet, setIsDate] = useState<boolean>(false); | |||||
const [isTimeSlot, setIsTimeSlot] = useState<boolean>(false); | |||||
const [date, setDate] = useState<Date>(new Date()); | |||||
const [days, hours, minutes, seconds] = useCountdown(new Date('may 7, 2022 07:00:00')); | |||||
const [days, hours, minutes, seconds] = useCountdown(date); | |||||
const getDate = () => { | const getDate = () => { | ||||
setTimeSlot(false); | |||||
setDate(true); | |||||
setIsTimeSlot(false); | |||||
setIsDate(true); | |||||
} | } | ||||
const HideTimeSlot = () => { | const HideTimeSlot = () => { | ||||
setTimeSlot(false); | |||||
setIsTimeSlot(false); | |||||
} | } | ||||
const getTimeSlot = (date: any, time: string) => { | |||||
setDate(new Date(`${format(date, "LLL")} ${format(date, "d")} ${format(date, "y")} ${time.substring(0, 8)}`)); | |||||
} | |||||
return ( | return ( | ||||
<IonPage> | <IonPage> | ||||
<StepHeader stepNumber={3} roundName="Technical Interview" /> | <StepHeader stepNumber={3} roundName="Technical Interview" /> | ||||
@@ -60,7 +67,7 @@ const TechnicalInterview: React.FC = () => { | |||||
</div> | </div> | ||||
{ | { | ||||
!isDateSet ? | !isDateSet ? | ||||
<div className={styles.techinicalInterviewBtn} onClick={() => setTimeSlot(true)}> | |||||
<div className={styles.techinicalInterviewBtn} onClick={() => setIsTimeSlot(true)}> | |||||
<IonButton shape="round" expand='block'>Find a slot</IonButton> | <IonButton shape="round" expand='block'>Find a slot</IonButton> | ||||
</div> | </div> | ||||
: | : | ||||
@@ -79,7 +86,8 @@ const TechnicalInterview: React.FC = () => { | |||||
<TimeSlot | <TimeSlot | ||||
month="April-May" | month="April-May" | ||||
getDate={getDate} | getDate={getDate} | ||||
HideTimeSlot={HideTimeSlot} /> | |||||
HideTimeSlot={HideTimeSlot} | |||||
getTimeSlot={getTimeSlot} /> | |||||
} | } | ||||
</IonContent> | </IonContent> | ||||