diff --git a/app/component/ItemDoctor.js b/app/component/ItemDoctor.js
index bf4cc7b..40c7759 100644
--- a/app/component/ItemDoctor.js
+++ b/app/component/ItemDoctor.js
@@ -10,7 +10,6 @@ import ArrowLeftD from "@/components/icons/ArrowLeftD";
import ClockD from "@/components/icons/ClockD";
import LikeD from "@/components/icons/LikeD";
import PointD from "@/components/icons/PointD";
-import { convertTimestampToPersianDateSimple } from "@/helper";
function ItemDoctor({ doctor, loading, setDoctors }) {
const handleLoading = () => {
@@ -90,8 +89,8 @@ function ItemDoctor({ doctor, loading, setDoctors }) {
: "bg-[rgba(211,_47,_47,_0.04)] text-[#D32F2F]"
}`}
>
- {Number(doctor?.active)
- ? `اولین نوبت آزاد: ${convertTimestampToPersianDateSimple(doctor?.free_turn)}`
+ {doctor?.free_turn
+ ? `اولین نوبت آزاد: ${doctor?.free_turn}`
: "نوبت ندارد"}
diff --git a/app/component/PaginationContent.js b/app/component/PaginationContent.js
index dc3222f..d2503a5 100644
--- a/app/component/PaginationContent.js
+++ b/app/component/PaginationContent.js
@@ -1,25 +1,28 @@
-import { Pagination } from "@mui/material";
+import { Pagination, useMediaQuery, useTheme } from "@mui/material";
function PaginationContent({ page, pageDetail, changePage, limit = 12 }) {
+ const theme = useTheme();
+ const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
+
const count = Math.ceil(pageDetail.totalRecords / limit);
return (
-
- {numberToArStyle(data)}%
+
+ {data ? `${numberToArStyle(data)}%` : "بدون نمره"}
);
diff --git a/app/component/ProgressChange.js b/app/component/ProgressChange.js
index a83e3fe..d02742a 100644
--- a/app/component/ProgressChange.js
+++ b/app/component/ProgressChange.js
@@ -2,7 +2,7 @@ import { Slider } from "@mui/material";
import { useState } from "react";
function ProgressChange({ data, changeData, parent }) {
- const [value, setValue] = useState(70);
+ const [value, setValue] = useState(data.progress);
return (
diff --git a/app/component/date/dateTime/SendAppo.js b/app/component/date/dateTime/SendAppo.js
index 2c468c1..86468b8 100644
--- a/app/component/date/dateTime/SendAppo.js
+++ b/app/component/date/dateTime/SendAppo.js
@@ -1,5 +1,4 @@
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";
diff --git a/components/clinics/list/index.js b/components/clinics/list/index.js
index 2c66ce0..9889af8 100644
--- a/components/clinics/list/index.js
+++ b/components/clinics/list/index.js
@@ -37,9 +37,8 @@ function List({
.then((res) => {
if (res.data) setFilteredClinics(res.data);
})
- .catch((err) => {
- console.log(err);
- })
+ .catch(() => {})
+ //
.finally(() => setLoading(false));
};
diff --git a/components/doctor/appointmentList/ItemAppointment.js b/components/doctor/appointmentList/ItemAppointment.js
index a376ec7..d5f8728 100644
--- a/components/doctor/appointmentList/ItemAppointment.js
+++ b/components/doctor/appointmentList/ItemAppointment.js
@@ -5,7 +5,6 @@ import GreenCalendarTurn from "@/components/icons/GreenCalendarTurn";
import { Button } from "@mui/material";
import Image from "next/image";
import Link from "next/link";
-import { convertTimestampToPersianDateSimple } from "@/helper";
function ItemAppointment({ turn, loading }) {
return (
@@ -45,8 +44,8 @@ function ItemAppointment({ turn, loading }) {
- {Number(turn?.free_turn)
- ? `اولین نوبت آزاد: ${convertTimestampToPersianDateSimple(turn?.free_turn)}`
+ {turn?.free_turn
+ ? `اولین نوبت آزاد: ${turn?.free_turn}`
: "نوبت ندارد"}
diff --git a/components/doctor/detailDoctor/cards/comments/chart/index.js b/components/doctor/detailDoctor/cards/comments/chart/index.js
index 4c7faf8..2620b8b 100644
--- a/components/doctor/detailDoctor/cards/comments/chart/index.js
+++ b/components/doctor/detailDoctor/cards/comments/chart/index.js
@@ -7,6 +7,7 @@ import TextLoading from "@/app/component/loading/Text";
import CustomLoading from "@/app/component/loading/Custom";
function Chart({ comments, doctor }) {
+ const averages = doctor?.average_rate?.averages;
return (
- {doctor?.average_rate?.averages &&
- Object.values(doctor?.average_rate?.averages).map((item, idx) => (
-
-
-
- ))}
+ {Object.values(averages ? averages : Array(5).fill(false)).map(
+ (item, idx) => (
+
+ )
+ )}
diff --git a/components/doctor/detailDoctor/cards/comments/index.js b/components/doctor/detailDoctor/cards/comments/index.js
index d4ed233..a12d96c 100644
--- a/components/doctor/detailDoctor/cards/comments/index.js
+++ b/components/doctor/detailDoctor/cards/comments/index.js
@@ -1,3 +1,5 @@
+"use client";
+
import Chart from "./chart";
import Comment from "@/app/component/comment";
import ModalAnswer from "./modal/ModalAnswer";
diff --git a/components/doctor/detailDoctor/cards/comments/modal/ModalAnswer.js b/components/doctor/detailDoctor/cards/comments/modal/ModalAnswer.js
index 2d04b36..0ef9be6 100644
--- a/components/doctor/detailDoctor/cards/comments/modal/ModalAnswer.js
+++ b/components/doctor/detailDoctor/cards/comments/modal/ModalAnswer.js
@@ -1,15 +1,13 @@
"use client";
-import { useState } from "react";
+import { useEffect, useState } from "react";
import { styleDefault } from "@/mui";
-import { Box, Button, Modal, Rating } from "@mui/material";
-import CloseModalD from "@/components/icons/CloseModalD";
-import Field from "@/app/component/fields/Field";
-import ArrowLeftD from "@/components/icons/ArrowLeftD";
-import ProgressChange from "@/app/component/ProgressChange";
+import { Box, Modal } from "@mui/material";
import ProgressDetail from "@/data/progress_detail.json";
-import { request } from "@/services/response";
import BtnNewComment from "./BtnNewComment";
+import Content from "./content";
+import { request } from "@/services/response";
+import Cookies from "js-cookie";
function ModalAnswer({ doctor }) {
const [open, setOpen] = useState(false);
@@ -17,67 +15,41 @@ function ModalAnswer({ doctor }) {
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const [comment, setComment] = useState({
+ defaultRate: false,
+ uuid: "",
rate: ProgressDetail,
detail: {
comment: "",
doctor_id: doctor?.id,
},
});
- const changeData = (parent, child, value) => {
- if (parent === "rate") {
- setComment((prevComment) => ({
- ...prevComment,
- rate: prevComment.rate.map((item) =>
- item.name === child ? { ...item, progress: value } : item
- ),
- }));
- } else {
- setComment((prevComment) => ({
- ...prevComment,
- [parent]: {
- ...prevComment[parent],
- [child]: value,
- },
- }));
+
+ useEffect(() => {
+ const isLogged = Cookies.get("access_token");
+
+ if (doctor && doctor.uuid && isLogged) {
+ let newRate = comment.rate;
+ request
+ .getDoctorRate(doctor.uuid)
+ .then((res) => {
+ if (res.doctor_id) {
+ newRate.map((item) => (item.progress = res[item.name]));
+ setComment({
+ ...comment,
+ defaultRate: true,
+ uuid: res.uuid,
+ rate: newRate,
+ });
+ }
+ const data = res.response?.data;
+ // setComment();
+ })
+ .catch((err) => {
+ const data = err.response?.data;
+ // setComment();
+ });
}
- };
- const averageRate =
- comment.rate.reduce((sum, item) => sum + item.progress, 0) /
- comment.rate.length /
- 20;
-
- const sendReq = () => {
- setLoading(true);
- request
- .postDoctorComment(comment.detail)
- .then(() => {
- let newComment = comment.rate;
- newComment = {
- correct_diagnosis: newComment[1].progress,
- doctor_skill: newComment[4].progress,
- behavior_doctor: newComment[2].progress,
- office_cleaning: newComment[3].progress,
- time_in_office: newComment[0].progress,
- doctor: doctor?.id,
- rate: averageRate,
- };
-
- request
- .postDoctorRate(newComment)
- .then((res) => {
- setLoading(false);
- setOpen(false);
- })
- .catch((err) => {
- setLoading(false);
- setOpen(false);
- });
- })
- .catch((err) => {
- setLoading(false);
- setOpen(false);
- });
- };
+ }, []);
return (
<>
@@ -87,56 +59,15 @@ function ModalAnswer({ doctor }) {
sx={styleDefault}
className="!w-full md:!min-w-[485px] !h-full md:!w-fit md:!h-fit !px-[24px] !pt-[22px] !pb-[30px] !rounded-none md:!rounded-lg"
>
-
-
- امتیاز شما به دکتر مهران امینی
-
-
-
-
-
-
-
- {comment.rate?.map((item, idx) => (
-
- ))}
-
-
-
متن نظر
-
changeData("detail", "comment", val)}
- title="نظر خود را بنویسید..."
- />
-
-
>
diff --git a/components/doctor/detailDoctor/cards/comments/modal/content/Form.js b/components/doctor/detailDoctor/cards/comments/modal/content/Form.js
new file mode 100644
index 0000000..5063116
--- /dev/null
+++ b/components/doctor/detailDoctor/cards/comments/modal/content/Form.js
@@ -0,0 +1,69 @@
+import React from "react";
+import Field from "@/app/component/fields/Field";
+import { Button } from "@mui/material";
+import { request } from "@/services/response";
+import ArrowLeftD from "@/components/icons/ArrowLeftD";
+
+function Form({ doctor, changeData, setOpen, comment, loading, setLoading }) {
+ console.log(comment.rate);
+
+ const sendReq = () => {
+ setLoading(true);
+
+ request
+ .postDoctorComment(comment.detail)
+ .then((res) => {
+ let newComment = comment.rate;
+ newComment = {
+ doctor_id: doctor?.id,
+ accuracy_of_diagnosis: newComment[1].progress,
+ doctor_expertise: newComment[4].progress,
+ doctor_behavior: newComment[2].progress,
+ clinic_cleanliness: newComment[3].progress,
+ waiting_time_at_clinic: newComment[0].progress,
+ };
+
+ request[comment.defaultRate ? "patchDoctorRate" : "postDoctorRate"](
+ newComment,
+ comment.uuid
+ )
+ .then((res) => {
+ setLoading(false);
+ setOpen(false);
+ })
+ .catch((err) => {
+ setLoading(false);
+ setOpen(false);
+ });
+ })
+ .catch((err) => {
+ setLoading(false);
+ setOpen(false);
+ });
+ };
+
+ return (
+
+
متن نظر
+
changeData("detail", "comment", val)}
+ title="نظر خود را بنویسید..."
+ />
+
+
+ );
+}
+
+export default Form;
diff --git a/components/doctor/detailDoctor/cards/comments/modal/content/Rates.js b/components/doctor/detailDoctor/cards/comments/modal/content/Rates.js
new file mode 100644
index 0000000..d01eadc
--- /dev/null
+++ b/components/doctor/detailDoctor/cards/comments/modal/content/Rates.js
@@ -0,0 +1,19 @@
+import ProgressChange from "@/app/component/ProgressChange";
+import React from "react";
+
+function Rates({ comment, changeData }) {
+ return (
+
+ {comment.rate?.map((item, idx) => (
+
+ ))}
+
+ );
+}
+
+export default Rates;
diff --git a/components/doctor/detailDoctor/cards/comments/modal/content/index.js b/components/doctor/detailDoctor/cards/comments/modal/content/index.js
new file mode 100644
index 0000000..02074bd
--- /dev/null
+++ b/components/doctor/detailDoctor/cards/comments/modal/content/index.js
@@ -0,0 +1,73 @@
+import Form from "./Form";
+import Rates from "./Rates";
+import { Rating } from "@mui/material";
+import CloseModalD from "@/components/icons/CloseModalD";
+
+function Content({
+ doctor,
+ comment,
+ setOpen,
+ loading,
+ setComment,
+ setLoading,
+ handleClose,
+}) {
+ const averageRate =
+ comment.rate?.reduce((sum, item) => sum + item.progress, 0) /
+ comment.rate?.length /
+ 20;
+ const changeData = (parent, child, value) => {
+ if (parent === "rate") {
+ setComment((prevComment) => ({
+ ...prevComment,
+ rate: prevComment.rate.map((item) =>
+ item.name === child ? { ...item, progress: value } : item
+ ),
+ }));
+ } else {
+ setComment((prevComment) => ({
+ ...prevComment,
+ [parent]: {
+ ...prevComment[parent],
+ [child]: value,
+ },
+ }));
+ }
+ };
+
+ return (
+ <>
+
+
+ امتیاز شما به دکتر مهران امینی
+
+
+
+
+
+
+
+
+ >
+ );
+}
+
+export default Content;
diff --git a/components/doctors/listDoctors/index.js b/components/doctors/listDoctors/index.js
index c4a0640..08beaae 100644
--- a/components/doctors/listDoctors/index.js
+++ b/components/doctors/listDoctors/index.js
@@ -1,7 +1,7 @@
import { useState } from "react";
import ItemDoctor from "@/app/component/ItemDoctor";
import PaginationContent from "@/app/component/PaginationContent";
-import { QueryForDoctorsFilter, QueryForDoctorsReq } from "@/helper";
+import { QueryForDoctorsReq } from "@/helper";
import { request } from "@/services/response";
import { useRouter } from "next/navigation";
@@ -37,18 +37,12 @@ function ListDoctors({
delete params.name;
}
- console.log(params);
-
request
.getDoctors(params)
.then((res) => {
- console.log(res);
-
if (res.data) setDoctors(res.data);
})
- .catch((err) => {
- console.log(err);
- })
+ .catch((err) => {})
.finally(() => setLoading(false));
};
diff --git a/components/register/verificationPage/SendReq.js b/components/register/verificationPage/SendReq.js
index ccf5952..47e60fd 100644
--- a/components/register/verificationPage/SendReq.js
+++ b/components/register/verificationPage/SendReq.js
@@ -27,36 +27,51 @@ function SendReq({
handleSetCookie(response);
}
})
- .catch(() => {});
+ .catch(() => {
+ setLoading(false);
+ setIsError(true);
+ });
};
const handleSetCookie = (response) => {
const expiresTime = handleTimeExpiresToken(response.expires_in);
- Cookies.set("access_token", response.access_token, {
- expires: expiresTime.accessTokenExpires,
+ const hostname = window.location.hostname;
+ const isHttps = window.location.protocol === "https:";
+ const isLocalhost = hostname.includes("localhost");
+
+ // تنظیمات پایه
+ let cookieOptions = {
path: "/",
- secure: true,
- sameSite: "strict",
- });
+ sameSite: "lax",
+ expires: expiresTime.accessTokenExpires,
+ };
+
+ // اگر روی دامنه اصلی و https بود
+ if (!isLocalhost && isHttps) {
+ cookieOptions = {
+ ...cookieOptions,
+ secure: true,
+ domain: ".nobat724.com",
+ };
+ }
+
+ Cookies.set("access_token", response.access_token, cookieOptions);
Cookies.set("refresh_token", response.refresh_token, {
+ ...cookieOptions,
expires: expiresTime.refreshTokenExpires,
- path: "/",
- secure: true,
- sameSite: "strict",
});
Cookies.set("uuid", uuid, {
+ ...cookieOptions,
expires: expiresTime.refreshTokenExpires,
- path: "/",
- secure: true,
- sameSite: "strict",
});
- getInfo(response.access_token);
+
+ getInfo(response.access_token, cookieOptions);
};
- const getInfo = (token) => {
+ const getInfo = (token, cookieOptions) => {
request
.getUserInfo({
headers: {
@@ -66,21 +81,20 @@ function SendReq({
.then((res) => {
setLoading(false);
if (res && res.uuid) {
+ Cookies.set("userInfo", JSON.stringify(res), cookieOptions);
window.location.pathname = "/";
- Cookies.set("userInfo", JSON.stringify(res), {
- path: "/",
- secure: true,
- sameSite: "strict",
- });
}
})
- .catch(() => {});
+ .catch(() => {
+ setLoading(false);
+ setIsError(true);
+ });
};
return (