From eed25b773b95540b1697ff9b0ef7d7c7eac5b64d Mon Sep 17 00:00:00 2001 From: MD ARIF KHAN Date: Fri, 28 Jul 2023 17:43:55 +0530 Subject: [PATCH] bsuiness --- src/auth.js | 21 ++- src/routes.js | 6 + src/views/Business/Businesses.js | 25 ++-- src/views/Business/ViewHealthCareProvider.js | 146 +++++++++++++++++++ 4 files changed, 174 insertions(+), 24 deletions(-) create mode 100644 src/views/Business/ViewHealthCareProvider.js diff --git a/src/auth.js b/src/auth.js index 434c3d9..06effdc 100644 --- a/src/auth.js +++ b/src/auth.js @@ -1,17 +1,16 @@ export const isAutheticated = () => { - if (typeof window == "undefined") { - return true; - } - if (localStorage.getItem("authToken")) { - - return (localStorage.getItem("authToken")); - } else { - return false; - } + if (typeof window == "undefined") { + return true; + } + if (localStorage.getItem("authToken")) { + return localStorage.getItem("authToken"); + } else { + return false; + } }; export const signout = () => { - localStorage.removeItem("authToken"); + localStorage.removeItem("authToken"); - return true; + return true; }; diff --git a/src/routes.js b/src/routes.js index 8f4f062..2a3d0cd 100644 --- a/src/routes.js +++ b/src/routes.js @@ -79,6 +79,7 @@ import EditPurpose from "./views/configuration/Purpose/EditPurpose.js"; import ViewAppointment from "./views/Appointments/ViewAppointment"; import EditAppointment from "./views/Appointments/EditAppointment"; import AddNewAppointment from "./views/Appointments/AddNewAppointment"; +import ViewHealthCareProvider from "./views/Business/ViewHealthCareProvider"; const routes = [ { path: "/", exact: true, name: "Home" }, { @@ -134,6 +135,11 @@ const routes = [ name: "Edit healthcare providers", element: EditBusiness, }, + { + path: "/healthcare/providers/view/:id", + name: "view healthcare providers", + element: ViewHealthCareProvider, + }, // { path: '/franchisee/view/:id', name: 'view franchisee', element: ViewFra }, //Contact Requests diff --git a/src/views/Business/Businesses.js b/src/views/Business/Businesses.js index a9d2da9..f7d0a5f 100644 --- a/src/views/Business/Businesses.js +++ b/src/views/Business/Businesses.js @@ -31,7 +31,6 @@ const Businesses = () => { }, }) .then((res) => { - console.log(res.data); setBusinessesData(res.data?.businesses); setLoading(false); }) @@ -208,8 +207,6 @@ const Businesses = () => { - {console.log(showData, "showData")} - {!loading && showData.length === 0 && ( @@ -269,21 +266,23 @@ const Businesses = () => { */} - {/* + - - - */} + > + View + + { + const [HealthCareData, setHealthCareData] = useState(); + const token = isAutheticated(); + + const [loading, setLoading] = useState(false); + + const { id } = useParams(); + + const getHealthCareProvider = () => { + setLoading(true); + axios + .get(`/api/businesses/get/${id}`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }) + + .then(async (res) => { + console.log(res.data); + setHealthCareData(res.data.businesses); + setLoading(false); + }) + .catch((err) => { + swal("Error", "Could not get data", "error"); + setLoading(false); + }); + }; + + useEffect(() => { + getHealthCareProvider(); + }, []); + + const navigate = useNavigate(); + + return ( +
+
+
+
+ HealthCare Provider Details +
+ +
+ +
+
+
+ + {loading &&
Loading...
} + {!loading && !HealthCareData &&
No data found
} + {!loading && HealthCareData && ( +
+ + + + + + + + + + + + {HealthCareData?.business_name ? ( + + {" "} + + + + ) : ( + + + + + )} + + + + + + + + + + + + + + + + + + + + + + +
HealthCare Provider ID{HealthCareData?._id}
Provider Type{HealthCareData?.business}
HealthCare Name{HealthCareData?.business_name}
Specialization{HealthCareData?.specialization}
Contact Person Name{HealthCareData?.contact_Person_Name}
Phone{HealthCareData?.contact_Number}
Email{HealthCareData?.email}
Url + {HealthCareData?.url ? ( + HealthCareData?.url + ) : ( + Not Set + )} +
Address + {HealthCareData?.address_Line_1}
+ {HealthCareData?.address_Line_2} +
+ {HealthCareData?.city}, {HealthCareData?.state}
+ {HealthCareData?.country}
+ {HealthCareData?.pincode} +
+
+ )} +
+ ); +}; + +export default ViewHealthCareProvider;