Additional Cleanup on Job Details Header Actions Menu
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -54,7 +54,23 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
setMessage: (text) => dispatch(setMessage(text)),
|
setMessage: (text) => dispatch(setMessage(text)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, setScheduleContext, setBillEnterContext, setPaymentContext, setJobCostingContext, jobRO, setTimeTicketContext, setCardPaymentContext, insertAuditTrail, setEmailOptions, openChatByPhone, setMessage }) {
|
export function JobsDetailHeaderActions({
|
||||||
|
job,
|
||||||
|
bodyshop,
|
||||||
|
currentUser,
|
||||||
|
refetch,
|
||||||
|
setScheduleContext,
|
||||||
|
setBillEnterContext,
|
||||||
|
setPaymentContext,
|
||||||
|
setJobCostingContext,
|
||||||
|
jobRO,
|
||||||
|
setTimeTicketContext,
|
||||||
|
setCardPaymentContext,
|
||||||
|
insertAuditTrail,
|
||||||
|
setEmailOptions,
|
||||||
|
openChatByPhone,
|
||||||
|
setMessage
|
||||||
|
}) {
|
||||||
const {t} = useTranslation();
|
const {t} = useTranslation();
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
const history = useNavigate();
|
const history = useNavigate();
|
||||||
@@ -81,6 +97,33 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
);
|
);
|
||||||
}, [job.status, bodyshop.md_ro_statuses.post_production_statuses]);
|
}, [job.status, bodyshop.md_ro_statuses.post_production_statuses]);
|
||||||
|
|
||||||
|
const handleDuplicate =() =>
|
||||||
|
DuplicateJob(
|
||||||
|
client,
|
||||||
|
job.id,
|
||||||
|
{defaultOpenStatus: bodyshop.md_ro_statuses.default_imported},
|
||||||
|
(newJobId) => {
|
||||||
|
history(`/manage/jobs/${newJobId}`);
|
||||||
|
notification["success"]({
|
||||||
|
message: t("jobs.successes.duplicated"),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleDuplicateConfirm = () =>
|
||||||
|
DuplicateJob(
|
||||||
|
client,
|
||||||
|
job.id,
|
||||||
|
{defaultOpenStatus: bodyshop.md_ro_statuses.default_imported},
|
||||||
|
(newJobId) => {
|
||||||
|
history(`/manage/jobs/${newJobId}`);
|
||||||
|
notification["success"]({
|
||||||
|
message: t("jobs.successes.duplicated"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
logImEXEvent("schedule_manual_event");
|
logImEXEvent("schedule_manual_event");
|
||||||
|
|
||||||
@@ -88,7 +131,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
try {
|
try {
|
||||||
insertAppointment({
|
insertAppointment({
|
||||||
variables: {
|
variables: {
|
||||||
apt: { ...values, isintake: false, jobid: job.id, bodyshopid: bodyshop.id },
|
apt: {...values, isintake: false, jobid: job.id, bodyshopid: bodyshop.id},
|
||||||
},
|
},
|
||||||
refetchQueries: ["QUERY_ALL_ACTIVE_APPOINTMENTS"],
|
refetchQueries: ["QUERY_ALL_ACTIVE_APPOINTMENTS"],
|
||||||
});
|
});
|
||||||
@@ -104,6 +147,25 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDeleteJob = async () => {
|
||||||
|
//delete the job.
|
||||||
|
const result = await deleteJob({variables: {id: job.id}});
|
||||||
|
|
||||||
|
if (!!!result.errors) {
|
||||||
|
notification["success"]({
|
||||||
|
message: t("jobs.successes.delete"),
|
||||||
|
});
|
||||||
|
//go back to jobs list.
|
||||||
|
history(`/manage/`);
|
||||||
|
} else {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("jobs.errors.deleted", {
|
||||||
|
error: JSON.stringify(result.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleCreateCsi = async (e) => {
|
const handleCreateCsi = async (e) => {
|
||||||
logImEXEvent("job_create_csi");
|
logImEXEvent("job_create_csi");
|
||||||
|
|
||||||
@@ -199,8 +261,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
message: t("csi.errors.notconfigured"),
|
message: t("csi.errors.notconfigured"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (e.key === "email")
|
if (e.key === "email")
|
||||||
setEmailOptions({
|
setEmailOptions({
|
||||||
jobid: job.id,
|
jobid: job.id,
|
||||||
@@ -242,6 +303,45 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleVoidJob = async () => {
|
||||||
|
//delete the job.
|
||||||
|
const result = await voidJob({
|
||||||
|
variables: {
|
||||||
|
jobId: job.id,
|
||||||
|
job: {
|
||||||
|
status: bodyshop.md_ro_statuses.default_void,
|
||||||
|
voided: true,
|
||||||
|
scheduled_in: null,
|
||||||
|
scheduled_completion: null,
|
||||||
|
inproduction: false,
|
||||||
|
date_void: new Date(),
|
||||||
|
},
|
||||||
|
note: [
|
||||||
|
{
|
||||||
|
jobid: job.id,
|
||||||
|
created_by: currentUser.email,
|
||||||
|
audit: true,
|
||||||
|
text: t("jobs.labels.voidnote"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!!!result.errors) {
|
||||||
|
notification["success"]({
|
||||||
|
message: t("jobs.successes.voided"),
|
||||||
|
});
|
||||||
|
//go back to jobs list.
|
||||||
|
history(`/manage/`);
|
||||||
|
} else {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("jobs.errors.voiding", {
|
||||||
|
error: JSON.stringify(result.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleExportCustData = async (e) => {
|
const handleExportCustData = async (e) => {
|
||||||
logImEXEvent("job_export_cust_data");
|
logImEXEvent("job_export_cust_data");
|
||||||
let PartnerResponse;
|
let PartnerResponse;
|
||||||
@@ -350,6 +450,33 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLostSaleFinish = async ({lost_sale_reason}) => {
|
||||||
|
const jobUpdate = await cancelAllAppointments({
|
||||||
|
variables: {
|
||||||
|
jobid: job.id,
|
||||||
|
job: {
|
||||||
|
date_scheduled: null,
|
||||||
|
scheduled_in: null,
|
||||||
|
scheduled_completion: null,
|
||||||
|
lost_sale_reason,
|
||||||
|
date_lost_sale: new Date(),
|
||||||
|
status: bodyshop.md_ro_statuses.default_imported,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!jobUpdate.errors) {
|
||||||
|
notification["success"]({
|
||||||
|
message: t("appointments.successes.canceled"),
|
||||||
|
});
|
||||||
|
insertAuditTrail({
|
||||||
|
jobid: job.id,
|
||||||
|
operation:
|
||||||
|
AuditTrailMapping.appointmentcancel(lost_sale_reason),
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSuspend = (e) => {
|
const handleSuspend = (e) => {
|
||||||
logImEXEvent("production_toggle_alert");
|
logImEXEvent("production_toggle_alert");
|
||||||
//e.stopPropagation();
|
//e.stopPropagation();
|
||||||
@@ -363,7 +490,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const overlay = (
|
const popOverContent = (
|
||||||
<Card>
|
<Card>
|
||||||
<div>
|
<div>
|
||||||
<Form form={form} layout="vertical" onFinish={handleFinish}>
|
<Form form={form} layout="vertical" onFinish={handleFinish}>
|
||||||
@@ -377,10 +504,10 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Input />
|
<Input/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("appointments.fields.note")} name="note">
|
<Form.Item label={t("appointments.fields.note")} name="note">
|
||||||
<Input />
|
<Input/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("appointments.fields.start")}
|
label={t("appointments.fields.start")}
|
||||||
@@ -395,7 +522,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
<FormDateTimePickerComponent
|
<FormDateTimePickerComponent
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const start = form.getFieldValue("start");
|
const start = form.getFieldValue("start");
|
||||||
form.setFieldsValue({ end: start.add(30, "minutes") });
|
form.setFieldsValue({end: start.add(30, "minutes")});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@@ -407,10 +534,10 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
required: true,
|
required: true,
|
||||||
//message: t("general.validation.required"),
|
//message: t("general.validation.required"),
|
||||||
},
|
},
|
||||||
({ getFieldValue }) => ({
|
({getFieldValue}) => ({
|
||||||
async validator(rule, value) {
|
async validator(rule, value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
const { start } = form.getFieldsValue();
|
const {start} = form.getFieldsValue();
|
||||||
if (dayjs(start).isAfter(dayjs(value))) {
|
if (dayjs(start).isAfter(dayjs(value))) {
|
||||||
return Promise.reject(
|
return Promise.reject(
|
||||||
t("employees.labels.endmustbeafterstart")
|
t("employees.labels.endmustbeafterstart")
|
||||||
@@ -425,7 +552,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
}),
|
}),
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<FormDateTimePickerComponent />
|
<FormDateTimePickerComponent/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("appointments.fields.color")} name="color">
|
<Form.Item label={t("appointments.fields.color")} name="color">
|
||||||
<Select>
|
<Select>
|
||||||
@@ -477,32 +604,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
content={
|
content={
|
||||||
<Form
|
<Form
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
onFinish={async ({lost_sale_reason}) => {
|
onFinish={handleLostSaleFinish}
|
||||||
const jobUpdate = await cancelAllAppointments({
|
|
||||||
variables: {
|
|
||||||
jobid: job.id,
|
|
||||||
job: {
|
|
||||||
date_scheduled: null,
|
|
||||||
scheduled_in: null,
|
|
||||||
scheduled_completion: null,
|
|
||||||
lost_sale_reason,
|
|
||||||
date_lost_sale: new Date(),
|
|
||||||
status: bodyshop.md_ro_statuses.default_imported,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!jobUpdate.errors) {
|
|
||||||
notification["success"]({
|
|
||||||
message: t("appointments.successes.canceled"),
|
|
||||||
});
|
|
||||||
insertAuditTrail({
|
|
||||||
jobid: job.id,
|
|
||||||
operation:
|
|
||||||
AuditTrailMapping.appointmentcancel(lost_sale_reason),
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="lost_sale_reason"
|
name="lost_sale_reason"
|
||||||
@@ -661,20 +763,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
okText="Yes"
|
okText="Yes"
|
||||||
cancelText="No"
|
cancelText="No"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onConfirm={() =>
|
onConfirm={handleDuplicate}
|
||||||
DuplicateJob(
|
|
||||||
client,
|
|
||||||
job.id,
|
|
||||||
{defaultOpenStatus: bodyshop.md_ro_statuses.default_imported},
|
|
||||||
(newJobId) => {
|
|
||||||
history(`/manage/jobs/${newJobId}`);
|
|
||||||
notification["success"]({
|
|
||||||
message: t("jobs.successes.duplicated"),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
getPopupContainer={(trigger) => trigger.parentNode}
|
getPopupContainer={(trigger) => trigger.parentNode}
|
||||||
>
|
>
|
||||||
{t("menus.jobsactions.duplicate")}
|
{t("menus.jobsactions.duplicate")}
|
||||||
@@ -686,19 +775,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
okText="Yes"
|
okText="Yes"
|
||||||
cancelText="No"
|
cancelText="No"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onConfirm={() =>
|
onConfirm={handleDuplicateConfirm}
|
||||||
DuplicateJob(
|
|
||||||
client,
|
|
||||||
job.id,
|
|
||||||
{defaultOpenStatus: bodyshop.md_ro_statuses.default_imported},
|
|
||||||
(newJobId) => {
|
|
||||||
history(`/manage/jobs/${newJobId}`);
|
|
||||||
notification["success"]({
|
|
||||||
message: t("jobs.successes.duplicated"),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
getPopupContainer={(trigger) => trigger.parentNode}
|
getPopupContainer={(trigger) => trigger.parentNode}
|
||||||
>
|
>
|
||||||
{t("menus.jobsactions.duplicatenolines")}
|
{t("menus.jobsactions.duplicatenolines")}
|
||||||
@@ -864,24 +941,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
okText={t("general.labels.yes")}
|
okText={t("general.labels.yes")}
|
||||||
cancelText={t("general.labels.no")}
|
cancelText={t("general.labels.no")}
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onConfirm={async () => {
|
onConfirm={handleDeleteJob}
|
||||||
//delete the job.
|
|
||||||
const result = await deleteJob({variables: {id: job.id}});
|
|
||||||
|
|
||||||
if (!!!result.errors) {
|
|
||||||
notification["success"]({
|
|
||||||
message: t("jobs.successes.delete"),
|
|
||||||
});
|
|
||||||
//go back to jobs list.
|
|
||||||
history(`/manage/`);
|
|
||||||
} else {
|
|
||||||
notification["error"]({
|
|
||||||
message: t("jobs.errors.deleted", {
|
|
||||||
error: JSON.stringify(result.errors),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
getPopupContainer={(trigger) => trigger.parentNode}
|
getPopupContainer={(trigger) => trigger.parentNode}
|
||||||
>
|
>
|
||||||
{t("menus.jobsactions.deletejob")}
|
{t("menus.jobsactions.deletejob")}
|
||||||
@@ -907,44 +967,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
okText="Yes"
|
okText="Yes"
|
||||||
cancelText="No"
|
cancelText="No"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
onConfirm={async () => {
|
onConfirm={handleVoidJob}
|
||||||
//delete the job.
|
|
||||||
const result = await voidJob({
|
|
||||||
variables: {
|
|
||||||
jobId: job.id,
|
|
||||||
job: {
|
|
||||||
status: bodyshop.md_ro_statuses.default_void,
|
|
||||||
voided: true,
|
|
||||||
scheduled_in: null,
|
|
||||||
scheduled_completion: null,
|
|
||||||
inproduction: false,
|
|
||||||
date_void: new Date(),
|
|
||||||
},
|
|
||||||
note: [
|
|
||||||
{
|
|
||||||
jobid: job.id,
|
|
||||||
created_by: currentUser.email,
|
|
||||||
audit: true,
|
|
||||||
text: t("jobs.labels.voidnote"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!!!result.errors) {
|
|
||||||
notification["success"]({
|
|
||||||
message: t("jobs.successes.voided"),
|
|
||||||
});
|
|
||||||
//go back to jobs list.
|
|
||||||
history(`/manage/`);
|
|
||||||
} else {
|
|
||||||
notification["error"]({
|
|
||||||
message: t("jobs.errors.voiding", {
|
|
||||||
error: JSON.stringify(result.errors),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
getPopupContainer={(trigger) => trigger.parentNode}
|
getPopupContainer={(trigger) => trigger.parentNode}
|
||||||
>
|
>
|
||||||
{t("menus.jobsactions.void")}
|
{t("menus.jobsactions.void")}
|
||||||
@@ -966,7 +989,7 @@ export function JobsDetailHeaderActions({job, bodyshop, currentUser, refetch, se
|
|||||||
<DownCircleFilled/>
|
<DownCircleFilled/>
|
||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Popover content={overlay} open={visibility} />
|
<Popover content={popOverContent} open={visibility}/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user