Merge branch 'Project_Branch_Management' of https://git.marcoaiot.com/admin/marco.pms.web into Project_Branch_Management
This commit is contained in:
commit
742337a3d0
@ -3,7 +3,7 @@ import React, { useEffect, useState } from "react";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { defaultExpense, ExpenseSchema } from "./ExpenseSchema";
|
import { defaultExpense, ExpenseSchema } from "./ExpenseSchema";
|
||||||
import { formatFileSize, localToUtc } from "../../utils/appUtils";
|
import { formatFileSize, localToUtc } from "../../utils/appUtils";
|
||||||
import { useProjectName } from "../../hooks/useProjects";
|
import { useProjectName } from "../../hooks/useProjects";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { changeMaster } from "../../slices/localVariablesSlice";
|
import { changeMaster } from "../../slices/localVariablesSlice";
|
||||||
import useMaster, {
|
import useMaster, {
|
||||||
@ -32,6 +32,8 @@ import Label from "../common/Label";
|
|||||||
import EmployeeSearchInput from "../common/EmployeeSearchInput";
|
import EmployeeSearchInput from "../common/EmployeeSearchInput";
|
||||||
import Filelist from "./Filelist";
|
import Filelist from "./Filelist";
|
||||||
import { DEFAULT_CURRENCY } from "../../utils/constants";
|
import { DEFAULT_CURRENCY } from "../../utils/constants";
|
||||||
|
import SelectEmployeeServerSide, { SelectProjectField } from "../common/Forms/SelectFieldServerSide";
|
||||||
|
import { useAllocationServiceProjectTeam } from "../../hooks/useServiceProject";
|
||||||
|
|
||||||
const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
||||||
const {
|
const {
|
||||||
@ -40,6 +42,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
error: ExpenseErrorLoad,
|
error: ExpenseErrorLoad,
|
||||||
} = useExpense(expenseToEdit);
|
} = useExpense(expenseToEdit);
|
||||||
const [expenseCategory, setExpenseCategory] = useState();
|
const [expenseCategory, setExpenseCategory] = useState();
|
||||||
|
const [selectedEmployees, setSelectedEmployees] = useState([]);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const {
|
const {
|
||||||
expenseCategories,
|
expenseCategories,
|
||||||
@ -83,11 +86,11 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
loading: StatusLoadding,
|
loading: StatusLoadding,
|
||||||
error: stausError,
|
error: stausError,
|
||||||
} = useExpenseStatus();
|
} = useExpenseStatus();
|
||||||
const {
|
// const {
|
||||||
data: employees,
|
// data: employees,
|
||||||
isLoading: EmpLoading,
|
// isLoading: EmpLoading,
|
||||||
isError: isEmployeeError,
|
// isError: isEmployeeError,
|
||||||
} = useEmployeesNameByProject(selectedproject);
|
// } = useEmployeesNameByProject(selectedproject);
|
||||||
|
|
||||||
const files = watch("billAttachments");
|
const files = watch("billAttachments");
|
||||||
const onFileChange = async (e) => {
|
const onFileChange = async (e) => {
|
||||||
@ -150,6 +153,15 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { mutate: AllocationTeam, isPending1 } = useAllocationServiceProjectTeam(
|
||||||
|
() => {
|
||||||
|
setSelectedEmployees([]);
|
||||||
|
setSeletingEmp({
|
||||||
|
employee: null,
|
||||||
|
isOpen: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (expenseToEdit && data) {
|
if (expenseToEdit && data) {
|
||||||
reset({
|
reset({
|
||||||
@ -168,19 +180,19 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
currencyId: data.currency.id || DEFAULT_CURRENCY,
|
currencyId: data.currency.id || DEFAULT_CURRENCY,
|
||||||
billAttachments: data.documents
|
billAttachments: data.documents
|
||||||
? data.documents.map((doc) => ({
|
? data.documents.map((doc) => ({
|
||||||
fileName: doc.fileName,
|
fileName: doc.fileName,
|
||||||
base64Data: null,
|
base64Data: null,
|
||||||
contentType: doc.contentType,
|
contentType: doc.contentType,
|
||||||
documentId: doc.documentId,
|
documentId: doc.documentId,
|
||||||
fileSize: 0,
|
fileSize: 0,
|
||||||
description: "",
|
description: "",
|
||||||
preSignedUrl: doc.preSignedUrl,
|
preSignedUrl: doc.preSignedUrl,
|
||||||
isActive: doc.isActive ?? true,
|
isActive: doc.isActive ?? true,
|
||||||
}))
|
}))
|
||||||
: [],
|
: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data, reset, employees]);
|
}, [data, reset]);
|
||||||
const { mutate: ExpenseUpdate, isPending } = useUpdateExpense(() =>
|
const { mutate: ExpenseUpdate, isPending } = useUpdateExpense(() =>
|
||||||
handleClose()
|
handleClose()
|
||||||
);
|
);
|
||||||
@ -223,7 +235,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
</h5>
|
</h5>
|
||||||
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
|
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-6">
|
{/* <div className="col-md-6">
|
||||||
<Label className="form-label" required>
|
<Label className="form-label" required>
|
||||||
Select Project
|
Select Project
|
||||||
</Label>
|
</Label>
|
||||||
@ -245,6 +257,24 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
{errors.projectId && (
|
{errors.projectId && (
|
||||||
<small className="danger-text">{errors.projectId.message}</small>
|
<small className="danger-text">{errors.projectId.message}</small>
|
||||||
)}
|
)}
|
||||||
|
</div> */}
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<SelectProjectField
|
||||||
|
label="Project"
|
||||||
|
required
|
||||||
|
placeholder="Select Project"
|
||||||
|
value={watch("projectId")}
|
||||||
|
|
||||||
|
onChange={(val) =>
|
||||||
|
setValue("projectId", val, {
|
||||||
|
shouldDirty: true,
|
||||||
|
shouldValidate: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{errors.projectId && (
|
||||||
|
<small className="danger-text">{errors.projectId.message}</small>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
@ -314,9 +344,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
control={control}
|
control={control}
|
||||||
name="paidById"
|
name="paidById"
|
||||||
projectId={null}
|
projectId={null}
|
||||||
forAll={expenseToEdit ? true : false}
|
forAll={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
@ -423,10 +453,10 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
<small className="danger-text">{errors.gstNumber.message}</small>
|
<small className="danger-text">{errors.gstNumber.message}</small>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-6 text-start ">
|
<div className="col-md-6 text-start ">
|
||||||
<Label htmlFor="currencyId" className="form-label" required>
|
<Label htmlFor="currencyId" className="form-label" required>
|
||||||
Select Currency
|
Select Currency
|
||||||
</Label>
|
</Label>
|
||||||
@ -452,24 +482,24 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
<small className="danger-text">{errors.currencyId.message}</small>
|
<small className="danger-text">{errors.currencyId.message}</small>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{expenseCategory?.noOfPersonsRequired && (
|
{expenseCategory?.noOfPersonsRequired && (
|
||||||
<div className="col-md-6 text-start">
|
<div className="col-md-6 text-start">
|
||||||
<Label className="form-label" required>No. of Persons</Label>
|
<Label className="form-label" required>No. of Persons</Label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="noOfPersons"
|
id="noOfPersons"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register("noOfPersons")}
|
{...register("noOfPersons")}
|
||||||
inputMode="numeric"
|
inputMode="numeric"
|
||||||
/>
|
/>
|
||||||
{errors.noOfPersons && (
|
{errors.noOfPersons && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
{errors.noOfPersons.message}
|
{errors.noOfPersons.message}
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
@ -540,7 +570,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
(fileError?.fileSize?.message ||
|
(fileError?.fileSize?.message ||
|
||||||
fileError?.contentType?.message ||
|
fileError?.contentType?.message ||
|
||||||
fileError?.base64Data?.message,
|
fileError?.base64Data?.message,
|
||||||
fileError?.documentId?.message)
|
fileError?.documentId?.message)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@ -565,8 +595,8 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
{isPending || createPending
|
{isPending || createPending
|
||||||
? "Please Wait..."
|
? "Please Wait..."
|
||||||
: expenseToEdit
|
: expenseToEdit
|
||||||
? "Update"
|
? "Update"
|
||||||
: "Save as Draft"}
|
: "Save as Draft"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import Avatar from "./Avatar";
|
|||||||
const EmployeeSearchInput = ({
|
const EmployeeSearchInput = ({
|
||||||
control,
|
control,
|
||||||
name,
|
name,
|
||||||
|
size = "sm",
|
||||||
projectId,
|
projectId,
|
||||||
placeholder,
|
placeholder,
|
||||||
forAll,
|
forAll,
|
||||||
@ -46,7 +47,7 @@ const EmployeeSearchInput = ({
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={`form-control form-control-sm`}
|
className={`form-control form-control-sm-${size}`}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user