IO-2206 WIP Time Ticket Approval Queue.

This commit is contained in:
Patrick Fic
2023-04-21 11:23:48 -07:00
parent d4d10998f8
commit ad9868b575
13 changed files with 804 additions and 21 deletions

View File

@@ -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;
};