diff --git a/app/component/ItemDoctor.js b/app/component/ItemDoctor.js index 719ba37..4d3ea87 100644 --- a/app/component/ItemDoctor.js +++ b/app/component/ItemDoctor.js @@ -20,7 +20,7 @@ function ItemDoctor({ doctor }) { image-doctor @@ -28,12 +28,12 @@ function ItemDoctor({ doctor }) {

- {doctor.name} + {doctor?.name}

- تخصص: {doctor.expertise} + تخصص: {doctor?.expertise}

@@ -41,13 +41,13 @@ function ItemDoctor({ doctor }) {

- {doctor.satisfaction}% + {doctor?.satisfaction}%

- {doctor.point} + {doctor?.point}

@@ -60,7 +60,7 @@ function ItemDoctor({ doctor }) {

- ساعت کاری: {doctor.hours_of_work} + ساعت کاری: {doctor?.hours_of_work}

@@ -68,24 +68,24 @@ function ItemDoctor({ doctor }) {

- {Number(doctor.active) - ? `اولین نوبت آزاد: ${Number(doctor.active)}` + {Number(doctor?.active) + ? `اولین نوبت آزاد: ${Number(doctor?.active)}` : "نوبت ندارد"}

{/* Arrow */} - + diff --git a/app/component/date/datePicker/date/FirstDatePicker.js b/app/component/date/datePicker/date/FirstDatePicker.js index 56e867c..44c2d0a 100644 --- a/app/component/date/datePicker/date/FirstDatePicker.js +++ b/app/component/date/datePicker/date/FirstDatePicker.js @@ -5,8 +5,9 @@ import LoadingDate from "../LoadingDate"; import Image from "next/image"; function FirstDatePicker({ - startDate, loading, + startDate, + disableDates, handleDisableDate, nextIconDatePickerF, prevIconDatePickerF, diff --git a/app/component/date/datePicker/index.js b/app/component/date/datePicker/index.js index 0a364ad..f13e1a9 100644 --- a/app/component/date/datePicker/index.js +++ b/app/component/date/datePicker/index.js @@ -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 }) { { - 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 (
diff --git a/app/component/date/dateTime/index.js b/app/component/date/dateTime/index.js index e39d21a..a3c58be 100644 --- a/app/component/date/dateTime/index.js +++ b/app/component/date/dateTime/index.js @@ -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} /> - +
); } diff --git a/app/component/selectors/DefaultSelect.js b/app/component/selectors/DefaultSelect.js new file mode 100644 index 0000000..5198b5d --- /dev/null +++ b/app/component/selectors/DefaultSelect.js @@ -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 ( + { + 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) => ( + + )} + renderInput={(params) => ( + + + + ), + }} + placeholder={label} + sx={{ + borderRadius: "8px", + }} + /> + )} + /> + ); +} + +export default DefaultSelect; diff --git a/components/appointment/Container.js b/components/appointment/Container.js new file mode 100644 index 0000000..6f5a9aa --- /dev/null +++ b/components/appointment/Container.js @@ -0,0 +1,64 @@ +import Date from "./date"; + +// Components +import Content from "./Content"; +import Layout from "@/components/layout"; +import Paying from "@/components/appointment/paying"; +import Detail from "@/components/appointment/detail"; +import FailedPay from "@/components/appointment/failedPay"; +import SuccessPay from "@/components/appointment/successPay"; + +function Container({ + step, + data, + doctor, + setData, + setStep, + matchedCity, + isForAnother, + setIsForAnother, +}) { + const elements = [ + , + // , + // , + , + , + , + , + ]; + + return ( + <> + {/* {step === 1 || step === 2 ? ( + {elements[step]} + ) : ( */} + 2} + matchedCity={matchedCity} + paddingBottom="pb-[80px]" + > + + {elements[step]} + + + {/* )} */} + + ); +} + +export default Container; diff --git a/components/appointment/date/index.js b/components/appointment/date/index.js index 9588edd..bb0b81d 100644 --- a/components/appointment/date/index.js +++ b/components/appointment/date/index.js @@ -4,7 +4,6 @@ import Time from "./Time"; function Date({ doctor, setStep }) { const [locateVisit, setLocateVisit] = useState(true); - const [isError, setIsError] = useState(false); const [date, setDate] = useState(); return ( diff --git a/components/appointment/detail/Form.js b/components/appointment/detail/Form.js index 980ce9d..7ba00a9 100644 --- a/components/appointment/detail/Form.js +++ b/components/appointment/detail/Form.js @@ -1,14 +1,16 @@ -import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect"; -import EditField from "../../../app/component/fields/EditField"; import Content from "./Content"; +import EditField from "../../../app/component/fields/EditField"; +import DefaultSelect from "@/app/component/selectors/DefaultSelect"; -const bime = [ - { label: "بیمه 1", id: 10 }, - { label: "بیمه 2", id: 20 }, - { label: "بیمه 3", id: 30 }, -]; +function Form({ changeData, insurance, data, updateSelect, isForAnother }) { + const findVal = () => { + return insurance?.find( + (g) => + g.id === + (data?.basic_insurance?.value ? data?.basic_insurance.value.id : false) + ); + }; -function Form({ changeData, data, updateSelect, isForAnother }) { return (
- updateSelect(val, "value", name)} label="نوع بیمه" - name="first" - list={bime} + name="basic_insurance" + list={insurance} + value={findVal()} />
diff --git a/components/appointment/detail/index.js b/components/appointment/detail/index.js index 1cdf5a0..e384397 100644 --- a/components/appointment/detail/index.js +++ b/components/appointment/detail/index.js @@ -1,9 +1,10 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { Button } from "@mui/material"; import AddCircleBlueA from "@/components/icons/AddCircleBlueA"; import ArrowLeftB from "@/components/icons/ArrowLeftB"; import ButtonFixed from "../paying/ButtonFixed"; import Form from "./Form"; +import { request } from "@/services/response"; function Detail({ isForAnother, @@ -14,6 +15,7 @@ function Detail({ fadeElement, setIsPay, }) { + const [insurance, setInsurance] = useState(); const [selected, setSelected] = useState({ first: "", second: "", @@ -31,6 +33,19 @@ function Detail({ const updateSelect = (event, name) => setSelected({ ...selected, [name]: event }); + const newStep = () => { + // if(data) + setStep((prev) => prev + 1); + }; + + useEffect(() => { + request.getInsuranceType().then((res) => { + if (res && res.data) { + setInsurance(res.data); + } + }); + }, []); + return ( // ${typePay === 'success' || typePay === 'failed' ? 'bg-transparent border-transparent md:bg-[#FFF] md:border-[#EFEFEF]' : ''}
@@ -43,10 +58,11 @@ function Detail({ {isForAnother ? "اطلاعات کاربر جدید" : "اطلاعات حساب کاربری"}

{!isForAnother && (

- آدرس: {doctor.location} + آدرس: {doctor?.location}

  • diff --git a/components/appointment/information/Head.js b/components/appointment/information/Head.js index 080a65c..7fe5ee7 100644 --- a/components/appointment/information/Head.js +++ b/components/appointment/information/Head.js @@ -16,16 +16,16 @@ function Head({ doctor }) { h-[40px] sm:h-[58px] md:h-[77px] lg:h-[95px] " alt="profile doctor" - src={doctor.img} + src={doctor?.img} height={95} width={95} />

    - {doctor.name} + {doctor?.name}

    - تخصص: {doctor.expertise} + تخصص: {doctor?.expertise}

    diff --git a/components/dashboard/userAccount/detailUser/information/component/AutoSelector.js b/components/dashboard/userAccount/detailUser/information/component/AutoSelector.js index 5a506fe..34cca06 100644 --- a/components/dashboard/userAccount/detailUser/information/component/AutoSelector.js +++ b/components/dashboard/userAccount/detailUser/information/component/AutoSelector.js @@ -2,30 +2,18 @@ import BottomSelect from "@/components/icons/BottomSelect"; import { Autocomplete, Button, TextField } from "@mui/material"; import { styleTextSelectRight } from "@/mui"; -function AutoSelector({ - list, - value, - isError, - updateData, - label, - error, - disabled = false, - listboxProps, - name, -}) { +function AutoSelector({ list, value, updateData, label, error, name }) { return ( { if (typeof option === "string") return option; return option?.name || option?.label || ""; }} className="!w-full !rounded-lg auto-complete-selector" - onChange={(e, newValue) => { + onChange={(_, newValue) => { updateData(name, newValue?.label || newValue || ""); }} sx={{ @@ -62,9 +50,6 @@ function AutoSelector({ { border: "1px solid #5559CE !important", }, - "& .MuiOutlinedInput-notchedOutline": { - border: isError ? "1px solid red !important" : "", - }, }} renderOption={(props, option) => (