From be464a8a61566f412e25d608571ecd7b34cf49d6 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 10 Mar 2021 17:15:36 +0100 Subject: [PATCH] WIP: migrate stripe keys form to react --- .../components/select-gateway-modal.tsx | 5 +- .../components/stripe-keys-form.tsx | 89 +++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 app/frontend/src/javascript/components/stripe-keys-form.tsx diff --git a/app/frontend/src/javascript/components/select-gateway-modal.tsx b/app/frontend/src/javascript/components/select-gateway-modal.tsx index 7a7f258af..93c71c02a 100644 --- a/app/frontend/src/javascript/components/select-gateway-modal.tsx +++ b/app/frontend/src/javascript/components/select-gateway-modal.tsx @@ -1,8 +1,9 @@ /** - * This component ... + * This component allows an administrator to select and configure a payment gateway. + * The configuration of a payment gateway is required to enable the online payments. */ -import React, { BaseSyntheticEvent, SyntheticEvent, useState } from 'react'; +import React, { BaseSyntheticEvent, useState } from 'react'; import { react2angular } from 'react2angular'; import { Loader } from './loader'; import { IApplication } from '../models/application'; diff --git a/app/frontend/src/javascript/components/stripe-keys-form.tsx b/app/frontend/src/javascript/components/stripe-keys-form.tsx new file mode 100644 index 000000000..216170da4 --- /dev/null +++ b/app/frontend/src/javascript/components/stripe-keys-form.tsx @@ -0,0 +1,89 @@ +/** + * Form to set the stripe's public and private keys + */ + +import React, { useEffect, useState } from 'react'; +import { Loader } from './loader'; +import { useTranslation } from 'react-i18next'; +import SettingAPI from '../api/setting'; +import { SettingName } from '../models/setting'; + + +interface StripeKeysFormProps { + param: string +} + +const stripeKeys = SettingAPI.query([SettingName.StripePublicKey, SettingName.StripeSecretKey]); + +const StripeKeysFormComponent: React.FC = ({ param }) => { + const { t } = useTranslation('admin'); + + const [publicKey, setPublicKey] = useState(''); + const [secretKey, setSecretKey] = useState(''); + + useEffect(() => { + const keys = stripeKeys.read(); + setPublicKey(keys.get(SettingName.StripePublicKey)); + setSecretKey(keys.get(SettingName.StripeSecretKey)); + }, []); + + + // see StripeKeysModalController + // from app/frontend/src/javascript/controllers/admin/invoices.js + + return ( +
+
+
+
+ +
+ + + + + + +
+
+
+ +
+ + + + + + +
+
+ +
+ ); +} + +export const StripeKeysForm: React.FC = ({ param }) => { + return ( + + + + ); +}