Merged in feature/IO-2261-opensearch-replacements (pull request #764)

Feature/IO-2261 opensearch replacements

Approved-by: Patrick Fic
This commit is contained in:
Allan Carr
2023-05-05 20:14:02 +00:00
committed by Patrick Fic
7 changed files with 69 additions and 53 deletions

View File

@@ -6,7 +6,7 @@ import { useTranslation } from "react-i18next";
import { DELETE_BILL } from "../../graphql/bills.queries";
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
export default function BillDeleteButton({ bill }) {
export default function BillDeleteButton({ bill, callback }) {
const [loading, setLoading] = useState(false);
const { t } = useTranslation();
const [deleteBill] = useMutation(DELETE_BILL);
@@ -36,6 +36,8 @@ export default function BillDeleteButton({ bill }) {
if (!!!result.errors) {
notification["success"]({ message: t("bills.successes.deleted") });
if (callback && typeof callback === "function") callback(bill.id);
} else {
//Check if it's an fkey violation.
const error = JSON.stringify(result.errors);

View File

@@ -1,4 +1,5 @@
import { EditFilled, SyncOutlined } from "@ant-design/icons";
import { useApolloClient } from "@apollo/client";
import { Button, Card, Input, Space, Table, Typography } from "antd";
import axios from "axios";
import queryString from "query-string";
@@ -7,6 +8,7 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { Link, useHistory, useLocation } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { QUERY_PAYMENT_BY_ID } from "../../graphql/payments.queries";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
@@ -43,6 +45,7 @@ export function PaymentsListPaginated({
const [openSearchResults, setOpenSearchResults] = useState([]);
const [searchLoading, setSearchLoading] = useState(false);
const { page, sortcolumn, sortorder } = search;
const client = useApolloClient();
const history = useHistory();
const [state, setState] = useState({
sortedInfo: {},
@@ -154,10 +157,20 @@ export function PaymentsListPaginated({
<Space>
<Button
disabled={record.exportedat}
onClick={() => {
onClick={async () => {
let apolloResults;
if (search.search) {
const { data } = await client.query({
query: QUERY_PAYMENT_BY_ID,
variables: {
paymentId: record.id,
},
});
apolloResults = data.payments_by_pk;
}
setPaymentContext({
actions: { refetch: refetch },
context: record,
context: apolloResults ? record : apolloResults,
});
}}
>

View File

@@ -114,3 +114,37 @@ export const QUERY_JOB_PAYMENT_TOTALS = gql`
}
}
`;
export const QUERY_PAYMENT_BY_ID = gql`query QUERY_PAYMENT_BY_ID($paymentId: uuid!) {
payments_by_pk(id: $paymentId) {
id
created_at
jobid
paymentnum
date
job {
id
ro_number
ownerid
ownr_co_nm
ownr_fn
ownr_ln
owner {
id
ownr_co_nm
ownr_fn
ownr_ln
}
}
transactionid
memo
type
amount
stripeid
exportedat
stripeid
payer
}
}
`

View File

@@ -177,7 +177,15 @@ export function BillsListPage({
// {t("bills.actions.return")}
// </Button>
}
<BillDeleteButton bill={record} />
<BillDeleteButton
bill={record}
callback={(deletedBillid) => {
//Filter out the state and set it again.
setOpenSearchResults((currentResults) =>
currentResults.filter((bill) => bill.id !== deletedBillid)
);
}}
/>
{record.isinhouse && (
<PrintWrapperComponent
templateObject={{

View File

@@ -682,14 +682,7 @@
insert:
columns: '*'
update:
columns:
- jobid
- invoice_number
- due_date
- exported_at
- vendorid
- id
- date
columns: '*'
retry_conf:
interval_sec: 10
num_retries: 3
@@ -4095,22 +4088,7 @@
insert:
columns: '*'
update:
columns:
- v_color
- ownerid
- ownr_fn
- v_model_desc
- ownr_ln
- id
- v_make_desc
- ownr_st
- clm_no
- voided
- status
- ownr_co_nm
- v_model_yr
- v_vin
- converted
columns: '*'
retry_conf:
interval_sec: 10
num_retries: 3
@@ -4558,12 +4536,7 @@
insert:
columns: '*'
update:
columns:
- shopid
- ownr_fn
- id
- ownr_co_nm
- ownr_ln
columns: '*'
retry_conf:
interval_sec: 10
num_retries: 3
@@ -5010,17 +4983,7 @@
insert:
columns: '*'
update:
columns:
- paymentnum
- exportedat
- type
- amount
- date
- transactionid
- memo
- payer
- id
- jobid
columns: '*'
retry_conf:
interval_sec: 10
num_retries: 3
@@ -5958,14 +5921,7 @@
insert:
columns: '*'
update:
columns:
- v_model_yr
- plate_no
- id
- v_vin
- v_model_desc
- plate_st
- shopid
columns: '*'
retry_conf:
interval_sec: 10
num_retries: 3

View File

@@ -210,6 +210,7 @@ async function OpenSearchUpdateHandler(req, res) {
id
date
exported
exported_at
invoice_number
is_credit_memo
total

View File

@@ -135,8 +135,10 @@ async function OpenSearchUpdateHandler(req, res) {
"id",
"date",
"exported",
"exported_at",
"invoice_number",
"is_credit_memo",
"total"
]),
...bill.bills_by_pk,
bodyshopid: bill.bills_by_pk.job.shopid,