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

View File

@@ -16,6 +16,7 @@ import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
import { selectTechnician } from "../../redux/tech/tech.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({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
technician: selectTechnician, technician: selectTechnician,
@@ -114,6 +115,7 @@ export function TechClockOffButton({
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit">
{t("general.actions.save")} {t("general.actions.save")}
</Button> </Button>
<TechJobClockoutDelete timeTicketId={timeTicketId} />
</Form> </Form>
</div> </div>
</Card> </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": { "errors": {
"clockingin": "Error while clocking in. {{message}}", "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": { "fields": {
"actualhrs": "Actual Hours", "actualhrs": "Actual Hours",
@@ -1090,6 +1091,7 @@
"labels": { "labels": {
"alreadyclockedon": "You are already clocked in to the following job(s):", "alreadyclockedon": "You are already clocked in to the following job(s):",
"clockintojob": "Clock In to Job", "clockintojob": "Clock In to Job",
"deleteconfirm": "Are you sure you want to delete this time ticket? This cannot be undone.",
"edit": "Edit Time Ticket", "edit": "Edit Time Ticket",
"flat_rate": "Flat Rate", "flat_rate": "Flat Rate",
"new": "New Time Ticket", "new": "New Time Ticket",
@@ -1097,7 +1099,8 @@
}, },
"successes": { "successes": {
"clockedin": "Clocked in successfully.", "clockedin": "Clocked in successfully.",
"clockedout": "Clocked out successfully." "clockedout": "Clocked out successfully.",
"deleted": "Time ticket deleted successfully."
} }
}, },
"titles": { "titles": {

View File

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

View File

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