WIP Transfer.
This commit is contained in:
@@ -45,6 +45,23 @@ export function ScheduleJobModalComponent({
|
||||
}
|
||||
};
|
||||
|
||||
const handleDateBlur = () => {
|
||||
const values = form.getFieldsValue();
|
||||
if (lbrHrsData) {
|
||||
const totalHours =
|
||||
lbrHrsData.jobs_by_pk.labhrs.aggregate.sum.mod_lb_hrs +
|
||||
lbrHrsData.jobs_by_pk.larhrs.aggregate.sum.mod_lb_hrs;
|
||||
|
||||
if (values.start && !values.scheduled_completion)
|
||||
form.setFieldsValue({
|
||||
scheduled_completion: moment(values.start).businessAdd(
|
||||
totalHours / bodyshop.target_touchtime,
|
||||
"days"
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//TODO Existing appointments list only refreshes sometimes after modal close. May have to do with the container class.
|
||||
return (
|
||||
<Row gutter={[32, 32]}>
|
||||
@@ -60,24 +77,7 @@ export function ScheduleJobModalComponent({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<DateTimePicker
|
||||
onBlur={() => {
|
||||
const values = form.getFieldsValue();
|
||||
if (lbrHrsData) {
|
||||
const totalHours =
|
||||
lbrHrsData.jobs_by_pk.labhrs.aggregate.sum.mod_lb_hrs +
|
||||
lbrHrsData.jobs_by_pk.larhrs.aggregate.sum.mod_lb_hrs;
|
||||
|
||||
if (values.start && !values.scheduled_completion)
|
||||
form.setFieldsValue({
|
||||
scheduled_completion: moment(values.start).businessAdd(
|
||||
totalHours / bodyshop.target_touchtime,
|
||||
"days"
|
||||
),
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<DateTimePicker onBlur={handleDateBlur} />
|
||||
</Form.Item>
|
||||
<Button onClick={handleAuto} loading={loading}>
|
||||
{t("appointments.actions.smartscheduling")}
|
||||
@@ -89,6 +89,7 @@ export function ScheduleJobModalComponent({
|
||||
key={idx}
|
||||
onClick={() => {
|
||||
form.setFieldsValue({ start: new moment(d).add(8, "hours") });
|
||||
handleDateBlur();
|
||||
}}
|
||||
>
|
||||
<DateFormatter>{d}</DateFormatter>
|
||||
|
||||
@@ -184,6 +184,7 @@ query QUERY_UPCOMING_APPOINTMENTS($now: timestamptz!, $jobId: uuid!) {
|
||||
jobs_by_pk(id: $jobId) {
|
||||
bodyshop {
|
||||
ssbuckets
|
||||
target_touchtime
|
||||
}
|
||||
jobhrs: joblines_aggregate {
|
||||
aggregate {
|
||||
@@ -207,13 +208,26 @@ query QUERY_UPCOMING_APPOINTMENTS($now: timestamptz!, $jobId: uuid!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
productionview {
|
||||
jobs(where: {inproduction: {_eq: true}}) {
|
||||
id
|
||||
labhrs
|
||||
larhrs
|
||||
scheduled_completion
|
||||
labhrs: joblines_aggregate(where: {mod_lbr_ty: {_eq: "LAB"}}) {
|
||||
aggregate {
|
||||
sum {
|
||||
mod_lb_hrs
|
||||
}
|
||||
}
|
||||
}
|
||||
larhrs: joblines_aggregate(where: {mod_lbr_ty: {_eq: "LAR"}}) {
|
||||
aggregate {
|
||||
sum {
|
||||
mod_lb_hrs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} `;
|
||||
}
|
||||
`;
|
||||
|
||||
exports.QUERY_EMPLOYEE_PIN = `query QUERY_EMPLOYEE_PIN($shopId: uuid!, $employeeId: String!) {
|
||||
employees(where: {_and: {shopid: {_eq: $shopId}, employee_number: {_eq: $employeeId}}}) {
|
||||
|
||||
@@ -15,7 +15,7 @@ exports.job = async (req, res) => {
|
||||
try {
|
||||
const BearerToken = req.headers.authorization;
|
||||
const { jobId } = req.body;
|
||||
console.log("exports.job -> jobId", jobId)
|
||||
console.log("exports.job -> jobId", jobId);
|
||||
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
@@ -30,7 +30,7 @@ exports.job = async (req, res) => {
|
||||
jobId: jobId,
|
||||
});
|
||||
|
||||
const { appointments, productionview } = result;
|
||||
const { appointments, jobs } = result;
|
||||
const { ssbuckets } = result.jobs_by_pk.bodyshop;
|
||||
const jobHrs = result.jobs_by_pk.jobhrs.aggregate.sum.mod_lb_hrs;
|
||||
|
||||
@@ -45,7 +45,7 @@ exports.job = async (req, res) => {
|
||||
const totalMatrixDays = moment
|
||||
.max([
|
||||
...appointments.map((a) => moment(a.start)),
|
||||
...productionview
|
||||
...jobs
|
||||
.map((p) => moment(p.scheduled_completion))
|
||||
.filter((p) => p.isValid()),
|
||||
])
|
||||
@@ -87,8 +87,10 @@ exports.job = async (req, res) => {
|
||||
|
||||
//Populate the jobs that are leaving today.
|
||||
const todayIsoString = moment().format("yyyy-MM-DD");
|
||||
productionview.forEach((pjob) => {
|
||||
const jobHrs = pjob.larhrs + pjob.labhrs;
|
||||
jobs.forEach((pjob) => {
|
||||
const jobHrs =
|
||||
pjob.larhrs.aggregate.sum.mod_lb_hrs +
|
||||
pjob.labhrs.aggregate.sum.mod_lb_hrs;
|
||||
//Is the job in the same bucket?
|
||||
const pjobBucket = ssbuckets.filter(
|
||||
(bucket) =>
|
||||
|
||||
Reference in New Issue
Block a user