- {/* Created & Paid By */}
+ {/* Row 6 */}
{data.createdBy && (
-
+
-
)}
-
-
+
-
+
Paid By :
-
-
- {`${data.paidBy?.firstName ?? ""} ${data.paidBy?.lastName ?? ""}`.trim() || "N/A"}
-
+
+
+
+ {`${data.paidBy?.firstName ?? ""} ${
+ data.paidBy?.lastName ?? ""
+ }`.trim() || "N/A"}
+
+
-
- {/* Description */}
-
-
Description :
+
+
+
Description :
{data?.description}
+
- {/* Attachments */}
-
-
Attachment :
-
- {data?.documents?.map((doc) => {
- const isImage = doc.contentType?.includes("image");
- return (
-
{
- if (isImage) {
- setDocumentView({
- IsOpen: true,
- Image: doc.preSignedUrl,
- });
- }
- }}
+
+
Attachment :
+
+
+ {data?.documents?.map((doc) => {
+ const isImage = doc.contentType?.includes("image");
+
+ return (
+
{
+ if (isImage) {
+ setDocumentView({
+ IsOpen: true,
+ Image: doc.preSignedUrl,
+ });
+ }
+ }}
+ >
+
+
-
-
- {doc.fileName}
-
-
- );
- })}
-
-
+ {doc.fileName}
+
+
+ );
+ })}
-
- {/* ... your remaining conditional sections */}
-
-
-
+ {data.expensesReimburse && (
+
+
+
+ Transaction ID :
+
+ {data.expensesReimburse.reimburseTransactionId || "N/A"}
+
+
+
+ Reimburse Date :
+
+ {formatUTCToLocalTime(data.expensesReimburse.reimburseDate)}
+
+
+ {data.expensesReimburse && (
+ <>
+
+
+ Reimburse By :
+
+
+
+ {`${data?.expensesReimburse?.reimburseBy?.firstName} ${data?.expensesReimburse?.reimburseBy?.lastName}`.trim()}
+
+
+ >
+ )}
+
+ )}
+
+
+ {Array.isArray(data?.nextStatus) && data.nextStatus.length > 0 && (
+ <>
+ {IsPaymentProcess && nextStatusWithPermission?.length > 0 && (
+
+
+ Transaction Id
+
+ {errors.reimburseTransactionId && (
+
+ {errors.reimburseTransactionId.message}
+
+ )}
+
+
+ Transaction Date
+
+ {errors.reimburseDate && (
+
+ {errors.reimburseDate.message}
+
+ )}
+
+
+ Reimburse By
+
+
+
+ )}
+
+ {((nextStatusWithPermission.length > 0 && !IsRejectedExpense) ||
+ (IsRejectedExpense && isCreatedBy)) && (
+ <>
+
Comment
+
+ {errors.comment && (
+
+ {errors.comment.message}
+
+ )}
+ >
+ )}
+
+ {nextStatusWithPermission?.length > 0 &&
+ (!IsRejectedExpense || isCreatedBy) && (
+
+ {nextStatusWithPermission.map((status, index) => (
+
+ ))}
+
+ )}
+
+ >
+ )}
+
-
-
-
-
+
);
};
diff --git a/src/components/PaymentRequest/ManagePaymentRequest.jsx b/src/components/PaymentRequest/ManagePaymentRequest.jsx
index 066a41fb..531468f4 100644
--- a/src/components/PaymentRequest/ManagePaymentRequest.jsx
+++ b/src/components/PaymentRequest/ManagePaymentRequest.jsx
@@ -1,508 +1,519 @@
-import React, { useEffect, useState } from "react";
-import { useCurrencies, useProjectName } from "../../hooks/useProjects";
-import Label from "../common/Label";
-import { useForm } from "react-hook-form";
-import { useExpenseCategory } from "../../hooks/masterHook/useMaster";
-import DatePicker from "../common/DatePicker";
-import {
- useCreatePaymentRequest,
- usePayee,
- usePaymentRequestDetail,
- useUpdatePaymentRequest,
-} from "../../hooks/useExpense";
+import React, { useEffect, useState } from 'react'
+import { useCurrencies, useProjectName } from '../../hooks/useProjects';
+import Label from '../common/Label';
+import { useForm } from 'react-hook-form';
+import { useExpenseCategory } from '../../hooks/masterHook/useMaster';
+import DatePicker from '../common/DatePicker';
+import { useCreatePaymentRequest, usePaymentRequestDetail, useUpdatePaymentRequest } from '../../hooks/useExpense';
-import { zodResolver } from "@hookform/resolvers/zod";
-import { formatFileSize, localToUtc } from "../../utils/appUtils";
-import {
- defaultPaymentRequest,
- PaymentRequestSchema,
-} from "./PaymentRequestSchema";
-import { INR_CURRENCY_CODE } from "../../utils/constants";
-import { useProfile } from "../../hooks/useProfile";
-import Filelist from "../Expenses/Filelist";
-import InputSuggestions from "../common/InputSuggestion";
+import { zodResolver } from '@hookform/resolvers/zod';
+import { formatFileSize, localToUtc } from '../../utils/appUtils';
+import { defaultPaymentRequest, PaymentRequestSchema } from './PaymentRequestSchema';
+import { INR_CURRENCY_CODE } from '../../utils/constants';
+import { useProfile } from '../../hooks/useProfile';
function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
- const {
- data,
- isLoading,
- isError,
- error: requestError,
- } = usePaymentRequestDetail(requestToEdit);
+ const { data, isLoading, isError, error: requestError } = usePaymentRequestDetail(requestToEdit)
+ // const data = {}
- const {
- projectNames,
- loading: projectLoading,
- error,
- isError: isProjectError,
- } = useProjectName();
+ const { projectNames, loading: projectLoading, error, isError: isProjectError,
+ } = useProjectName();
- const {
- data: currencyData,
- isLoading: currencyLoading,
- isError: currencyError,
- } = useCurrencies();
+ const { data: currencyData, isLoading: currencyLoading, isError: currencyError } = useCurrencies();
- const {
- ExpenseCategories,
- loading: ExpenseLoading,
- error: ExpenseError,
- } = useExpenseCategory();
- const { profile } = useProfile();
- const {data:Payees,isLoading:isPayeeLoaing,isError:isPayeeError,error:payeeError} = usePayee()
- const schema = PaymentRequestSchema(ExpenseCategories);
- const {
- register,
- control,
- watch,
- handleSubmit,
- setValue,
- reset,
- formState: { errors },
- } = useForm({
- resolver: zodResolver(schema),
- defaultValues: defaultPaymentRequest,
- });
+ const {
+ ExpenseCategories,
+ loading: ExpenseLoading,
+ error: ExpenseError,
+ } = useExpenseCategory();
- const [isItself, setisItself] = useState(false);
+ const { profile } = useProfile();
- const files = watch("billAttachments");
- const onFileChange = async (e) => {
- const newFiles = Array.from(e.target.files);
- if (newFiles.length === 0) return;
+ const schema = PaymentRequestSchema(ExpenseCategories);
+ const { register, control, watch, handleSubmit, setValue, reset, formState: { errors }, } = useForm({
+ resolver: zodResolver(schema),
+ defaultValues: defaultPaymentRequest,
+ });
- const existingFiles = watch("billAttachments") || [];
+ const [isItself, setisItself] = useState(false);
- const parsedFiles = await Promise.all(
- newFiles.map(async (file) => {
- const base64Data = await toBase64(file);
- return {
- fileName: file.name,
- base64Data,
- contentType: file.type,
- fileSize: file.size,
- description: "",
- isActive: true,
- };
- })
+ const files = watch("billAttachments");
+ const onFileChange = async (e) => {
+ const newFiles = Array.from(e.target.files);
+ if (newFiles.length === 0) return;
+
+ const existingFiles = watch("billAttachments") || [];
+
+ const parsedFiles = await Promise.all(
+ newFiles.map(async (file) => {
+ const base64Data = await toBase64(file);
+ return {
+ fileName: file.name,
+ base64Data,
+ contentType: file.type,
+ fileSize: file.size,
+ description: "",
+ isActive: true,
+ };
+ })
+ );
+
+ const combinedFiles = [
+ ...existingFiles,
+ ...parsedFiles.filter(
+ (newFile) =>
+ !existingFiles.some(
+ (f) =>
+ f.fileName === newFile.fileName && f.fileSize === newFile.fileSize
+ )
+ ),
+ ];
+
+ setValue("billAttachments", combinedFiles, {
+ shouldDirty: true,
+ shouldValidate: true,
+ });
+ };
+
+ const toBase64 = (file) =>
+ new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.readAsDataURL(file);
+ reader.onload = () => resolve(reader.result.split(",")[1]);
+ reader.onerror = (error) => reject(error);
+ });
+ const removeFile = (index) => {
+ if (requestToEdit) {
+ const newFiles = files.map((file, i) => {
+ if (file.documentId !== index) return file;
+ return {
+ ...file,
+ isActive: false,
+ };
+ });
+ setValue("billAttachments", newFiles, { shouldValidate: true });
+ } else {
+ const newFiles = files.filter((_, i) => i !== index);
+ setValue("billAttachments", newFiles, { shouldValidate: true });
+ }
+ };
+
+ const handleClose = () => {
+ reset();
+ closeModal();
+ };
+
+ const { mutate: CreatePaymentRequest, isPending: createPending } = useCreatePaymentRequest(
+ () => {
+ handleClose();
+ }
+ );
+ const { mutate: PaymentRequestUpdate, isPending } = useUpdatePaymentRequest(() =>
+ handleClose()
);
- const combinedFiles = [
- ...existingFiles,
- ...parsedFiles.filter(
- (newFile) =>
- !existingFiles.some(
- (f) =>
- f.fileName === newFile.fileName && f.fileSize === newFile.fileSize
- )
- ),
- ];
+ useEffect(() => {
+ if (requestToEdit && data) {
+ reset({
+ title: data.title || "",
+ description: data.description || "",
+ payee: data.payee || "",
+ currencyId: data.currency.id || "",
+ amount: data.amount || "",
+ dueDate: data.dueDate?.slice(0, 10) || "",
+ projectId: data.project.id || "",
+ expenseCategoryId: data.expenseCategory.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,
+ }))
+ : [],
- setValue("billAttachments", combinedFiles, {
- shouldDirty: true,
- shouldValidate: true,
- });
- };
+ });
+ }
+ }, [data, reset]);
- const toBase64 = (file) =>
- new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.readAsDataURL(file);
- reader.onload = () => resolve(reader.result.split(",")[1]);
- reader.onerror = (error) => reject(error);
- });
- const removeFile = (index) => {
- debugger
- if (requestToEdit) {
- const newFiles = files.map((file, i) => {
- if (file.documentId !== index) return file;
- return {
- ...file,
- isActive: false,
+ useEffect(() => {
+ if (!requestToEdit && currencyData && currencyData.length > 0) {
+ const inrCurrency = currencyData.find(
+ (c) => c.id === INR_CURRENCY_CODE
+ );
+ if (inrCurrency) {
+ setValue("currencyId", INR_CURRENCY_CODE, { shouldValidate: true });
+ }
+ }
+ }, [currencyData, requestToEdit, setValue]);
+
+ const onSubmit = (fromdata) => {
+
+ let payload = {
+ ...fromdata,
+ dueDate: localToUtc(fromdata.dueDate),
+ payee:isItself ? profile?.employeeInfo?.id : fromdata.payee
};
- });
- setValue("billAttachments", newFiles, { shouldValidate: true });
- } else {
- const newFiles = files.filter((_, i) => i !== index);
- setValue("billAttachments", newFiles, { shouldValidate: true });
- }
- };
-
- const handleClose = () => {
- reset();
- closeModal();
- };
-
- const { mutate: CreatePaymentRequest, isPending: createPending } =
- useCreatePaymentRequest(() => {
- handleClose();
- });
- const { mutate: PaymentRequestUpdate, isPending } = useUpdatePaymentRequest(
- () => handleClose()
- );
-
- useEffect(() => {
- if (requestToEdit && data) {
- reset({
- title: data.title || "",
- description: data.description || "",
- payee: data.payee || "",
- currencyId: data.currency.id || "",
- amount: data.amount || "",
- dueDate: data.dueDate?.slice(0, 10) || "",
- projectId: data.project.id || "",
- expenseCategoryId: data.expenseCategory.id || "",
- isAdvancePayment: data.isAdvancePayment || false,
- billAttachments: data.attachments
- ? data?.attachments?.map((doc) => ({
- fileName: doc.fileName,
- base64Data: null,
- contentType: doc.contentType,
- documentId: doc.id,
- fileSize: 0,
- description: "",
- preSignedUrl: doc.preSignedUrl,
- isActive: doc.isActive ?? true,
- }))
- : [],
- });
- }
- }, [data, reset]);
-
- useEffect(() => {
- if (!requestToEdit && currencyData && currencyData.length > 0) {
- const inrCurrency = currencyData.find((c) => c.id === INR_CURRENCY_CODE);
- if (inrCurrency) {
- setValue("currencyId", INR_CURRENCY_CODE, { shouldValidate: true });
- }
- }
- }, [currencyData, requestToEdit, setValue]);
-
- const onSubmit = (fromdata) => {
- let payload = {
- ...fromdata,
- dueDate: localToUtc(fromdata.dueDate),
- payee: isItself ? profile?.employeeInfo?.id : fromdata.payee,
+ if (requestToEdit) {
+ const editPayload = { ...payload, id: data.id, payee:isItself ? profile?.employeeInfo?.id : fromdata.payee };
+ PaymentRequestUpdate({ id: data.id, payload: editPayload });
+ } else {
+ CreatePaymentRequest(payload);
+ }
};
- if (requestToEdit) {
- const editPayload = {
- ...payload,
- id: data.id,
- payee: isItself ? profile?.employeeInfo?.id : fromdata.payee,
- };
- PaymentRequestUpdate({ id: data.id, payload: editPayload });
- } else {
- CreatePaymentRequest(payload);
- }
- };
- const handleSetItSelf = (e) => {
- setisItself(e.target.value);
- setValue("payee", `${profile?.employeeInfo.firstName} ${profile?.employeeInfo.lastName}`);
- };
-
- return (
-
-
- {requestToEdit ? "Update Payment Request " : "Create Payment Request"}
-
-
-
- );
+const handleSetItSelf=(e)=>{
+setisItself(e.target.value);
+setValue('payee',profile?.employeeInfo.id)
}
-export default ManagePaymentRequest;
+ return (
+
+
+ {requestToEdit ? "Update Payment Request " : "Create Payment Request"}
+
+
+
+ )
+}
+
+export default ManagePaymentRequest
diff --git a/src/components/PaymentRequest/PaymentRequestList.jsx b/src/components/PaymentRequest/PaymentRequestList.jsx
index 3e8152d5..9e5f351d 100644
--- a/src/components/PaymentRequest/PaymentRequestList.jsx
+++ b/src/components/PaymentRequest/PaymentRequestList.jsx
@@ -6,7 +6,6 @@ import {
} from "../../utils/constants";
import {
formatCurrency,
- formatFigure,
getColorNameFromHex,
useDebounce,
} from "../../utils/appUtils";
@@ -132,7 +131,7 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
align: "text-start",
getValue: (e) => (
<>
- {formatFigure(e?.amount,{type:"currency",currency : e?.currency?.currencyCode})}
+ {formatCurrency(e?.amount)} {e.currency.currencyCode}
>
),
@@ -254,7 +253,7 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
{" "}
-
+
{displayField} :{" "}
{" "}
@@ -272,9 +271,9 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
key={col.key}
className={`d-table-cell ${col.align ?? ""}`}
>
- {col?.customRender
+ {col?.customRender
? col?.customRender(paymentRequest)
- : col?.getValue(paymentRequest)}
+ : col?.getValue(paymentRequest)}
|
)
)}
diff --git a/src/components/PaymentRequest/PaymentRequestSchema.js b/src/components/PaymentRequest/PaymentRequestSchema.js
index 018b092f..fb813b63 100644
--- a/src/components/PaymentRequest/PaymentRequestSchema.js
+++ b/src/components/PaymentRequest/PaymentRequestSchema.js
@@ -7,48 +7,56 @@ const ALLOWED_TYPES = [
"image/jpg",
"image/jpeg",
];
-export const PaymentRequestSchema = (expenseTypes, isItself) => {
- return z.object({
- title: z.string().min(1, { message: "Project is required" }),
- projectId: z.string().min(1, { message: "Project is required" }),
- expenseCategoryId: z
- .string()
- .min(1, { message: "Expense Category is required" }),
- currencyId: z.string().min(1, { message: "Currency is required" }),
- dueDate: z.string().min(1, { message: "Date is required" }),
- description: z.string().min(1, { message: "Description is required" }),
- payee: z.string().min(1, { message: "Supplier name is required" }),
- isAdvancePayment: z.boolean().optional(),
- amount: z.coerce
- .number({
- invalid_type_error: "Amount is required and must be a number",
- })
- .min(1, "Amount must be Enter")
- .refine((val) => /^\d+(\.\d{1,2})?$/.test(val.toString()), {
- message: "Amount must have at most 2 decimal places",
- }),
- billAttachments: z
- .array(
- z.object({
- fileName: z.string().min(1, { message: "Filename is required" }),
- base64Data: z.string().nullable(),
- contentType: z.string().refine((val) => ALLOWED_TYPES.includes(val), {
- message: "Only PDF, PNG, JPG, or JPEG files are allowed",
- }),
- documentId: z.string().optional(),
- fileSize: z.number().max(MAX_FILE_SIZE, {
- message: "File size must be less than or equal to 5MB",
- }),
- description: z.string().optional(),
- isActive: z.boolean().default(true),
+export const PaymentRequestSchema = (expenseTypes,isItself) => {
+ return z
+ .object({
+ title: z.string().min(1, { message: "Project is required" }),
+ projectId: z.string().min(1, { message: "Project is required" }),
+ expenseCategoryId: z
+ .string()
+ .min(1, { message: "Expense Category is required" }),
+ currencyId: z
+ .string()
+ .min(1, { message: "Currency is required" }),
+ dueDate: z.string().min(1, { message: "Date is required" }),
+ description: z.string().min(1, { message: "Description is required" }),
+ payee: z.string().min(1, { message: "Supplier name is required" }),
+ isAdvancePayment: z.boolean().optional(),
+ amount: z.coerce
+ .number({
+ invalid_type_error: "Amount is required and must be a number",
})
- )
- .optional(),
- });
-};
+ .min(1, "Amount must be Enter")
+ .refine((val) => /^\d+(\.\d{1,2})?$/.test(val.toString()), {
+ message: "Amount must have at most 2 decimal places",
+ }),
+ billAttachments: z
+ .array(
+ z.object({
+ fileName: z.string().min(1, { message: "Filename is required" }),
+ base64Data: z.string().nullable(),
+ contentType: z
+ .string()
+ .refine((val) => ALLOWED_TYPES.includes(val), {
+ message: "Only PDF, PNG, JPG, or JPEG files are allowed",
+ }),
+ documentId: z.string().optional(),
+ fileSize: z.number().max(MAX_FILE_SIZE, {
+ message: "File size must be less than or equal to 5MB",
+ }),
+ description: z.string().optional(),
+ isActive: z.boolean().default(true),
+ })
+ ).refine((data)=>{
+ if(isItself){
+ payee.z.string().optional();
+ }
+ }),
+ })
+ };
export const defaultPaymentRequest = {
- title: "",
+ title:"",
description: "",
payee: "",
currencyId: "",
@@ -56,10 +64,11 @@ export const defaultPaymentRequest = {
dueDate: "",
projectId: "",
expenseCategoryId: "",
- isAdvancePayment: boolean,
+ isAdvancePayment:boolean,
billAttachments: [],
};
+
export const SearchPaymentRequestSchema = z.object({
projectIds: z.array(z.string()).optional(),
statusIds: z.array(z.string()).optional(),
@@ -82,6 +91,7 @@ export const defaultPaymentRequestFilter = {
endDate: null,
};
+
export const PaymentRequestActionScheam = (
isTransaction = false,
transactionDate
@@ -90,16 +100,17 @@ export const PaymentRequestActionScheam = (
.object({
comment: z.string().min(1, { message: "Please leave comment" }),
statusId: z.string().min(1, { message: "Please select a status" }),
- paidTransactionId: z.string().nullable().optional(),
+ paymentRequestId: z.string().nullable().optional(),
paidAt: z.string().nullable().optional(),
paidById: z.string().nullable().optional(),
+
})
.superRefine((data, ctx) => {
if (isTransaction) {
- if (!data.paidTransactionId?.trim()) {
+ if (!data.paymentRequestId?.trim()) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
- path: ["paidTransactionId"],
+ path: ["reimburseTransactionId"],
message: "Reimburse Transaction ID is required",
});
}
@@ -110,7 +121,15 @@ export const PaymentRequestActionScheam = (
message: "Transacion Date is required",
});
}
-
+ // let reimburse_Date = localToUtc(data.reimburseDate);
+ // if (transactionDate > reimburse_Date) {
+ // ctx.addIssue({
+ // code: z.ZodIssueCode.custom,
+ // path: ["reimburseDate"],
+ // message:
+ // "Reimburse Date must be greater than or equal to Expense created Date",
+ // });
+ // }
if (!data.paidById) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
@@ -122,11 +141,11 @@ export const PaymentRequestActionScheam = (
});
};
-export const defaultPaymentRequestActionValues = {
+export const defaultActionValues = {
comment: "",
statusId: "",
paidTransactionId: null,
paidAt: null,
paidById: null,
-};
+};
\ No newline at end of file
diff --git a/src/components/PaymentRequest/PaymentStatusLogs.jsx b/src/components/PaymentRequest/PaymentStatusLogs.jsx
deleted file mode 100644
index 9abb3fa5..00000000
--- a/src/components/PaymentRequest/PaymentStatusLogs.jsx
+++ /dev/null
@@ -1,93 +0,0 @@
-import { useState, useMemo } from "react";
-import Avatar from "../common/Avatar";
-import { formatUTCToLocalTime } from "../../utils/dateUtils";
-import Timeline from "../common/TimeLine";
-import moment from "moment";
-import { getColorNameFromHex } from "../../utils/appUtils";
-const PaymentStatusLogs = ({ data }) => {
- const [visibleCount, setVisibleCount] = useState(4);
-
- const sortedLogs = useMemo(() => {
- if (!data?.updateLogs) return [];
- return [...data.updateLogs].sort(
- (a, b) => new Date(b.updatedAt) - new Date(a.updatedAt)
- );
- }, [data?.updateLogs]);
-
- const logsToShow = useMemo(
- () => sortedLogs.slice(0, visibleCount),
- [sortedLogs, visibleCount]
- );
-
- const timelineData = useMemo(() => {
- return logsToShow.map((log, index) => ({
- id: index + 1,
- title: log.nextStatus?.name || "Status Updated",
- description: log.nextStatus?.description || "",
- timeAgo: log.updatedAt,
- color: getColorNameFromHex(log.nextStatus?.color) || "primary",
- users: log.updatedBy
- ? [
- {
- firstName: log.updatedBy.firstName || "",
- lastName: log?.updatedBy?.lastName || "",
- role: log.updatedBy.jobRoleName || "",
- avatar: log.updatedBy.photo,
- },
- ]
- : [],
- }));
- }, [logsToShow]);
-
- const handleShowMore = () => {
- setVisibleCount((prev) => prev + 4);
- };
-
- return (
-
- {/*
- {logsToShow.map((log) => (
-
-
-
-
-
-
- {`${log.updatedBy.firstName} ${log.updatedBy.lastName}`}
-
- {log.action}
-
-
- {formatUTCToLocalTime(log.updateAt, true)}
-
-
-
- {log.comment}
-
-
-
-
- ))}
-
-
- {sortedLogs.length > visibleCount && (
-
-
-
- )} */}
-
-
-
- );
-};
-
-export default PaymentStatusLogs;
diff --git a/src/components/PaymentRequest/ViewPaymentRequest.jsx b/src/components/PaymentRequest/ViewPaymentRequest.jsx
index 0d7d280b..7be1b5e3 100644
--- a/src/components/PaymentRequest/ViewPaymentRequest.jsx
+++ b/src/components/PaymentRequest/ViewPaymentRequest.jsx
@@ -1,4 +1,4 @@
-import { useEffect, useMemo, useState } from "react";
+import { useMemo, useState } from "react";
import {
useActionOnExpense,
useActionOnPaymentRequest,
@@ -6,7 +6,6 @@ import {
} from "../../hooks/useExpense";
import {
formatCurrency,
- formatFigure,
getColorNameFromHex,
getIconByFileType,
localToUtc,
@@ -29,18 +28,11 @@ import { useNavigate } from "react-router-dom";
import { usePaymentRequestContext } from "../../pages/PaymentRequest/PaymentRequestPage";
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
import {
- EXPENSE_DRAFT,
EXPENSE_REJECTEDBY,
PROCESS_EXPENSE,
REVIEW_EXPENSE,
} from "../../utils/constants";
import Label from "../common/Label";
-import {
- defaultPaymentRequestActionValues,
- PaymentRequestActionScheam,
-} from "./PaymentRequestSchema";
-import PaymentStatusLogs from "./PaymentStatusLogs";
-import { FilelistView } from "../Expenses/Filelist";
const ViewPaymentRequest = ({ requestId }) => {
const { data, isLoading, isError, error, isFetching } =
@@ -50,10 +42,9 @@ const ViewPaymentRequest = ({ requestId }) => {
const IsReview = useHasUserPermission(REVIEW_EXPENSE);
const [imageLoaded, setImageLoaded] = useState({});
- const { setDocumentView, setModalSize } = usePaymentRequestContext();
+ const { setDocumentView } = usePaymentRequestContext();
const ActionSchema =
- PaymentRequestActionScheam(IsPaymentProcess, data?.createdAt) ??
- z.object({});
+ ExpenseActionScheam(IsPaymentProcess, data?.createdAt) ?? z.object({});
const navigate = useNavigate();
const {
register,
@@ -64,7 +55,7 @@ const ViewPaymentRequest = ({ requestId }) => {
formState: { errors },
} = useForm({
resolver: zodResolver(ActionSchema),
- defaultValues: defaultPaymentRequestActionValues,
+ defaultValues: defaultActionValues,
});
const userPermissions = useSelector(
@@ -106,7 +97,7 @@ const ViewPaymentRequest = ({ requestId }) => {
const onSubmit = (formData) => {
const Payload = {
...formData,
- paidAt: localToUtc(formData.paidAt),
+ paidAt: localToUtc(formData.reimburseDate),
paymentRequestId: data.id,
comment: formData.comment,
};
@@ -121,24 +112,17 @@ const ViewPaymentRequest = ({ requestId }) => {
return (