|
|
@@ -3,16 +3,20 @@ 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"; |
|
|
|
|
|
|
|
|
|
|
|
interface dates { |
|
|
|
date: string; |
|
|
|
day: string; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface OwnProps { |
|
|
|
month: string; |
|
|
|
dates: dates[]; |
|
|
|
timeSlots: string[]; |
|
|
|
getDate: (date: string) => void; |
|
|
|
} |
|
|
|
|
|
|
|
const TimeSlot: React.FC<OwnProps> = (props) => { |
|
|
@@ -20,7 +24,16 @@ const TimeSlot: React.FC<OwnProps> = (props) => { |
|
|
|
const [highlightedDate, setHighlightedDate] = useState<dates>(); |
|
|
|
const [highlightedTime, setHighlightedTime] = useState<string>(""); |
|
|
|
|
|
|
|
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(); |
|
|
|
// } |
|
|
|
return ( |
|
|
|
<div |
|
|
|
className={styles.date + " " + (date === highlightedDate ? styles.active : "")} |
|
|
@@ -28,10 +41,10 @@ const TimeSlot: React.FC<OwnProps> = (props) => { |
|
|
|
onClick={() => setHighlightedDate(date)}> |
|
|
|
|
|
|
|
<div className={styles.day}> |
|
|
|
{date.day} |
|
|
|
{daysMap.get(day.getDay())} |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
{date.date} |
|
|
|
{day.getDate()} |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
@@ -49,10 +62,6 @@ const TimeSlot: React.FC<OwnProps> = (props) => { |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
if (highlightedDate && highlightedTime !== "") { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<IonPage> |
|
|
|
<header className={styles.header}> |
|
|
@@ -73,10 +82,10 @@ const TimeSlot: React.FC<OwnProps> = (props) => { |
|
|
|
{timeSlots} |
|
|
|
</div> |
|
|
|
|
|
|
|
<Link to="/" |
|
|
|
<div onClick={(highlightedDate && highlightedTime !== "") ? () => props.getDate("test") : undefined} |
|
|
|
className={styles.timeSlotButton + " " + (highlightedDate && highlightedTime !== "" ? styles.buttonActive : "")}> |
|
|
|
<IonButton shape="round" expand='block'>Confirm slot</IonButton> |
|
|
|
</Link> |
|
|
|
<IonButton shape="round" expand='block' >Confirm slot</IonButton> |
|
|
|
</div> |
|
|
|
</IonContent> |
|
|
|
|
|
|
|
</IonPage> |
|
|
|