IO-2206 WIP Time Ticket Approval Queue.
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import { useApolloClient } from "@apollo/client";
|
||||
import { Button } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
QUERY_TT_APPROVALS_BY_IDS,
|
||||
UPDATE_TT_BY_APPROVAL,
|
||||
} from "../../graphql/tt-approvals.queries";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
export function TtApproveButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
selectedTickets,
|
||||
disabled,
|
||||
loadingCallback,
|
||||
completedCallback,
|
||||
refetch,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const client = useApolloClient();
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleQbxml = async () => {
|
||||
const { data } = await client.query({
|
||||
query: QUERY_TT_APPROVALS_BY_IDS,
|
||||
variables: { ids: selectedTickets },
|
||||
});
|
||||
|
||||
const { data: insertData } = await client.query({
|
||||
query: UPDATE_TT_BY_APPROVAL,
|
||||
variables: {
|
||||
ttApprovalUpdates: data.map((tta) => ({
|
||||
_set: {},
|
||||
where: { id: { _eq: tta.id } },
|
||||
})),
|
||||
},
|
||||
});
|
||||
|
||||
// if (!!completedCallback) completedCallback([]);
|
||||
// if (!!loadingCallback) loadingCallback(false);
|
||||
|
||||
// setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
||||
{t("tt_approvals.actions.approveselected")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, null)(TtApproveButton);
|
||||
|
||||
const generateGqlUpdate = (ttapproval) => {
|
||||
return;
|
||||
};
|
||||
Reference in New Issue
Block a user