diff --git a/src/components/Expenses/ExpenseList.jsx b/src/components/Expenses/ExpenseList.jsx index 89ae489f..32463732 100644 --- a/src/components/Expenses/ExpenseList.jsx +++ b/src/components/Expenses/ExpenseList.jsx @@ -3,6 +3,8 @@ import { useExpenseList } from "../../hooks/useExpense"; import Avatar from "../common/Avatar"; import { useExpenseContext } from "../../pages/Expense/ExpensePage"; import { formatDate, formatUTCToLocalTime } from "../../utils/dateUtils"; +import Pagination from "../common/Pagination"; +import { ITEMS_PER_PAGE } from "../../utils/constants"; const ExpenseList = () => { const { setViewExpense } = useExpenseContext(); @@ -18,10 +20,9 @@ const ExpenseList = () => { endDate: null, }; - const { data, isLoading, isError } = useExpenseList(5, currentPage, filter); - + const { data, isLoading, isError } = useExpenseList(ITEMS_PER_PAGE, currentPage, filter); if (isLoading) return
Loading...
; - const items = data ?? []; + const items = data.data ?? []; const totalPages = data?.totalPages ?? 1; const hasMore = currentPage < totalPages; @@ -167,7 +168,7 @@ const ExpenseList = () => { - {expense.amount} + {expense.amount} { - setViewExpense({ expenseId: expense.id, view: true }) + setViewExpense({ expenseId: expense, view: true }) } > @@ -197,52 +198,15 @@ const ExpenseList = () => { - {!isLoading && items.length > 0 && totalPages > 1 && ( - - )} + {!isLoading && items.length > 0 && ( + + )} + ); }; diff --git a/src/components/Expenses/ViewExpense.jsx b/src/components/Expenses/ViewExpense.jsx index a2849ede..8c15f2a5 100644 --- a/src/components/Expenses/ViewExpense.jsx +++ b/src/components/Expenses/ViewExpense.jsx @@ -1,14 +1,176 @@ -import React from 'react' -import { useExpense } from '../../hooks/useExpense' +import React from "react"; +import { useActionOnExpense } from "../../hooks/useExpense"; +import { formatUTCToLocalTime } from "../../utils/dateUtils"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { ActionSchema } from "./ExpenseSchema"; + +const ViewExpense = ({ ExpenseId }) => { + const { + register, + handleSubmit, + setValue, + formState: { errors }, + } = useForm({ + resolver: zodResolver(ActionSchema), + defaultValues: { + comment: "", + selectedStatus: "", + }, + }); + + const { mutate: MakeAction } = useActionOnExpense(); + + const onSubmit = (formData) => { + const Payload = { + expenseId: ExpenseId?.id, + statusId: formData.selectedStatus, + comment: formData.comment, + }; + + MakeAction(Payload); + }; -const ViewExpense = ({ExpenseId}) => { - console.log(ExpenseId) - const {} = useExpense(ExpenseId) return ( -
- -
- ) -} +
+
+
+
Expense Details
+
+
-export default ViewExpense \ No newline at end of file + {/* Expense Info Rows */} +
+
+ +
{formatUTCToLocalTime(ExpenseId.transactionDate)}
+
+
+ +
+
+ +
{ExpenseId.expensesType.name}
+
+
+ +
+
+ +
{ExpenseId.supplerName}
+
+
+ +
+
+ +
₹ {ExpenseId.amount}
+
+
+ +
+
+ +
{ExpenseId.paymentMode.name}
+
+
+ +
+
+ +
+ {ExpenseId.paidBy.firstName} {ExpenseId.paidBy.lastName} +
+
+
+ +
+
+ + + {ExpenseId.status.displayName} + +
+
+ +
+
+ +
{ExpenseId.preApproved ? "Yes" : "No"}
+
+
+ +
+
+ +
{ExpenseId.project.name}
+
+
+ +
+
+ +
+ {ExpenseId.createdBy.firstName} {ExpenseId.createdBy.lastName} +
+
+
+ +
+
+ +
{formatUTCToLocalTime(ExpenseId.createdAt, true)}
+
+
+
+ +
+ +
+ Local travel reimbursement for delivery of materials to client site via City Taxi Service +
+
+ +
+ + {Array.isArray(ExpenseId.nextStatus) && ExpenseId.nextStatus.length > 0 && ( +
+ +