From 10e54637d56e9263ed4c73c74fbc2a9f69838765 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Wed, 19 Nov 2025 10:47:11 +0530 Subject: [PATCH] Adding list view in Advance payment list. --- .../AdvancePayment/AdvancePaymentList1.jsx | 255 +++++++++++------- 1 file changed, 159 insertions(+), 96 deletions(-) diff --git a/src/components/AdvancePayment/AdvancePaymentList1.jsx b/src/components/AdvancePayment/AdvancePaymentList1.jsx index eb35942c..2269f23f 100644 --- a/src/components/AdvancePayment/AdvancePaymentList1.jsx +++ b/src/components/AdvancePayment/AdvancePaymentList1.jsx @@ -1,109 +1,172 @@ +// import React from 'react' +// import { useExpenseAllTransactionsList } from '../../hooks/useExpense'; + +// const AdvancePaymentList1 = ({ searchString }) => { +// const { data, isError, isLoading, error, isFetching } = +// useExpenseAllTransactionsList(searchString); +// console.log("Kartik", data) + +// const recurringExpenseColumns = [ +// { +// key: "date", +// label: ( +// <> +// Date +// +// ), +// align: "text-start", +// }, +// { key: "description", label: "Description", align: "text-start" }, +// { +// key: "credit", +// label: ( +// <> +// Credit +// +// ), +// align: "text-end", +// }, +// { +// key: "debit", +// label: ( +// <> +// Debit +// +// ), +// align: "text-end", +// }, + +// { +// key: "balance", +// label: ( +// <> +// Balance +// +// ), +// align: "text-end fw-bold", +// }, + +// ]; +// return ( +//
+//
+// {/* {Array.isArray(data) && data.length > 0 && ( */} +// +// +// +// {recurringExpenseColumns.map((col) => ( +// +// ))} +// +// + +// +// {data?.length > 0 ? ( +// data?.map((recurringExpense) => ( +// +// {recurringExpenseColumns.map((col) => ( +// +// ))} + +// +// )) +// ) : ( +// +// +// +// )} +// +//
+// {col.label} +//
+// {col?.customRender +// ? col?.customRender(recurringExpense) +// : col?.getValue(recurringExpense)} +//
+// {/* )} */} +// {/* {!data || +// data.length === 0 +// && ( +//
+// {isError ? (

{error.message}

) : (

No Recurring Expense Found

)} +//
+// )} */} +//
+//
+// ) +// } + +// export default AdvancePaymentList1 + import React from 'react' import { useExpenseAllTransactionsList } from '../../hooks/useExpense'; const AdvancePaymentList1 = ({ searchString }) => { - const { data, isError, isLoading, error, isFetching } = + + const { data, isError, isLoading, error } = useExpenseAllTransactionsList(searchString); - console.log("Kartik", data) - const recurringExpenseColumns = [ - { - key: "date", - label: ( - <> - Date - - ), - align: "text-start", - }, - { key: "description", label: "Description", align: "text-start" }, - { - key: "credit", - label: ( - <> - Credit - - ), - align: "text-end", - }, - { - key: "debit", - label: ( - <> - Debit - - ), - align: "text-end", - }, - - { - key: "balance", - label: ( - <> - Balance - - ), - align: "text-end fw-bold", - }, + const rows = data; + const columns = [ + { key: "employee", label: "Employee Name", align: "text-start", getValue: (r) => r.firstName + " " + r.lastName }, + { key: "jobRoleName", label: "Job Role", align: "text-start", getValue: (r) => r.jobRoleName }, + { key: "balanceAmount", label: "Balance (₹)", align: "text-end", getValue: (r) => r.balanceAmount }, ]; - return ( -
-
- {/* {Array.isArray(data) && data.length > 0 && ( */} - - - - {recurringExpenseColumns.map((col) => ( - - ))} - - - - {data?.length > 0 ? ( - data?.map((recurringExpense) => ( - - {recurringExpenseColumns.map((col) => ( - - ))} - - - )) - ) : ( - - - - )} - -
- {col.label} -
- {col?.customRender - ? col?.customRender(recurringExpense) - : col?.getValue(recurringExpense)} -
- {/* )} */} - {/* {!data || - data.length === 0 - && ( -
- {isError ? (

{error.message}

) : (

No Recurring Expense Found

)} -
- )} */} -
+ if (isLoading) return

Loading...

; + if (isError) return

{error.message}

; + + return ( +
+
+ + + + + {columns.map((col) => ( + + ))} + + + + + {rows.length > 0 ? ( + rows.map((row) => ( + + {columns.map((col) => ( + + ))} + + )) + ) : ( + + + + )} + +
+ {col.label} +
+ {col.getValue(row)} +
+ No Employees Found +
+
+
) } -export default AdvancePaymentList1 +export default AdvancePaymentList1; +