From af2fdcede69b00571f56a4f13bb769261a90675d Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Fri, 9 Jan 2026 18:10:34 +0100 Subject: [PATCH] added endpoint for payment, product and system reports --- src/component/reports/PaymentReportTable.jsx | 40 ++- src/component/reports/ProductReportTable.jsx | 335 ++++++++++--------- src/component/reports/Reports.jsx | 76 +++-- src/component/reports/SystemReportTable.jsx | 335 ++++++++++--------- src/services/queryKeys.js | 3 + src/services/services.js | 24 ++ 6 files changed, 475 insertions(+), 338 deletions(-) diff --git a/src/component/reports/PaymentReportTable.jsx b/src/component/reports/PaymentReportTable.jsx index 361e78e..9b12b11 100644 --- a/src/component/reports/PaymentReportTable.jsx +++ b/src/component/reports/PaymentReportTable.jsx @@ -1,7 +1,27 @@ -import React from "react"; +import React, { useState } from "react"; +import { useQuery } from "@tanstack/react-query"; +import { getPaymentReports } from "../../services/services"; +import queryKeys from "../../services/queryKeys"; export default function PaymentReportTable() { - return (<> + + const [page, setPage] = useState(0) + + const {data, isFetching, isError, error} = useQuery({ + queryKey: [...queryKeys.payment_report, page], + queryFn: () => { + let reqData = { + token: localStorage.getItem('token'), // USER TOKEN + uid: localStorage.getItem('uid'), // USER UID + page + } + return getPaymentReports(reqData) + } + }) + + console.log('DATA', data?.data) + return ( + <>
@@ -12,6 +32,17 @@ export default function PaymentReportTable() {
+ {isFetching ? + <> +
+

Loading...

+
+ + : isError ? +
+

{error?.message}

+
+ :
@@ -164,7 +195,8 @@ export default function PaymentReportTable() {
+ }
- - ) + + ) } \ No newline at end of file diff --git a/src/component/reports/ProductReportTable.jsx b/src/component/reports/ProductReportTable.jsx index 1f6e869..38058f1 100644 --- a/src/component/reports/ProductReportTable.jsx +++ b/src/component/reports/ProductReportTable.jsx @@ -1,7 +1,28 @@ -import React from "react"; +import React, { useState } from "react"; +import { useQuery } from "@tanstack/react-query"; +import { getProductReports } from "../../services/services"; +import queryKeys from "../../services/queryKeys"; export default function ProductReportTable() { - return (<> + + const [page, setPage] = useState(0) + + const {data, isFetching, isError, error} = useQuery({ + queryKey: [...queryKeys.product_report, page], + queryFn: () => { + let reqData = { + token: localStorage.getItem('token'), // USER TOKEN + uid: localStorage.getItem('uid'), // USER UID + page + } + return getProductReports(reqData) + } + }) + + console.log('DATA', data?.data) + + return ( + <>
@@ -14,159 +35,171 @@ export default function ProductReportTable() {
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + {isFetching ? + <> +
+

Loading...

+
+ + : isError ? +
+

{error?.message}

+
+ : +
+
+
+
+
NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011/04/25$320,800
Garrett WintersAccountantTokyo632011/07/25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
Airi SatouAccountantTokyo332008/11/28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Herrod ChandlerSales AssistantSan Francisco592012/08/06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010/10/14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009/09/15$205,500
Sonya FrostSoftware EngineerEdinburgh232008/12/13$103,600
Jena GainesOffice ManagerLondon302008/12/19$90,560
Quinn FlynnSupport LeadEdinburgh222013/03/03$342,000
Charde MarshallRegional DirectorSan Francisco362008/10/16$470,600
Haley KennedySenior Marketing DesignerLondon432012/12/18$313,500
Tatyana FitzpatrickRegional DirectorLondon192010/03/17$385,750
Michael SilvaMarketing DesignerLondon662012/11/27$198,500
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + -
NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011/04/25$320,800
Garrett WintersAccountantTokyo632011/07/25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
Airi SatouAccountantTokyo332008/11/28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Herrod ChandlerSales AssistantSan Francisco592012/08/06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010/10/14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009/09/15$205,500
Sonya FrostSoftware EngineerEdinburgh232008/12/13$103,600
Jena GainesOffice ManagerLondon302008/12/19$90,560
Quinn FlynnSupport LeadEdinburgh222013/03/03$342,000
Charde MarshallRegional DirectorSan Francisco362008/10/16$470,600
Haley KennedySenior Marketing DesignerLondon432012/12/18$313,500
Tatyana FitzpatrickRegional DirectorLondon192010/03/17$385,750
Michael SilvaMarketing DesignerLondon662012/11/27$198,500
+ +
-
+ }
- - ) + + ) } \ No newline at end of file diff --git a/src/component/reports/Reports.jsx b/src/component/reports/Reports.jsx index b5eabfd..f7c6448 100644 --- a/src/component/reports/Reports.jsx +++ b/src/component/reports/Reports.jsx @@ -36,46 +36,58 @@ export default function Reports() { <>
+ {isFetching ? + <> +
+

Loading...

+
+ + : isError ? +
+

{error?.message}

+
+ : +
-
-
- {/*
*/} - {/*
*/} - {/*

Tab vertical

*/} - {/*
*/} - {/*
*/} -
-
- - {/* */} -
    - {sortedReportTopicList && sortedReportTopicList.map((item, index) => { - return ( -
  • - - {item?.name} - -
  • - ) - })} -
+
+ {/*
*/} + {/*
*/} + {/*

Tab vertical

*/} + {/*
*/} + {/*
*/} +
+
+ + {/* */} +
    + {sortedReportTopicList && sortedReportTopicList.map((item, index) => { + return ( +
  • + + {item?.name} + +
  • + ) + })} +
- {/* */} -
- {sortedReportTopicList && sortedReportTopicList.map((item, index) => { - return ( -
- {renderedTable[item?.url]} -
- ) - })} -
+ {/* */} +
+ {sortedReportTopicList && sortedReportTopicList.map((item, index) => { + return ( +
+ {renderedTable[item?.url]} +
+ ) + })}
+ } +
) } \ No newline at end of file diff --git a/src/component/reports/SystemReportTable.jsx b/src/component/reports/SystemReportTable.jsx index 7695c29..3bbcd94 100644 --- a/src/component/reports/SystemReportTable.jsx +++ b/src/component/reports/SystemReportTable.jsx @@ -1,7 +1,28 @@ -import React from "react"; +import React, { useState } from "react"; +import { useQuery } from "@tanstack/react-query"; +import { getSystemReports } from "../../services/services"; +import queryKeys from "../../services/queryKeys"; export default function SystemReportTable() { - return (<> + + const [page, setPage] = useState(0) + + const {data, isFetching, isError, error} = useQuery({ + queryKey: [...queryKeys.system_report, page], + queryFn: () => { + let reqData = { + token: localStorage.getItem('token'), // USER TOKEN + uid: localStorage.getItem('uid'), // USER UID + page + } + return getSystemReports(reqData) + }, + }) + + console.log('DATA', data?.data) + + return ( + <>
@@ -14,159 +35,171 @@ export default function SystemReportTable() {
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + {isFetching ? + <> +
+

Loading...

+
+ + : isError ? +
+

{error?.message}

+
+ : +
+
+
+
+
NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011/04/25$320,800
Garrett WintersAccountantTokyo632011/07/25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
Airi SatouAccountantTokyo332008/11/28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Herrod ChandlerSales AssistantSan Francisco592012/08/06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010/10/14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009/09/15$205,500
Sonya FrostSoftware EngineerEdinburgh232008/12/13$103,600
Jena GainesOffice ManagerLondon302008/12/19$90,560
Quinn FlynnSupport LeadEdinburgh222013/03/03$342,000
Charde MarshallRegional DirectorSan Francisco362008/10/16$470,600
Haley KennedySenior Marketing DesignerLondon432012/12/18$313,500
Tatyana FitzpatrickRegional DirectorLondon192010/03/17$385,750
Michael SilvaMarketing DesignerLondon662012/11/27$198,500
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + -
NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011/04/25$320,800
Garrett WintersAccountantTokyo632011/07/25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
Airi SatouAccountantTokyo332008/11/28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Herrod ChandlerSales AssistantSan Francisco592012/08/06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010/10/14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009/09/15$205,500
Sonya FrostSoftware EngineerEdinburgh232008/12/13$103,600
Jena GainesOffice ManagerLondon302008/12/19$90,560
Quinn FlynnSupport LeadEdinburgh222013/03/03$342,000
Charde MarshallRegional DirectorSan Francisco362008/10/16$470,600
Haley KennedySenior Marketing DesignerLondon432012/12/18$313,500
Tatyana FitzpatrickRegional DirectorLondon192010/03/17$385,750
Michael SilvaMarketing DesignerLondon662012/11/27$198,500
+ +
-
+ }
- - ) + + ) } \ No newline at end of file diff --git a/src/services/queryKeys.js b/src/services/queryKeys.js index bc8e206..75b3d1c 100644 --- a/src/services/queryKeys.js +++ b/src/services/queryKeys.js @@ -13,6 +13,9 @@ const queryKeys = { profile_data: ['profile_data'], my_files: ['my_files'], topics: ['topics'], + payment_report: ['payment_report'], + product_report: ['product_report'], + system_report: ['system_report'], dashboard: ['dashboard'], topBar: ['top-bar'], diff --git a/src/services/services.js b/src/services/services.js index 637dba1..b2cf95d 100644 --- a/src/services/services.js +++ b/src/services/services.js @@ -297,6 +297,30 @@ export const getReportsTopicsList = (reqData) => { return postAuxEnd(`/panel/report/topics`, postData, false) } +// FUNCTION TO GET PAYMENT REPORTS +export const getPaymentReports = (reqData) => { + let postData = { + ...reqData, + } + return postAuxEnd(`/panel/report/item/payment`, postData, false) +} + +// FUNCTION TO GET PRODUCT REPORTS +export const getProductReports = (reqData) => { + let postData = { + ...reqData, + } + return postAuxEnd(`/panel/report/item/product`, postData, false) +} + +// FUNCTION TO GET SYSTEM REPORTS +export const getSystemReports = (reqData) => { + let postData = { + ...reqData, + } + return postAuxEnd(`/panel/report/item/system`, postData, false) +} + // FUNCTION TO GET COMMON PRACTICE export const getCommonPractice = (reqData) => { let postData = {