changed filed for project and employee now not need project for select employee
This commit is contained in:
parent
4d8af5da91
commit
0ac1141579
@ -32,8 +32,11 @@ 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 SelectEmployeeServerSide, {
|
||||||
|
SelectProjectField,
|
||||||
|
} from "../common/Forms/SelectFieldServerSide";
|
||||||
import { useAllocationServiceProjectTeam } from "../../hooks/useServiceProject";
|
import { useAllocationServiceProjectTeam } from "../../hooks/useServiceProject";
|
||||||
|
import { AppFormController } from "../../hooks/appHooks/useAppForm";
|
||||||
|
|
||||||
const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
||||||
const {
|
const {
|
||||||
@ -153,15 +156,14 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const { mutate: AllocationTeam, isPending1 } = useAllocationServiceProjectTeam(
|
const { mutate: AllocationTeam, isPending1 } =
|
||||||
() => {
|
useAllocationServiceProjectTeam(() => {
|
||||||
setSelectedEmployees([]);
|
setSelectedEmployees([]);
|
||||||
setSeletingEmp({
|
setSeletingEmp({
|
||||||
employee: null,
|
employee: null,
|
||||||
isOpen: false,
|
isOpen: false,
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (expenseToEdit && data) {
|
if (expenseToEdit && data) {
|
||||||
reset({
|
reset({
|
||||||
@ -180,15 +182,15 @@ 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,
|
||||||
}))
|
}))
|
||||||
: [],
|
: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -264,7 +266,6 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
required
|
required
|
||||||
placeholder="Select Project"
|
placeholder="Select Project"
|
||||||
value={watch("projectId")}
|
value={watch("projectId")}
|
||||||
|
|
||||||
onChange={(val) =>
|
onChange={(val) =>
|
||||||
setValue("projectId", val, {
|
setValue("projectId", val, {
|
||||||
shouldDirty: true,
|
shouldDirty: true,
|
||||||
@ -337,14 +338,28 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12 col-md-6 text-start">
|
<div className="col-12 col-md-6 text-start">
|
||||||
<Label className="form-label" required>
|
{/* <Label className="form-label" required>
|
||||||
Paid By{" "}
|
Paid By{" "}
|
||||||
</Label>
|
</Label> */}
|
||||||
<EmployeeSearchInput
|
{/* <EmployeeSearchInput
|
||||||
control={control}
|
control={control}
|
||||||
name="paidById"
|
name="paidById"
|
||||||
projectId={null}
|
projectId={null}
|
||||||
forAll={true}
|
forAll={true}
|
||||||
|
/> */}
|
||||||
|
|
||||||
|
<AppFormController
|
||||||
|
name="paidById"
|
||||||
|
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<SelectEmployeeServerSide
|
||||||
|
label="Paid By" required
|
||||||
|
value={field.value}
|
||||||
|
onChange={field.onChange}
|
||||||
|
isFullObject={false} // because using ID
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -453,7 +468,6 @@ 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 ">
|
||||||
@ -484,7 +498,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
</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"
|
||||||
@ -570,7 +586,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>
|
||||||
))}
|
))}
|
||||||
@ -595,8 +611,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>
|
||||||
|
|||||||
@ -231,7 +231,7 @@ export const useEmployeesName = (projectId, search, allEmployee) => {
|
|||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
await EmployeeRepository.getEmployeeName(projectId, search, allEmployee),
|
await EmployeeRepository.getEmployeeName(projectId, search, allEmployee),
|
||||||
|
|
||||||
staleTime: 5 * 60 * 1000, // Optional: cache for 5 minutes
|
staleTime: 5 * 60 * 1000,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,12 +11,13 @@ 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, active) => api.delete(`/api/employee/${id}?active=${active}`),
|
deleteEmployee: (id, active) => api.delete(`/api/employee/${id}?active=${active}`),
|
||||||
getEmployeeName: (projectId, search, allEmployee) => {
|
getEmployeeName: (projectId, search, allEmployee,employeeId) => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
if (projectId) params.append("projectId", projectId);
|
if (projectId) params.append("projectId", projectId);
|
||||||
if (search) params.append("searchString", search);
|
if (search) params.append("searchString", search);
|
||||||
if (allEmployee) params.append("allEmployee", allEmployee)
|
if (allEmployee) params.append("allEmployee", allEmployee);
|
||||||
|
if (employeeId) params.append("employeeId", employeeId);
|
||||||
|
|
||||||
const query = params.toString();
|
const query = params.toString();
|
||||||
return api.get(`/api/Employee/basic${query ? `?${query}` : ""}`);
|
return api.get(`/api/Employee/basic${query ? `?${query}` : ""}`);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user