1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

[bug] invalid text shown when a member confirms a free cart

This commit is contained in:
Sylvain 2021-10-22 15:43:33 +02:00
parent ca603f85af
commit 4a59f6faed
6 changed files with 35 additions and 4 deletions

View File

@ -14,6 +14,7 @@
- Fix a bug: the upgrade script report an invalid version to upgrade to
- Fix a bug: invalid amount provided to the PayZen payment gateway when using a currency with anything else than 2 decimals
- Fix a bug: incorrect behavior for the setting "email confirmation required"
- Fix a bug: invalid text shown when a member confirms a free cart
- Updated @rails/webpacker to 5.4.3
- Updated react-refresh-webpack-plugin to 0.5.1
- Updated react-refresh to 0.10.0

View File

@ -229,7 +229,8 @@ export const AbstractPaymentModal: React.FC<AbstractPaymentModalProps> = ({ isOp
disabled={!canSubmit()}
form={formId}
className="validate-btn">
{t('app.shared.payment.confirm_payment_of_', { AMOUNT: FormatLib.price(remainingPrice) })}
{remainingPrice > 0 && t('app.shared.payment.confirm_payment_of_', { AMOUNT: FormatLib.price(remainingPrice) })}
{remainingPrice === 0 && t('app.shared.payment.validate')}
</button>}
{submitState && <div className="payment-pending">
<div className="fa-2x">

View File

@ -109,9 +109,26 @@ export const LocalPaymentForm: React.FC<GatewayFormProps> = ({ onSubmit, onSucce
onSuccess(document);
};
/**
* Generally, this form component is only shown to admins or to managers when they book for someone else.
* If this is not the case, then it is shown to validate a free (or prepaid by wallet) cart.
* This function will return `true` in the later case.
*/
const isFreeOfCharge = (): boolean => {
return (customer.id === operator.id);
};
/**
* Get the type of the main item in the cart compile
*/
const mainItemType = (): string => {
return Object.keys(cart.items[0])[0];
};
return (
<form onSubmit={handleSubmit} id={formId} className={className || ''}>
{!paymentSchedule && <p className="payment">{t('app.admin.local_payment.about_to_cash')}</p>}
{!paymentSchedule && !isFreeOfCharge && <p className="payment">{t('app.admin.local_payment.about_to_cash')}</p>}
{!paymentSchedule && isFreeOfCharge && <p className="payment">{t('app.admin.local_payment.about_to_confirm', { ITEM: mainItemType() })}</p>}
{paymentSchedule && <div className="payment-schedule">
<div className="schedule-method">
<label htmlFor="payment-method">{t('app.admin.local_payment.payment_method')}</label>

View File

@ -3,7 +3,7 @@ import { AbstractPaymentModal, GatewayFormProps } from '../abstract-payment-moda
import { LocalPaymentForm } from './local-payment-form';
import { ShoppingCart } from '../../../models/payment';
import { PaymentSchedule } from '../../../models/payment-schedule';
import { User } from '../../../models/user';
import { User, UserRole } from '../../../models/user';
import { Invoice } from '../../../models/invoice';
import { useTranslation } from 'react-i18next';
import { ModalSize } from '../../base/fab-modal';
@ -42,6 +42,15 @@ const LocalPaymentModalComponent: React.FC<LocalPaymentModalProps> = ({ isOpen,
);
};
/**
* Generally, this modal dialog is only shown to admins or to managers when they book for someone else.
* If this is not the case, then it is shown to validate a free (or prepaid by wallet) cart.
* This function will return `true` in the later case.
*/
const isFreeOfCharge = (): boolean => {
return (customer.id === currentUser.id);
};
/**
* Integrates the LocalPaymentForm into the parent AbstractPaymentModal
*/
@ -67,7 +76,7 @@ const LocalPaymentModalComponent: React.FC<LocalPaymentModalProps> = ({ isOpen,
isOpen={isOpen}
toggleModal={toggleModal}
logoFooter={logoFooter()}
title={t('app.admin.local_payment.offline_payment')}
title={isFreeOfCharge() ? t('app.admin.local_payment.validate_cart') : t('app.admin.local_payment.offline_payment')}
formId="local-payment-form"
formClassName="local-payment-form"
currentUser={currentUser}

View File

@ -1396,8 +1396,10 @@ en:
category_deleted: "The category was successfully deleted"
unable_to_delete: "Unable to delete the category: "
local_payment:
validate_cart: "Validate my cart"
offline_payment: "Payment on site"
about_to_cash: "You're about to confirm the cashing by an external payment mean. Please do not click on the button below until you have fully cashed the requested payment."
about_to_confirm: "You're about to confirm your {ITEM, select, subscription{subscription} other{reservation}}."
payment_method: "Payment method"
method_card: "Online by card"
method_check: "By check"

View File

@ -125,6 +125,7 @@ en:
_the_general_terms_and_conditions: "the general terms and conditions."
payment_schedule_html: "<p>You're about to subscribe to a payment schedule of {DEADLINES} months.</p><p>By paying this bill, you agree to send instructions to the financial institution that issue your card, to take payments from your card account, for the whole duration of this subscription. This imply that your card data are saved by {GATEWAY} and a series of payments will be initiated on your behalf, conforming to the payment schedule previously shown.</p>"
confirm_payment_of_: "Pay: {AMOUNT}"
validate: "Validate"
#dialog of on site payment for reservations
valid_reservation_modal:
booking_confirmation: "Booking confirmation"