From 71f3c7bcd6a3a5d7cdbda975465f0190862975c0 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Fri, 13 Dec 2024 19:20:20 +0100 Subject: [PATCH] top bar contents updated --- src/component/home/HomeSections.jsx | 100 +-------------------------- src/component/home/RecentActions.jsx | 2 +- src/component/home/TopBar.jsx | 66 ++++++++++++++++++ 3 files changed, 69 insertions(+), 99 deletions(-) create mode 100644 src/component/home/TopBar.jsx diff --git a/src/component/home/HomeSections.jsx b/src/component/home/HomeSections.jsx index f6fe7e9..62804a8 100644 --- a/src/component/home/HomeSections.jsx +++ b/src/component/home/HomeSections.jsx @@ -2,6 +2,7 @@ import React from "react"; import BreadcrumbComBS from "../breadcrumb/BreadcrumbComBS"; import RecentActions from "./RecentActions"; import Products from "./Products"; +import TopBar from "./TopBar"; // import { useQuery } from "@tanstack/react-query"; // import { accountDashboard } from "../../services/services"; // import queryKeys from "../../services/queryKeys"; @@ -63,104 +64,7 @@ export default function HomeSections(){ */}
-
-
-
-
-
-
-
-

0

- Last 2 months -
-
-
Contacts
- N/A -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

0

- Past 12 hours -
-
-
Site Traffic
- 0.00% -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

0

- Last 14 days -
-
-
Appointments
- 0.00% -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

5,687

- Last 3 months -
-
-
Purchases
- 9.89% -
-
-
-
-
-
-
-
-
-
+
diff --git a/src/component/home/RecentActions.jsx b/src/component/home/RecentActions.jsx index f2a1128..ffd4836 100644 --- a/src/component/home/RecentActions.jsx +++ b/src/component/home/RecentActions.jsx @@ -43,7 +43,7 @@ export default function RecentActions() {

Last Update

-

{dataAction?.data?.action_data?.last_update}

+

{dataAction?.data?.action_data?.last_update}

{/**/} diff --git a/src/component/home/TopBar.jsx b/src/component/home/TopBar.jsx new file mode 100644 index 0000000..8febf4c --- /dev/null +++ b/src/component/home/TopBar.jsx @@ -0,0 +1,66 @@ +import { useQuery } from '@tanstack/react-query' +import React from 'react' +import { recentActions } from '../../services/services' +import queryKeys from '../../services/queryKeys' + +export default function TopBar() { + + const {data:dataAction, isFetching, isError, error} = useQuery({ + queryKey: queryKeys.recentAction, + queryFn: () => recentActions() + }) + + const actionData = dataAction?.data?.action_data + + return ( + <> + {isFetching ? + <> +
+
+

Loading...

+
+
+ + : isError ? +
+
+

{error.message}

+
+
+ : + <> + {actionData && actionData?.top_bar?.map((item, index)=>{ + let textColor = item?.description == 'Contacts' ? 'text-danger' : item?.description == 'Site Traffic' ? 'text-primary' : item?.description == 'Appointments' ? 'text-orange' : 'text-success' + return ( +
+
+
+
+
+
+
+

{item?.value || 0}

+ {item?.data_span} +
+
+
{item?.description}
+ N/A +
+
+
+
+
+
+
+
+
+
+ ) + })} + + } + + ) +}