-
-
-
- {errors.projectId && (
- {errors.projectId.message}
- )}
-
+ const { mutate: CreateRecurringExpense, isPending: createPending } = useCreateRecurringExpense(
+ () => {
+ handleClose();
+ }
+ );
+ const { mutate: RecurringExpenseUpdate, isPending } = useUpdateRecurringExpense(() =>
+ handleClose()
+ );
-
-
-
- {errors.expenseCategoryId && (
-
- {errors.expenseCategoryId.message}
-
- )}
-
-
+ useEffect(() => {
+ if (requestToEdit && data) {
+ reset({
+ title: data.title || "",
+ description: data.description || "",
+ payee: data.payee || "",
+ notifyTo: data.notifyTo || "",
+ currencyId: data.currency.id || "",
+ amount: data.amount || "",
+ strikeDate: data.strikeDate?.slice(0, 10) || "",
+ projectId: data.project.id || "",
+ paymentBufferDays: data.paymentBufferDays || "",
+ numberOfIteration: data.numberOfIteration || "",
+ expenseCategoryId: data.expenseCategory.id || "",
+ statusId: data.statusId || "",
+ frequency: data.frequency || "",
+ isVariable: data.isVariable || false,
- {/* Title and Is Variable */}
-
-
-
-
- {errors.title && (
- {errors.title.message}
- )}
-
+ });
+ }
+ }, [data, reset]);
-
-
-
(
-
-
- field.onChange(true)}
- />
-
-
+ 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]);
-
- field.onChange(false)}
- />
-
-
+ const onSubmit = (fromdata) => {
+ let payload = {
+ ...fromdata,
+ strikeDate: fromdata.strikeDate ? new Date(fromdata.strikeDate).toISOString() : null,
+ };
+ if (requestToEdit) {
+ const editPayload = { ...payload, id: data.id };
+ RecurringExpenseUpdate({ id: data.id, payload: editPayload });
+ } else {
+ CreateRecurringExpense(payload);
+ }
+ };
+
+ return (
+
+
+ {requestToEdit ? "Update Expense Recurring " : "Create Expense Recurring"}
+
+
+
+ {/* Title and Is Variable */}
+
+
+
+
+ {errors.title && (
+
+ {errors.title.message}
+
+ )}
+
+
+ {/*
+
+
+ {errors.isVariable && (
+ {errors.isVariable.message}
+ )}
+
*/}
+
+
+
+
+
(
+
+ )}
+ />
+ {errors.isVariable && (
+ {errors.isVariable.message}
+ )}
+
+
+
+ {/* Date and Amount */}
+
+
+
+
+ {errors.strikeDate && (
+
+ {errors.strikeDate.message}
+
+ )}
+
+
+
+
+
+ {errors.amount && (
+ {errors.amount.message}
+ )}
+
+
+
+ {/* Payee and Currency */}
+
+
+
+
+ setValue("payee", val, { shouldValidate: true })
+ }
+ error={errors.payee?.message}
+ placeholder="Select or enter payee"
+ />
+
+
+
+
+
+ {errors.currencyId && (
+ {errors.currencyId.message}
+ )}
+
+
+
+ {/* Frequency To and Status Id */}
+
+
+
+
+ {errors.frequency && (
+ {errors.frequency.message}
+ )}
+
+
+
+
+ {errors.statusId && (
+ {errors.statusId.message}
+ )}
+
+
+
+ {/* Payment Buffer Days and Number of Iteration */}
+
+
+ {/* Notify */}
+ {/*
+
+
+
+ {errors.notifyTo && (
+
+ {errors.notifyTo.message}
+
+ )}
+
+
*/}
+
+
+
+
+
+
+
+
+
+ {/* Description */}
+
+
+
+
+ {errors.description && (
+
+ {errors.description.message}
+
+ )}
+
+
+
+
+
+
+
+
-
- {/* Date and Amount */}
-
-
-
-
- {errors.strikeDate && (
- {errors.strikeDate.message}
- )}
-
-
-
-
-
- {errors.amount && (
- {errors.amount.message}
- )}
-
-
-
- {/* Payee and Currency */}
-
-
-
-
- setValue("payee", val, { shouldValidate: true })
- }
- error={errors.payee?.message}
- placeholder="Select or enter payee"
- />
-
-
-
-
-
- {errors.currencyId && (
- {errors.currencyId.message}
- )}
-
-
-
- {/* Frequency To and Status Id */}
-
-
-
-
- {errors.frequency && (
- {errors.frequency.message}
- )}
-
-
-
-
-
- {errors.statusId && (
- {errors.statusId.message}
- )}
-
-
-
- {/* Payment Buffer Days and Number of Iteration */}
-
-
-
-
-
-
-
-
-
-
- {/* Description */}
-
-
-
-
- {errors.description && (
-
- {errors.description.message}
-
- )}
-
-
-
-
-
-
-
-
-
- );
+ )
}
-export default ManageRecurringExpense;
+export default ManageRecurringExpense
+
diff --git a/src/components/RecurringExpense/RecurringExpenseList.jsx b/src/components/RecurringExpense/RecurringExpenseList.jsx
index 1a61847f..8fb81227 100644
--- a/src/components/RecurringExpense/RecurringExpenseList.jsx
+++ b/src/components/RecurringExpense/RecurringExpenseList.jsx
@@ -148,7 +148,7 @@ const RecurringExpenseList = ({ search, filterStatuses }) => {
isOpen={IsDeleteModalOpen}
type="delete"
header="Delete Recurring Expense"
- message="Are you sure you want to delete?"
+ message="Under the working"
onSubmit={handleDelete}
onClose={() => setIsDeleteModalOpen(false)}
paramData={deletingId}
@@ -188,7 +188,7 @@ const RecurringExpenseList = ({ search, filterStatuses }) => {
))}
-
+
@@ -198,7 +198,6 @@ const RecurringExpenseList = ({ search, filterStatuses }) => {
// })
// }
>
- {/* Uncomment for edit/delete actions */}
|