From df1adc34a2c5723dcc73524d1b0c63ed912d59d8 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 30 Aug 2022 14:11:34 -0700 Subject: [PATCH 1/8] IO-2033 Mark payment as exported. --- bodyshop_translations.babel | 21 ++++ .../accounting-payments-table.component.jsx | 18 +++- ...yment-mark-selected-exported.component.jsx | 96 +++++++++++++++++++ client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 6 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 client/src/components/payment-mark-selected-exported/payment-mark-selected-exported.component.jsx diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 65c608655..776e3e524 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -35220,6 +35220,27 @@ + + markexported + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + payment false diff --git a/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx b/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx index 05e5277dd..61b1bb5f9 100644 --- a/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx +++ b/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx @@ -1,19 +1,20 @@ import { Card, Input, Space, Table } from "antd"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; import { Link } from "react-router-dom"; +import { createStructuredSelector } from "reselect"; import { logImEXEvent } from "../../firebase/firebase.utils"; +import { selectBodyshop } from "../../redux/user/user.selectors"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter"; import { alphaSort, dateSort } from "../../utils/sorters"; +import ExportLogsCountDisplay from "../export-logs-count-display/export-logs-count-display.component"; +import OwnerNameDisplay from "../owner-name-display/owner-name-display.component"; import PaymentExportButton from "../payment-export-button/payment-export-button.component"; +import PaymentMarkSelectedExported from "../payment-mark-selected-exported/payment-mark-selected-exported.component"; import PaymentsExportAllButton from "../payments-export-all-button/payments-export-all-button.component"; import QboAuthorizeComponent from "../qbo-authorize/qbo-authorize.component"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; -import OwnerNameDisplay from "../owner-name-display/owner-name-display.component"; -import ExportLogsCountDisplay from "../export-logs-count-display/export-logs-count-display.component"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -184,6 +185,13 @@ export function AccountingPayablesTableComponent({ + ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)(PaymentMarkSelectedExported); + +export function PaymentMarkSelectedExported({ + bodyshop, + currentUser, + paymentIds, + disabled, + loadingCallback, + completedCallback, + refetch, +}) { + const { t } = useTranslation(); + const [loading, setLoading] = useState(false); + const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); + const [updatePayments] = useMutation(gql` + mutation UPDATE_PAYMENTS($paymentIds: [uuid!]!, $exportedat: timestamptz!) { + update_payments( + where: { id: { _in: $paymentIds } } + _set: { exportedat: $exportedat } + ) { + returning { + id + exportedat + } + } + } + `); + + const handleUpdate = async () => { + setLoading(true); + loadingCallback(true); + const result = await updatePayments({ + variables: { paymentIds: paymentIds, exportedat: new Date() }, + update(cache) {}, + }); + + await insertExportLog({ + variables: { + logs: paymentIds.map((id) => { + return { + bodyshopid: bodyshop.id, + paymentid: id, + successful: true, + message: JSON.stringify([t("general.labels.markedexported")]), + useremail: currentUser.email, + }; + }), + }, + }); + + if (!result.errors) { + notification["success"]({ + message: t("payments.successes.markexported"), + }); + } else { + notification["error"]({ + message: t("bills.errors.saving", { + error: JSON.stringify(result.errors), + }), + }); + } + loadingCallback(false); + completedCallback && completedCallback([]); + setLoading(false); + refetch && refetch(); + }; + + return ( + + ); +} diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index a83e17ba6..81da5a4d8 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -2085,6 +2085,7 @@ }, "successes": { "exported": "Payment(s) exported successfully.", + "markexported": "Payment(s) marked exported.", "payment": "Payment created successfully. ", "stripe": "Credit card transaction charged successfully." } diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 1044b521c..713cacc30 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -2085,6 +2085,7 @@ }, "successes": { "exported": "", + "markexported": "", "payment": "", "stripe": "" } diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 57f9cdb9b..566c5e541 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -2085,6 +2085,7 @@ }, "successes": { "exported": "", + "markexported": "", "payment": "", "stripe": "" } From dea4d508210fe01694cbde110c8d8e6afade95b3 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Tue, 30 Aug 2022 16:16:07 -0700 Subject: [PATCH 2/8] IO-1949 Add additional buttons to email overlay. --- bodyshop_translations.babel | 21 ++++++ .../email-overlay/email-overlay.container.jsx | 69 ++++++++++++++----- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 5 files changed, 77 insertions(+), 16 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 776e3e524..60953c7a6 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -15416,6 +15416,27 @@ + + send + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + senderrortosupport false diff --git a/client/src/components/email-overlay/email-overlay.container.jsx b/client/src/components/email-overlay/email-overlay.container.jsx index 95ad60426..5a939ae31 100644 --- a/client/src/components/email-overlay/email-overlay.container.jsx +++ b/client/src/components/email-overlay/email-overlay.container.jsx @@ -1,4 +1,4 @@ -import { Divider, Form, Modal, notification } from "antd"; +import { Button, Divider, Form, Modal, notification, Space } from "antd"; import axios from "axios"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -180,8 +180,10 @@ export function EmailOverlayContainer({ onCancel={() => { toggleEmailOverlayVisible(); }} + okText={t("general.actions.send")} okButtonProps={{ loading: sending, + disabled: selectedMedia && (selectedMedia @@ -191,21 +193,56 @@ export function EmailOverlayContainer({ selectedMedia.filter((s) => s.isSelected).length > 10), }} > -
- {loading && ( -
- - {t("emails.labels.preview")} - -
- )} - {!loading && ( - - )} - +
+
+ + + + +
+
+ {loading && ( +
+ + {t("emails.labels.preview")} + +
+ )} + + {!loading && ( + + )} + +
); } diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 81da5a4d8..eacfb5b06 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -964,6 +964,7 @@ "save": "Save", "saveandnew": "Save and New", "selectall": "Select All", + "send": "Send", "senderrortosupport": "Send Error to Support", "submit": "Submit", "tryagain": "Try Again", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 713cacc30..57e0e7ad8 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -964,6 +964,7 @@ "save": "Salvar", "saveandnew": "", "selectall": "", + "send": "", "senderrortosupport": "", "submit": "", "tryagain": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 566c5e541..fbf06c781 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -964,6 +964,7 @@ "save": "sauvegarder", "saveandnew": "", "selectall": "", + "send": "", "senderrortosupport": "", "submit": "", "tryagain": "", From cb0c4d55dfcf2ee0116e82f8a922b33f3418cd21 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 31 Aug 2022 10:32:41 -0700 Subject: [PATCH 3/8] IO-1950 Parts Order Discounts --- bodyshop_translations.babel | 44 ++++++++- ...rts-order-modal-price-change.component.jsx | 97 +++++++++++++++++++ .../parts-order-modal.component.jsx | 10 +- client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + 6 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 client/src/components/parts-order-modal/parts-order-modal-price-change.component.jsx diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 60953c7a6..95f87f121 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1,4 +1,4 @@ - +