From ca5610c7202dd741cada056ca5b93c4d5d091e5c Mon Sep 17 00:00:00 2001 From: pramod mahajan Date: Fri, 1 Aug 2025 18:39:03 +0530 Subject: [PATCH] user can not select reimburseDate before transaction date --- src/components/Expenses/ManageExpense.jsx | 2 +- src/components/Expenses/ViewExpense.jsx | 188 ++++++++++-------- src/components/common/DatePicker.jsx | 2 + src/components/common/EmployeeSearchInput.jsx | 2 +- 4 files changed, 107 insertions(+), 87 deletions(-) diff --git a/src/components/Expenses/ManageExpense.jsx b/src/components/Expenses/ManageExpense.jsx index 80ba23a5..37bc50b5 100644 --- a/src/components/Expenses/ManageExpense.jsx +++ b/src/components/Expenses/ManageExpense.jsx @@ -57,7 +57,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => { (store) => store.localVariables.projectId ); const { projectNames, loading: projectLoading, error } = useProjectName(); - +debugger const { PaymentModes, loading: PaymentModeLoading, diff --git a/src/components/Expenses/ViewExpense.jsx b/src/components/Expenses/ViewExpense.jsx index e46b005d..3ff0d32d 100644 --- a/src/components/Expenses/ViewExpense.jsx +++ b/src/components/Expenses/ViewExpense.jsx @@ -12,7 +12,11 @@ import { useExpenseContext } from "../../pages/Expense/ExpensePage"; import { getColorNameFromHex } from "../../utils/appUtils"; import { ExpenseDetailsSkeleton } from "./ExpenseSkeleton"; import { useHasUserPermission } from "../../hooks/useHasUserPermission"; -import { EXPENSE_REJECTEDBY, PROCESS_EXPENSE, REVIEW_EXPENSE } from "../../utils/constants"; +import { + EXPENSE_REJECTEDBY, + PROCESS_EXPENSE, + REVIEW_EXPENSE, +} from "../../utils/constants"; import { useProfile } from "../../hooks/useProfile"; import { useSelector } from "react-redux"; import { useNavigate } from "react-router-dom"; @@ -69,22 +73,25 @@ const ViewExpense = ({ ExpenseId }) => { }); }, [data, userPermissions]); - const IsRejectedExpense = useMemo(()=>{ - return EXPENSE_REJECTEDBY.includes(data?.status?.id) - },[data]) + const IsRejectedExpense = useMemo(() => { + return EXPENSE_REJECTEDBY.includes(data?.status?.id); + }, [data]); const isCreatedBy = useMemo(() => { - return data?.createdBy.id === CurrentUser?.id; -}, [data, CurrentUser]); + return data?.createdBy.id === CurrentUser?.id; + }, [data, CurrentUser]); - const { mutate: MakeAction,isPending } = useActionOnExpense(() => { + const { mutate: MakeAction, isPending } = useActionOnExpense(() => { setClickedStatusId(null); - reset()}); + reset(); + }); const onSubmit = (formData) => { const Payload = { ...formData, - reimburseDate:moment.utc(formData.reimburseDate, "DD-MM-YYYY").toISOString(), + reimburseDate: moment + .utc(formData.reimburseDate, "DD-MM-YYYY") + .toISOString(), expenseId: ExpenseId, comment: formData.comment, }; @@ -340,42 +347,51 @@ const ViewExpense = ({ ExpenseId }) => { )} - {data.expensesReimburse && (
-
- Transaction ID : {data.expensesReimburse.reimburseTransactionId || "N/A"} -
-
- Reimburse Date :{" "} - { moment(data.expensesReimburse.reimburseDate).format("DD-MM-YYYY") } -
+ {data.expensesReimburse && ( +
+
+ + {data.expensesReimburse.reimburseTransactionId || "N/A"} +
+
+ + {formatUTCToLocalTime(data.expensesReimburse.reimburseDate)} +
- {data.expensesReimburse && ( - <> -
- Reimburse By : - - - {`${data?.expensesReimburse?.reimburseBy?.firstName} ${data?.expensesReimburse?.reimburseBy?.lastName}`.trim()} - -
- - )} + {data.expensesReimburse && ( + <> +
+ + + + {`${data?.expensesReimburse?.reimburseBy?.firstName} ${data?.expensesReimburse?.reimburseBy?.lastName}`.trim()} + +
+ + )} -
- Note : {data.expensesReimburse.reimburseNote} -
- -
)} - - +
+ {" "} + {data.expensesReimburse.reimburseNote} +
+
+ )}
- +
{data?.description}
@@ -444,7 +460,7 @@ const ViewExpense = ({ ExpenseId }) => { {Array.isArray(data?.nextStatus) && data.nextStatus.length > 0 && ( <> - {(IsPaymentProcess && nextStatusWithPermission?.length > 0) && ( + {IsPaymentProcess && nextStatusWithPermission?.length > 0 && (
@@ -461,7 +477,11 @@ const ViewExpense = ({ ExpenseId }) => {
- + {errors.reimburseDate && ( {errors.reimburseDate.message} @@ -478,49 +498,47 @@ const ViewExpense = ({ ExpenseId }) => {
)} -
- {( - (nextStatusWithPermission.length > 0 && !IsRejectedExpense) || - (IsRejectedExpense && isCreatedBy) - ) && ( - <> - -