1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-20 09:52:19 +01:00

select gateway modal

This commit is contained in:
Sylvain 2021-03-10 16:46:18 +01:00
parent 141f4f31b1
commit 18465ee8e9
7 changed files with 93 additions and 7 deletions

View File

@ -2,7 +2,7 @@
* This component ... * This component ...
*/ */
import React from 'react'; import React, { BaseSyntheticEvent, SyntheticEvent, useState } from 'react';
import { react2angular } from 'react2angular'; import { react2angular } from 'react2angular';
import { Loader } from './loader'; import { Loader } from './loader';
import { IApplication } from '../models/application'; import { IApplication } from '../models/application';
@ -20,23 +20,50 @@ interface SelectGatewayModalModalProps {
} }
const SelectGatewayModal: React.FC<SelectGatewayModalModalProps> = ({ isOpen, toggleModal }) => { const SelectGatewayModal: React.FC<SelectGatewayModalModalProps> = ({ isOpen, toggleModal }) => {
const { t } = useTranslation('admin'); const { t } = useTranslation('admin');
const [preventConfirmGateway, setPreventConfirmGateway] = useState<boolean>(true);
const [selectedGateway, setSelectedGateway] = useState<string>('');
/**
* Callback triggered when the user has filled and confirmed the settings of his gateway
*/
const onGatewayConfirmed = () => {
setPreventConfirmGateway(true);
toggleModal();
}
const setGateway = (event: BaseSyntheticEvent) => {
const gateway = event.target.value;
setSelectedGateway(gateway);
setPreventConfirmGateway(!gateway);
}
return ( return (
<FabModal title={t('app.shared.stripe.online_payment')} <FabModal title={t('app.admin.invoices.payment.gateway_modal.select_gateway_title')}
isOpen={isOpen} isOpen={isOpen}
toggleModal={toggleModal} toggleModal={toggleModal}
width={ModalSize.medium} width={ModalSize.medium}
closeButton={false} closeButton={false}
className="stripe-modal"> className="gateway-modal"
confirmButton={t('app.admin.invoices.payment.gateway_modal.confirm_button')}
onConfirm={onGatewayConfirmed}
preventConfirm={preventConfirmGateway}>
<p className="info-gateway">
{t('app.admin.invoices.payment.gateway_modal.gateway_info')}
</p>
<label htmlFor="gateway">{t('app.admin.invoices.payment.gateway_modal.select_gateway')}</label>
<select id="gateway" className="select-gateway" onChange={setGateway} value={selectedGateway}>
<option />
<option value="stripe">{t('app.admin.invoices.payment.gateway_modal.stripe')}</option>
<option value="payzen">{t('app.admin.invoices.payment.gateway_modal.payzen')}</option>
</select>
</FabModal> </FabModal>
); );
} }
const StripeModalWrapper: React.FC<SelectGatewayModalModalProps> = ({ isOpen, toggleModal,currentUser }) => { const SelectGatewayModalWrapper: React.FC<SelectGatewayModalModalProps> = ({ isOpen, toggleModal, currentUser }) => {
return ( return (
<Loader> <Loader>
<SelectGatewayModal isOpen={isOpen} toggleModal={toggleModal} currentUser={currentUser} /> <SelectGatewayModal isOpen={isOpen} toggleModal={toggleModal} currentUser={currentUser} />
@ -44,4 +71,4 @@ const StripeModalWrapper: React.FC<SelectGatewayModalModalProps> = ({ isOpen, to
); );
} }
Application.Components.component('stripeModal', react2angular(StripeModalWrapper, ['isOpen', 'toggleModal', 'currentUser'])); Application.Components.component('selectGatewayModal', react2angular(SelectGatewayModalWrapper, ['isOpen', 'toggleModal', 'currentUser']));

View File

@ -198,6 +198,9 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
// Placeholding date for the reservation end // Placeholding date for the reservation end
$scope.inOneWeekAndOneHour = moment().add(1, 'week').add(1, 'hour').startOf('hour'); $scope.inOneWeekAndOneHour = moment().add(1, 'week').add(1, 'hour').startOf('hour');
// Is shown the modal dialog to select a payment gateway
$scope.openSelectGatewayModal = false;
/** /**
* Change the invoices ordering criterion to the one provided * Change the invoices ordering criterion to the one provided
* @param orderBy {string} ordering criterion * @param orderBy {string} ordering criterion
@ -644,6 +647,9 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
$scope.selectPaymentGateway = function (onlinePaymentModule) { $scope.selectPaymentGateway = function (onlinePaymentModule) {
// if the online payment is about to be disabled, accept the change without any further question // if the online payment is about to be disabled, accept the change without any further question
if (onlinePaymentModule.value === false) return true; if (onlinePaymentModule.value === false) return true;
// otherwise, open a modal to ask for the selection of a payment gateway
$scope.openSelectGatewayModal = true;
}; };
/** /**
@ -682,6 +688,16 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
return modalInstance.result; return modalInstance.result;
}; };
/**
* This will open/close the gateway selection modal
*/
$scope.toggleSelectGatewayModal = function () {
setTimeout(() => {
$scope.openSelectGatewayModal = !$scope.openSelectGatewayModal;
$scope.$apply();
}, 50);
};
/** /**
* Setup the feature-tour for the admin/invoices page. * Setup the feature-tour for the admin/invoices page.
* This is intended as a contextual help (when pressing F1) * This is intended as a contextual help (when pressing F1)

View File

@ -32,5 +32,6 @@
@import "modules/payment-schedules-list"; @import "modules/payment-schedules-list";
@import "modules/stripe-confirm"; @import "modules/stripe-confirm";
@import "modules/payment-schedule-dashboard"; @import "modules/payment-schedule-dashboard";
@import "modules/select-gateway-modal";
@import "app.responsive"; @import "app.responsive";

View File

@ -0,0 +1,25 @@
.gateway-modal {
.info-gateway {
border: 1px solid #bce8f1;
border-radius: 4px;
color: #31708f;
background-color: #d9edf7;
padding: 15px;
}
.select-gateway {
display: block;
width: 100%;
height: 38px;
padding: 6px 12px;
font-size: 16px;
line-height: 1.5;
color: #555555;
background-color: #fff;
background-image: none;
border: 1px solid #c4c4c4;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .08);
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}
}

View File

@ -13,6 +13,7 @@
on-before-save="selectPaymentGateway" on-before-save="selectPaymentGateway"
fa-icon="fa-font"> fa-icon="fa-font">
</boolean-setting> </boolean-setting>
<select-gateway-modal is-open="openSelectGatewayModal" toggle-modal="toggleSelectGatewayModal" current-user="currentUser" />
</div> </div>
<div class="row m-t" ng-show="allSettings.online_payment_module === 'true'"> <div class="row m-t" ng-show="allSettings.online_payment_module === 'true'">
<h3 class="m-l" translate>{{ 'app.admin.invoices.payment.stripe_keys' }}</h3> <h3 class="m-l" translate>{{ 'app.admin.invoices.payment.stripe_keys' }}</h3>

View File

@ -640,6 +640,14 @@ en:
currency_info_html: "Please specify below the currency used for online payment. You should provide a three-letter ISO code, from the list of <a href='https://stripe.com/docs/currencies' target='_blank'>Stripe supported currencies</a>." currency_info_html: "Please specify below the currency used for online payment. You should provide a three-letter ISO code, from the list of <a href='https://stripe.com/docs/currencies' target='_blank'>Stripe supported currencies</a>."
currency_alert_html: "<strong>Warning</strong>: the currency cannot be changed after the first online payment was made. Please define this setting carefully before opening Fab-manager to your members." currency_alert_html: "<strong>Warning</strong>: the currency cannot be changed after the first online payment was made. Please define this setting carefully before opening Fab-manager to your members."
stripe_currency: "Stripe currency" stripe_currency: "Stripe currency"
# select a payment gateway
gateway_modal:
select_gateway_title: "Select a payment gateway"
gateway_info: "To securely collect and process payments online, Fab-manager needs to use an third-party service authorized by the financial institutions, called a payment gateway."
select_gateway: "Please select an available gateway"
stripe: "Stripe"
payzen: "PayZen"
confirm_button: "Validate the gateway"
payment_schedules: payment_schedules:
filter_schedules: "Filter schedules" filter_schedules: "Filter schedules"
no_payment_schedules: "No payment schedules to display" no_payment_schedules: "No payment schedules to display"

View File

@ -640,6 +640,14 @@ fr:
currency_info_html: "Veuillez indiquer la devise à utiliser lors des paiements en ligne. Vous devez fournir un code ISO à trois lettres, issu de la liste des <a href='https://stripe.com/docs/currencies' target='_blank'>devises supportées par Stripe</a>." currency_info_html: "Veuillez indiquer la devise à utiliser lors des paiements en ligne. Vous devez fournir un code ISO à trois lettres, issu de la liste des <a href='https://stripe.com/docs/currencies' target='_blank'>devises supportées par Stripe</a>."
currency_alert_html: "<strong>Attention</strong> : la devise ne peut pas être modifiée après que le premier paiement en ligne ait été effectué. Veuillez définir attentivement ce paramètre avant d'ouvrir Fab-manager à vos membres." currency_alert_html: "<strong>Attention</strong> : la devise ne peut pas être modifiée après que le premier paiement en ligne ait été effectué. Veuillez définir attentivement ce paramètre avant d'ouvrir Fab-manager à vos membres."
stripe_currency: "Devise Stripe" stripe_currency: "Devise Stripe"
# select a payment gateway
gateway_modal:
select_gateway_title: "Sélectionnez une passerelle de paiement"
gateway_info: "Pour collecter et traiter les paiements en ligne en toute sécurité, Fab-manager a besoin d'utiliser un service tiers autorisé par les institutions financières, appelé une passerelle de paiement."
select_gateway: "Veuillez choisir une des passerelles disponibles"
stripe: "Stripe"
payzen: "PayZen"
confirm_button: "Valider la passerelle"
payment_schedules: payment_schedules:
filter_schedules: "Filtrer les échéanciers" filter_schedules: "Filtrer les échéanciers"
no_payment_schedules: "Pas d'échéancier à afficher" no_payment_schedules: "Pas d'échéancier à afficher"