Compare commits

..

No commits in common. "0f5473bddd833adda3d110a61d67566f1a89ddd4" and "68bd0d6bb53eb99d247d43aa4a9cccfe18216033" have entirely different histories.

6 changed files with 85 additions and 104 deletions

View File

@ -33,7 +33,7 @@ const ExpenseStatusLogs = ({ data }) => {
<small className="text-secondary text-tiny ms-2"> <small className="text-secondary text-tiny ms-2">
<em>{log.action}</em> <em>{log.action}</em>
</small> </small>
<span className="text-tiny text-secondary d-block small">{log?.updateAt}</span> <span className="text-tiny text-secondary d-block small">{log?.updateAt ?? "14-Aug-2025"}</span>
</div> </div>
</div> </div>
<div className="d-flex align-items-center text-muted small mt-1"> <div className="d-flex align-items-center text-muted small mt-1">

View File

@ -14,8 +14,6 @@ import useMaster, {
import { import {
useEmployeesAllOrByProjectId, useEmployeesAllOrByProjectId,
useEmployeesByProject, useEmployeesByProject,
useEmployeesName,
useEmployeesNameByProject,
} from "../../hooks/useEmployees"; } from "../../hooks/useEmployees";
import Avatar from "../common/Avatar"; import Avatar from "../common/Avatar";
import { import {
@ -26,7 +24,6 @@ import {
import ExpenseSkeleton from "./ExpenseSkeleton"; import ExpenseSkeleton from "./ExpenseSkeleton";
import moment from "moment"; import moment from "moment";
import DatePicker from "../common/DatePicker"; import DatePicker from "../common/DatePicker";
import ErrorPage from "../../pages/ErrorPage";
const ManageExpense = ({ closeModal, expenseToEdit = null }) => { const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
const { const {
@ -34,7 +31,6 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
isLoading, isLoading,
error: ExpenseErrorLoad, error: ExpenseErrorLoad,
} = useExpense(expenseToEdit); } = useExpense(expenseToEdit);
console.log(data)
const [ExpenseType, setExpenseType] = useState(); const [ExpenseType, setExpenseType] = useState();
const dispatch = useDispatch(); const dispatch = useDispatch();
const { const {
@ -57,14 +53,11 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
}); });
const selectedproject = watch("projectId"); const selectedproject = watch("projectId");
const selectedProject = useSelector(
const { (store) => store.localVariables.projectId
projectNames, );
loading: projectLoading, const { projectNames, loading: projectLoading, error } = useProjectName();
error, debugger
isError: isProjectError,
} = useProjectName();
const { const {
PaymentModes, PaymentModes,
loading: PaymentModeLoading, loading: PaymentModeLoading,
@ -76,10 +69,11 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
error: stausError, error: stausError,
} = useExpenseStatus(); } = useExpenseStatus();
const { const {
data: employees, employees,
isLoading: EmpLoading, loading: EmpLoading,
isError: isEmployeeError, error: EmpError,
} = useEmployeesNameByProject(selectedproject); } = useEmployeesByProject(selectedproject);
const files = watch("billAttachments"); const files = watch("billAttachments");
const onFileChange = async (e) => { const onFileChange = async (e) => {
const newFiles = Array.from(e.target.files); const newFiles = Array.from(e.target.files);
@ -96,7 +90,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
contentType: file.type, contentType: file.type,
fileSize: file.size, fileSize: file.size,
description: "", description: "",
isActive: true, isActive:true
}; };
}) })
); );
@ -142,8 +136,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
}; };
useEffect(() => { useEffect(() => {
if (expenseToEdit && data ) { if (expenseToEdit && data && employees) {
reset({ reset({
projectId: data.project.id || "", projectId: data.project.id || "",
expensesTypeId: data.expensesType.id || "", expensesTypeId: data.expensesType.id || "",
@ -180,12 +173,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
} }
); );
const onSubmit = (fromdata) => { const onSubmit = (fromdata) => {
let payload = { let payload = {...fromdata,transactionDate: moment.utc(fromdata.transactionDate, 'DD-MM-YYYY').toISOString()}
...fromdata,
transactionDate: moment
.utc(fromdata.transactionDate, "DD-MM-YYYY")
.toISOString(),
};
if (expenseToEdit) { if (expenseToEdit) {
const editPayload = { ...payload, id: data.id }; const editPayload = { ...payload, id: data.id };
ExpenseUpdate({ id: data.id, payload: editPayload }); ExpenseUpdate({ id: data.id, payload: editPayload });
@ -203,10 +191,13 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
reset(); reset();
closeModal(); closeModal();
}; };
if (StatusLoadding || projectLoading || ExpenseLoading || isLoading) if (
StatusLoadding ||
projectLoading ||
ExpenseLoading ||
isLoading
)
return <ExpenseSkeleton />; return <ExpenseSkeleton />;
return ( return (
<div className="container p-3"> <div className="container p-3">
<h5 className="m-0"> <h5 className="m-0">
@ -215,7 +206,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}> <form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
<div className="row my-2"> <div className="row my-2">
<div className="col-md-6"> <div className="col-md-6">
<label className="form-label">Select Project</label> <label className="form-label">
Select Project
</label>
<select <select
className="form-select form-select-sm" className="form-select form-select-sm"
{...register("projectId")} {...register("projectId")}
@ -330,7 +323,17 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
<label htmlFor="transactionDate" className="form-label "> <label htmlFor="transactionDate" className="form-label ">
Transaction Date Transaction Date
</label> </label>
<DatePicker name="transactionDate" control={control} /> {/* <input
type="date"
className="form-control form-control-sm"
placeholder="YYYY-MM-DD"
id="flatpickr-date"
{...register("transactionDate")}
/> */}
<DatePicker
name="transactionDate"
control={control}
/>
{errors.transactionDate && ( {errors.transactionDate && (
<small className="danger-text"> <small className="danger-text">
@ -412,7 +415,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
{ExpenseType?.noOfPersonsRequired && ( {ExpenseType?.noOfPersonsRequired && (
<div className="col-md-6"> <div className="col-md-6">
<label>No. of Persons</label> <label >
No. of Persons
</label>
<input <input
type="number" type="number"
id="noOfPersons" id="noOfPersons"
@ -430,7 +435,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
</div> </div>
<div className="row my-2"> <div className="row my-2">
<div className="col-md-12"> <div className="col-md-12" >
<label htmlFor="description">Description</label> <label htmlFor="description">Description</label>
<textarea <textarea
id="description" id="description"
@ -537,11 +542,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
className="btn btn-primary btn-sm mt-3" className="btn btn-primary btn-sm mt-3"
disabled={isPending || createPending} disabled={isPending || createPending}
> >
{isPending || createPending {isPending || createPending ? "Please Wait..." : expenseToEdit ? "Update" : "Submit"}
? "Please Wait..."
: expenseToEdit
? "Update"
: "Submit"}
</button> </button>
<button <button
type="reset" type="reset"

View File

@ -251,7 +251,7 @@ const ViewExpense = ({ ExpenseId }) => {
{/* Row 6 */} {/* Row 6 */}
{data.createdBy && ( {data.createdBy && (
<div className="col-md-6 text-start"> <div className="col-md-6 mb-3 text-start">
<div className="d-flex align-items-center"> <div className="d-flex align-items-center">
<label <label
className="form-label me-2 mb-0 fw-semibold" className="form-label me-2 mb-0 fw-semibold"
@ -353,7 +353,41 @@ const ViewExpense = ({ ExpenseId }) => {
</div> </div>
)} */} )} */}
</div> </div>
{data.expensesReimburse && (
<div className="row text-start">
<div className="col-md-6 ">
<label className="form-label me-2 mb-0 fw-semibold">
Transaction ID :
</label>
{data.expensesReimburse.reimburseTransactionId || "N/A"}
</div>
<div className="col-md-6 ">
<label className="form-label me-2 mb-0 fw-semibold">
Reimburse Date :
</label>
{formatUTCToLocalTime(data.expensesReimburse.reimburseDate)}
</div>
{data.expensesReimburse && (
<>
<div className="col-md-6 d-flex align-items-center">
<label className="form-label me-2 mb-0 fw-semibold">
Reimburse By :
</label>
<Avatar
size="xs"
classAvatar="m-0 me-1"
firstName={data?.expensesReimburse?.reimburseBy?.firstName}
lastName={data?.expensesReimburse?.reimburseBy?.lastName}
/>
<span className="text-muted">
{`${data?.expensesReimburse?.reimburseBy?.firstName} ${data?.expensesReimburse?.reimburseBy?.lastName}`.trim()}
</span>
</div>
</>
)}
</div>
)}
{/* <div className="text-start"> {/* <div className="text-start">
<label className="form-label me-2 mb-0 fw-semibold"> <label className="form-label me-2 mb-0 fw-semibold">
@ -361,7 +395,7 @@ const ViewExpense = ({ ExpenseId }) => {
</label> </label>
<div className="text-muted">{data?.description}</div> <div className="text-muted">{data?.description}</div>
</div> */} </div> */}
<div className="col-12 text-start"> <div className="col-12 my-2 text-start">
<label className="form-label me-2 mb-0 fw-semibold">Attachment :</label> <label className="form-label me-2 mb-0 fw-semibold">Attachment :</label>
{data?.documents?.map((doc) => { {data?.documents?.map((doc) => {
@ -422,42 +456,6 @@ const ViewExpense = ({ ExpenseId }) => {
})} })}
</div> </div>
{data.expensesReimburse && (
<div className="row text-start">
<div className="col-md-6 mb-sm-0 mb-2">
<label className="form-label me-2 mb-0 fw-semibold">
Transaction ID :
</label>
{data.expensesReimburse.reimburseTransactionId || "N/A"}
</div>
<div className="col-md-6 ">
<label className="form-label me-2 mb-0 fw-semibold">
Reimburse Date :
</label>
{formatUTCToLocalTime(data.expensesReimburse.reimburseDate)}
</div>
{data.expensesReimburse && (
<>
<div className="col-md-6 d-flex align-items-center">
<label className="form-label me-2 mb-0 fw-semibold">
Reimburse By :
</label>
<Avatar
size="xs"
classAvatar="m-0 me-1"
firstName={data?.expensesReimburse?.reimburseBy?.firstName}
lastName={data?.expensesReimburse?.reimburseBy?.lastName}
/>
<span className="text-muted">
{`${data?.expensesReimburse?.reimburseBy?.firstName} ${data?.expensesReimburse?.reimburseBy?.lastName}`.trim()}
</span>
</div>
</>
)}
</div>
)}
<hr className="divider my-1" /> <hr className="divider my-1" />
{Array.isArray(data?.nextStatus) && data.nextStatus.length > 0 && ( {Array.isArray(data?.nextStatus) && data.nextStatus.length > 0 && (

View File

@ -182,19 +182,6 @@ export const useEmployeesName = (projectId, search) => {
}); });
}; };
export const useEmployeesNameByProject = (projectId) => {
return useQuery({
queryKey: ["Projectemployees", projectId],
queryFn: async () => {
const response = await EmployeeRepository.getEmployeeName(projectId);
return response?.data || []; // handle undefined/null response
},
enabled: !!projectId, // only fetch if projectId is truthy
staleTime: 5 * 60 * 1000, // cache for 5 minutes
});
};
// Mutation------------------------------------------------------------------ // Mutation------------------------------------------------------------------
export const useUpdateEmployee = () => { export const useUpdateEmployee = () => {

View File

@ -313,7 +313,6 @@ export const useProjectName = () => {
isLoading, isLoading,
error, error,
refetch, refetch,
isError
} = useQuery({ } = useQuery({
queryKey: ["basicProjectNameList"], queryKey: ["basicProjectNameList"],
queryFn: async () => { queryFn: async () => {
@ -324,7 +323,7 @@ export const useProjectName = () => {
showToast(error.message || "Error while Fetching project Name", "error"); showToast(error.message || "Error while Fetching project Name", "error");
}, },
}); });
return { projectNames: data, loading: isLoading, Error: error, refetch,isError }; return { projectNames: data, loading: isLoading, Error: error, refetch };
}; };
export const useProjectInfra = (projectId) => { export const useProjectInfra = (projectId) => {

View File

@ -11,16 +11,12 @@ const EmployeeRepository = {
// deleteEmployee: ( id ) => api.delete( `/users/${ id }` ), // deleteEmployee: ( id ) => api.delete( `/users/${ id }` ),
getEmployeeProfile: (id) => api.get(`/api/employee/profile/get/${id}`), getEmployeeProfile: (id) => api.get(`/api/employee/profile/get/${id}`),
deleteEmployee: (id) => api.delete(`/api/employee/${id}`), deleteEmployee: (id) => api.delete(`/api/employee/${id}`),
getEmployeeName: (projectId, search) => { getEmployeeName: (projectId, search) =>
const params = new URLSearchParams(); api.get(
`/api/Employee/basic${projectId ? `?projectId=${projectId}` : ""}${
if (projectId) params.append("projectId", projectId); search ? `${projectId ? "&" : "?"}searchString=${search}` : ""
if (search) params.append("searchString", search); }`
),
const query = params.toString();
return api.get(`/api/Employee/basic${query ? `?${query}` : ""}`);
}
}; };
export default EmployeeRepository; export default EmployeeRepository;