feature/IO-3499-React-19: Ticket Ticket Issues, Employee Select Issues
This commit is contained in:
@@ -11,9 +11,7 @@ import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
});
|
||||
const mapStateToProps = createStructuredSelector({});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
insertAuditTrail: ({ jobid, operation, type }) => dispatch(insertAuditTrail({ jobid, operation, type }))
|
||||
});
|
||||
@@ -26,55 +24,69 @@ export function JobEmployeeAssignmentsContainer({ job, refetch, insertAuditTrail
|
||||
const notification = useNotification();
|
||||
|
||||
const handleAdd = async (assignment) => {
|
||||
setLoading(true);
|
||||
const { operation, employeeid, name } = assignment;
|
||||
logImEXEvent("job_assign_employee", { operation });
|
||||
const empAssignment = determineFieldName(operation);
|
||||
|
||||
let empAssignment = determineFieldName(operation);
|
||||
if (!job?.id || !empAssignment || !employeeid) return;
|
||||
|
||||
const result = await updateJob({
|
||||
variables: { jobId: job.id, job: { [empAssignment]: employeeid } }
|
||||
});
|
||||
if (refetch) refetch();
|
||||
|
||||
if (!result.errors) {
|
||||
insertAuditTrail({
|
||||
jobid: job.id,
|
||||
operation: AuditTrailMapping.jobassignmentchange(operation, name),
|
||||
type: "jobassignmentchange"
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
title: t("jobs.errors.assigning", {
|
||||
message: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
const handleRemove = async (operation) => {
|
||||
setLoading(true);
|
||||
logImEXEvent("job_unassign_employee", { operation });
|
||||
try {
|
||||
logImEXEvent("job_assign_employee", { operation });
|
||||
|
||||
let empAssignment = determineFieldName(operation);
|
||||
const result = await updateJob({
|
||||
variables: { jobId: job.id, job: { [empAssignment]: null } }
|
||||
});
|
||||
const result = await updateJob({
|
||||
variables: { jobId: job.id, job: { [empAssignment]: employeeid } }
|
||||
});
|
||||
|
||||
if (!result.errors) {
|
||||
insertAuditTrail({
|
||||
jobid: job.id,
|
||||
operation: AuditTrailMapping.jobassignmentremoved(operation),
|
||||
type: "jobassignmentremoved"
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
title: t("jobs.errors.assigning", {
|
||||
message: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
if (typeof refetch === "function") await refetch();
|
||||
|
||||
if (!result.errors) {
|
||||
insertAuditTrail({
|
||||
jobid: job.id,
|
||||
operation: AuditTrailMapping.jobassignmentchange(operation, name),
|
||||
type: "jobassignmentchange"
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
title: t("jobs.errors.assigning", {
|
||||
message: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemove = async (operation) => {
|
||||
const empAssignment = determineFieldName(operation);
|
||||
if (!job?.id || !empAssignment) return;
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
logImEXEvent("job_unassign_employee", { operation });
|
||||
|
||||
const result = await updateJob({
|
||||
variables: { jobId: job.id, job: { [empAssignment]: null } }
|
||||
});
|
||||
|
||||
if (typeof refetch === "function") await refetch();
|
||||
|
||||
if (!result.errors) {
|
||||
insertAuditTrail({
|
||||
jobid: job.id,
|
||||
operation: AuditTrailMapping.jobassignmentremoved(operation),
|
||||
type: "jobassignmentremoved"
|
||||
});
|
||||
} else {
|
||||
notification.error({
|
||||
title: t("jobs.errors.assigning", {
|
||||
message: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -102,7 +114,6 @@ const determineFieldName = (operation) => {
|
||||
return "employee_csr";
|
||||
case "refinish":
|
||||
return "employee_refinish";
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user