Added a delete in-progress time ticket button. BOD-183

This commit is contained in:
Patrick Fic
2020-07-03 16:53:43 -07:00
parent 88c29490ca
commit d81255b582
7 changed files with 127 additions and 6 deletions

View File

@@ -16970,6 +16970,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>deleting</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>
</folder_node>
<folder_node>
@@ -17211,6 +17232,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>deleteconfirm</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>edit</name>
<definition_loaded>false</definition_loaded>
@@ -17342,6 +17384,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>deleted</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>
</folder_node>
</children>

View File

@@ -16,6 +16,7 @@ import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { selectTechnician } from "../../redux/tech/tech.selectors";
import TechJobClockoutDelete from "../tech-job-clock-out-delete/tech-job-clock-out-delete.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
technician: selectTechnician,
@@ -114,6 +115,7 @@ export function TechClockOffButton({
<Button type="primary" htmlType="submit">
{t("general.actions.save")}
</Button>
<TechJobClockoutDelete timeTicketId={timeTicketId} />
</Form>
</div>
</Card>

View File

@@ -0,0 +1,40 @@
import React from "react";
import { Popconfirm, notification } from "antd";
import { DeleteFilled } from "@ant-design/icons";
import { DELETE_TIME_TICKET } from "../../graphql/timetickets.queries";
import { useTranslation } from "react-i18next";
import { useMutation } from "@apollo/react-hooks";
export default function TechJobClockoutDelete({ timeTicketId }) {
const [deleteTimeTicket] = useMutation(DELETE_TIME_TICKET);
const { t } = useTranslation();
const handleDelete = async () => {
const result = await deleteTimeTicket({
variables: { id: timeTicketId },
refetchQueries: ["QUERY_ACTIVE_TIME_TICKETS"],
});
if (!!result.errors) {
notification["error"]({
message: t("timetickets.errors.deleting", {
message: JSON.stringify(result.errors),
}),
});
} else {
notification["success"]({
message: t("timetickets.successes.deleted"),
});
}
};
return (
<Popconfirm
title={t("timetickets.labels.deleteconfirm")}
okButtonProps={{ type: "danger" }}
okText={t("general.actions.delete")}
onConfirm={handleDelete}
>
<DeleteFilled style={{ margin: "1rem", color: "red" }} />
</Popconfirm>
);
}

View File

@@ -91,3 +91,10 @@ export const QUERY_ACTIVE_TIME_TICKETS = gql`
}
}
`;
export const DELETE_TIME_TICKET = gql`
mutation DELETE_TIME_TICKET($id: uuid!) {
delete_timetickets_by_pk(id: $id) {
id
}
}
`;

View File

@@ -1074,7 +1074,8 @@
},
"errors": {
"clockingin": "Error while clocking in. {{message}}",
"clockingout": "Error while clocking out. {{message}}"
"clockingout": "Error while clocking out. {{message}}",
"deleting": "Error deleting time ticket. {{message}}"
},
"fields": {
"actualhrs": "Actual Hours",
@@ -1090,6 +1091,7 @@
"labels": {
"alreadyclockedon": "You are already clocked in to the following job(s):",
"clockintojob": "Clock In to Job",
"deleteconfirm": "Are you sure you want to delete this time ticket? This cannot be undone.",
"edit": "Edit Time Ticket",
"flat_rate": "Flat Rate",
"new": "New Time Ticket",
@@ -1097,7 +1099,8 @@
},
"successes": {
"clockedin": "Clocked in successfully.",
"clockedout": "Clocked out successfully."
"clockedout": "Clocked out successfully.",
"deleted": "Time ticket deleted successfully."
}
},
"titles": {

View File

@@ -1074,7 +1074,8 @@
},
"errors": {
"clockingin": "",
"clockingout": ""
"clockingout": "",
"deleting": ""
},
"fields": {
"actualhrs": "",
@@ -1090,6 +1091,7 @@
"labels": {
"alreadyclockedon": "",
"clockintojob": "",
"deleteconfirm": "",
"edit": "",
"flat_rate": "",
"new": "",
@@ -1097,7 +1099,8 @@
},
"successes": {
"clockedin": "",
"clockedout": ""
"clockedout": "",
"deleted": ""
}
},
"titles": {

View File

@@ -1074,7 +1074,8 @@
},
"errors": {
"clockingin": "",
"clockingout": ""
"clockingout": "",
"deleting": ""
},
"fields": {
"actualhrs": "",
@@ -1090,6 +1091,7 @@
"labels": {
"alreadyclockedon": "",
"clockintojob": "",
"deleteconfirm": "",
"edit": "",
"flat_rate": "",
"new": "",
@@ -1097,7 +1099,8 @@
},
"successes": {
"clockedin": "",
"clockedout": ""
"clockedout": "",
"deleted": ""
}
},
"titles": {