import React, { useState } from 'react';
import './AppointmentConfirmationScreen.css';
function AppointmentConfirmationScreen(props) {
const [selectedTime, setSelectedTime] = useState(null);
const [selectedDate, setSelectedDate] = useState(null);
return (
<div className="appointment-confirmation-screen">
<h1>{props.provider.name}</h1>
<p>Select a time and date for your appointment:</p>
<form>
<label htmlFor="time">Time:</label>
<select
id="time"
value={selectedTime}
onChange={(event) => setSelectedTime(event.target.value)}
>
<option value="">-- Please select a time --</option>
{props.provider.availability.map((availability) => (
<option key={availability.time} value={availability.time}>
{availability.time}
</option>
))}
</select>
<br />
<label htmlFor="date">Date:</label>
<input
type="date"
id="date"
value={selectedDate}
onChange={(event) => setSelectedDate(event.target.value)}
/>
<br />
</form>
<button disabled={!selectedTime || !selectedDate} onClick={props.onConfirm}>
Confirm Appointment
</button>
</div>
);
}
export default AppointmentConfirmationScreen;