Code clean up prior to merge.
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import { SyncOutlined, EditFilled } from "@ant-design/icons";
|
import { SyncOutlined } from "@ant-design/icons";
|
||||||
import { Button, Card, Space, Table, Tag } from "antd";
|
import { Button, Card, Space, Table, Tag } from "antd";
|
||||||
import Dinero from "dinero.js";
|
import Dinero from "dinero.js";
|
||||||
import moment from "moment";
|
import queryString from "query-string";
|
||||||
import React, { useMemo, useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
@@ -15,11 +15,6 @@ import {
|
|||||||
import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter";
|
import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter";
|
||||||
import { onlyUnique } from "../../utils/arrayHelper";
|
import { onlyUnique } from "../../utils/arrayHelper";
|
||||||
import { alphaSort, dateSort } from "../../utils/sorters";
|
import { alphaSort, dateSort } from "../../utils/sorters";
|
||||||
import RbacWrapper, {
|
|
||||||
HasRbacAccess,
|
|
||||||
} from "../rbac-wrapper/rbac-wrapper.component";
|
|
||||||
import TimeTicketEnterButton from "../time-ticket-enter-button/time-ticket-enter-button.component";
|
|
||||||
import queryString from "query-string";
|
|
||||||
import TtApproveButtonComponent from "../tt-approve-button/tt-approve-button.component";
|
import TtApproveButtonComponent from "../tt-approve-button/tt-approve-button.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
import { useQuery } from "@apollo/client";
|
import { useQuery } from "@apollo/client";
|
||||||
|
import queryString from "query-string";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import { QUERY_ALL_TT_APPROVALS_PAGINATED } from "../../graphql/tt-approvals.queries";
|
||||||
import { QUERY_TIME_TICKETS_IN_RANGE } from "../../graphql/timetickets.queries";
|
|
||||||
import {
|
import {
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
} from "../../redux/application/application.actions";
|
} from "../../redux/application/application.actions";
|
||||||
|
import AlertComponent from "../alert/alert.component";
|
||||||
import TtApprovalsListComponent from "./tt-approvals-list.component";
|
import TtApprovalsListComponent from "./tt-approvals-list.component";
|
||||||
import { useLocation } from "react-router-dom";
|
|
||||||
import queryString from "query-string";
|
|
||||||
import { QUERY_ALL_TT_APPROVALS_PAGINATED } from "../../graphql/tt-approvals.queries";
|
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({});
|
const mapStateToProps = createStructuredSelector({});
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useApolloClient } from "@apollo/client";
|
import { useApolloClient } from "@apollo/client";
|
||||||
import { Button } from "antd";
|
import { Button, notification } from "antd";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import moment from "moment";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { INSERT_TIME_TICKET_AND_APPROVE } from "../../graphql/timetickets.queries";
|
import { INSERT_TIME_TICKET_AND_APPROVE } from "../../graphql/timetickets.queries";
|
||||||
import { QUERY_TT_APPROVALS_BY_IDS } from "../../graphql/tt-approvals.queries";
|
import { QUERY_TT_APPROVALS_BY_IDS } from "../../graphql/tt-approvals.queries";
|
||||||
import moment from "moment";
|
|
||||||
import {
|
import {
|
||||||
selectBodyshop,
|
selectBodyshop,
|
||||||
selectCurrentUser,
|
selectCurrentUser,
|
||||||
@@ -33,30 +33,53 @@ export function TtApproveButton({
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
const { data } = await client.query({
|
setLoading(true);
|
||||||
query: QUERY_TT_APPROVALS_BY_IDS,
|
try {
|
||||||
variables: { ids: selectedTickets },
|
const { data } = await client.query({
|
||||||
});
|
query: QUERY_TT_APPROVALS_BY_IDS,
|
||||||
|
variables: { ids: selectedTickets },
|
||||||
|
});
|
||||||
|
|
||||||
const { data: insertData } = await client.mutate({
|
const insertResponse = await client.mutate({
|
||||||
mutation: INSERT_TIME_TICKET_AND_APPROVE,
|
mutation: INSERT_TIME_TICKET_AND_APPROVE,
|
||||||
variables: {
|
variables: {
|
||||||
timeTicketInput: data.tt_approval_queue.map((tta) => ({
|
timeTicketInput: data.tt_approval_queue.map((tta) => ({
|
||||||
..._.omit(tta, ["id", "__typename"]),
|
..._.omit(tta, ["id", "__typename"]),
|
||||||
ttapprovalqueueid: tta.id,
|
ttapprovalqueueid: tta.id,
|
||||||
})),
|
})),
|
||||||
approvalIds: selectedTickets,
|
approvalIds: selectedTickets,
|
||||||
approvalUpdate: {
|
approvalUpdate: {
|
||||||
approved_at: moment(),
|
approved_at: moment(),
|
||||||
approved_by: currentUser.email,
|
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 (!!completedCallback) completedCallback([]);
|
||||||
// if (!!loadingCallback) loadingCallback(false);
|
// if (!!loadingCallback) loadingCallback(false);
|
||||||
|
|
||||||
// setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -67,7 +90,3 @@ export function TtApproveButton({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, null)(TtApproveButton);
|
export default connect(mapStateToProps, null)(TtApproveButton);
|
||||||
|
|
||||||
const generateGqlUpdate = (ttapproval) => {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user