Files
nobat724_front/app/component/date/dateTime/SendAppo.js
T

60 lines
1.5 KiB
JavaScript

import ArrowLeftB from "@/components/icons/ArrowLeftB";
import { Button } from "@mui/material";
import Cookies from "js-cookie";
import { useParams } from "next/navigation";
import { useState } from "react";
function SendAppo({ hour, setStep, setSelectedSlot, date, setSelectedDate }) {
const params = useParams();
const doctorId = params.doctorId;
const [loading, setLoading] = useState(false);
const sendReq = () => {
const isLogged = Cookies.get("access_token");
// ذخیره کردن اطلاعات اسلات انتخاب شده
if (hour && date) {
setSelectedSlot(hour);
setSelectedDate(date);
}
if (isLogged) {
// اگر لاگین کرده، به مرحله 3 (Detail) می‌رود
setStep(3);
} else {
// اگر لاگین نکرده، به مرحله 1 (Login) می‌رود
setStep(1);
}
// setLoading(true);
// request
// .postAppointment({
// doctor_id: doctorId,
// slot: hour,
// })
// .then(() => {
// setLoading(false);
// })
// .catch(() => {
// //
// });
};
return (
<div className="w-full flex justify-end">
<Button
className="!gap-[4px] !text-[16px] !font-medium !shadow-none !px-[12px] !py-[8px] md:!py-[9px] !w-full md:!w-fit !min-w-[157px]"
variant="contained"
loading={loading}
onClick={sendReq}
disabled={!hour}
>
تایید نوبت
<ArrowLeftB />
</Button>
</div>
);
}
export default SendAppo;