fix bug save and set data just with one key, remove page login from appo page, disable not avalaible data in calendar, change steps for pages in appo, get data user, edit and set in page user-info
This commit is contained in:
@@ -5,8 +5,9 @@ import LoadingDate from "../LoadingDate";
|
||||
import Image from "next/image";
|
||||
|
||||
function FirstDatePicker({
|
||||
startDate,
|
||||
loading,
|
||||
startDate,
|
||||
disableDates,
|
||||
handleDisableDate,
|
||||
nextIconDatePickerF,
|
||||
prevIconDatePickerF,
|
||||
|
||||
@@ -4,6 +4,8 @@ import { useEffect, useRef, useState } from "react";
|
||||
import FirstDatePicker from "./date/FirstDatePicker";
|
||||
import SecondDatePicker from "./date/SecondDatePicker";
|
||||
import { dateToTimestamp } from "@/helper";
|
||||
import { request } from "@/services/response";
|
||||
import moment from "moment-jalaali";
|
||||
|
||||
function DatePicker({ setDate }) {
|
||||
const nextIconDatePickerF = useRef();
|
||||
@@ -14,6 +16,7 @@ function DatePicker({ setDate }) {
|
||||
const [startDate, setStartDate] = useState(null);
|
||||
const [endDate, setEndDate] = useState();
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [disableDates, setDisableDates] = useState([]);
|
||||
|
||||
const handleStartDateChange = (date, e) => {
|
||||
if (date) {
|
||||
@@ -31,16 +34,35 @@ function DatePicker({ setDate }) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleDisableDate = (e) => {
|
||||
const today = new Date();
|
||||
return today >= e._d;
|
||||
const date = moment(e).startOf("day");
|
||||
const today = moment().startOf("day");
|
||||
|
||||
if (date.isBefore(today)) return true;
|
||||
|
||||
if (
|
||||
disableDates.some((ts) => date.isSame(moment.unix(ts).startOf("day")))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
request
|
||||
.getAppointmentNotAvailable(47)
|
||||
.then((res) => {
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
}, 1000);
|
||||
setDisableDates(res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
});
|
||||
if (nextIconDatePickerS.current) {
|
||||
nextIconDatePickerS.current.click();
|
||||
|
||||
setLoading(false);
|
||||
}
|
||||
}, [nextIconDatePickerS]);
|
||||
|
||||
@@ -49,6 +71,7 @@ function DatePicker({ setDate }) {
|
||||
<FirstDatePicker
|
||||
loading={loading}
|
||||
startDate={startDate}
|
||||
disableDates={disableDates}
|
||||
handleDisableDate={handleDisableDate}
|
||||
nextIconDatePickerF={nextIconDatePickerF}
|
||||
prevIconDatePickerF={prevIconDatePickerF}
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
import ArrowLeftB from "@/components/icons/ArrowLeftB";
|
||||
import { request } from "@/services/response";
|
||||
import { Button } from "@mui/material";
|
||||
import Cookies from "js-cookie";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
function SendAppo({ hour }) {
|
||||
function SendAppo({ hour, setStep }) {
|
||||
const params = useParams();
|
||||
const doctorId = params.doctorId;
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const sendReq = () => {
|
||||
setLoading(true);
|
||||
request
|
||||
.postAppointment({
|
||||
doctor_id: doctorId,
|
||||
slot: hour,
|
||||
})
|
||||
.then(() => {
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(() => {
|
||||
//
|
||||
});
|
||||
const isLogged = Cookies.get("access_token");
|
||||
if (isLogged) {
|
||||
setStep((step) => step + 1);
|
||||
}
|
||||
// setLoading(true);
|
||||
// request
|
||||
// .postAppointment({
|
||||
// doctor_id: doctorId,
|
||||
// slot: hour,
|
||||
// })
|
||||
// .then(() => {
|
||||
// setLoading(false);
|
||||
// })
|
||||
// .catch(() => {
|
||||
// //
|
||||
// });
|
||||
};
|
||||
console.log(hour);
|
||||
|
||||
return (
|
||||
<div className="w-full flex justify-end">
|
||||
|
||||
@@ -10,7 +10,7 @@ import SendAppo from "./SendAppo";
|
||||
const listTab = ["صبح", "بعد از ظهر"];
|
||||
const nameHours = ["hours_morning", "hours_afternoon"];
|
||||
|
||||
function DateTime({ date, doctor }) {
|
||||
function DateTime({ date, doctor, setStep }) {
|
||||
const params = useParams();
|
||||
const doctorId = params.doctorId;
|
||||
const [value, setValue] = useState(0);
|
||||
@@ -73,7 +73,7 @@ function DateTime({ date, doctor }) {
|
||||
setHour={setHour}
|
||||
nameHours={nameHours}
|
||||
/>
|
||||
<SendAppo hour={hour} />
|
||||
<SendAppo hour={hour} setStep={setStep} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user