refactor: add location address handling in DateTime component and update Hours component to display address
This commit is contained in:
@@ -13,12 +13,30 @@ function DateTime({ date, doctor, setStep }) {
|
||||
const [value, setValue] = useState(0);
|
||||
const [hour, setHour] = useState();
|
||||
const [appo, setAppo] = useState("تاریخ مورد نظرتان را انتخاب کنید.");
|
||||
const [locationAddress, setLocationAddress] = useState(null);
|
||||
|
||||
const handleChange = (event, newValue) => {
|
||||
setHour();
|
||||
setValue(newValue);
|
||||
};
|
||||
|
||||
// دریافت آدرس بر اساس location_id وقتی ساعت انتخاب میشود
|
||||
useEffect(() => {
|
||||
if (hour && hour.location_id) {
|
||||
request
|
||||
.getDoctorAddress(hour.location_id)
|
||||
.then((res) => {
|
||||
setLocationAddress(res.address);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Error fetching address:", err);
|
||||
setLocationAddress(null);
|
||||
});
|
||||
} else {
|
||||
setLocationAddress(null);
|
||||
}
|
||||
}, [hour]);
|
||||
|
||||
useEffect(() => {
|
||||
if (date && doctor?.id) {
|
||||
setAppo("loading");
|
||||
@@ -85,6 +103,7 @@ function DateTime({ date, doctor, setStep }) {
|
||||
doctor={doctor}
|
||||
setHour={setHour}
|
||||
nameHours={nameHours}
|
||||
locationAddress={locationAddress}
|
||||
/>
|
||||
<SendAppo hour={hour} setStep={setStep} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user