diff --git a/src/_nav.js b/src/_nav.js index 58396fc..445e5c5 100644 --- a/src/_nav.js +++ b/src/_nav.js @@ -128,6 +128,13 @@ const _nav = [ }, ], }, + { + component: CNavItem, + name: "Patients", + icon: , + to: "/patients", + group: "Patients", + }, // { // component: CNavGroup, // name: "Orders", diff --git a/src/routes.js b/src/routes.js index 0ac335e..52fe84a 100644 --- a/src/routes.js +++ b/src/routes.js @@ -149,6 +149,7 @@ import AddEmployee from "./views/EmployeeAccess/addEmployee"; import EditEmployee from "./views/EmployeeAccess/editEmployee"; import ExportToExcel from "./views/exportExcel"; import Currency from "./views/configuration/Currency"; +import Patient from "./views/Patients/Patient"; const routes = [ // { path: "/", exact: true, name: "Home", navName: "" }, //dashboard @@ -236,6 +237,13 @@ const routes = [ element: Categories, navName: "Product Management", }, + + { + path: "/patients", + name: "Patients", + element: Patient, + navName: "Patients", + }, //Gst tax { path: "/vat", diff --git a/src/views/Patients/Patient.js b/src/views/Patients/Patient.js new file mode 100644 index 0000000..3793926 --- /dev/null +++ b/src/views/Patients/Patient.js @@ -0,0 +1,639 @@ + + +import React, { useState, useEffect, useRef } from "react"; +import { Link } from "react-router-dom"; +import axios from "axios"; +import Button from "@material-ui/core/Button"; +import { useNavigate } from "react-router-dom"; +import { isAutheticated } from "src/auth"; +import swal from "sweetalert"; +const Patient = () => { + const token = isAutheticated(); + const navigate = useNavigate(); + const [loading, setLoading] = useState(false); + const [success, setSuccess] = useState(true); + const [patientsData, setPatientsData] = useState([]); + + const nameRef = useRef(); + // const categoryRef = useRef(); + const VerifyPatientRef = useRef(); + + const [currentPage, setCurrentPage] = useState(1); + const [itemPerPage, setItemPerPage] = useState(10); + const [totalData, setTotalData] = useState(0); + + // const { + // edit, + // add, + // delete: deletepermission, + // } = checkPermission("Patient Master"); + const getPatientsData = async () => { + setLoading(true); + await axios + .get(`/api/patient/getAll/`, { + headers: { + Authorization: `Bearer ${token}`, + }, + params: { + page: currentPage, + show: itemPerPage, + name: nameRef.current.value, + // category: categoryRef.current.value, + isVerified: VerifyPatientRef.current.value, + }, + }) + .then((res) => { + console.log("res.data?.data", res.data); + setPatientsData(res.data?.patient); + setTotalData(res.data?.total_data); + setLoading(false); + }) + .catch((err) => { + const msg = err?.response?.data?.message || "Something went wrong!"; + swal({ + title: err, + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + setLoading(false); + }); + + setLoading(false); + }; + + // const getCatagories = () => { + // axios + // .get(`/api/category/getCategories`, { + // headers: { + // "Access-Control-Allow-Origin": "*", + // Authorization: `Bearer ${token}`, + // }, + // }) + // .then((res) => { + // setCategories(res?.data?.categories); + // }); + // }; + + + // useEffect(() => { + // getCatagories(); + // }, []); + + useEffect(() => { + getPatientsData(); + }, [success, itemPerPage, currentPage]); + + const handleDelete = (id) => { + swal({ + title: "Are you sure?", + icon: "error", + buttons: { + Yes: { text: "Yes", value: true }, + Cancel: { text: "Cancel", value: "cancel" }, + }, + }).then((value) => { + if (value === true) { + axios + .delete(`/api/patient/delete/${id}`, { + headers: { + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + }) + .then((res) => { + swal({ + title: "Deleted", + text: "Patient Deleted successfully!", + icon: "success", + button: "ok", + }); + setSuccess((prev) => !prev); + }) + .catch((err) => { + let msg = err?.response?.data?.message + ? err?.response?.data?.message + : "Something went wrong!"; + swal({ + title: "Warning", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + }); + } + }); + }; + const handleVerifydPatient = (id) => { + swal({ + title: "Are you sure?", + icon: "warning", + buttons: { + Yes: { text: "Yes", value: true }, + Cancel: { text: "Cancel", value: "cancel" }, + }, + }).then((value) => { + if (value === true) { + axios + .patch(`/api/patient/admin/feature_product/status/${id}`, { + headers: { + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + }) + .then((res) => { + swal({ + title: "Changed", + text: " Verify Patient status changed successfully!", + icon: "success", + button: "ok", + }); + setSuccess((prev) => !prev); + }) + .catch((err) => { + let msg = err?.response?.data?.msg + ? err?.response?.data?.msg + : "Something went wrong!"; + swal({ + title: "Warning", + text: msg, + icon: "warning", + button: "ok", + dangerMode: true, + }); + }); + } + }); + }; + const handleStatus = (id) => { + swal({ + title: "Are you sure?", + icon: "warning", + buttons: { + Yes: { text: "Yes", value: true }, + Cancel: { text: "Cancel", value: "cancel" }, + }, + }).then((value) => { + if (value === true) { + axios + .patch(`/api/patient/admin/status/${id}`, { + headers: { + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + }) + .then((res) => { + swal({ + title: "Changed", + text: "Patient status changed successfully!", + icon: "success", + button: "ok", + }); + setSuccess((prev) => !prev); + }) + .catch((err) => { + swal({ + title: "Warning", + text: "Something went wrong!", + icon: "error", + button: "Retry", + dangerMode: true, + }); + }); + } + }); + }; + return ( +
+
+
+
+
+
+
+ Patients +
+ {/*
+ +
*/} +
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+ + +
+ {/*
+ + +
*/} +
+ + +
+
+ +
+
+ +
+ + + + {/* */} + + {/* */} + + + {/* */} + + + + + + + + {/* */} + + + + + + {loading ? ( + + + + ) : patientsData?.length > 0 ? ( + patientsData?.map((patient, i) => { + return ( + + {/* */} + + + + + + + + + + + + + + + + + {/* */} + + ); + }) + ) : ( + !loading && + patientsData?.length === 0 && ( + + + + ) + )} + +
ImageNameCategoryMobile No.PriceEmailVerifyDevice AddedRegister OnActions
+ Loading... +
+ {patient?.image && + patient?.image?.length !== 0 ? ( + <> + preview + + ) : ( +
+

No

+

image

+

uploaded!

+
+ )} +
{patient?.name}{patient?.mobileNumber}{patient?.email ? patient?.email : <>No Email Added! + } + + {patient?.isVerified ? "YES" : "NO"} + + + + + + {patient?.deviceAdded ? "YES" : "NO"} + + + + + {new Date(patient.createdAt).toLocaleString( + "en-IN", + { + weekday: "short", + month: "short", + day: "numeric", + year: "numeric", + hour: "numeric", + minute: "numeric", + hour12: true, + } + )} + */} + {/* + + */} + {/* + + */} + + {/* + + + + + + +
+
No Patient Available...
+
+
+ +
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "} + {Math.min(currentPage * itemPerPage, totalData)} of{" "} + {totalData} entries +
+
+ +
+
+
    +
  • + setCurrentPage((prev) => prev - 1)} + disabled={loading} + > + Previous + +
  • + + {!(currentPage - 1 < 1) && ( +
  • + + setCurrentPage((prev) => prev - 1) + } + disabled={loading} + > + {currentPage - 1} + +
  • + )} + +
  • + + {currentPage} + +
  • + + {!( + (currentPage + 1) * itemPerPage - itemPerPage > + totalData - 1 + ) && ( +
  • + { + setCurrentPage((prev) => prev + 1); + }} + disabled={loading} + > + {currentPage + 1} + +
  • + )} + +
  • + totalData - 1 + ) + ? "paginate_button page-item next" + : "paginate_button page-item next disabled" + } + > + setCurrentPage((prev) => prev + 1)} + disabled={loading} + > + Next + +
  • +
+
+
+
+
+
+
+
+
+
+
+ ); +}; + +export default Patient;