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:
Ehsan
2025-08-31 01:21:59 +03:30
parent 09867bf84a
commit 1e70d88a84
20 changed files with 332 additions and 146 deletions
+12 -12
View File
@@ -20,7 +20,7 @@ function ItemDoctor({ doctor }) {
<Image
width={72}
height={72}
src={doctor.img}
src={doctor?.img}
alt="image-doctor"
className="w-[64px] md:w-[68px] lg:w-[72px] h-[64px] md:h-[68px] lg:h-[72px]"
/>
@@ -28,12 +28,12 @@ function ItemDoctor({ doctor }) {
<div className="flex flex-col items-start justify-center gap-2">
<TextLoading width={90} height={15}>
<p className="text-[#3B3B3B] text-[14px] font-bold">
{doctor.name}
{doctor?.name}
</p>
</TextLoading>
<TextLoading width={120} height={15}>
<p className="text-[#616161] text-[14px] font-normal">
تخصص: {doctor.expertise}
تخصص: {doctor?.expertise}
</p>
</TextLoading>
<CustomLoading width={100} height={25}>
@@ -41,13 +41,13 @@ function ItemDoctor({ doctor }) {
<div className="p-1 bg-[#F8F8FF] flex items-center rounded-[4px] gap-0.5">
<LikeD />
<p className="text-[#616161] text-[12px] font-normal">
{doctor.satisfaction}%
{doctor?.satisfaction}%
</p>
</div>
<div className="p-1 bg-[#F8F8FF] flex items-center rounded-[4px] gap-0.5">
<PointD />
<p className="text-[#616161] text-[12px] font-normal">
{doctor.point}
{doctor?.point}
</p>
</div>
</div>
@@ -60,7 +60,7 @@ function ItemDoctor({ doctor }) {
<ClockD />
<TextLoading width={150} height={15}>
<p className="text-[#7E7E7E] text-[12px] font-normal">
ساعت کاری: {doctor.hours_of_work}
ساعت کاری: {doctor?.hours_of_work}
</p>
</TextLoading>
</div>
@@ -68,24 +68,24 @@ function ItemDoctor({ doctor }) {
<p
className={`text-[12px] font-medium rounded w-fit p-1.5 ml-[52px]
${
Number(doctor.active)
Number(doctor?.active)
? "bg-[rgba(5,_186,_88,_0.04)] text-[#05BA58]"
: "bg-[rgba(211,_47,_47,_0.04)] text-[#D32F2F]"
}`}
>
{Number(doctor.active)
? `اولین نوبت آزاد: ${Number(doctor.active)}`
{Number(doctor?.active)
? `اولین نوبت آزاد: ${Number(doctor?.active)}`
: "نوبت ندارد"}
</p>
</CustomLoading>
{/* Arrow */}
<Link href={`/doctor/${doctor.uuid}`}>
<Link href={`/doctor/${doctor?.uuid}`}>
<Button
variant="contained"
className={`!p-[14px] !absolute !left-4 !bottom-4 !rounded-full !w-fit
${!Number(doctor.active)}
${!Number(doctor?.active)}
`}
disabled={!Number(doctor.active)}
disabled={!Number(doctor?.active)}
>
<ArrowLeftD />
</Button>
@@ -5,8 +5,9 @@ import LoadingDate from "../LoadingDate";
import Image from "next/image";
function FirstDatePicker({
startDate,
loading,
startDate,
disableDates,
handleDisableDate,
nextIconDatePickerF,
prevIconDatePickerF,
+27 -4
View File
@@ -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}
+18 -14
View File
@@ -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">
+2 -2
View File
@@ -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>
);
}
+86
View File
@@ -0,0 +1,86 @@
import BottomSelect from "@/components/icons/BottomSelect";
import { Autocomplete, Button, TextField } from "@mui/material";
import { styleTextSelectRight } from "@/mui";
function DefaultSelect({ list, value, updateData, label, error, name }) {
return (
<Autocomplete
disablePortal
options={list}
value={value || ""}
getOptionLabel={(option) => {
if (typeof option === "string") return option;
return option?.name || option?.label || "";
}}
className="!w-full !rounded-lg auto-complete-selector"
onChange={(_, newValue) => {
updateData(name, newValue?.label || newValue || "");
}}
sx={{
...styleTextSelectRight,
// Hide Icon Number
"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":
{
display: "none",
},
"& input[type=number]": {
MozAppearance: "textfield",
},
"& .MuiInputBase-input": { padding: "12.5px 14px !important" },
"& .MuiInputBase-root": {
borderRadius: 2,
padding: "0 !important",
height: {
xs: "43px !important",
sm: "43px !important",
md: "46px !important",
lg: "48px !important",
},
},
"& .MuiOutlinedInput-notchedOutline": {
border: error
? "1px solid red !important"
: "1px solid #D7D7D7 !important",
},
"& .MuiInput-underline:hover:not(.Mui-disabled):before, .MuiOutlinedInput-notchedOutline":
{
borderColor: error ? "red !important" : "#D7D7D7 !important",
},
"& .muirtl-1kiro5a-MuiInputBase-root-MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":
{
border: "1px solid #5559CE !important",
},
}}
renderOption={(props, option) => (
<Button
fullWidth
{...props}
key={option.id || props.id}
className="!flex !justify-start !p-[8px] !text-start !text-[#A1A1A1] hover:dark:!bg-[#35343D] !bg-[#FFF] dark:!bg-[#1F1D2B]"
>
{option.name || option.label}
</Button>
)}
renderInput={(params) => (
<TextField
fullWidth
{...params}
InputProps={{
...params.InputProps,
endAdornment: (
<div className="absolute left-4">
<BottomSelect />
</div>
),
}}
placeholder={label}
sx={{
borderRadius: "8px",
}}
/>
)}
/>
);
}
export default DefaultSelect;