diff --git a/app/appointment/[slug]/page.js b/app/appointment/[slug]/page.js new file mode 100644 index 0000000..32db7b9 --- /dev/null +++ b/app/appointment/[slug]/page.js @@ -0,0 +1,21 @@ +import AppointmentPage from "@/components/appointment"; +import { getStateInfo } from "@/lib/getStateInfo"; +import axios from "axios"; + +async function Appointment({ params: { slug } }) { + const { matchedCity } = getStateInfo(); + + let apt = null; + try { + const response = await axios.get( + "https://back-dev.clinic-pro.ir/api/v1/appointment-slots" + ); + apt = response.data.data; + } catch (error) { + // console.error("problem with req:", error.message); + } + + return ; +} + +export default Appointment; diff --git a/app/booking/[slug]/page.js b/app/booking/[slug]/page.js deleted file mode 100644 index a46998b..0000000 --- a/app/booking/[slug]/page.js +++ /dev/null @@ -1,10 +0,0 @@ -import BookingPage from "@/components/booking"; -import { getStateInfo } from "@/lib/getStateInfo"; - -function Booking({ params: { slug } }) { - const { matchedCity } = getStateInfo(); - - return ; -} - -export default Booking; diff --git a/app/component/LoadingComponent.js b/app/component/LoadingComponent.js new file mode 100644 index 0000000..6b33b01 --- /dev/null +++ b/app/component/LoadingComponent.js @@ -0,0 +1,18 @@ +import { CircularProgress } from "@mui/material"; +import React from "react"; + +function LoadingComponent({ children, loading }) { + return ( +
+ {loading ? ( +
+ +
+ ) : ( + children + )} +
+ ); +} + +export default LoadingComponent; diff --git a/app/component/date/datePicker/LoadingDate.js b/app/component/date/datePicker/LoadingDate.js new file mode 100644 index 0000000..1d74ade --- /dev/null +++ b/app/component/date/datePicker/LoadingDate.js @@ -0,0 +1,16 @@ +import { Skeleton } from "@mui/material"; +import React from "react"; + +function LoadingDate({ loading }) { + if (loading) { + return ( + + ); + } +} + +export default LoadingDate; diff --git a/app/component/date/datePicker/NextIconDatePicker.js b/app/component/date/datePicker/NextIconDatePicker.js deleted file mode 100644 index bb5937f..0000000 --- a/app/component/date/datePicker/NextIconDatePicker.js +++ /dev/null @@ -1,22 +0,0 @@ -import { Button } from "@mui/material"; -import Image from "next/image"; - -function NextIconDatePicker({ nextIconDatePicker }) { - return ( - - ); -} - -export default NextIconDatePicker; diff --git a/app/component/date/datePicker/PrevIconDatePicker.js b/app/component/date/datePicker/PrevIconDatePicker.js deleted file mode 100644 index 61398ef..0000000 --- a/app/component/date/datePicker/PrevIconDatePicker.js +++ /dev/null @@ -1,22 +0,0 @@ -import { Button } from "@mui/material"; -import Image from "next/image"; - -function PrevIconDatePicker({ prevIconDatePicker }) { - return ( - - ); -} - -export default PrevIconDatePicker; diff --git a/app/component/date/datePicker/date/FirstDatePicker.js b/app/component/date/datePicker/date/FirstDatePicker.js new file mode 100644 index 0000000..56e867c --- /dev/null +++ b/app/component/date/datePicker/date/FirstDatePicker.js @@ -0,0 +1,41 @@ +import React from "react"; +import { DatePicker } from "jalaali-react-date-picker"; +import { nextIconData, prevIconData } from "./dataIcon"; +import LoadingDate from "../LoadingDate"; +import Image from "next/image"; + +function FirstDatePicker({ + startDate, + loading, + handleDisableDate, + nextIconDatePickerF, + prevIconDatePickerF, + prevIconDatePickerS, + handleStartDateChange, +}) { + return ( +
+ + } + prevIcon={ + prevIconDatePickerS.current.click()} + /> + } + isFirst={true} + onChange={handleStartDateChange} + disabledDates={(e) => handleDisableDate(e)} + /> + +
+ ); +} + +export default FirstDatePicker; diff --git a/app/component/date/datePicker/date/SecondDatePicker.js b/app/component/date/datePicker/date/SecondDatePicker.js new file mode 100644 index 0000000..e50e9f1 --- /dev/null +++ b/app/component/date/datePicker/date/SecondDatePicker.js @@ -0,0 +1,42 @@ +import React from "react"; +import { DatePicker } from "jalaali-react-date-picker"; +import { nextIconData, prevIconData } from "./dataIcon"; +import LoadingDate from "../LoadingDate"; +import Image from "next/image"; + +function SecondDatePicker({ + endDate, + loading, + handleDisableDate, + nextIconDatePickerF, + nextIconDatePickerS, + prevIconDatePickerS, + handleEndDateChange, +}) { + return ( +
+
+ !loading && nextIconDatePickerF.current.click()} + /> + } + prevIcon={ + + } + onChange={handleEndDateChange} + disabledDates={(e) => handleDisableDate(e)} + /> + +
+
+ ); +} + +export default SecondDatePicker; diff --git a/app/component/date/datePicker/date/dataIcon.js b/app/component/date/datePicker/date/dataIcon.js new file mode 100644 index 0000000..ff9af4f --- /dev/null +++ b/app/component/date/datePicker/date/dataIcon.js @@ -0,0 +1,16 @@ +export const fixedIconData = { + src: "/assets/icons/arrow-right.svg", + alt: "arrow", + height: 24, + width: 24, +}; + +export const nextIconData = { + ...fixedIconData, + className: "icon-left-datepicker cursor-pointer", +}; + +export const prevIconData = { + ...fixedIconData, + className: "icon-left-datepicker cursor-pointer rotate-180", +}; diff --git a/app/component/date/datePicker/index.js b/app/component/date/datePicker/index.js index 651ac79..20e849b 100644 --- a/app/component/date/datePicker/index.js +++ b/app/component/date/datePicker/index.js @@ -1,20 +1,20 @@ "use client"; import { useEffect, useRef, useState } from "react"; -import { DatePicker as DatePickerJalali } from "jalaali-react-date-picker"; -import { Skeleton } from "@mui/material"; -import NextIconDatePicker from "./NextIconDatePicker"; -import PrevIconDatePicker from "./PrevIconDatePicker"; +import FirstDatePicker from "./date/FirstDatePicker"; +import SecondDatePicker from "./date/SecondDatePicker"; function DatePicker({ date, updateDate }) { - const nextIconDatePicker = useRef(); - const prevIconDatePicker = useRef(); + const nextIconDatePickerF = useRef(); + const prevIconDatePickerF = useRef(); + const nextIconDatePickerS = useRef(); + const prevIconDatePickerS = useRef(); const [startDate, setStartDate] = useState(null); const [endDate, setEndDate] = useState(); const [loading, setLoading] = useState(true); - const handleStartDateChange = (date) => { + const handleStartDateChange = (date, e) => { if (date) { setStartDate(date); setEndDate(null); @@ -34,64 +34,34 @@ function DatePicker({ date, updateDate }) { }; useEffect(() => { - if (nextIconDatePicker.current) { - nextIconDatePicker.current.click(); + if (nextIconDatePickerS.current) { + nextIconDatePickerS.current.click(); + console.log(nextIconDatePickerS.current); + setLoading(false); } - }, [nextIconDatePicker]); + }, [nextIconDatePickerS]); return ( -
-
- - -
- } - prevIcon={ - - } - onChange={handleStartDateChange} - disabledDates={(e) => handleDisableDate(e)} - /> - {loading && ( - - )} -
-
-
- - } - prevIcon={ -
- -
- } - onChange={handleEndDateChange} - disabledDates={(e) => handleDisableDate(e)} - /> - {loading && ( - - )} -
-
+
+ +
); } diff --git a/app/component/date/dateTime/Hours.js b/app/component/date/dateTime/Hours.js index 794356f..eff8943 100644 --- a/app/component/date/dateTime/Hours.js +++ b/app/component/date/dateTime/Hours.js @@ -3,28 +3,30 @@ import { Button } from "@mui/material"; function Hours({ doctor, hour, setHour, value, nameHours }) { return (
    - {doctor[nameHours[value]].map((item, idx) => ( -
  • - -
  • - ))} + > + {item.hour} +

    + + + ))}
); } diff --git a/app/dashboard/page.js b/app/dashboard/page.js index 4010100..5f704e7 100644 --- a/app/dashboard/page.js +++ b/app/dashboard/page.js @@ -2,9 +2,8 @@ import Content from "@/components/dashboard/Content"; import { defineAbilitiesFor } from "@/lib/ability"; import { getUser } from "@/lib/auth"; import { getStateInfo } from "@/lib/getStateInfo"; -import { fetchReq } from "@/lib/req"; import { removeToken } from "@/utils"; -import { cookies, headers } from "next/headers"; +import { cookies } from "next/headers"; import { redirect } from "next/navigation"; export default async function Dashboard({ searchParams }) { diff --git a/app/doctor/[slug]/page.js b/app/doctor/[slug]/page.js index 7fa9ffb..eac2c2a 100644 --- a/app/doctor/[slug]/page.js +++ b/app/doctor/[slug]/page.js @@ -3,14 +3,26 @@ import Layout from "@/components/layout/StLayout"; import axios from "axios"; async function Doctor({ params: { slug } }) { - const response = await axios.get( - `https://back-dev.clinic-pro.ir/api/v1/doctor/${slug}` - ); - const doctor = response.data; + let doctors = null; + let doctor = null; + try { + const resDoctors = await axios.get( + "https://back-dev.clinic-pro.ir/api/v1/doctors?active=1" + ); + const resDoctor = await axios.get( + `https://back-dev.clinic-pro.ir/api/v1/doctor/${slug}` + ); + + doctor = resDoctor.data; + doctors = resDoctors.data.data; + } catch (error) { + // console.error("problem with req:", error.message); + // return redirect("/unauthorized"); + } return ( - + ); } diff --git a/app/doctors/page.js b/app/doctors/page.js index 90dc433..3293b69 100644 --- a/app/doctors/page.js +++ b/app/doctors/page.js @@ -11,10 +11,9 @@ async function Doctors({ searchParams }) { const response = await axios.get( "https://back-dev.clinic-pro.ir/api/v1/doctors" ); - doctors = response.data.$data; + doctors = response.data.data; } catch (error) { // console.error("problem with req:", error.message); - // return redirect("/unauthorized"); } return ( diff --git a/app/globals.css b/app/globals.css index bcbc7e9..ad601b2 100644 --- a/app/globals.css +++ b/app/globals.css @@ -885,3 +885,56 @@ html { .spin { animation: spin 1s linear infinite; } + +/* date picker appointment */ + +.datePickerApt + .first + .panel-header-wrapper + .center:first-child + .iconItem:first-child, +.datePickerApt + .first + .panel-header-wrapper + .center:last-child + .iconItem:last-child, +.datePickerApt + .second + .panel-header-wrapper + .center:first-child + .iconItem:first-child, +.datePickerApt + .second + .panel-header-wrapper + .center:last-child + .iconItem:last-child { + display: none; +} + +.datePickerApt #nextIconF, +.datePickerApt #prevIconS { + display: flex; +} + +@media (min-width: 768px) { + .datePickerApt #nextIconF, + .datePickerApt #prevIconS { + display: none; + } +} + +@media (min-width: 1024px) { + .datePickerApt #nextIconF, + .datePickerApt #prevIconS { + display: flex; + } +} + +@media (min-width: 1280px) { + .datePickerApt #nextIconF, + .datePickerApt #prevIconS { + display: none; + } +} + +/* end of date picker appointment */ diff --git a/components/booking/Content.js b/components/appointment/Content.js similarity index 100% rename from components/booking/Content.js rename to components/appointment/Content.js diff --git a/components/booking/date/PlaceVisit.js b/components/appointment/date/PlaceVisit.js similarity index 100% rename from components/booking/date/PlaceVisit.js rename to components/appointment/date/PlaceVisit.js diff --git a/components/appointment/date/Time/SelectDatePicker.js b/components/appointment/date/Time/SelectDatePicker.js new file mode 100644 index 0000000..452ddae --- /dev/null +++ b/components/appointment/date/Time/SelectDatePicker.js @@ -0,0 +1,20 @@ +import DatePicker from "@/app/component/date/datePicker"; +import { request } from "@/services/response"; +import { useEffect } from "react"; + +function SelectDatePicker() { + useEffect(() => { + request + .getAppointment(47, 1753859133) + .then((res) => { + console.log(res); + }) + .catch((err) => { + console.log(err); + }); + }); + + return ; +} + +export default SelectDatePicker; diff --git a/components/booking/date/Time/index.js b/components/appointment/date/Time/index.js similarity index 100% rename from components/booking/date/Time/index.js rename to components/appointment/date/Time/index.js diff --git a/components/booking/date/hour/index.js b/components/appointment/date/hour/index.js similarity index 100% rename from components/booking/date/hour/index.js rename to components/appointment/date/hour/index.js diff --git a/components/booking/date/index.js b/components/appointment/date/index.js similarity index 88% rename from components/booking/date/index.js rename to components/appointment/date/index.js index 586759a..cf77d58 100644 --- a/components/booking/date/index.js +++ b/components/appointment/date/index.js @@ -19,11 +19,11 @@ function Date({ doctor, setStep }) { isError={isError} />