Adding AdvancePayment a list view.
This commit is contained in:
parent
dd41600045
commit
9822ae91ec
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import React, { useEffect, useMemo } from "react";
|
import React, { useEffect, useMemo } from "react";
|
||||||
import { useExpenseTransactions } from "../../hooks/useExpense";
|
import { useExpenseAllTransactionsList, useExpenseTransactions } from "../../hooks/useExpense";
|
||||||
import Error from "../common/Error";
|
import Error from "../common/Error";
|
||||||
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
import Loader, { SpinnerLoader } from "../common/Loader";
|
import Loader, { SpinnerLoader } from "../common/Loader";
|
||||||
@ -11,11 +11,16 @@ import { employee } from "../../data/masters";
|
|||||||
import { useAdvancePaymentContext } from "../../pages/AdvancePayment/AdvancePaymentPage";
|
import { useAdvancePaymentContext } from "../../pages/AdvancePayment/AdvancePaymentPage";
|
||||||
import { formatFigure } from "../../utils/appUtils";
|
import { formatFigure } from "../../utils/appUtils";
|
||||||
|
|
||||||
const AdvancePaymentList = ({ employeeId }) => {
|
const AdvancePaymentList = ({ employeeId, searchString }) => {
|
||||||
const { setBalance } = useAdvancePaymentContext();
|
const { setBalance } = useAdvancePaymentContext();
|
||||||
const { data, isError, isLoading, error, isFetching } =
|
const { data, isError, isLoading, error, isFetching } =
|
||||||
useExpenseTransactions(employeeId, { enabled: !!employeeId });
|
useExpenseTransactions(employeeId, { enabled: !!employeeId });
|
||||||
|
|
||||||
|
const { data: getAllData } =
|
||||||
|
useExpenseAllTransactionsList(searchString ?? "");
|
||||||
|
|
||||||
|
console.log("Kartik", getAllData)
|
||||||
|
|
||||||
const records = Array.isArray(data) ? data : [];
|
const records = Array.isArray(data) ? data : [];
|
||||||
|
|
||||||
let currentBalance = 0;
|
let currentBalance = 0;
|
||||||
@ -85,7 +90,7 @@ const AdvancePaymentList = ({ employeeId }) => {
|
|||||||
key: "date",
|
key: "date",
|
||||||
label: (
|
label: (
|
||||||
<>
|
<>
|
||||||
Date
|
Date
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
align: "text-start",
|
align: "text-start",
|
||||||
@ -154,8 +159,8 @@ const AdvancePaymentList = ({ employeeId }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{Array.isArray(data) && data.length > 0 ? (
|
{Array.isArray(getAllData) && getAllData.length > 0 ? (
|
||||||
data.map((row) => (
|
getAllData.map((row) => (
|
||||||
<tr key={row.id}>
|
<tr key={row.id}>
|
||||||
{columns.map((col) => (
|
{columns.map((col) => (
|
||||||
<td key={col.key} className={`${col.align} p-2`}>
|
<td key={col.key} className={`${col.align} p-2`}>
|
||||||
|
|||||||
16
src/components/AdvancePayment/AdvancePaymentList1.jsx
Normal file
16
src/components/AdvancePayment/AdvancePaymentList1.jsx
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { useExpenseAllTransactionsList } from '../../hooks/useExpense';
|
||||||
|
|
||||||
|
const AdvancePaymentList1 = ({searchString}) => {
|
||||||
|
const { data, isError, isLoading, error, isFetching } =
|
||||||
|
useExpenseAllTransactionsList();
|
||||||
|
return (
|
||||||
|
<div className="card page-min-h table-responsive px-sm-4">
|
||||||
|
<div className="card-datatable" id="payment-request-table">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AdvancePaymentList1
|
||||||
@ -438,6 +438,15 @@ export const useExpenseTransactions = (employeeId)=>{
|
|||||||
keepPreviousData:true,
|
keepPreviousData:true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export const useExpenseAllTransactionsList = (searchString) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["transaction", searchString],
|
||||||
|
queryFn: async () => {
|
||||||
|
const resp = await ExpenseRepository.getAllTranctionList(searchString);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
// ---------------------------Put Post Recurring Expense---------------------------------------
|
// ---------------------------Put Post Recurring Expense---------------------------------------
|
||||||
|
|||||||
@ -29,10 +29,13 @@ const AdvancePaymentPage = () => {
|
|||||||
const { control, reset, watch } = useForm({
|
const { control, reset, watch } = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
employeeId: "",
|
employeeId: "",
|
||||||
|
searchString: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedEmployeeId = watch("employeeId");
|
const selectedEmployeeId = watch("employeeId");
|
||||||
|
const searchString = watch("searchString");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const selectedEmpoyee = sessionStorage.getItem("transaction-empId");
|
const selectedEmpoyee = sessionStorage.getItem("transaction-empId");
|
||||||
reset({
|
reset({
|
||||||
@ -68,9 +71,8 @@ const AdvancePaymentPage = () => {
|
|||||||
<>
|
<>
|
||||||
<label className="fs-5 fw-semibold">Current Balance : </label>
|
<label className="fs-5 fw-semibold">Current Balance : </label>
|
||||||
<span
|
<span
|
||||||
className={`${
|
className={`${balance > 0 ? "text-success" : "text-danger"
|
||||||
balance > 0 ? "text-success" : "text-danger"
|
} fs-5 fw-bold ms-1`}
|
||||||
} fs-5 fw-bold ms-1`}
|
|
||||||
>
|
>
|
||||||
{balance > 0 ? (
|
{balance > 0 ? (
|
||||||
<i className="bx bx-plus b-sm"></i>
|
<i className="bx bx-plus b-sm"></i>
|
||||||
@ -88,7 +90,7 @@ const AdvancePaymentPage = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<AdvancePaymentList employeeId={selectedEmployeeId} />
|
<AdvancePaymentList employeeId={selectedEmployeeId} searchString={searchString} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</AdvancePaymentContext.Provider>
|
</AdvancePaymentContext.Provider>
|
||||||
|
|||||||
29
src/pages/AdvancePayment/AdvancePaymentPage1.jsx
Normal file
29
src/pages/AdvancePayment/AdvancePaymentPage1.jsx
Normal file
@ -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 (
|
||||||
|
<div className="container-fluid">
|
||||||
|
<Breadcrumb
|
||||||
|
data={[
|
||||||
|
{ label: "Home", link: "/dashboard" },
|
||||||
|
{ label: "Finance", link: "/advance-payment" },
|
||||||
|
{ label: "Advance Payment" },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<div className="card px-4 py-2 page-min-h ">
|
||||||
|
<AdvancePaymentList1 searchString={searchString} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AdvancePaymentPage1
|
||||||
@ -44,13 +44,13 @@ const ExpenseRepository = {
|
|||||||
DeletePaymentRequest: () => api.get("delete here come"),
|
DeletePaymentRequest: () => api.get("delete here come"),
|
||||||
CreatePaymentRequestExpense: (data) =>
|
CreatePaymentRequestExpense: (data) =>
|
||||||
api.post("/api/Expense/payment-request/expense/create", 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
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#region Recurring Expense
|
//#region Recurring Expense
|
||||||
GetRecurringExpenseList:(pageSize, pageNumber, filter,isActive, searchString) => {
|
GetRecurringExpenseList: (pageSize, pageNumber, filter, isActive, searchString) => {
|
||||||
const payloadJsonString = JSON.stringify(filter);
|
const payloadJsonString = JSON.stringify(filter);
|
||||||
return api.get(
|
return api.get(
|
||||||
`/api/expense/get/recurring-payment/list?pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${payloadJsonString}&isActive=${isActive}&searchString=${searchString}`
|
`/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
|
//#region Advance Payment
|
||||||
GetTranctionList: (employeeId) =>
|
GetTranctionList: (employeeId) =>
|
||||||
api.get(`/api/Expense/get/transactions/${employeeId}`),
|
api.get(`/api/Expense/get/transactions/${employeeId}`),
|
||||||
|
getAllTranctionList: (searchString) =>
|
||||||
|
api.get(`/api/Expense/get/advance-payment/employee/list?searchString=${searchString}`),
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ExpenseRepository;
|
export default ExpenseRepository;
|
||||||
|
|||||||
@ -61,6 +61,7 @@ import RecurringExpensePage from "../pages/RecurringExpense/RecurringExpensePage
|
|||||||
import AdvancePaymentPage from "../pages/AdvancePayment/AdvancePaymentPage";
|
import AdvancePaymentPage from "../pages/AdvancePayment/AdvancePaymentPage";
|
||||||
import ServiceProjectDetail from "../pages/ServiceProject/ServiceProjectDetail";
|
import ServiceProjectDetail from "../pages/ServiceProject/ServiceProjectDetail";
|
||||||
import ManageJob from "../components/ServiceProject/ManageJob";
|
import ManageJob from "../components/ServiceProject/ManageJob";
|
||||||
|
import AdvancePaymentPage1 from "../pages/AdvancePayment/AdvancePaymentPage1";
|
||||||
const router = createBrowserRouter(
|
const router = createBrowserRouter(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -116,7 +117,7 @@ const router = createBrowserRouter(
|
|||||||
{ path: "/expenses", element: <ExpensePage /> },
|
{ path: "/expenses", element: <ExpensePage /> },
|
||||||
{ path: "/payment-request", element: <PaymentRequestPage /> },
|
{ path: "/payment-request", element: <PaymentRequestPage /> },
|
||||||
{ path: "/recurring-payment", element: <RecurringExpensePage /> },
|
{ path: "/recurring-payment", element: <RecurringExpensePage /> },
|
||||||
{ path: "/advance-payment", element: <AdvancePaymentPage /> },
|
{ path: "/advance-payment", element: <AdvancePaymentPage1 /> },
|
||||||
{ path: "/collection", element: <CollectionPage /> },
|
{ path: "/collection", element: <CollectionPage /> },
|
||||||
{ path: "/masters", element: <MasterPage /> },
|
{ path: "/masters", element: <MasterPage /> },
|
||||||
{ path: "/tenants", element: <TenantPage /> },
|
{ path: "/tenants", element: <TenantPage /> },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user