diff --git a/src/components/PaymentRequest/ManagePaymentRequest.jsx b/src/components/PaymentRequest/ManagePaymentRequest.jsx
index 66d64715..c5fd2f2d 100644
--- a/src/components/PaymentRequest/ManagePaymentRequest.jsx
+++ b/src/components/PaymentRequest/ManagePaymentRequest.jsx
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'
-import { useProjectName } from '../../hooks/useProjects';
+import { useCurrencies, useProjectName } from '../../hooks/useProjects';
import Label from '../common/Label';
import { useForm } from 'react-hook-form';
import { useExpenseType } from '../../hooks/masterHook/useMaster';
@@ -11,8 +11,14 @@ import { formatFileSize, localToUtc } from '../../utils/appUtils';
function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
+ const { data } = {}
+
const { projectNames, loading: projectLoading, error, isError: isProjectError,
} = useProjectName();
+
+ const { data: currencyData, isLoading: currencyLoading, isError: currencyError } = useCurrencies();
+
+
const {
ExpenseTypes,
loading: ExpenseLoading,
@@ -98,39 +104,39 @@ function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
}
);
- // useEffect(() => {
- // if (expenseToEdit && data) {
- // reset({
- // title: data.title || "",
- // description: data.description || "",
- // payee: data.payee || "",
- // currencyId: data.currencyId.id || "",
- // amount: data.amount || "",
- // dueDate: data.dueDate?.slice(0, 10) || "",
- // projectId: data.project.id || "",
- // expenseCategoryId: data.expenseCategoryId.id || "",
- // isAdvancePayment: data.isAdvancePayment || "",
- // billAttachments: data.documents
- // ? data.documents.map((doc) => ({
- // fileName: doc.fileName,
- // base64Data: null,
- // contentType: doc.contentType,
- // documentId: doc.documentId,
- // fileSize: 0,
- // description: "",
- // preSignedUrl: doc.preSignedUrl,
- // isActive: doc.isActive ?? true,
- // }))
- // : [],
+ useEffect(() => {
+ if (expenseToEdit && data) {
+ reset({
+ title: data.title || "",
+ description: data.description || "",
+ payee: data.payee || "",
+ currencyId: data.currencyId.id || "",
+ amount: data.amount || "",
+ dueDate: data.dueDate?.slice(0, 10) || "",
+ projectId: data.project.id || "",
+ expenseCategoryId: data.expenseCategoryId.id || "",
+ isAdvancePayment: data.isAdvancePayment || false,
+ billAttachments: data.documents
+ ? data.documents.map((doc) => ({
+ fileName: doc.fileName,
+ base64Data: null,
+ contentType: doc.contentType,
+ documentId: doc.documentId,
+ fileSize: 0,
+ description: "",
+ preSignedUrl: doc.preSignedUrl,
+ isActive: doc.isActive ?? true,
+ }))
+ : [],
- // });
- // }
- // }, [data, reset, employees]);
+ });
+ }
+ }, [data, reset]);
const onSubmit = (fromdata) => {
let payload = {
...fromdata,
- transactionDate: localToUtc(fromdata.transactionDate),
+ dueDate: localToUtc(fromdata.dueDate),
};
if (expenseToEdit) {
const editPayload = { ...payload, id: data.id };
@@ -140,6 +146,7 @@ function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
}
};
+
return (
@@ -172,13 +179,13 @@ function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
-
@@ -204,18 +211,18 @@ function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
-
+
Transaction Date
- {errors.transactionDate && (
+ {errors.dueDate && (
- {errors.transactionDate.message}
+ {errors.dueDate.message}
)}
@@ -241,36 +248,48 @@ function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
@@ -285,9 +304,33 @@ function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
{...register("title")}
/>
{errors.title && (
- {errors.title.message}
+
+ {errors.title.message}
+
)}
+
+
+
+ Advance Payment
+
+
+ {errors.isAdvancePayment && (
+ {errors.isAdvancePayment.message}
+ )}
+
+
+
@@ -396,7 +439,7 @@ function ManagePaymentRequest({ closeModal, expenseToEdit = null }) {
-
+