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: },