Code clean up prior to merge.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { useApolloClient } from "@apollo/client";
|
||||
import { Button } from "antd";
|
||||
import { Button, notification } from "antd";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { INSERT_TIME_TICKET_AND_APPROVE } from "../../graphql/timetickets.queries";
|
||||
import { QUERY_TT_APPROVALS_BY_IDS } from "../../graphql/tt-approvals.queries";
|
||||
import moment from "moment";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
@@ -33,30 +33,53 @@ export function TtApproveButton({
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleQbxml = async () => {
|
||||
const { data } = await client.query({
|
||||
query: QUERY_TT_APPROVALS_BY_IDS,
|
||||
variables: { ids: selectedTickets },
|
||||
});
|
||||
setLoading(true);
|
||||
try {
|
||||
const { data } = await client.query({
|
||||
query: QUERY_TT_APPROVALS_BY_IDS,
|
||||
variables: { ids: selectedTickets },
|
||||
});
|
||||
|
||||
const { data: insertData } = await client.mutate({
|
||||
mutation: INSERT_TIME_TICKET_AND_APPROVE,
|
||||
variables: {
|
||||
timeTicketInput: data.tt_approval_queue.map((tta) => ({
|
||||
..._.omit(tta, ["id", "__typename"]),
|
||||
ttapprovalqueueid: tta.id,
|
||||
})),
|
||||
approvalIds: selectedTickets,
|
||||
approvalUpdate: {
|
||||
approved_at: moment(),
|
||||
approved_by: currentUser.email,
|
||||
const insertResponse = await client.mutate({
|
||||
mutation: INSERT_TIME_TICKET_AND_APPROVE,
|
||||
variables: {
|
||||
timeTicketInput: data.tt_approval_queue.map((tta) => ({
|
||||
..._.omit(tta, ["id", "__typename"]),
|
||||
ttapprovalqueueid: tta.id,
|
||||
})),
|
||||
approvalIds: selectedTickets,
|
||||
approvalUpdate: {
|
||||
approved_at: moment(),
|
||||
approved_by: currentUser.email,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
if (insertResponse.errors) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("timetickets.errors.creating", {
|
||||
message: JSON.stringify(insertResponse.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification.open({
|
||||
type: "success",
|
||||
message: t("timetickets.successes.createdg"),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
message: t("timetickets.errors.creating", {
|
||||
message: error.message,
|
||||
}),
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
// if (!!completedCallback) completedCallback([]);
|
||||
// if (!!loadingCallback) loadingCallback(false);
|
||||
|
||||
// setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -67,7 +90,3 @@ export function TtApproveButton({
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, null)(TtApproveButton);
|
||||
|
||||
const generateGqlUpdate = (ttapproval) => {
|
||||
return;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user