IO-2038 Resolve duplicate shift clock login.
This commit is contained in:
@@ -43102,6 +43102,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>shiftalreadyclockedon</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
</children>
|
</children>
|
||||||
</folder_node>
|
</folder_node>
|
||||||
<folder_node>
|
<folder_node>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export function TimeTicektShiftContainer({
|
|||||||
technician,
|
technician,
|
||||||
currentUser,
|
currentUser,
|
||||||
isTechConsole,
|
isTechConsole,
|
||||||
|
checkIfAlreadyClocked,
|
||||||
}) {
|
}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [insertTimeTicket] = useMutation(INSERT_NEW_TIME_TICKET);
|
const [insertTimeTicket] = useMutation(INSERT_NEW_TIME_TICKET);
|
||||||
@@ -43,36 +44,47 @@ export function TimeTicektShiftContainer({
|
|||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const theTime = moment((await axios.post("/utils/time")).data);
|
|
||||||
|
|
||||||
const result = await insertTimeTicket({
|
const alreadyClocked = await checkIfAlreadyClocked();
|
||||||
variables: {
|
|
||||||
timeTicketInput: [
|
|
||||||
{
|
|
||||||
bodyshopid: bodyshop.id,
|
|
||||||
employeeid: isTechConsole ? technician.id : employeeId,
|
|
||||||
cost_center: "timetickets.labels.shift",
|
|
||||||
clockon: theTime,
|
|
||||||
date: theTime,
|
|
||||||
memo: values.memo,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
awaitRefetchQueries: true,
|
|
||||||
refetchQueries: ["QUERY_ACTIVE_SHIFT_TIME_TICKETS"],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!!result.errors) {
|
if (alreadyClocked) {
|
||||||
|
//Show the error.
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("timetickets.errors.clockingin", {
|
message: t("timetickets.errors.shiftalreadyclockedon"),
|
||||||
message: JSON.stringify(result.errors),
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
notification["success"]({
|
const theTime = moment((await axios.post("/utils/time")).data);
|
||||||
message: t("timetickets.successes.clockedin"),
|
|
||||||
|
const result = await insertTimeTicket({
|
||||||
|
variables: {
|
||||||
|
timeTicketInput: [
|
||||||
|
{
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
|
employeeid: isTechConsole ? technician.id : employeeId,
|
||||||
|
cost_center: "timetickets.labels.shift",
|
||||||
|
clockon: theTime,
|
||||||
|
date: theTime,
|
||||||
|
memo: values.memo,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
awaitRefetchQueries: true,
|
||||||
|
refetchQueries: ["QUERY_ACTIVE_SHIFT_TIME_TICKETS"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!!result.errors) {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("timetickets.errors.clockingin", {
|
||||||
|
message: JSON.stringify(result.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
notification["success"]({
|
||||||
|
message: t("timetickets.successes.clockedin"),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ export function TimeTicketShiftContainer({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const checkIfAlreadyClocked = async () => {
|
||||||
|
const { data } = await refetch();
|
||||||
|
|
||||||
|
return data.timetickets.length > 0;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{data.timetickets.length > 0 ? (
|
{data.timetickets.length > 0 ? (
|
||||||
@@ -72,7 +78,10 @@ export function TimeTicketShiftContainer({
|
|||||||
refetch={refetch}
|
refetch={refetch}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TimeTicketShiftFormContainer isTechConsole={isTechConsole} />
|
<TimeTicketShiftFormContainer
|
||||||
|
isTechConsole={isTechConsole}
|
||||||
|
checkIfAlreadyClocked={checkIfAlreadyClocked}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2558,7 +2558,8 @@
|
|||||||
"creating": "Error creating time ticket. {{message}}",
|
"creating": "Error creating time ticket. {{message}}",
|
||||||
"deleting": "Error deleting time ticket. {{message}}",
|
"deleting": "Error deleting time ticket. {{message}}",
|
||||||
"noemployeeforuser": "Unable to use Shift Clock",
|
"noemployeeforuser": "Unable to use Shift Clock",
|
||||||
"noemployeeforuser_sub": "An employee record has not been created for this user. Please create one before using the shift clock. "
|
"noemployeeforuser_sub": "An employee record has not been created for this user. Please create one before using the shift clock. ",
|
||||||
|
"shiftalreadyclockedon": "You are already clocked onto a shift. Unable to create shift entry."
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"actualhrs": "Actual Hours",
|
"actualhrs": "Actual Hours",
|
||||||
|
|||||||
@@ -2558,7 +2558,8 @@
|
|||||||
"creating": "",
|
"creating": "",
|
||||||
"deleting": "",
|
"deleting": "",
|
||||||
"noemployeeforuser": "",
|
"noemployeeforuser": "",
|
||||||
"noemployeeforuser_sub": ""
|
"noemployeeforuser_sub": "",
|
||||||
|
"shiftalreadyclockedon": ""
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"actualhrs": "",
|
"actualhrs": "",
|
||||||
|
|||||||
@@ -2558,7 +2558,8 @@
|
|||||||
"creating": "",
|
"creating": "",
|
||||||
"deleting": "",
|
"deleting": "",
|
||||||
"noemployeeforuser": "",
|
"noemployeeforuser": "",
|
||||||
"noemployeeforuser_sub": ""
|
"noemployeeforuser_sub": "",
|
||||||
|
"shiftalreadyclockedon": ""
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"actualhrs": "",
|
"actualhrs": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user