From c74c81cb4ed645495fac8f8a70c744e1d9e3df40 Mon Sep 17 00:00:00 2001 From: leon666 Date: Sun, 17 Dec 2023 00:38:01 +0800 Subject: [PATCH] refactor: use antd third party library to enhance the user experience --- src/components/Cards/AppointmentCard.js | 7 ++++--- src/components/Cards/BookingCard.js | 7 ++++--- src/components/Cards/DashCard.js | 2 +- src/components/Cards/DocListCard.js | 5 +++-- src/components/Cards/DuePaymentCard.js | 7 ++++--- src/components/Cards/FeedbackCard.js | 13 +++++++------ src/components/Cards/VerifyCard.js | 13 +++++++------ src/components/DashBar/DashBar.js | 3 ++- src/components/FileUploader/FileUploader.js | 7 ++++--- src/components/Payments/Card/CardPay.js | 7 ++++--- src/components/Payments/Cash/CashPay.js | 7 ++++--- src/components/Payments/UPI/UpiPay.js | 7 ++++--- src/pages/AdminDash/Tabs/DocList.js | 5 +++-- src/pages/AdminDash/Tabs/Feedbacks.js | 5 +++-- src/pages/AdminDash/Tabs/GenerateStats.js | 5 +++-- src/pages/AdminDash/Tabs/VerifySignUp.js | 5 +++-- src/pages/DoctorDash/Tabs/Appointments.js | 5 +++-- src/pages/DoctorDash/Tabs/UploadPrescription.js | 5 +++-- src/pages/PatientDash/Tabs/Feedback.js | 5 +++-- src/pages/PatientDash/Tabs/MakePayment.js | 5 +++-- src/pages/PatientDash/Tabs/MyAppointments.js | 5 +++-- src/pages/PatientDash/Tabs/Prescriptions.js | 5 +++-- src/pages/StaffDash/Tabs/CancelAppointment.js | 7 ++++--- src/pages/StaffDash/Tabs/CardPayment.js | 7 ++++--- src/pages/StaffDash/Tabs/MakePayment.js | 7 ++++--- 25 files changed, 90 insertions(+), 66 deletions(-) diff --git a/src/components/Cards/AppointmentCard.js b/src/components/Cards/AppointmentCard.js index 68cc284..a3337ad 100644 --- a/src/components/Cards/AppointmentCard.js +++ b/src/components/Cards/AppointmentCard.js @@ -8,6 +8,7 @@ import CancelIcon from "@mui/icons-material/Cancel"; import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import API from "../../api"; +import { message } from "antd"; export default function AppointmentCard(props) { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -19,15 +20,15 @@ export default function AppointmentCard(props) { }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.erroMsg); + message.error(res.data.erroMsg); } else { setOpenBackdrop(false); - alert(res.data.msg); + message.error(res.data.msg); window.location.reload(); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/components/Cards/BookingCard.js b/src/components/Cards/BookingCard.js index 8dc0f6e..174f9fa 100644 --- a/src/components/Cards/BookingCard.js +++ b/src/components/Cards/BookingCard.js @@ -11,6 +11,7 @@ import { useNavigate, createSearchParams } from "react-router-dom"; import jwt from "jsonwebtoken"; import API from "../../api"; +import { message } from "antd"; export default function BookingCard(props) { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -27,7 +28,7 @@ export default function BookingCard(props) { if (props.linkto === "staff") { setOpenBackdrop(false); if (!validateEmail(props.ptemail)) { - alert("Enter a valid email"); + message.error("Enter a valid email"); return; } } @@ -67,7 +68,7 @@ export default function BookingCard(props) { const res = await API.bookAppointment(postData); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); navigate({ @@ -81,7 +82,7 @@ export default function BookingCard(props) { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/components/Cards/DashCard.js b/src/components/Cards/DashCard.js index b4dcbd3..7d09eaf 100644 --- a/src/components/Cards/DashCard.js +++ b/src/components/Cards/DashCard.js @@ -5,7 +5,7 @@ import Typography from "@mui/material/Typography"; import { useNavigate, useLocation, createSearchParams } from "react-router-dom"; import "./DashCard.css"; import { PaymentContext } from "../../pages/PatientDash/Tabs/MakePayment"; -import { StaffPaymentContext } from "../Dashboards/StaffDash/Tabs/MakePayment"; +import { StaffPaymentContext } from "../../pages/StaffDash/Tabs/MakePayment"; export default function DashCard(props) { const payment = React.useContext( diff --git a/src/components/Cards/DocListCard.js b/src/components/Cards/DocListCard.js index d2bd10d..b60d353 100644 --- a/src/components/Cards/DocListCard.js +++ b/src/components/Cards/DocListCard.js @@ -11,6 +11,7 @@ import TextField from "@mui/material/TextField"; import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import API from "../../api"; +import { message } from "antd"; const styles = { @@ -46,7 +47,7 @@ export default function DocListCard(props) { const res = await API.updateFee({ docName: props.heading, fee: newFee }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); setNewFee(""); @@ -54,7 +55,7 @@ export default function DocListCard(props) { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/components/Cards/DuePaymentCard.js b/src/components/Cards/DuePaymentCard.js index d7673ce..03347ea 100644 --- a/src/components/Cards/DuePaymentCard.js +++ b/src/components/Cards/DuePaymentCard.js @@ -10,6 +10,7 @@ import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import { useNavigate, createSearchParams } from "react-router-dom"; import API from "../../api"; +import { message } from "antd"; export default function DuePaymentCard(props) { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -33,15 +34,15 @@ export default function DuePaymentCard(props) { }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.erroMsg); + message.error(res.data.erroMsg); } else { setOpenBackdrop(false); - alert(res.data.msg); + message.error(res.data.msg); window.location.reload(); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/components/Cards/FeedbackCard.js b/src/components/Cards/FeedbackCard.js index 2402f57..ecafa10 100644 --- a/src/components/Cards/FeedbackCard.js +++ b/src/components/Cards/FeedbackCard.js @@ -12,6 +12,7 @@ import Tooltip from "@mui/material/Tooltip"; import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import API from "../../api"; +import { message } from "antd"; export default function FeedbackCard(props) { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -36,15 +37,15 @@ export default function FeedbackCard(props) { }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); setSubmit(true); - alert(res.data.msg); + message.error(res.data.msg); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } @@ -61,17 +62,17 @@ export default function FeedbackCard(props) { }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); setFeedbackText(""); setValue(0); setSubmit(false); - alert(res.data.msg); + message.error(res.data.msg); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/components/Cards/VerifyCard.js b/src/components/Cards/VerifyCard.js index 5e6b647..c5b1eb4 100644 --- a/src/components/Cards/VerifyCard.js +++ b/src/components/Cards/VerifyCard.js @@ -11,6 +11,7 @@ import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import { useNavigate, createSearchParams } from "react-router-dom"; import API from "../../api"; +import { message } from "antd"; const styleVerify = { backgroundColor: "#64dd17", @@ -41,7 +42,7 @@ export default function VerifyCard(props) { const res = await API.verify({ email: props.subheading }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); if (props.unvuser === "doctor") { @@ -54,14 +55,14 @@ export default function VerifyCard(props) { })}`, }); } else { - if (!alert(res.data.msg)) { + if (!message.error(res.data.msg)) { window.location.reload(); } } } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } @@ -72,16 +73,16 @@ export default function VerifyCard(props) { const res = await API.reject({ data: { email: props.subheading } }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); - if (!alert(res.data.msg)) { + if (!message.error(res.data.msg)) { window.location.reload(); } } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/components/DashBar/DashBar.js b/src/components/DashBar/DashBar.js index 8e4cd7a..da12a56 100644 --- a/src/components/DashBar/DashBar.js +++ b/src/components/DashBar/DashBar.js @@ -14,6 +14,7 @@ import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import { useNavigate } from "react-router-dom"; import API from "../../api"; +import { message } from "antd"; export default function DashBar() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -37,7 +38,7 @@ export default function DashBar() { } catch (error) { setOpenBackdrop(false); console.error(error); - alert(error.response.data.error); + message.error(error.response.data.error); } } diff --git a/src/components/FileUploader/FileUploader.js b/src/components/FileUploader/FileUploader.js index 26c5b8c..291b232 100644 --- a/src/components/FileUploader/FileUploader.js +++ b/src/components/FileUploader/FileUploader.js @@ -7,6 +7,7 @@ import Typography from "@mui/material/Typography"; import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import API from "../../api"; +import { message } from "antd"; const Input = styled("input")({ display: "none", @@ -50,18 +51,18 @@ export default function FileUploader(props) { const res = await API.uploadPrescription(formData); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); setFileName(null); setErrFileName(null); - if (!alert(res.data.msg)) { + if (!message.error(res.data.msg)) { window.location.reload(); } } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/components/Payments/Card/CardPay.js b/src/components/Payments/Card/CardPay.js index ce1cbe7..13d0539 100644 --- a/src/components/Payments/Card/CardPay.js +++ b/src/components/Payments/Card/CardPay.js @@ -19,6 +19,7 @@ import "react-credit-cards/es/styles-compiled.css"; import "./CardPay.css"; import API from "../../../api"; import { useSearchParams, useNavigate } from "react-router-dom"; +import { message } from "antd"; function CardPay() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -80,14 +81,14 @@ function CardPay() { const res = await API.makePayment({ pemail, demail, doa }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); - alert(res.data.msg); + message.error(res.data.msg); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.error(error); } setNumber(""); diff --git a/src/components/Payments/Cash/CashPay.js b/src/components/Payments/Cash/CashPay.js index 9962521..f670e12 100644 --- a/src/components/Payments/Cash/CashPay.js +++ b/src/components/Payments/Cash/CashPay.js @@ -8,6 +8,7 @@ import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import { useSearchParams, useNavigate } from "react-router-dom"; import API from "../../../api"; +import { message } from "antd"; function CashPay() { const navigate = useNavigate(); @@ -25,15 +26,15 @@ function CashPay() { const res = await API.makePayment({ pemail, demail, doa }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); - alert(res.data.msg); + message.error(res.data.msg); setConfirm(true); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.error(error); } } diff --git a/src/components/Payments/UPI/UpiPay.js b/src/components/Payments/UPI/UpiPay.js index 32f3f35..d6dc87c 100644 --- a/src/components/Payments/UPI/UpiPay.js +++ b/src/components/Payments/UPI/UpiPay.js @@ -8,6 +8,7 @@ import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import { useSearchParams, useNavigate } from "react-router-dom"; import API from "../../../api"; +import { message } from "antd"; function UpiPay() { const navigate = useNavigate(); @@ -25,15 +26,15 @@ function UpiPay() { const res = await API.makePayment({ pemail, demail, doa }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); - alert(res.data.msg); + message.error(res.data.msg); setConfirm(true); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.error(error); } } diff --git a/src/pages/AdminDash/Tabs/DocList.js b/src/pages/AdminDash/Tabs/DocList.js index bf00e18..7b701e1 100644 --- a/src/pages/AdminDash/Tabs/DocList.js +++ b/src/pages/AdminDash/Tabs/DocList.js @@ -9,6 +9,7 @@ import { Link } from "react-router-dom"; import DashBar from "../../../components/DashBar/DashBar"; import DocListCard from "../../../components/Cards/DocListCard"; import API from "../../../api"; +import { message } from "antd"; function DocList() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -21,14 +22,14 @@ function DocList() { const res = await API.docList(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); setDocs(res.data) } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/AdminDash/Tabs/Feedbacks.js b/src/pages/AdminDash/Tabs/Feedbacks.js index 7ad07e7..2df86cb 100644 --- a/src/pages/AdminDash/Tabs/Feedbacks.js +++ b/src/pages/AdminDash/Tabs/Feedbacks.js @@ -8,6 +8,7 @@ import API from "../../../api"; import Typography from "@mui/material/Typography"; import ViewFeedbackCard from "../../../components/Cards/ViewFeedbackCard"; import DashBar from "../../../components/DashBar/DashBar"; +import { message } from "antd"; function Feedbacks() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -21,7 +22,7 @@ function Feedbacks() { const res = await API.patientFeedbacks(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); setPf(res.data); @@ -31,7 +32,7 @@ function Feedbacks() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/AdminDash/Tabs/GenerateStats.js b/src/pages/AdminDash/Tabs/GenerateStats.js index f38598c..439421a 100644 --- a/src/pages/AdminDash/Tabs/GenerateStats.js +++ b/src/pages/AdminDash/Tabs/GenerateStats.js @@ -9,6 +9,7 @@ import CircularProgress from "@mui/material/CircularProgress"; import API from "../../../api"; import DashBar from "../../../components/DashBar/DashBar"; import StatsCard from "../../../components/Cards/StatsCard"; +import { message } from "antd"; function GenerateStats() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -25,7 +26,7 @@ function GenerateStats() { const res = await API.generateStats(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); setMrd(res.data.mrd); @@ -36,7 +37,7 @@ function GenerateStats() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/AdminDash/Tabs/VerifySignUp.js b/src/pages/AdminDash/Tabs/VerifySignUp.js index aece656..749c885 100644 --- a/src/pages/AdminDash/Tabs/VerifySignUp.js +++ b/src/pages/AdminDash/Tabs/VerifySignUp.js @@ -6,6 +6,7 @@ import CircularProgress from "@mui/material/CircularProgress"; import DashBar from "../../../components/DashBar/DashBar"; import VerifyCard from "../../../components/Cards/VerifyCard"; import API from "../../../api" +import { message } from "antd"; @@ -20,14 +21,14 @@ function VerifySignUp() { const res = await API.unverified(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.error); + message.error(res.data.error); } else { setOpenBackdrop(false); setUnvUsers(res.data); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/DoctorDash/Tabs/Appointments.js b/src/pages/DoctorDash/Tabs/Appointments.js index 4fdd18d..c84cd81 100644 --- a/src/pages/DoctorDash/Tabs/Appointments.js +++ b/src/pages/DoctorDash/Tabs/Appointments.js @@ -8,6 +8,7 @@ import jwt from "jsonwebtoken"; import API from "../../../api"; import DashBar from "../../../components/DashBar/DashBar"; import DocAppointmentCard from "../../../components/Cards/DocAppointmentCard"; +import { message } from "antd"; function Appointments() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -24,7 +25,7 @@ function Appointments() { const res = await API.myAppointments(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const appoints = res.data.filter( @@ -35,7 +36,7 @@ function Appointments() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/DoctorDash/Tabs/UploadPrescription.js b/src/pages/DoctorDash/Tabs/UploadPrescription.js index 0a4b00b..f621bf9 100644 --- a/src/pages/DoctorDash/Tabs/UploadPrescription.js +++ b/src/pages/DoctorDash/Tabs/UploadPrescription.js @@ -8,6 +8,7 @@ import jwt from "jsonwebtoken"; import DashBar from "../../../components/DashBar/DashBar"; import UploadPrescriptionCard from "../../../components/Cards/UploadPrescriptionCard"; import API from "../../../api"; +import { message } from "antd"; function UploadPrescription() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -24,7 +25,7 @@ function UploadPrescription() { const res = await API.myAppointments(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const appoints = res.data.filter( @@ -38,7 +39,7 @@ function UploadPrescription() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/PatientDash/Tabs/Feedback.js b/src/pages/PatientDash/Tabs/Feedback.js index 564d12c..9233114 100644 --- a/src/pages/PatientDash/Tabs/Feedback.js +++ b/src/pages/PatientDash/Tabs/Feedback.js @@ -8,6 +8,7 @@ import CircularProgress from "@mui/material/CircularProgress"; import API from "../../../api"; import DashBar from "../../../components/DashBar/DashBar"; import FeedbackCard from "../../../components/Cards/FeedbackCard"; +import { message } from "antd"; function Feedback() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -31,7 +32,7 @@ function Feedback() { const res = await API.myAppointments(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const appoints = res.data.filter( @@ -47,7 +48,7 @@ function Feedback() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/PatientDash/Tabs/MakePayment.js b/src/pages/PatientDash/Tabs/MakePayment.js index 4740cce..1159172 100644 --- a/src/pages/PatientDash/Tabs/MakePayment.js +++ b/src/pages/PatientDash/Tabs/MakePayment.js @@ -10,6 +10,7 @@ import API from "../../../api"; import Dashboard from "../../../components/Dashboards/Dashboard"; import DashBar from "../../../components/DashBar/DashBar"; import DuePaymentCard from "../../../components/Cards/DuePaymentCard"; +import { message } from "antd"; export const PaymentContext = React.createContext(); @@ -35,7 +36,7 @@ function MakePaymentPatinet() { const res = await API.duePayment(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const myUnpaid = res.data.filter((unp) => unp.pemail === ptemail); @@ -47,7 +48,7 @@ function MakePaymentPatinet() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/PatientDash/Tabs/MyAppointments.js b/src/pages/PatientDash/Tabs/MyAppointments.js index e59c478..3f305c6 100644 --- a/src/pages/PatientDash/Tabs/MyAppointments.js +++ b/src/pages/PatientDash/Tabs/MyAppointments.js @@ -12,6 +12,7 @@ import jwt from "jsonwebtoken"; import API from "../../../api"; import DashBar from "../../../components/DashBar/DashBar"; import AppointmentCard from "../../../components/Cards/AppointmentCard"; +import { message } from "antd"; function MyAppointments() { @@ -31,7 +32,7 @@ function MyAppointments() { const res = await API.myAppointments(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const appoints = res.data.filter( @@ -46,7 +47,7 @@ function MyAppointments() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/PatientDash/Tabs/Prescriptions.js b/src/pages/PatientDash/Tabs/Prescriptions.js index b3ac49f..3a2f73a 100644 --- a/src/pages/PatientDash/Tabs/Prescriptions.js +++ b/src/pages/PatientDash/Tabs/Prescriptions.js @@ -8,6 +8,7 @@ import CircularProgress from "@mui/material/CircularProgress"; import API from "../../../api"; import DashBar from "../../../components/DashBar/DashBar"; import PrescriptionCard from "../../../components/Cards/PrescriptionCard"; +import { message } from "antd"; function Prescriptions() { @@ -25,7 +26,7 @@ function Prescriptions() { const res = await API.prescriptions(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const prescs = res.data.filter((presc) => presc.pemail === ptemail); @@ -36,7 +37,7 @@ function Prescriptions() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/StaffDash/Tabs/CancelAppointment.js b/src/pages/StaffDash/Tabs/CancelAppointment.js index b33e909..e01250f 100644 --- a/src/pages/StaffDash/Tabs/CancelAppointment.js +++ b/src/pages/StaffDash/Tabs/CancelAppointment.js @@ -10,6 +10,7 @@ import CircularProgress from "@mui/material/CircularProgress"; import API from "../../../api"; import DashBar from "../../../components/DashBar/DashBar"; import AppointmentCard from "../../../components/Cards/AppointmentCard"; +import { message } from "antd"; function CancelAppointment() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -29,7 +30,7 @@ function CancelAppointment() { setOpenBackdrop(true); if (!validateEmail(email)) { setOpenBackdrop(false); - alert("Enter a valid email!"); + message.error("Enter a valid email!"); return; } try { @@ -37,7 +38,7 @@ function CancelAppointment() { const res = await API.myAppointments(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const appoints = res.data.filter( @@ -48,7 +49,7 @@ function CancelAppointment() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } } diff --git a/src/pages/StaffDash/Tabs/CardPayment.js b/src/pages/StaffDash/Tabs/CardPayment.js index 9ba19a7..8396c85 100644 --- a/src/pages/StaffDash/Tabs/CardPayment.js +++ b/src/pages/StaffDash/Tabs/CardPayment.js @@ -8,6 +8,7 @@ import Backdrop from "@mui/material/Backdrop"; import CircularProgress from "@mui/material/CircularProgress"; import { useSearchParams, useNavigate } from "react-router-dom"; import API from "../../../api"; +import { message } from "antd"; function CardPaymentStaff() { const [openBackdrop, setOpenBackdrop] = useState(false); @@ -24,15 +25,15 @@ function CardPaymentStaff() { const res = await API.makePayment({ pemail, demail, doa }); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); - alert(res.data.msg); + message.error(res.data.msg); setConfirm(true); } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.error(error); } } diff --git a/src/pages/StaffDash/Tabs/MakePayment.js b/src/pages/StaffDash/Tabs/MakePayment.js index f92d6e3..7521677 100644 --- a/src/pages/StaffDash/Tabs/MakePayment.js +++ b/src/pages/StaffDash/Tabs/MakePayment.js @@ -12,6 +12,7 @@ import API from "../../../api"; import Dashboard from "../../../components/Dashboards/Dashboard"; import DashBar from "../../../components/DashBar/DashBar"; import DuePaymentCard from "../../../components/Cards/DuePaymentCard"; +import { message } from "antd"; export const StaffPaymentContext = React.createContext(); @@ -40,7 +41,7 @@ function MakePaymentStaff() { setOpenBackdrop(true); if (!validateEmail(email)) { setOpenBackdrop(false); - alert("Enter a valid Email."); + message.error("Enter a valid Email."); return; } try { @@ -48,7 +49,7 @@ function MakePaymentStaff() { const res = await API.duePayment(); if (res.data.error) { setOpenBackdrop(false); - alert(res.data.errorMsg); + message.error(res.data.errorMsg); } else { setOpenBackdrop(false); const unpaids = res.data.filter((unp) => unp.pemail === ptemail); @@ -57,7 +58,7 @@ function MakePaymentStaff() { } } catch (error) { setOpenBackdrop(false); - alert(error.response.data.errorMsg); + message.error(error.response.data.errorMsg); console.log(error); } }