Shift Clock error handling IO-699

This commit is contained in:
Patrick Fic
2021-02-26 14:55:16 -08:00
parent 3caf02f3f7
commit 7e25ca40b8
8 changed files with 74 additions and 11 deletions

View File

@@ -27559,6 +27559,48 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>noemployeeforuser</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>
<concept_node>
<name>noemployeeforuser_sub</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>

View File

@@ -30,6 +30,7 @@ function ShopEmployeesContainer({ bodyshop }) {
const [updateEmployee] = useMutation(UPDATE_EMPLOYEE); const [updateEmployee] = useMutation(UPDATE_EMPLOYEE);
const [insertEmployees] = useMutation(INSERT_EMPLOYEES); const [insertEmployees] = useMutation(INSERT_EMPLOYEES);
const [deleteEmployee] = useMutation(DELETE_EMPLOYEE); const [deleteEmployee] = useMutation(DELETE_EMPLOYEE);
const handleDelete = (id) => { const handleDelete = (id) => {
logImEXEvent("shop_employee_delete"); logImEXEvent("shop_employee_delete");
@@ -57,7 +58,13 @@ function ShopEmployeesContainer({ bodyshop }) {
logImEXEvent("shop_employee_update"); logImEXEvent("shop_employee_update");
updateEmployee({ updateEmployee({
variables: { id: employeeState[0].id, employee: values }, variables: {
id: employeeState[0].id,
employee: {
...values,
user_email: values.user_email === "" ? null : values.user_email,
},
},
}) })
.then((r) => { .then((r) => {
notification["success"]({ notification["success"]({

View File

@@ -40,10 +40,6 @@ export function TimeTicektShiftContainer({
return assoc && assoc.user && assoc.user.employee && assoc.user.employee.id; return assoc && assoc.user && assoc.user.employee && assoc.user.employee.id;
}, [bodyshop, currentUser.email]); }, [bodyshop, currentUser.email]);
console.log(
"🚀 ~ file: time-ticket-shift-form.container.jsx ~ line 42 ~ employeeId",
employeeId
);
const handleFinish = async (values) => { const handleFinish = async (values) => {
setLoading(true); setLoading(true);

View File

@@ -1,5 +1,7 @@
import { useQuery } from "@apollo/client"; import { useQuery } from "@apollo/client";
import { Result } from "antd";
import React, { useMemo } from "react"; import React, { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { QUERY_ACTIVE_SHIFT_TIME_TICKETS } from "../../graphql/timetickets.queries"; import { QUERY_ACTIVE_SHIFT_TIME_TICKETS } from "../../graphql/timetickets.queries";
@@ -28,6 +30,7 @@ export function TimeTicketShiftContainer({
currentUser, currentUser,
isTechConsole, isTechConsole,
}) { }) {
const { t } = useTranslation();
const employeeId = useMemo(() => { const employeeId = useMemo(() => {
const assoc = bodyshop.associations.filter( const assoc = bodyshop.associations.filter(
(a) => a.useremail === currentUser.email (a) => a.useremail === currentUser.email
@@ -48,6 +51,17 @@ export function TimeTicketShiftContainer({
if (loading) return <LoadingSpinner />; if (loading) return <LoadingSpinner />;
if (error) return <AlertComponent message={error.message} type="error" />; if (error) return <AlertComponent message={error.message} type="error" />;
if (!employeeId)
return (
<div>
<Result
status="500"
title={t("timetickets.errors.noemployeeforuser")}
subTitle={t("timetickets.errors.noemployeeforuser_sub")}
/>
</div>
);
return ( return (
<div> <div>
{data.timetickets.length > 0 ? ( {data.timetickets.length > 0 ? (

View File

@@ -5,9 +5,7 @@ import TimeTicketShift from "../../components/time-ticket-shift/time-ticket-shif
export default function ShiftClock() { export default function ShiftClock() {
return ( return (
<RbacWrapper action="shiftclock:view"> <RbacWrapper action="shiftclock:view">
<div> <TimeTicketShift />
<TimeTicketShift />
</div>
</RbacWrapper> </RbacWrapper>
); );
} }

View File

@@ -1691,7 +1691,9 @@
"clockingin": "Error while clocking in. {{message}}", "clockingin": "Error while clocking in. {{message}}",
"clockingout": "Error while clocking out. {{message}}", "clockingout": "Error while clocking out. {{message}}",
"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_sub": "An employee record has not been created for this user. Please create one before using the shift clock. "
}, },
"fields": { "fields": {
"actualhrs": "Actual Hours", "actualhrs": "Actual Hours",

View File

@@ -1691,7 +1691,9 @@
"clockingin": "", "clockingin": "",
"clockingout": "", "clockingout": "",
"creating": "", "creating": "",
"deleting": "" "deleting": "",
"noemployeeforuser": "",
"noemployeeforuser_sub": ""
}, },
"fields": { "fields": {
"actualhrs": "", "actualhrs": "",

View File

@@ -1691,7 +1691,9 @@
"clockingin": "", "clockingin": "",
"clockingout": "", "clockingout": "",
"creating": "", "creating": "",
"deleting": "" "deleting": "",
"noemployeeforuser": "",
"noemployeeforuser_sub": ""
}, },
"fields": { "fields": {
"actualhrs": "", "actualhrs": "",