From 9822ae91ece024b16ecd75dafd00d2f09a7f1772 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Tue, 18 Nov 2025 15:56:16 +0530 Subject: [PATCH 1/6] Adding AdvancePayment a list view. --- .../AdvancePayment/AdvancePaymentList.jsx | 17 +++++++---- .../AdvancePayment/AdvancePaymentList1.jsx | 16 ++++++++++ src/hooks/useExpense.js | 9 ++++++ .../AdvancePayment/AdvancePaymentPage.jsx | 10 ++++--- .../AdvancePayment/AdvancePaymentPage1.jsx | 29 +++++++++++++++++++ src/repositories/ExpsenseRepository.jsx | 8 +++-- src/router/AppRoutes.jsx | 3 +- 7 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 src/components/AdvancePayment/AdvancePaymentList1.jsx create mode 100644 src/pages/AdvancePayment/AdvancePaymentPage1.jsx diff --git a/src/components/AdvancePayment/AdvancePaymentList.jsx b/src/components/AdvancePayment/AdvancePaymentList.jsx index e9113b48..5aef0de7 100644 --- a/src/components/AdvancePayment/AdvancePaymentList.jsx +++ b/src/components/AdvancePayment/AdvancePaymentList.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useMemo } from "react"; -import { useExpenseTransactions } from "../../hooks/useExpense"; +import { useExpenseAllTransactionsList, useExpenseTransactions } from "../../hooks/useExpense"; import Error from "../common/Error"; import { formatUTCToLocalTime } from "../../utils/dateUtils"; import Loader, { SpinnerLoader } from "../common/Loader"; @@ -11,11 +11,16 @@ import { employee } from "../../data/masters"; import { useAdvancePaymentContext } from "../../pages/AdvancePayment/AdvancePaymentPage"; import { formatFigure } from "../../utils/appUtils"; -const AdvancePaymentList = ({ employeeId }) => { - const { setBalance } = useAdvancePaymentContext(); +const AdvancePaymentList = ({ employeeId, searchString }) => { + const { setBalance } = useAdvancePaymentContext(); const { data, isError, isLoading, error, isFetching } = useExpenseTransactions(employeeId, { enabled: !!employeeId }); + const { data: getAllData } = + useExpenseAllTransactionsList(searchString ?? ""); + + console.log("Kartik", getAllData) + const records = Array.isArray(data) ? data : []; let currentBalance = 0; @@ -85,7 +90,7 @@ const AdvancePaymentList = ({ employeeId }) => { key: "date", label: ( <> - Date + Date ), align: "text-start", @@ -154,8 +159,8 @@ const AdvancePaymentList = ({ employeeId }) => { - {Array.isArray(data) && data.length > 0 ? ( - data.map((row) => ( + {Array.isArray(getAllData) && getAllData.length > 0 ? ( + getAllData.map((row) => ( {columns.map((col) => ( diff --git a/src/components/AdvancePayment/AdvancePaymentList1.jsx b/src/components/AdvancePayment/AdvancePaymentList1.jsx new file mode 100644 index 00000000..9e5fb3e5 --- /dev/null +++ b/src/components/AdvancePayment/AdvancePaymentList1.jsx @@ -0,0 +1,16 @@ +import React from 'react' +import { useExpenseAllTransactionsList } from '../../hooks/useExpense'; + +const AdvancePaymentList1 = ({searchString}) => { + const { data, isError, isLoading, error, isFetching } = + useExpenseAllTransactionsList(); + return ( +
+
+ +
+
+ ) +} + +export default AdvancePaymentList1 diff --git a/src/hooks/useExpense.js b/src/hooks/useExpense.js index bc5c1da4..539f0afd 100644 --- a/src/hooks/useExpense.js +++ b/src/hooks/useExpense.js @@ -438,6 +438,15 @@ export const useExpenseTransactions = (employeeId)=>{ keepPreviousData:true, }) } +export const useExpenseAllTransactionsList = (searchString) => { + return useQuery({ + queryKey: ["transaction", searchString], + queryFn: async () => { + const resp = await ExpenseRepository.getAllTranctionList(searchString); + return resp.data; + }, + }); +}; //#endregion // ---------------------------Put Post Recurring Expense--------------------------------------- diff --git a/src/pages/AdvancePayment/AdvancePaymentPage.jsx b/src/pages/AdvancePayment/AdvancePaymentPage.jsx index 9af4a6c9..70913ba8 100644 --- a/src/pages/AdvancePayment/AdvancePaymentPage.jsx +++ b/src/pages/AdvancePayment/AdvancePaymentPage.jsx @@ -29,10 +29,13 @@ const AdvancePaymentPage = () => { const { control, reset, watch } = useForm({ defaultValues: { employeeId: "", + searchString: "", }, }); const selectedEmployeeId = watch("employeeId"); + const searchString = watch("searchString"); + useEffect(() => { const selectedEmpoyee = sessionStorage.getItem("transaction-empId"); reset({ @@ -68,9 +71,8 @@ const AdvancePaymentPage = () => { <> 0 ? "text-success" : "text-danger" - } fs-5 fw-bold ms-1`} + className={`${balance > 0 ? "text-success" : "text-danger" + } fs-5 fw-bold ms-1`} > {balance > 0 ? ( @@ -88,7 +90,7 @@ const AdvancePaymentPage = () => { )} - + diff --git a/src/pages/AdvancePayment/AdvancePaymentPage1.jsx b/src/pages/AdvancePayment/AdvancePaymentPage1.jsx new file mode 100644 index 00000000..1d1b457a --- /dev/null +++ b/src/pages/AdvancePayment/AdvancePaymentPage1.jsx @@ -0,0 +1,29 @@ +import React from 'react' +import Breadcrumb from '../../components/common/Breadcrumb' +import AdvancePaymentList1 from '../../components/AdvancePayment/AdvancePaymentList1' +import { useForm } from 'react-hook-form'; + +const AdvancePaymentPage1 = () => { + const { control, reset, watch } = useForm({ + defaultValues: { + searchString: "", + }, + }); + const searchString = watch("searchString"); + return ( +
+ +
+ +
+
+ ) +} + +export default AdvancePaymentPage1 diff --git a/src/repositories/ExpsenseRepository.jsx b/src/repositories/ExpsenseRepository.jsx index 5e30bf76..6be424b0 100644 --- a/src/repositories/ExpsenseRepository.jsx +++ b/src/repositories/ExpsenseRepository.jsx @@ -44,13 +44,13 @@ const ExpenseRepository = { DeletePaymentRequest: () => api.get("delete here come"), CreatePaymentRequestExpense: (data) => api.post("/api/Expense/payment-request/expense/create", data), - GetPayee:()=>api.get('/api/Expense/payment-request/payee'), + GetPayee: () => api.get('/api/Expense/payment-request/payee'), //#endregion //#region Recurring Expense - GetRecurringExpenseList:(pageSize, pageNumber, filter,isActive, searchString) => { + GetRecurringExpenseList: (pageSize, pageNumber, filter, isActive, searchString) => { const payloadJsonString = JSON.stringify(filter); return api.get( `/api/expense/get/recurring-payment/list?pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${payloadJsonString}&isActive=${isActive}&searchString=${searchString}` @@ -70,9 +70,11 @@ const ExpenseRepository = { //#region Advance Payment GetTranctionList: (employeeId) => api.get(`/api/Expense/get/transactions/${employeeId}`), + getAllTranctionList: (searchString) => + api.get(`/api/Expense/get/advance-payment/employee/list?searchString=${searchString}`), //#endregion - + }; export default ExpenseRepository; diff --git a/src/router/AppRoutes.jsx b/src/router/AppRoutes.jsx index 1c95ec64..619b5465 100644 --- a/src/router/AppRoutes.jsx +++ b/src/router/AppRoutes.jsx @@ -61,6 +61,7 @@ import RecurringExpensePage from "../pages/RecurringExpense/RecurringExpensePage import AdvancePaymentPage from "../pages/AdvancePayment/AdvancePaymentPage"; import ServiceProjectDetail from "../pages/ServiceProject/ServiceProjectDetail"; import ManageJob from "../components/ServiceProject/ManageJob"; +import AdvancePaymentPage1 from "../pages/AdvancePayment/AdvancePaymentPage1"; const router = createBrowserRouter( [ { @@ -116,7 +117,7 @@ const router = createBrowserRouter( { path: "/expenses", element: }, { path: "/payment-request", element: }, { path: "/recurring-payment", element: }, - { path: "/advance-payment", element: }, + { path: "/advance-payment", element: }, { path: "/collection", element: }, { path: "/masters", element: }, { path: "/tenants", element: }, -- 2.43.0 From 5b91c13b857ab74157ba8f46a1da177e0ef579aa Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Wed, 19 Nov 2025 09:46:41 +0530 Subject: [PATCH 2/6] adding list view in advance payment list. --- .../AdvancePayment/AdvancePaymentList1.jsx | 105 +++++++++++++++++- .../RecurringExpense/RecurringExpenseList.jsx | 2 +- .../AdvancePayment/AdvancePaymentPage1.jsx | 21 +++- 3 files changed, 119 insertions(+), 9 deletions(-) diff --git a/src/components/AdvancePayment/AdvancePaymentList1.jsx b/src/components/AdvancePayment/AdvancePaymentList1.jsx index 9e5fb3e5..eb35942c 100644 --- a/src/components/AdvancePayment/AdvancePaymentList1.jsx +++ b/src/components/AdvancePayment/AdvancePaymentList1.jsx @@ -1,15 +1,108 @@ import React from 'react' import { useExpenseAllTransactionsList } from '../../hooks/useExpense'; -const AdvancePaymentList1 = ({searchString}) => { +const AdvancePaymentList1 = ({ searchString }) => { const { data, isError, isLoading, error, isFetching } = - useExpenseAllTransactionsList(); - return ( -
-
+ 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

)} +
+ )} */} +
-
) } diff --git a/src/components/RecurringExpense/RecurringExpenseList.jsx b/src/components/RecurringExpense/RecurringExpenseList.jsx index 338a3f38..a4c45fba 100644 --- a/src/components/RecurringExpense/RecurringExpenseList.jsx +++ b/src/components/RecurringExpense/RecurringExpenseList.jsx @@ -166,7 +166,7 @@ const RecurringExpenseList = ({ search, filterStatuses }) => { } ); }; - +console.log("Tanish",filteredData) return ( <> {IsDeleteModalOpen && ( diff --git a/src/pages/AdvancePayment/AdvancePaymentPage1.jsx b/src/pages/AdvancePayment/AdvancePaymentPage1.jsx index 1d1b457a..0a35dd44 100644 --- a/src/pages/AdvancePayment/AdvancePaymentPage1.jsx +++ b/src/pages/AdvancePayment/AdvancePaymentPage1.jsx @@ -2,6 +2,7 @@ import React from 'react' import Breadcrumb from '../../components/common/Breadcrumb' import AdvancePaymentList1 from '../../components/AdvancePayment/AdvancePaymentList1' import { useForm } from 'react-hook-form'; +import EmployeeSearchInput from '../../components/common/EmployeeSearchInput'; const AdvancePaymentPage1 = () => { const { control, reset, watch } = useForm({ @@ -19,9 +20,25 @@ const AdvancePaymentPage1 = () => { { label: "Advance Payment" }, ]} /> -
- +
+
+
+
+ +
+
+ +
+ + +
) } -- 2.43.0 From 10e54637d56e9263ed4c73c74fbc2a9f69838765 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Wed, 19 Nov 2025 10:47:11 +0530 Subject: [PATCH 3/6] 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; + -- 2.43.0 From a3be63b74f2376f8dd6a28a98236c3906b690ada Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Wed, 19 Nov 2025 12:22:38 +0530 Subject: [PATCH 4/6] Implementing api for Advance payment all data. --- .../AdvancePayment/AdvancePaymentList.jsx | 10 +- .../AdvancePayment/AdvancePaymentList1.jsx | 164 +++++------------- src/components/Layout/Header.jsx | 5 +- .../AdvancePayment/AdvancePaymentPage.jsx | 40 +++-- .../AdvancePayment/AdvancePaymentPage1.jsx | 18 +- src/router/AppRoutes.jsx | 1 + 6 files changed, 80 insertions(+), 158 deletions(-) diff --git a/src/components/AdvancePayment/AdvancePaymentList.jsx b/src/components/AdvancePayment/AdvancePaymentList.jsx index 5aef0de7..c6e9d004 100644 --- a/src/components/AdvancePayment/AdvancePaymentList.jsx +++ b/src/components/AdvancePayment/AdvancePaymentList.jsx @@ -15,12 +15,6 @@ const AdvancePaymentList = ({ employeeId, searchString }) => { const { setBalance } = useAdvancePaymentContext(); const { data, isError, isLoading, error, isFetching } = useExpenseTransactions(employeeId, { enabled: !!employeeId }); - - const { data: getAllData } = - useExpenseAllTransactionsList(searchString ?? ""); - - console.log("Kartik", getAllData) - const records = Array.isArray(data) ? data : []; let currentBalance = 0; @@ -159,8 +153,8 @@ const AdvancePaymentList = ({ employeeId, searchString }) => { - {Array.isArray(getAllData) && getAllData.length > 0 ? ( - getAllData.map((row) => ( + {Array.isArray(data) && data.length > 0 ? ( + data.map((row) => ( {columns.map((col) => ( diff --git a/src/components/AdvancePayment/AdvancePaymentList1.jsx b/src/components/AdvancePayment/AdvancePaymentList1.jsx index 2269f23f..e17cd1b1 100644 --- a/src/components/AdvancePayment/AdvancePaymentList1.jsx +++ b/src/components/AdvancePayment/AdvancePaymentList1.jsx @@ -1,127 +1,56 @@ -// 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 Avatar from "../../components/common/Avatar"; // <-- ADD THIS import { useExpenseAllTransactionsList } from '../../hooks/useExpense'; +import { useNavigate } from 'react-router-dom'; +import { formatFigure } from '../../utils/appUtils'; const AdvancePaymentList1 = ({ searchString }) => { const { data, isError, isLoading, error } = useExpenseAllTransactionsList(searchString); - const rows = data; + const rows = data || []; + const navigate = useNavigate(); 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 }, + { + key: "employee", + label: "Employee Name", + align: "text-start", + customRender: (r) => ( +
navigate(`/advance-payment/${r.id}`)} + style={{ cursor: "pointer" }}> + + + + {r.firstName} {r.lastName} + +
+ ), + }, + { + key: "jobRoleName", + label: "Job Role", + align: "text-start", + customRender: (r) => ( + + {r.jobRoleName} + + ), + }, + { + key: "balanceAmount", + label: "Balance (₹)", + align: "text-end", + customRender: (r) => ( + + {formatFigure(r.balanceAmount, { + // type: "currency", + currency: "INR", + })} + + ), + }, ]; if (isLoading) return

Loading...

; @@ -130,7 +59,6 @@ const AdvancePaymentList1 = ({ searchString }) => { return (
- @@ -148,7 +76,9 @@ const AdvancePaymentList1 = ({ searchString }) => { {columns.map((col) => ( ))} @@ -162,11 +92,9 @@ const AdvancePaymentList1 = ({ searchString }) => { )}
- {col.getValue(row)} + {col.customRender + ? col.customRender(row) + : col.getValue(row)}
-
) } export default AdvancePaymentList1; - diff --git a/src/components/Layout/Header.jsx b/src/components/Layout/Header.jsx index 0437539e..0dca90e5 100644 --- a/src/components/Layout/Header.jsx +++ b/src/components/Layout/Header.jsx @@ -50,8 +50,11 @@ const Header = () => { const isRecurringExpense = /^\/recurring-payment$/.test(pathname); const isAdvancePayment = /^\/advance-payment$/.test(pathname); const isServiceProjectPage = /^\/service-projects\/[0-9a-fA-F-]{36}$/.test(pathname); + const isAdvancePayment1 = + /^\/advance-payment(\/[0-9a-fA-F-]{36})?$/.test(pathname); - return !(isDirectoryPath || isProfilePage || isExpensePage || isPaymentRequest || isRecurringExpense || isAdvancePayment ||isServiceProjectPage); + + return !(isDirectoryPath || isProfilePage || isExpensePage || isPaymentRequest || isRecurringExpense || isAdvancePayment ||isServiceProjectPage || isAdvancePayment1); }; const allowedProjectStatusIds = [ "603e994b-a27f-4e5d-a251-f3d69b0498ba", diff --git a/src/pages/AdvancePayment/AdvancePaymentPage.jsx b/src/pages/AdvancePayment/AdvancePaymentPage.jsx index 70913ba8..f95f199a 100644 --- a/src/pages/AdvancePayment/AdvancePaymentPage.jsx +++ b/src/pages/AdvancePayment/AdvancePaymentPage.jsx @@ -13,6 +13,8 @@ import Label from "../../components/common/Label"; import AdvancePaymentList from "../../components/AdvancePayment/AdvancePaymentList"; import { employee } from "../../data/masters"; import { formatFigure } from "../../utils/appUtils"; +import { useParams } from "react-router-dom"; +import { useExpenseTransactions } from "../../hooks/useExpense"; export const AdvancePaymentContext = createContext(); export const useAdvancePaymentContext = () => { @@ -25,15 +27,30 @@ export const useAdvancePaymentContext = () => { return context; }; const AdvancePaymentPage = () => { + const { employeeId } = useParams(); + + const { data: transactionData } = useExpenseTransactions(employeeId, { + enabled: !!employeeId + }); + + const employeeName = useMemo(() => { + if (Array.isArray(transactionData) && transactionData.length > 0) { + const emp = transactionData[0].employee; + if (emp) return `${emp.firstName} ${emp.lastName}`; + } + return ""; + }, [transactionData]); + const [balance, setBalance] = useState(null); const { control, reset, watch } = useForm({ defaultValues: { - employeeId: "", + employeeId: employeeId || "", searchString: "", }, }); - const selectedEmployeeId = watch("employeeId"); + const selectedEmployeeId = employeeId || watch("employeeId"); + const searchString = watch("searchString"); useEffect(() => { @@ -50,22 +67,13 @@ const AdvancePaymentPage = () => { data={[ { label: "Home", link: "/dashboard" }, { label: "Finance", link: "/advance-payment" }, - { label: "Advance Payment" }, - ]} + { label: "Advance Payment", link: "/advance-payment" }, + employeeName && { label: employeeName, link: "" }, + ].filter(Boolean)} /> +
-
-
-
- -
-
+
{balance ? ( <> diff --git a/src/pages/AdvancePayment/AdvancePaymentPage1.jsx b/src/pages/AdvancePayment/AdvancePaymentPage1.jsx index 0a35dd44..4ba3721b 100644 --- a/src/pages/AdvancePayment/AdvancePaymentPage1.jsx +++ b/src/pages/AdvancePayment/AdvancePaymentPage1.jsx @@ -11,6 +11,7 @@ const AdvancePaymentPage1 = () => { }, }); const searchString = watch("searchString"); + return (
{ ]} />
-
-
-
- -
-
+
-
- - +
) diff --git a/src/router/AppRoutes.jsx b/src/router/AppRoutes.jsx index 619b5465..c5d37aa3 100644 --- a/src/router/AppRoutes.jsx +++ b/src/router/AppRoutes.jsx @@ -118,6 +118,7 @@ const router = createBrowserRouter( { path: "/payment-request", element: }, { path: "/recurring-payment", element: }, { path: "/advance-payment", element: }, + { path: "/advance-payment/:employeeId", element: }, { path: "/collection", element: }, { path: "/masters", element: }, { path: "/tenants", element: }, -- 2.43.0 From 7773b7a43bb74e385158d5ade48f7527cc21cdbf Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Wed, 19 Nov 2025 12:59:57 +0530 Subject: [PATCH 5/6] Adding Status and UI implementation in Collection. --- src/components/collections/CollectionList.jsx | 13 +++++- src/components/collections/ViewCollection.jsx | 16 +++----- src/pages/collections/CollectionPage.jsx | 41 ++++++++++--------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/components/collections/CollectionList.jsx b/src/components/collections/CollectionList.jsx index bb94130e..339828ed 100644 --- a/src/components/collections/CollectionList.jsx +++ b/src/components/collections/CollectionList.jsx @@ -27,7 +27,7 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { const selectedProject = useSelectedProject(); const searchDebounce = useDebounce(searchString, 500); - + const { data, isLoading, isError, error } = useCollections( selectedProject, searchDebounce, @@ -40,7 +40,6 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { ); const { setProcessedPayment, setAddPayment, setViewCollection } = useCollectionContext(); - const paginate = (page) => { if (page >= 1 && page <= (data?.totalPages ?? 1)) { setCurrentPage(page); @@ -129,6 +128,16 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { ), align: "text-end", }, + { + key: "status", + label: "Status", + getValue: (col) => ( + + {col?.isActive ? "Active" : "Inactive"} + + ), + align: "text-center", + }, { key: "balance", label: "Balance", diff --git a/src/components/collections/ViewCollection.jsx b/src/components/collections/ViewCollection.jsx index 77bc78fe..fdf563b9 100644 --- a/src/components/collections/ViewCollection.jsx +++ b/src/components/collections/ViewCollection.jsx @@ -25,7 +25,6 @@ const ViewCollection = ({ onClose }) => { if (isLoading) return ; if (isError) return
{error.message}
; - return (

Collection Details

@@ -43,9 +42,8 @@ const ViewCollection = ({ onClose }) => {
{" "} {data?.isActive ? "Active" : "Inactive"} @@ -214,9 +212,8 @@ const ViewCollection = ({ onClose }) => {
  • +
{/* Right side: Search + Add Button */}
+ + + Date: Wed, 19 Nov 2025 14:26:12 +0530 Subject: [PATCH 6/6] Changing the position of Status in Collection list view. --- src/components/collections/CollectionList.jsx | 21 ++++++++++--------- src/pages/collections/CollectionPage.jsx | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/collections/CollectionList.jsx b/src/components/collections/CollectionList.jsx index 339828ed..ad1ff5c0 100644 --- a/src/components/collections/CollectionList.jsx +++ b/src/components/collections/CollectionList.jsx @@ -112,6 +112,16 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { ), align: "text-center", }, + { + key: "status", + label: "Status", + getValue: (col) => ( + + {col?.isActive ? "Active" : "Inactive"} + + ), + align: "text-center", + }, { key: "amount", label: "Total Amount", @@ -128,16 +138,7 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { ), align: "text-end", }, - { - key: "status", - label: "Status", - getValue: (col) => ( - - {col?.isActive ? "Active" : "Inactive"} - - ), - align: "text-center", - }, + { key: "balance", label: "Balance", diff --git a/src/pages/collections/CollectionPage.jsx b/src/pages/collections/CollectionPage.jsx index 8f68641d..5469be62 100644 --- a/src/pages/collections/CollectionPage.jsx +++ b/src/pages/collections/CollectionPage.jsx @@ -126,7 +126,7 @@ const CollectionPage = () => { }`} onClick={() => setShowPending(false)} > - All + Show All