Merged in feature/IO-2298-payment-export (pull request #802)
IO-2298 added export buttons on payments Approved-by: Patrick Fic
This commit is contained in:
@@ -99,7 +99,7 @@ export function JobPayments({
|
|||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button
|
<Button
|
||||||
disabled={record.exportedat}
|
// disabled={record.exportedat}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPaymentContext({
|
setPaymentContext({
|
||||||
actions: { refetch: refetch },
|
actions: { refetch: refetch },
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
|
|
||||||
import { Button, Form, Modal, notification } from "antd";
|
import { Button, Form, Modal, notification, Space } from "antd";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -19,6 +19,8 @@ import {
|
|||||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||||
import { TemplateList } from "../../utils/TemplateConstants";
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
import PaymentForm from "../payment-form/payment-form.component";
|
import PaymentForm from "../payment-form/payment-form.component";
|
||||||
|
import PaymentExportButton from "../payment-export-button/payment-export-button.component";
|
||||||
|
import PaymentReexportButton from "../payment-reexport-button/payment-reexport-button.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
paymentModal: selectPayment,
|
paymentModal: selectPayment,
|
||||||
@@ -176,12 +178,22 @@ function PaymentModalContainer({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<Space>
|
||||||
|
<PaymentReexportButton payment={context} refetch={actions.refetch} />
|
||||||
|
<PaymentExportButton
|
||||||
|
bodyshop={bodyshop}
|
||||||
|
paymentId={context.id}
|
||||||
|
disabled={!!context.exportedat}
|
||||||
|
refetch={actions.refetch}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
<Form
|
<Form
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
autoComplete={"off"}
|
autoComplete={"off"}
|
||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
initialValues={context || {}}
|
initialValues={context || {}}
|
||||||
|
disabled={context.exportedat}
|
||||||
>
|
>
|
||||||
<PaymentForm form={form} />
|
<PaymentForm form={form} />
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Button, notification } from "antd";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
||||||
|
import { useMutation } from "@apollo/client";
|
||||||
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
setPaymentContext: (context) =>
|
||||||
|
dispatch(setModalContext({ context: context, modal: "payment" })),
|
||||||
|
});
|
||||||
|
|
||||||
|
const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
|
||||||
|
|
||||||
|
const handleClick = async () => {
|
||||||
|
const paymentUpdateResponse = await updatePayment({
|
||||||
|
variables: {
|
||||||
|
paymentId: payment.id,
|
||||||
|
payment: {
|
||||||
|
exportedat: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!!!paymentUpdateResponse.errors) {
|
||||||
|
notification.open({
|
||||||
|
type: "success",
|
||||||
|
key: "paymentsuccessexport",
|
||||||
|
message: t("payments.successes.reexported"),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (refetch) refetch();
|
||||||
|
|
||||||
|
setPaymentContext({
|
||||||
|
actions: {
|
||||||
|
refetch,
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
...payment,
|
||||||
|
exportedat: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("payments.errors.exporting", {
|
||||||
|
error: JSON.stringify(paymentUpdateResponse.error),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
onClick={handleClick}
|
||||||
|
loading={loading}
|
||||||
|
disabled={!payment.exportedat}
|
||||||
|
>
|
||||||
|
{t("bills.labels.markforreexport")}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps)(PaymentReexportButton);
|
||||||
@@ -156,7 +156,7 @@ export function PaymentsListPaginated({
|
|||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space>
|
<Space>
|
||||||
<Button
|
<Button
|
||||||
disabled={record.exportedat}
|
// disabled={record.exportedat}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
let apolloResults;
|
let apolloResults;
|
||||||
if (search.search) {
|
if (search.search) {
|
||||||
|
|||||||
@@ -2217,10 +2217,13 @@
|
|||||||
"new": "New Payment",
|
"new": "New Payment",
|
||||||
"signup": "Please contact support to sign up for electronic payments.",
|
"signup": "Please contact support to sign up for electronic payments.",
|
||||||
"title": "Payments",
|
"title": "Payments",
|
||||||
"totalpayments": "Total Payments"
|
"totalpayments": "Total Payments",
|
||||||
|
"markforexport": "Mark for Export",
|
||||||
|
"markforreexport": "Mark for Reexport"
|
||||||
},
|
},
|
||||||
"successes": {
|
"successes": {
|
||||||
"exported": "Payment(s) exported successfully.",
|
"exported": "Payment(s) exported successfully.",
|
||||||
|
"reexported": "Payment Re-exported successfully",
|
||||||
"markexported": "Payment(s) marked exported.",
|
"markexported": "Payment(s) marked exported.",
|
||||||
"payment": "Payment created successfully. ",
|
"payment": "Payment created successfully. ",
|
||||||
"stripe": "Credit card transaction charged successfully."
|
"stripe": "Credit card transaction charged successfully."
|
||||||
|
|||||||
Reference in New Issue
Block a user