fixed updated recurring

This commit is contained in:
pramod.mahajan 2025-11-06 10:07:36 +05:30
parent a253eea33c
commit deda915e74
8 changed files with 475 additions and 487 deletions

View File

@ -55,7 +55,6 @@ const Filelist = ({ files, removeFile, expenseToEdit }) => {
export default Filelist; export default Filelist;
export const FilelistView = ({ files, viewFile }) => { export const FilelistView = ({ files, viewFile }) => {
console.log( files)
return ( return (
<div className="d-flex flex-wrap gap-2 mt-2"> <div className="d-flex flex-wrap gap-2 mt-2">
{files?.map((file, idx) => ( {files?.map((file, idx) => (

View File

@ -224,7 +224,7 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
isOpen={IsDeleteModalOpen} isOpen={IsDeleteModalOpen}
type="delete" type="delete"
header="Delete Expense" header="Delete Expense"
message="Are you sure you want delete?" message="Under the woring?"
onSubmit={handleDelete} onSubmit={handleDelete}
onClose={() => setIsDeleteModalOpen(false)} onClose={() => setIsDeleteModalOpen(false)}
// loading={isPending} // loading={isPending}

View File

@ -521,7 +521,7 @@ const ViewPaymentRequest = ({ requestId }) => {
)} )}
</div> </div>
</> </>
) : !data?.isExpenseCreated ? ( ) : (!data?.isExpenseCreated && ! data?.isAdvancePayment) ? (
<div className="text-end flex-wrap gap-2 my-2 mt-3"> <div className="text-end flex-wrap gap-2 my-2 mt-3">
<button <button
className="btn btn-sm btn-primary" className="btn btn-sm btn-primary"

View File

@ -1,490 +1,484 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from 'react'
import Label from "../common/Label"; import Label from '../common/Label';
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from 'react-hook-form';
import { import { useExpenseCategory, useRecurringStatus } from '../../hooks/masterHook/useMaster';
useExpenseCategory, import DatePicker from '../common/DatePicker';
useRecurringStatus, import { zodResolver } from '@hookform/resolvers/zod';
} from "../../hooks/masterHook/useMaster"; import { defaultRecurringExpense, PaymentRecurringExpense } from './RecurringExpenseSchema';
import DatePicker from "../common/DatePicker"; import { FREQUENCY_FOR_RECURRING, INR_CURRENCY_CODE } from '../../utils/constants';
import { zodResolver } from "@hookform/resolvers/zod"; import { useCurrencies, useProjectName } from '../../hooks/useProjects';
import { import { useCreateRecurringExpense, usePayee, useRecurringExpenseDetail, useUpdateRecurringExpense } from '../../hooks/useExpense';
defaultRecurringExpense, import InputSuggestions from '../common/InputSuggestion';
PaymentRecurringExpense, import MultiEmployeeSearchInput from '../common/MultiEmployeeSearchInput';
} from "./RecurringExpenseSchema";
import {
FREQUENCY_FOR_RECURRING,
INR_CURRENCY_CODE,
} from "../../utils/constants";
import { useCurrencies, useProjectName } from "../../hooks/useProjects";
import {
useCreateRecurringExpense,
usePayee,
useRecurringExpenseDetail,
useUpdateRecurringExpense,
} from "../../hooks/useExpense";
import InputSuggestions from "../common/InputSuggestion";
import MultiEmployeeSearchInput from "../common/MultiEmployeeSearchInput";
function ManageRecurringExpense({ closeModal, requestToEdit = null }) { function ManageRecurringExpense({ closeModal, requestToEdit = null }) {
const { const {
data, data,
isLoading, isLoading,
isError, isError,
error: requestError, error: requestError,
} = useRecurringExpenseDetail(requestToEdit); } = useRecurringExpenseDetail(requestToEdit);
//APIs
const { projectNames, loading: projectLoading, error, isError: isProjectError, } = useProjectName();
const { data: currencyData, isLoading: currencyLoading, isError: currencyError } = useCurrencies();
const { data: statusData, isLoading: statusLoading, isError: statusError } = useRecurringStatus();
const { data: Payees, isLoading: isPayeeLoaing, isError: isPayeeError, error: payeeError } = usePayee()
const { ExpenseCategories, loading: ExpenseLoading, error: ExpenseError } = useExpenseCategory();
//APIs const schema = PaymentRecurringExpense();
const { const { register, control, watch, handleSubmit, setValue, reset, formState: { errors }, } = useForm({
projectNames, resolver: zodResolver(schema),
loading: projectLoading, defaultValues: defaultRecurringExpense,
error,
isError: isProjectError,
} = useProjectName();
const {
data: currencyData,
isLoading: currencyLoading,
isError: currencyError,
} = useCurrencies();
const {
data: statusData,
isLoading: statusLoading,
isError: statusError,
} = useRecurringStatus();
const {
data: Payees,
isLoading: isPayeeLoaing,
isError: isPayeeError,
error: payeeError,
} = usePayee();
const {
ExpenseCategories,
loading: ExpenseLoading,
error: ExpenseError,
} = useExpenseCategory();
const schema = PaymentRecurringExpense();
const {
register,
control,
watch,
handleSubmit,
setValue,
reset,
formState: { errors },
} = useForm({
resolver: zodResolver(schema),
defaultValues: defaultRecurringExpense,
});
const handleClose = () => {
reset();
closeModal();
};
const { mutate: CreateRecurringExpense, isPending: createPending } =
useCreateRecurringExpense(() => {
handleClose();
}); });
// const { mutate: PaymentRequestUpdate, isPending } = useUpdatePaymentRequest(() => const handleClose = () => {
// handleClose() reset();
// ); closeModal();
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,
});
}
}, [data, reset]);
// console.log("Veer",data)
const onSubmit = (fromdata) => {
let payload = {
...fromdata,
// strikeDate: localToUtc(fromdata.strikeDate),
strikeDate: fromdata.strikeDate
? new Date(fromdata.strikeDate).toISOString()
: null,
}; };
if (requestToEdit) {
const editPayload = { ...payload, id: data.id };
PaymentRequestUpdate({ id: data.id, payload: editPayload });
} else {
CreateRecurringExpense(payload);
}
console.log("Kartik", payload);
};
return ( const { mutate: CreateRecurringExpense, isPending: createPending } = useCreateRecurringExpense(
<div className="container p-3"> () => {
<h5 className="m-0"> handleClose();
{requestToEdit }
? "Update Expense Recurring " );
: "Create Expense Recurring"} const { mutate: RecurringExpenseUpdate, isPending } = useUpdateRecurringExpense(() =>
</h5> handleClose()
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}> );
{/* Project and Category */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label className="form-label" required>
Select Project
</Label>
<select
className="form-select form-select-sm"
{...register("projectId")}
>
<option value="">Select Project</option>
{projectLoading ? (
<option>Loading...</option>
) : (
projectNames?.map((project) => (
<option key={project.id} value={project.id}>
{project.name}
</option>
))
)}
</select>
{errors.projectId && (
<small className="danger-text">{errors.projectId.message}</small>
)}
</div>
<div className="col-md-6"> useEffect(() => {
<Label htmlFor="expenseCategoryId" className="form-label" required> if (requestToEdit && data) {
Expense Category reset({
</Label> title: data.title || "",
<select description: data.description || "",
className="form-select form-select-sm" payee: data.payee || "",
id="expenseCategoryId" notifyTo: data.notifyTo || "",
{...register("expenseCategoryId")} currencyId: data.currency.id || "",
> amount: data.amount || "",
<option value="" disabled> strikeDate: data.strikeDate?.slice(0, 10) || "",
Select Category projectId: data.project.id || "",
</option> paymentBufferDays: data.paymentBufferDays || "",
{ExpenseLoading ? ( numberOfIteration: data.numberOfIteration || "",
<option disabled>Loading...</option> expenseCategoryId: data.expenseCategory.id || "",
) : ( statusId: data.statusId || "",
ExpenseCategories?.map((expense) => ( frequency: data.frequency || "",
<option key={expense.id} value={expense.id}> isVariable: data.isVariable || false,
{expense.name}
</option>
))
)}
</select>
{errors.expenseCategoryId && (
<small className="danger-text">
{errors.expenseCategoryId.message}
</small>
)}
</div>
</div>
{/* Title and Is Variable */} });
<div className="row my-2 text-start"> }
<div className="col-md-6"> }, [data, reset]);
<Label htmlFor="title" className="form-label" required>
Title
</Label>
<input
type="text"
id="title"
className="form-control form-control-sm"
{...register("title")}
placeholder="Enter title"
/>
{errors.title && (
<small className="danger-text">{errors.title.message}</small>
)}
</div>
<div className="col-md-6 mt-2">
<Label htmlFor="isVariable" className="form-label" required>
Payment Type
</Label>
<Controller useEffect(() => {
name="isVariable" if (!requestToEdit && currencyData && currencyData.length > 0) {
control={control} const inrCurrency = currencyData.find(
defaultValue={defaultRecurringExpense.isVariable ?? false} (c) => c.id === INR_CURRENCY_CODE
render={({ field }) => ( );
<div className="d-flex align-items-center gap-3"> if (inrCurrency) {
<div className="form-check"> setValue("currencyId", INR_CURRENCY_CODE, { shouldValidate: true });
<input }
type="radio" }
id="isVariableTrue" }, [currencyData, requestToEdit, setValue]);
className="form-check-input"
checked={field.value === true}
onChange={() => field.onChange(true)}
/>
<Label
htmlFor="isVariableTrue"
className="form-check-label"
>
Is Variable
</Label>
</div>
<div className="form-check"> const onSubmit = (fromdata) => {
<input let payload = {
type="radio" ...fromdata,
id="isVariableFalse" strikeDate: fromdata.strikeDate ? new Date(fromdata.strikeDate).toISOString() : null,
className="form-check-input" };
checked={field.value === false} if (requestToEdit) {
onChange={() => field.onChange(false)} const editPayload = { ...payload, id: data.id };
/> RecurringExpenseUpdate({ id: data.id, payload: editPayload });
<Label } else {
htmlFor="isVariableFalse" CreateRecurringExpense(payload);
className="form-check-label" }
> };
Fixed
</Label> return (
</div> <div className="container p-3">
<h5 className="m-0">
{requestToEdit ? "Update Expense Recurring " : "Create Expense Recurring"}
</h5>
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
{/* Project and Category */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label className="form-label" required>
Select Project
</Label>
<select
className="form-select form-select-sm"
{...register("projectId")}
>
<option value="">Select Project</option>
{projectLoading ? (
<option>Loading...</option>
) : (
projectNames?.map((project) => (
<option key={project.id} value={project.id}>
{project.name}
</option>
))
)}
</select>
{errors.projectId && (
<small className="danger-text">{errors.projectId.message}</small>
)}
</div>
<div className="col-md-6">
<Label htmlFor="expenseCategoryId" className="form-label" required>
Expense Category
</Label>
<select
className="form-select form-select-sm"
id="expenseCategoryId"
{...register("expenseCategoryId")}
>
<option value="" disabled>
Select Category
</option>
{ExpenseLoading ? (
<option disabled>Loading...</option>
) : (
ExpenseCategories?.map((expense) => (
<option key={expense.id} value={expense.id}>
{expense.name}
</option>
))
)}
</select>
{errors.expenseCategoryId && (
<small className="danger-text">
{errors.expenseCategoryId.message}
</small>
)}
</div>
</div> </div>
)}
/> {/* Title and Is Variable */}
{errors.isVariable && ( <div className="row my-2 text-start">
<small className="danger-text">{errors.isVariable.message}</small> <div className="col-md-6">
)} <Label htmlFor="title" className="form-label" required>
</div> Title
</Label>
<input
type="text"
id="title"
className="form-control form-control-sm"
{...register("title")}
placeholder="Enter title"
/>
{errors.title && (
<small className="danger-text">
{errors.title.message}
</small>
)}
</div>
{/* <div className="col-md-6">
<Label htmlFor="isVariable" className="form-label" required>
Is Variable
</Label>
<select
id="isVariable"
className="form-select form-select-sm"
{...register("isVariable", {
setValueAs: (v) => v === "true" ? true : v === "false" ? false : false,
})}
>
<option value="false">False</option>
<option value="true">True</option>
</select>
{errors.isVariable && (
<small className="danger-text">{errors.isVariable.message}</small>
)}
</div> */}
<div className="col-md-6 mt-2">
<Label htmlFor="isVariable" className="form-label" required>
Payment Type
</Label>
<Controller
name="isVariable"
control={control}
defaultValue={defaultRecurringExpense.isVariable ?? false}
render={({ field }) => (
<div className="d-flex align-items-center gap-3">
<div className="form-check">
<input
type="radio"
id="isVariableTrue"
className="form-check-input"
checked={field.value === true}
onChange={() => field.onChange(true)}
/>
<Label htmlFor="isVariableTrue" className="form-check-label">
Is Variable
</Label>
</div>
<div className="form-check">
<input
type="radio"
id="isVariableFalse"
className="form-check-input"
checked={field.value === false}
onChange={() => field.onChange(false)}
/>
<Label htmlFor="isVariableFalse" className="form-check-label">
Fixed
</Label>
</div>
</div>
)}
/>
{errors.isVariable && (
<small className="danger-text">{errors.isVariable.message}</small>
)}
</div>
</div>
{/* Date and Amount */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="strikeDate" className="form-label" required>
Strike Date
</Label>
<DatePicker
name="strikeDate"
control={control}
minDate={new Date()}
className='w-100'
/>
{errors.strikeDate && (
<small className="danger-text">
{errors.strikeDate.message}
</small>
)}
</div>
<div className="col-md-6">
<Label htmlFor="amount" className="form-label" required>
Amount
</Label>
<input
type="number"
id="amount"
className="form-control form-control-sm"
min="1"
step="0.01"
inputMode="decimal"
{...register("amount", { valueAsNumber: true })}
placeholder="Enter amount"
/>
{errors.amount && (
<small className="danger-text">{errors.amount.message}</small>
)}
</div>
</div>
{/* Payee and Currency */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="payee" className="form-label" required>
Payee (Supplier Name/Transporter Name/Other)
</Label>
<InputSuggestions
organizationList={Payees}
value={watch("payee") || ""}
onChange={(val) =>
setValue("payee", val, { shouldValidate: true })
}
error={errors.payee?.message}
placeholder="Select or enter payee"
/>
</div>
<div className="col-md-6">
<Label htmlFor="currencyId" className="form-label" required>
Currency
</Label>
<select
id="currencyId"
className="form-select form-select-sm"
{...register("currencyId")}
>
<option value="">Select Currency</option>
{currencyLoading && <option>Loading...</option>}
{!currencyLoading &&
!currencyError &&
currencyData?.map((currency) => (
<option key={currency.id} value={currency.id}>
{`${currency.currencyName} (${currency.symbol})`}
</option>
))}
</select>
{errors.currencyId && (
<small className="danger-text">{errors.currencyId.message}</small>
)}
</div>
</div>
{/* Frequency To and Status Id */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="frequency" className="form-label" required>
Frequency
</Label>
<select
id="frequency"
className="form-select form-select-sm"
{...register("frequency", { valueAsNumber: true })}
>
<option value="">Select Frequency</option>
{Object.entries(FREQUENCY_FOR_RECURRING).map(([key, label]) => (
<option key={key} value={key}>
{label}
</option>
))}
</select>
{errors.frequency && (
<small className="danger-text">{errors.frequency.message}</small>
)}
</div>
<div className="col-md-6">
<Label htmlFor="statusId" className="form-label" required>
Status
</Label>
<select
id="statusId"
className="form-select form-select-sm"
{...register("statusId")}
>
<option value="">Select Status</option>
{statusLoading && <option>Loading...</option>}
{!statusLoading && !statusError && statusData?.map((status) => (
<option key={status.id} value={status.id}>
{status.name}
</option>
))}
</select>
{errors.statusId && (
<small className="danger-text">{errors.statusId.message}</small>
)}
</div>
</div>
{/* Payment Buffer Days and Number of Iteration */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="paymentBufferDays" className="form-label" required>
Payment Buffer Days
</Label>
<input
type="number"
id="paymentBufferDays"
className="form-control form-control-sm"
min="0"
step="1"
{...register("paymentBufferDays", { valueAsNumber: true })}
placeholder="Enter payment buffer days"
/>
{errors.paymentBufferDays && (
<small className="danger-text">{errors.paymentBufferDays.message}</small>
)}
</div>
<div className="col-md-6">
<Label htmlFor="numberOfIteration" className="form-label" required>
Number of Iteration
</Label>
<input
type="number"
id="numberOfIteration"
className="form-control form-control-sm"
min="1"
step="1"
{...register("numberOfIteration", { valueAsNumber: true })}
placeholder="Enter number of iterations"
/>
{errors.numberOfIteration && (
<small className="danger-text">{errors.numberOfIteration.message}</small>
)}
</div>
</div>
{/* Notify */}
{/* <div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="notifyTo" className="form-label" required>
Notify Employees
</Label>
<input
type="text"
id="notifyTo"
className="form-control form-control-sm"
{...register("notifyTo")}
/>
{errors.notifyTo && (
<small className="danger-text">
{errors.notifyTo.message}
</small>
)}
</div>
</div> */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="notifyTo" className="form-label" required>
Notify Employees
</Label>
<MultiEmployeeSearchInput
control={control}
name="notifyTo"
projectId={watch("projectId")}
placeholder="Select Employees"
forAll={true}
/>
</div>
</div>
{/* Description */}
<div className="row my-2 text-start">
<div className="col-md-12">
<Label htmlFor="description" className="form-label" required>
Description
</Label>
<textarea
id="description"
className="form-control form-control-sm"
{...register("description")}
rows="2"
></textarea>
{errors.description && (
<small className="danger-text">
{errors.description.message}
</small>
)}
</div>
</div>
<div className="d-flex justify-content-end gap-3">
<button
type="reset"
onClick={handleClose}
className="btn btn-label-secondary btn-sm mt-3"
>
Cancel
</button>
<button
type="submit"
className="btn btn-primary btn-sm mt-3"
>
{createPending || isPending ? "Please wait...." : requestToEdit ? "Update":"Submit"}
</button>
</div>
</form>
</div> </div>
)
{/* Date and Amount */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="strikeDate" className="form-label" required>
Strike Date
</Label>
<DatePicker
name="strikeDate"
control={control}
minDate={new Date()}
className="w-100"
/>
{errors.strikeDate && (
<small className="danger-text">{errors.strikeDate.message}</small>
)}
</div>
<div className="col-md-6">
<Label htmlFor="amount" className="form-label" required>
Amount
</Label>
<input
type="number"
id="amount"
className="form-control form-control-sm"
min="1"
step="0.01"
inputMode="decimal"
{...register("amount", { valueAsNumber: true })}
placeholder="Enter amount"
/>
{errors.amount && (
<small className="danger-text">{errors.amount.message}</small>
)}
</div>
</div>
{/* Payee and Currency */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="payee" className="form-label" required>
Payee (Supplier Name/Transporter Name/Other)
</Label>
<InputSuggestions
organizationList={Payees}
value={watch("payee") || ""}
onChange={(val) =>
setValue("payee", val, { shouldValidate: true })
}
error={errors.payee?.message}
placeholder="Select or enter payee"
/>
</div>
<div className="col-md-6">
<Label htmlFor="currencyId" className="form-label" required>
Currency
</Label>
<select
id="currencyId"
className="form-select form-select-sm"
{...register("currencyId")}
>
<option value="">Select Currency</option>
{currencyLoading && <option>Loading...</option>}
{!currencyLoading &&
!currencyError &&
currencyData?.map((currency) => (
<option key={currency.id} value={currency.id}>
{`${currency.currencyName} (${currency.symbol})`}
</option>
))}
</select>
{errors.currencyId && (
<small className="danger-text">{errors.currencyId.message}</small>
)}
</div>
</div>
{/* Frequency To and Status Id */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="frequency" className="form-label" required>
Frequency
</Label>
<select
id="frequency"
className="form-select form-select-sm"
{...register("frequency", { valueAsNumber: true })}
>
<option value="">Select Frequency</option>
{Object.entries(FREQUENCY_FOR_RECURRING).map(([key, label]) => (
<option key={key} value={key}>
{label}
</option>
))}
</select>
{errors.frequency && (
<small className="danger-text">{errors.frequency.message}</small>
)}
</div>
<div className="col-md-6">
<Label htmlFor="statusId" className="form-label" required>
Status
</Label>
<select
id="statusId"
className="form-select form-select-sm"
{...register("statusId")}
>
<option value="">Select Status</option>
{statusLoading && <option>Loading...</option>}
{!currencyLoading &&
!currencyError &&
statusData?.map((status) => (
<option key={status.id} value={status.id}>
{`${status.name} `}
</option>
))}
</select>
{errors.statusId && (
<small className="danger-text">{errors.statusId.message}</small>
)}
</div>
</div>
{/* Payment Buffer Days and Number of Iteration */}
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="paymentBufferDays" className="form-label" required>
Payment Buffer Days
</Label>
<input
type="number"
id="paymentBufferDays"
className="form-control form-control-sm"
min="0"
step="1"
{...register("paymentBufferDays", { valueAsNumber: true })}
placeholder="Enter payment buffer days"
/>
{errors.paymentBufferDays && (
<small className="danger-text">
{errors.paymentBufferDays.message}
</small>
)}
</div>
<div className="col-md-6">
<Label htmlFor="numberOfIteration" className="form-label" required>
Number of Iteration
</Label>
<input
type="number"
id="numberOfIteration"
className="form-control form-control-sm"
min="1"
step="1"
{...register("numberOfIteration", { valueAsNumber: true })}
placeholder="Enter number of iterations"
/>
{errors.numberOfIteration && (
<small className="danger-text">
{errors.numberOfIteration.message}
</small>
)}
</div>
</div>
<div className="row my-2 text-start">
<div className="col-md-6">
<Label htmlFor="notifyTo" className="form-label" required>
Notify Employees
</Label>
<MultiEmployeeSearchInput
control={control}
name="notifyTo"
projectId={watch("projectId")}
placeholder="Select Employees"
forAll={true}
/>
</div>
</div>
{/* Description */}
<div className="row my-2 text-start">
<div className="col-md-12">
<Label htmlFor="description" className="form-label" required>
Description
</Label>
<textarea
id="description"
className="form-control form-control-sm"
{...register("description")}
rows="2"
></textarea>
{errors.description && (
<small className="danger-text">
{errors.description.message}
</small>
)}
</div>
</div>
<div className="d-flex justify-content-end gap-3">
<button
type="reset"
onClick={handleClose}
className="btn btn-label-secondary btn-sm mt-3"
>
Cancel
</button>
<button type="submit" className="btn btn-primary btn-sm mt-3">
Submit
</button>
</div>
</form>
</div>
);
} }
export default ManageRecurringExpense; export default ManageRecurringExpense

View File

@ -148,7 +148,7 @@ const RecurringExpenseList = ({ search, filterStatuses }) => {
isOpen={IsDeleteModalOpen} isOpen={IsDeleteModalOpen}
type="delete" type="delete"
header="Delete Recurring Expense" header="Delete Recurring Expense"
message="Are you sure you want to delete?" message="Under the working"
onSubmit={handleDelete} onSubmit={handleDelete}
onClose={() => setIsDeleteModalOpen(false)} onClose={() => setIsDeleteModalOpen(false)}
paramData={deletingId} paramData={deletingId}
@ -188,7 +188,7 @@ const RecurringExpenseList = ({ search, filterStatuses }) => {
</td> </td>
))} ))}
<td className="sticky-action-column bg-white"> <td className="sticky-action-column bg-white">
<div className="d-flex justify-content-center gap-0"> <div className="d-flex flex-row gap-2 gap-0">
<i <i
className="bx bx-show text-primary cursor-pointer" className="bx bx-show text-primary cursor-pointer"
// onClick={() => // onClick={() =>
@ -198,7 +198,6 @@ const RecurringExpenseList = ({ search, filterStatuses }) => {
// }) // })
// } // }
></i> ></i>
{/* Uncomment for edit/delete actions */}
<div className="dropdown z-2"> <div className="dropdown z-2">
<button <button
@ -213,7 +212,7 @@ const RecurringExpenseList = ({ search, filterStatuses }) => {
onClick={() => onClick={() =>
setManageRequest({ setManageRequest({
IsOpen: true, IsOpen: true,
RecurringId: recurringExpense.id, RecurringId: recurringExpense?.id,
}) })
} }
> >

View File

@ -27,7 +27,7 @@ const Timeline = ({ items = [], transparent = true }) => {
<div className="timeline-event"> <div className="timeline-event">
<div className="timeline-header mb-3 d-flex justify-content-between"> <div className="timeline-header mb-3 d-flex justify-content-between">
<h6 className="mb-0 text-body">{item.title}</h6> <h6 className="mb-0 text-body">{item.title}</h6>
<small className="text-body-secondary"><Tooltip text={formatUTCToLocalTime(item.timeAgo,true)}>{moment(item.timeAgo).fromNow()}</Tooltip></small> <small className="text-body-secondary"><Tooltip text={formatUTCToLocalTime(item.timeAgo,true)}>{moment.utc(item.timeAgo).local().fromNow()}</Tooltip></small>
</div> </div>
{item.description && <p className="mb-2">{item.description}</p>} {item.description && <p className="mb-2">{item.description}</p>}

View File

@ -492,7 +492,6 @@ export const useRecurringExpenseList = (
return useQuery({ return useQuery({
queryKey: ["recurringExpenseList",pageSize,pageNumber,filter,isActive,searchString], queryKey: ["recurringExpenseList",pageSize,pageNumber,filter,isActive,searchString],
queryFn: async()=>{ queryFn: async()=>{
debugger
const resp = await ExpenseRepository.GetRecurringExpenseList(pageSize,pageNumber,filter,isActive,searchString); const resp = await ExpenseRepository.GetRecurringExpenseList(pageSize,pageNumber,filter,isActive,searchString);
return resp.data; return resp.data;
}, },
@ -504,7 +503,6 @@ export const useRecurringExpenseDetail =(RequestId)=>{
return useQuery({ return useQuery({
queryKey:['recurringExpense',RequestId], queryKey:['recurringExpense',RequestId],
queryFn:async()=>{ queryFn:async()=>{
RequestId
const resp = await ExpenseRepository.GetRecurringExpense(RequestId); const resp = await ExpenseRepository.GetRecurringExpense(RequestId);
return resp.data; return resp.data;
}, },

View File

@ -19,7 +19,7 @@ export const useRecurringExpenseContext = () => {
const RecurringExpensePage = () => { const RecurringExpensePage = () => {
const [ManageRequest, setManageRequest] = useState({ const [ManageRequest, setManageRequest] = useState({
IsOpen: null, IsOpen: null,
RequestId: null, RecurringId: null,
}); });
const [ViewRequest, setVieRequest] = useState({ view: false, requestId: null }) const [ViewRequest, setVieRequest] = useState({ view: false, requestId: null })
@ -41,7 +41,6 @@ const RecurringExpensePage = () => {
: [...prev, id] : [...prev, id]
); );
}; };
return ( return (
<RecurringExpenseContext.Provider value={contextValue}> <RecurringExpenseContext.Provider value={contextValue}>
<div className="container-fluid"> <div className="container-fluid">
@ -102,7 +101,7 @@ const RecurringExpensePage = () => {
onClick={() => onClick={() =>
setManageRequest({ setManageRequest({
IsOpen: true, IsOpen: true,
expenseId: null, RecurringId: null,
}) })
} }
> >
@ -118,7 +117,6 @@ const RecurringExpensePage = () => {
<RecurringExpenseList filterStatuses={selectedStatuses} search={search} /> <RecurringExpenseList filterStatuses={selectedStatuses} search={search} />
{/* Add/Edit Modal */}
{ManageRequest.IsOpen && ( {ManageRequest.IsOpen && (
<GlobalModel <GlobalModel
isOpen isOpen
@ -128,11 +126,11 @@ const RecurringExpensePage = () => {
} }
> >
<ManageRecurringExpense <ManageRecurringExpense
key={ManageRequest.RequestId ?? "new"} key={ManageRequest.RecurringId ?? "new"}
requestToEdit={ManageRequest.RequestId}
closeModal={() => closeModal={() =>
setManageRequest({ IsOpen: null, RequestId: null }) setManageRequest({ IsOpen: null, RecurringId: null })
} }
requestToEdit={ManageRequest.RecurringId}
/> />
</GlobalModel> </GlobalModel>
)} )}