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

[bug] do not load Stripe if no keys were defined

This commit is contained in:
Sylvain 2022-01-05 11:31:27 +01:00
parent e1256ec551
commit d7ccbdbb52
3 changed files with 10 additions and 7 deletions

View File

@ -5,6 +5,7 @@
- Ability to disable public account creation
- Updated caniuse db
- Optimized the load time of the payment schedules list
- Fix a bug: do not load Stripe if no keys were defined
- [TODO DEPLOY] `rails db:seed`
# v5.3.0 2021 December 29

View File

@ -1,6 +1,6 @@
import React, { memo, useEffect, useState } from 'react';
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
import { loadStripe, Stripe } from '@stripe/stripe-js';
import { SettingName } from '../../../models/setting';
import SettingAPI from '../../../api/setting';
@ -8,15 +8,17 @@ import SettingAPI from '../../../api/setting';
* This component initializes the stripe's Elements tag with the API key
*/
export const StripeElements: React.FC = memo(({ children }) => {
const [stripe, setStripe] = useState(undefined);
const [stripe, setStripe] = useState<Promise<Stripe | null>>(undefined);
/**
* When this component is mounted, we initialize the <Elements> tag with the Stripe's public key
*/
useEffect(() => {
SettingAPI.get(SettingName.StripePublicKey).then(key => {
const promise = loadStripe(key.value);
setStripe(promise);
if (key?.value) {
const promise = loadStripe(key.value);
setStripe(promise);
}
});
}, []);

View File

@ -2605,9 +2605,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001261:
version "1.0.30001295"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001295.tgz"
integrity sha512-lSP16vcyC0FEy0R4ECc9duSPoKoZy+YkpGkue9G4D81OfPnliopaZrU10+qtPdT8PbGXad/PNx43TIQrOmJZSQ==
version "1.0.30001296"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001296.tgz"
integrity sha512-WfrtPEoNSoeATDlf4y3QvkwiELl9GyPLISV5GejTbbQRtQx4LhsXmc9IQ6XCL2d7UxCyEzToEZNMeqR79OUw8Q==
case-sensitive-paths-webpack-plugin@^2.4.0:
version "2.4.0"