IO-897 Save and New for payment modal
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<babeledit_project be_version="2.7.1" version="1.2">
|
<babeledit_project version="1.2" be_version="2.7.1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
BabelEdit project file
|
BabelEdit project file
|
||||||
@@ -12480,6 +12480,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>none</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>out</name>
|
<name>out</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -140,9 +140,10 @@ export function PaymentFormComponent({
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("general.labels.sendby")}
|
label={t("general.labels.sendby")}
|
||||||
name="sendby"
|
name="sendby"
|
||||||
initialValue="email"
|
initialValue="none"
|
||||||
>
|
>
|
||||||
<Radio.Group disabled={disabled}>
|
<Radio.Group disabled={disabled}>
|
||||||
|
<Radio value="none">{t("general.labels.none")}</Radio>
|
||||||
<Radio value="email">{t("general.labels.email")}</Radio>
|
<Radio value="email">{t("general.labels.email")}</Radio>
|
||||||
<Radio value="print">{t("general.labels.print")}</Radio>
|
<Radio value="print">{t("general.labels.print")}</Radio>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
||||||
import { Form, Modal, notification } from "antd";
|
import { Button, Form, Modal, notification } from "antd";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -41,6 +41,7 @@ function BillEnterModalContainer({
|
|||||||
setEmailOptions,
|
setEmailOptions,
|
||||||
}) {
|
}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const [enterAgain, setEnterAgain] = useState(false);
|
||||||
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
||||||
const [updatePayment] = useMutation(UPDATE_PAYMENT);
|
const [updatePayment] = useMutation(UPDATE_PAYMENT);
|
||||||
const stripe = useStripe();
|
const stripe = useStripe();
|
||||||
@@ -119,20 +120,22 @@ function BillEnterModalContainer({
|
|||||||
notification["error"]({ message: t("payments.errors.payment") });
|
notification["error"]({ message: t("payments.errors.payment") });
|
||||||
}
|
}
|
||||||
const Templates = TemplateList("payment");
|
const Templates = TemplateList("payment");
|
||||||
GenerateDocument(
|
if (sendby !== "none") {
|
||||||
{
|
GenerateDocument(
|
||||||
name: Templates.payment_receipt.key,
|
{
|
||||||
variables: {
|
name: Templates.payment_receipt.key,
|
||||||
id: newPayment.data.insert_payments.returning[0].id,
|
variables: {
|
||||||
|
id: newPayment.data.insert_payments.returning[0].id,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
// to: [appData.email],
|
||||||
// to: [appData.email],
|
replyTo: bodyshop.email,
|
||||||
replyTo: bodyshop.email,
|
subject: Templates.payment_receipt.subject,
|
||||||
subject: Templates.payment_receipt.subject,
|
},
|
||||||
},
|
sendby === "email" ? "e" : "p"
|
||||||
sendby === "email" ? "e" : "p"
|
);
|
||||||
);
|
}
|
||||||
} else {
|
} else {
|
||||||
const updatedPayment = await updatePayment({
|
const updatedPayment = await updatePayment({
|
||||||
variables: {
|
variables: {
|
||||||
@@ -149,10 +152,17 @@ function BillEnterModalContainer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (actions.refetch) actions.refetch();
|
if (actions.refetch) actions.refetch();
|
||||||
toggleModalVisible();
|
if (enterAgain) {
|
||||||
|
form.resetFields();
|
||||||
|
form.setFieldsValue({ billlines: [] });
|
||||||
|
} else {
|
||||||
|
toggleModalVisible();
|
||||||
|
}
|
||||||
|
setEnterAgain(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("error", error);
|
console.log("error", error);
|
||||||
} finally {
|
} finally {
|
||||||
|
setEnterAgain(false);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -165,6 +175,10 @@ function BillEnterModalContainer({
|
|||||||
if (visible) form.resetFields();
|
if (visible) form.resetFields();
|
||||||
}, [visible, form, context]);
|
}, [visible, form, context]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (enterAgain) form.submit();
|
||||||
|
}, [enterAgain, form]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={
|
title={
|
||||||
@@ -179,6 +193,26 @@ function BillEnterModalContainer({
|
|||||||
okButtonProps={{
|
okButtonProps={{
|
||||||
loading: loading,
|
loading: loading,
|
||||||
}}
|
}}
|
||||||
|
afterClose={() => form.resetFields()}
|
||||||
|
footer={
|
||||||
|
<span>
|
||||||
|
<Button onClick={handleCancel}>{t("general.actions.cancel")}</Button>
|
||||||
|
<Button loading={loading} onClick={() => form.submit()}>
|
||||||
|
{t("general.actions.save")}
|
||||||
|
</Button>
|
||||||
|
{paymentModal.context && paymentModal.context.id ? null : (
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
loading={loading}
|
||||||
|
onClick={() => {
|
||||||
|
setEnterAgain(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("general.actions.saveandnew")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Form
|
<Form
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
|
|||||||
@@ -796,6 +796,7 @@
|
|||||||
"monday": "Monday",
|
"monday": "Monday",
|
||||||
"na": "N/A",
|
"na": "N/A",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
|
"none": "None",
|
||||||
"out": "Out",
|
"out": "Out",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
"passwordresetsuccess": "A password reset link has been sent to you.",
|
"passwordresetsuccess": "A password reset link has been sent to you.",
|
||||||
|
|||||||
@@ -796,6 +796,7 @@
|
|||||||
"monday": "",
|
"monday": "",
|
||||||
"na": "N / A",
|
"na": "N / A",
|
||||||
"no": "",
|
"no": "",
|
||||||
|
"none": "",
|
||||||
"out": "Afuera",
|
"out": "Afuera",
|
||||||
"password": "",
|
"password": "",
|
||||||
"passwordresetsuccess": "",
|
"passwordresetsuccess": "",
|
||||||
|
|||||||
@@ -796,6 +796,7 @@
|
|||||||
"monday": "",
|
"monday": "",
|
||||||
"na": "N / A",
|
"na": "N / A",
|
||||||
"no": "",
|
"no": "",
|
||||||
|
"none": "",
|
||||||
"out": "En dehors",
|
"out": "En dehors",
|
||||||
"password": "",
|
"password": "",
|
||||||
"passwordresetsuccess": "",
|
"passwordresetsuccess": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user