diff options
Diffstat (limited to 'frontend/src')
35 files changed, 0 insertions, 2560 deletions
diff --git a/frontend/src/App.less b/frontend/src/App.less deleted file mode 100644 index 2d9a3d60..00000000 --- a/frontend/src/App.less +++ /dev/null @@ -1,22 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -@import '~antd/dist/antd.less'; - -.App { - width: 100vw; - height: 100vh; -} diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx deleted file mode 100644 index de1195d4..00000000 --- a/frontend/src/App.tsx +++ /dev/null @@ -1,55 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React from 'react'; -import { connect } from 'react-redux'; -import { Route, Router } from 'react-router-dom'; -import history from './history'; -import Pages from './routes/Pages'; -import { checkAuthentication } from './actions/auth'; -import { Store } from './types'; -import './App.less'; - -interface Props { - checkAuthenticationConnect: () => void; - isAuthenticated: boolean | null; -} - -const App = ({ checkAuthenticationConnect, isAuthenticated }: Props) => { - React.useEffect(() => { - checkAuthenticationConnect(); - }); - - const app = - isAuthenticated !== null ? ( - <Router history={history}> - <Route component={Pages} /> - </Router> - ) : null; - - return <div className="App">{app}</div>; -}; - -const mapStateToProps = (state: Store) => ({ - ...state, - isAuthenticated: state.isAuthenticated, -}); - -const mapDispatchToProps = { - checkAuthenticationConnect: checkAuthentication, -}; - -export default connect(mapStateToProps, mapDispatchToProps)(App); diff --git a/frontend/src/actions/auth.tsx b/frontend/src/actions/auth.tsx deleted file mode 100644 index 23e42595..00000000 --- a/frontend/src/actions/auth.tsx +++ /dev/null @@ -1,91 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { ThunkDispatch as Dispatch } from 'redux-thunk'; -import { Base64 } from 'js-base64'; -import * as constants from '../constants'; - -export interface Authenticate { - type: constants.AUTHENTICATE; -} -const authenticate = (): Authenticate => { - return { - type: constants.AUTHENTICATE, - }; -}; - -export interface Unauthenticate { - type: constants.UNAUTHENTICATE; -} -const unauthenticate = (): Unauthenticate => { - return { - type: constants.UNAUTHENTICATE, - }; -}; - -export type AuthenticationAction = Authenticate | Unauthenticate; - -export const login = (nexusURL: string, username: string, password: string) => { - return async (dispatch: Dispatch<AuthenticationAction, {}, any>) => { - if (nexusURL && username && password) { - await fetch(`/user`, { - headers: new Headers({ - Authorization: `Basic ${Base64.encode(`${username}:${password}`)}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.json(); - } else if (response.status === 403) { - throw new Error('Invalid credentials'); - } - throw new Error('Cannot connect to server'); - }) - .then(async () => { - await window.localStorage.setItem('authenticated', 'true'); - await window.localStorage.setItem( - 'authHeader', - `${Base64.encode(`${username}:${password}`)}` - ); - dispatch(authenticate()); - }) - .catch((err: Error) => { - throw err; - }); - } - }; -}; -export const logout = () => { - return async (dispatch: Dispatch<AuthenticationAction, {}, any>) => { - await window.localStorage.setItem('authenticated', 'false'); - await window.localStorage.setItem('authHeader', ''); - dispatch(unauthenticate()); - }; -}; - -export const checkAuthentication = () => { - return async (dispatch: Dispatch<AuthenticationAction, {}, any>) => { - const auth = await window.localStorage.getItem('authenticated'); - const formattedAuth = typeof auth === 'string' ? JSON.parse(auth) : null; - - if (formattedAuth) { - dispatch(authenticate()); - } else { - dispatch(unauthenticate()); - } - }; -}; diff --git a/frontend/src/components/NotFound.tsx b/frontend/src/components/NotFound.tsx deleted file mode 100644 index a71caf91..00000000 --- a/frontend/src/components/NotFound.tsx +++ /dev/null @@ -1,21 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import * as React from 'react'; - -const NotFound = () => <p>Not Found</p>; - -export default NotFound; diff --git a/frontend/src/components/activity/Activity.less b/frontend/src/components/activity/Activity.less deleted file mode 100644 index 086ff54f..00000000 --- a/frontend/src/components/activity/Activity.less +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -.activity { - margin-top: 50px; -} - -.actions { - display: flex; - justify-content: flex-end; - position: absolute; - right: 0; - bottom: 0; - margin-bottom: 40px; -} - -.activity-buttons-row { - margin: 50px 0px 50px 0px; - display: flex; - justify-content: space-between; -} - -.account-id { - display: flex; - align-items: center; -} - -.account-id div { - margin-right: 10px; -} - -.payment-options button { - margin-left: 30px; -} diff --git a/frontend/src/components/activity/Index.tsx b/frontend/src/components/activity/Index.tsx deleted file mode 100644 index e66070d7..00000000 --- a/frontend/src/components/activity/Index.tsx +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { Tabs } from 'antd'; -import PaymentInitiationList from './payments/PaymentInitiationList'; -import TransactionsList from './transaction-history/TransactionsList'; - -import './Activity.less'; -const { TabPane } = Tabs; - -const Activity = () => { - const [visible, setVisible] = useState(false); - - const showDrawer = () => { - setVisible(true); - }; - const onClose = () => { - setVisible(false); - }; - - return ( - <div className="activity"> - <Tabs defaultActiveKey="1" type="card" size="large"> - <TabPane tab="Payments" key="1"> - <PaymentInitiationList - visible={visible} - onClose={onClose} - showDrawer={showDrawer} - /> - </TabPane> - <TabPane tab="Transaction History" key="2"> - <TransactionsList /> - </TabPane> - <TabPane tab="Taler View" key="3"> - Taler View - </TabPane> - </Tabs> - </div> - ); -}; - -export default Activity; diff --git a/frontend/src/components/activity/payments/AddPaymentInitiationDrawer.tsx b/frontend/src/components/activity/payments/AddPaymentInitiationDrawer.tsx deleted file mode 100644 index 366c095a..00000000 --- a/frontend/src/components/activity/payments/AddPaymentInitiationDrawer.tsx +++ /dev/null @@ -1,237 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { message, Button, Drawer, Input, Form, Select } from 'antd'; - -const { Option } = Select; - -const layout = { - labelCol: { span: 4 }, -}; - -const AddPaymentInitiationDrawer = (props) => { - const { visible, onClose, updatePaymentInitiations } = props; - - const [accountsList, setAccountsList] = useState([]); - - const [account, setAccount] = useState(''); - const [name, setName] = useState(''); - const [IBAN, setIBAN] = useState(''); - const [BIC, setBIC] = useState(''); - const [currency, setCurrency] = useState(''); - const [amount, setAmount] = useState(''); - const [subject, setSubject] = useState(''); - - const fetchBankAccounts = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-accounts`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.json(); - } - throw 'Cannot retrieve bank accounts'; - }) - .then((response) => { - setAccountsList(response.accounts); - }) - .catch((err) => { - showError(err); - }); - }; - - const createPaymentInitation = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-accounts/${account}/payment-initiations`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - 'Content-Type': 'application/json', - }), - method: 'POST', - body: JSON.stringify({ - name: name, - iban: IBAN, - bic: BIC, - amount: `${currency}:${amount}`, - subject: subject, - }), - }) - .then((response) => { - if (!response.ok) { - throw 'Cannot create payment initiation'; - } - }) - .catch((err) => { - throw new Error(err); - }); - }; - - React.useEffect(() => { - fetchBankAccounts(); - }, []); - - const showError = (err) => { - message.error(String(err)); - }; - - const closeDrawer = () => { - onClose(); - }; - - const submitPaymentInitation = async () => { - let isError = true; - await createPaymentInitation() - .then(() => (isError = false)) - .catch((err) => showError(err)); - if (!isError) { - await updatePaymentInitiations(); - onClose(); - } - }; - - return ( - <Drawer - title="Add payment initiation" - placement="right" - closable={false} - onClose={onClose} - visible={visible} - width={850} - > - <div> - <Form {...layout} name="basic"> - <Form.Item - label="Account ID" - name="Account ID" - rules={[ - { required: true, message: 'Please select your account ID!' }, - ]} - > - <Select - placeholder="Please select your account ID" - onChange={(e) => setAccount(String(e))} - > - {accountsList.map((account) => ( - <Option - key={account['nexusBankAccountId']} - value={account['nexusBankAccountId']} - > - {account['nexusBankAccountId']} - </Option> - ))} - </Select> - </Form.Item> - <Form.Item - label="Name" - name="Name" - rules={[ - { - required: true, - message: - 'Please input the name of the legal subject that will receive the payment!', - }, - ]} - > - <Input onChange={(e) => setName(e.target.value)} /> - </Form.Item> - <Form.Item - label="IBAN" - name="IBAN" - rules={[ - { - required: true, - message: 'Please input the IBAN that will receive the payment!', - }, - ]} - > - <Input onChange={(e) => setIBAN(e.target.value)} /> - </Form.Item> - <Form.Item - label="BIC" - name="BIC" - rules={[ - { - required: true, - message: 'Please input the BIC that will receive the payment!', - }, - ]} - > - <Input onChange={(e) => setBIC(e.target.value)} /> - </Form.Item> - <Form.Item - label="Currency" - name="Currency" - rules={[ - { - required: true, - message: 'Please input the currency to send!', - }, - ]} - > - <Input onChange={(e) => setCurrency(e.target.value)} /> - </Form.Item> - <Form.Item - label="Amount" - name="Amount" - rules={[ - { - required: true, - message: 'Please input the amount to send!', - }, - ]} - > - <Input onChange={(e) => setAmount(e.target.value)} /> - </Form.Item> - <Form.Item - label="Subject" - name="Subject" - rules={[ - { - required: true, - message: 'Please input the payment subject!', - }, - ]} - > - <Input onChange={(e) => setSubject(e.target.value)} /> - </Form.Item> - </Form> - </div> - <div className="actions"> - <Button - style={{ marginRight: '20px' }} - size="large" - onClick={() => closeDrawer()} - > - Cancel - </Button> - <Button - style={{ marginRight: '40px' }} - type="primary" - size="large" - onClick={() => submitPaymentInitation()} - > - Submit - </Button> - </div> - </Drawer> - ); -}; - -export default AddPaymentInitiationDrawer; diff --git a/frontend/src/components/activity/payments/PaymentInitiationList.tsx b/frontend/src/components/activity/payments/PaymentInitiationList.tsx deleted file mode 100644 index 7c543058..00000000 --- a/frontend/src/components/activity/payments/PaymentInitiationList.tsx +++ /dev/null @@ -1,222 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { message, Button, Select, Table } from 'antd'; -import AddPaymentInitiationDrawer from './AddPaymentInitiationDrawer'; -import '../Activity.less'; - -const { Option } = Select; - -const columns = [ - { - title: 'ID', - dataIndex: 'paymentInitiationId', - }, - { - title: 'Creditor BIC', - dataIndex: 'creditorBic', - }, - { - title: 'Creditor IBAN', - dataIndex: 'creditorIban', - }, - { - title: 'Creditor Name', - dataIndex: 'creditorName', - }, - { - title: 'Subject', - dataIndex: 'subject', - }, - { - title: 'Preparation Date', - dataIndex: 'preparationDate', - }, - { - title: 'Submission Date', - dataIndex: 'submissionDate', - }, - { - title: 'Submitted', - dataIndex: 'submitted', - }, -]; - -const PaymentInitiationList = (props) => { - const { showDrawer, visible, onClose } = props; - const [account, setAccount] = useState(''); - const [accountsList, setAccountsList] = useState([]); - const [paymentInitiationList, setPaymentInitiationList] = useState([]); - const [selectedRowKeys, setSelectedRowKeys] = useState([]); - - const showError = (err) => { - message.error(String(err)); - }; - - const onSelectChange = (selectedRowKeys) => { - setSelectedRowKeys(selectedRowKeys); - }; - - const fetchBankAccounts = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-accounts`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.json(); - } - throw 'Cannot retrieve bank accounts'; - }) - .then((response) => { - setAccountsList(response.accounts); - if (response.accounts.length > 0) { - setAccount(response.accounts[0]['nexusBankAccountId']); - } - }) - .catch((err) => { - showError(err); - }); - }; - - const fetchPaymentInitiations = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-accounts/${account}/payment-initiations`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.json(); - } - throw `Cannot retrieve payment initiations for ${account}`; - }) - .then((response) => { - setPaymentInitiationList( - response.initiatedPayments.map((initiatedPayment, index) => ({ - ...initiatedPayment, - key: index, - submitted: initiatedPayment.submitted ? 'Yes' : 'No', - submissionDate: initiatedPayment.submissionDate - ? initiatedPayment.submissionDate - : '-', - })) - ); - }) - .catch((err) => { - showError(err); - }); - }; - - const submitPaymentInitiations = async () => { - for (let selectedRow of selectedRowKeys) { - const { paymentInitiationId } = paymentInitiationList[selectedRow]; - await submitPaymentInitiation(Number(paymentInitiationId)); - } - await fetchPaymentInitiations(); // refresh table - onClose(); - }; - - const submitPaymentInitiation = async (paymentInitiationId) => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch( - `/bank-accounts/${account}/payment-initiations/${paymentInitiationId}/submit`, - { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - 'Content-Type': 'application/json', - }), - method: 'POST', - } - ) - .then((response) => { - if (!response.ok) { - throw `Cannot submit payment initiation of ID ${paymentInitiationId}`; - } - }) - .catch((err) => { - showError(err); - }); - }; - - React.useEffect(() => { - fetchBankAccounts(); - }, []); - - React.useEffect(() => { - if (account !== '') { - fetchPaymentInitiations(); - } - }, [account]); - - return ( - <> - <div className="activity-buttons-row"> - <div className="account-id"> - <div>Account ID: </div> - <Select - placeholder={ - accountsList.length > 0 - ? account - : 'Please select your account ID' - } - onChange={(e) => setAccount(String(e))} - > - {accountsList.map((account) => ( - <Option - key={account['nexusBankAccountId']} - value={account['nexusBankAccountId']} - > - {account['nexusBankAccountId']} - </Option> - ))} - </Select> - </div> - <div className="payment-options"> - <Button type="primary" size="middle" onClick={showDrawer}> - Add payment initiation - </Button> - <Button - type="primary" - size="middle" - onClick={() => submitPaymentInitiations()} - > - Submit selected payment initiation(s) - </Button> - </div> - </div> - <AddPaymentInitiationDrawer - visible={visible} - onClose={onClose} - updatePaymentInitiations={() => fetchPaymentInitiations()} - /> - <Table - rowSelection={{ - selectedRowKeys, - onChange: onSelectChange, - }} - columns={columns} - dataSource={paymentInitiationList} - /> - </> - ); -}; - -export default PaymentInitiationList; diff --git a/frontend/src/components/activity/transaction-history/TransactionsList.tsx b/frontend/src/components/activity/transaction-history/TransactionsList.tsx deleted file mode 100644 index 6c64682f..00000000 --- a/frontend/src/components/activity/transaction-history/TransactionsList.tsx +++ /dev/null @@ -1,291 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React from 'react'; -import { DatePicker, Table } from 'antd'; -import JSONTree from 'react-json-tree'; -import _ from 'lodash'; -import mapKeysDeep from 'map-keys-deep-lodash'; - -const { RangePicker } = DatePicker; - -const theme = { - scheme: 'monokai', - base00: '#272822', - base01: '#383830', - base02: '#49483e', - base03: '#75715e', - base04: '#a59f85', - base05: '#f8f8f2', - base06: '#f5f4f1', - base07: '#f9f8f5', - base08: '#f92672', - base09: '#fd971f', - base0A: '#f4bf75', - base0B: '#a6e22e', - base0C: '#a1efe4', - base0D: '#66d9ef', - base0E: '#ae81ff', - base0F: '#cc6633', -}; - -const mainColumns = [ - { - title: 'Reference ID', - dataIndex: 'Account Servicer Ref', - }, - { - title: 'Status', - dataIndex: 'Status', - }, - { - title: 'Creditor Debit Indicator', - dataIndex: 'Credit Debit Indicator', - }, - { - title: 'Bank Transaction Code', - dataIndex: 'Bank Transaction Code', - }, - { - title: 'Value Date', - dataIndex: 'Value Date', - }, - { - title: 'Booking Date', - dataIndex: 'Booking Date', - }, -]; - -const TransactionsList = () => { - let tempTransactions = [ - { - key: 'acctsvcrref-001', - amount: 'EUR:100.00', - creditDebitIndicator: 'CRDT', - status: 'BOOK', - bankTransactionCode: 'PMNT-RCDT-ESCT', // look at first component (e.g payment/trade) - valueDate: '2020-07-04', // when money moves - bookingDate: '2020-07-02', // value on account - accountServicerRef: 'acctsvcrref-001', // assigned by bank where you held acc - details: { - debtor: { - name: 'Debtor One', - }, - debtorAccount: { - iban: 'DE52123456789473323175', - }, - creditor: { - name: 'Creditor One', - }, - ultimateCreditor: { - name: 'Ultimate Creditor One', - }, - ultimateDebtor: { - name: 'Ultimate Debtor One', - }, - endToEndId: 'e2e-001', // assigned by person that starts payment - purpose: 'GDDS', // trans related to purchase (set by payment initiator) - unstructuredRemittanceInformation: 'unstructured info one', - }, - }, - { - key: 'acctsvcrref-002', - amount: 'EUR:50.00', - creditDebitIndicator: 'CRDT', - status: 'BOOK', - bankTransactionCode: 'PMNT-RCDT-ESCT', - valueDate: '2020-07-04', - bookingDate: '2020-07-02', - accountServicerRef: 'acctsvcrref-002', - details: { - debtor: { - name: 'Debtor One', - }, - debtorAccount: { - iban: 'DE52123456789473323175', - }, - creditor: { - name: 'Creditor One', - }, - endToEndId: 'e2e-002', - unstructuredRemittanceInformation: 'unstructured info across lines', - }, - }, - { - key: '2020063011423362000', - amount: 'EUR:1.12', - creditDebitIndicator: 'CRDT', - status: 'BOOK', - isRTransaction: true, - bankTransactionCode: 'PMNT-ICDT-RRTN', // return transaction (e.g IBAN doesn't exist) - valueDate: '2020-06-30', - bookingDate: '2020-06-30', - accountServicerRef: '2020063011423362000', - details: { - debtor: { - name: 'Account Owner', - }, - debtorAccount: { - iban: 'DE54123456784713474163', - }, - creditor: { - name: 'Nonexistent Creditor', - }, - creditorAccount: { - iban: 'DE24500105177398216438', - }, - endToEndId: 'NOTPROVIDED', - unstructuredRemittanceInformation: - 'Retoure SEPA Ueberweisung vom 29.06.2020, Rueckgabegrund: AC01 IBAN fehlerhaft und ungültig SVWZ: RETURN, Sammelposten Nummer Zwei IBAN: DE24500105177398216438 BIC: INGDDEFFXXX', // truncate at some point in table column, show all in details section - returnInfo: { - originalBankTransactionCode: 'PMNT-ICDT-ESCT', - originator: { - organizationId: { - bic: 'GENODEM1GLS', - }, - }, - reason: 'AC01', - additionalInfo: 'IBAN fehlerhaft und ungültig', - }, - }, - }, - { - key: 'acctsvcrref-002-1', - amount: 'EUR:1000', // in currency of the account - creditDebitIndicator: 'CRDT', - status: 'BOOK', - bankTransactionCode: 'PMNT-RCDT-XBCT', // cross currency bank xfer - valueDate: '2020-07-04', - bookingDate: '2020-07-03', - accountServicerRef: 'acctsvcrref-002', - details: { - debtor: { - name: 'Mr USA', - postalAddress: { - country: 'US', - addressLines: ['42 Some Street', '4242 Somewhere'], - }, - }, - debtorAccount: { - otherId: { - id: '9876543', - }, - }, - debtorAgent: { - bic: 'BANKUSNY', // show in details section - }, - currencyExchange: { - sourceCurrency: 'USD', - targetCurrency: 'EUR', - exchangeRate: '1.20', // depends on when currency switches over - }, - instructedAmount: 'USD:1500', // party that initiated payment - interBankSettlementAmount: 'EUR:1250.0', // used for cross currency xfer (amount that bank exchanges betweeen each other) - counterValueAmount: 'EUR:1250.0', // amount before/after currency conversion before fees were applied - unstructuredRemittanceInformation: 'Invoice No. 4242', - }, - }, - // { - // // ACH transaction (executes at the end of the day)/Most transactions are sent in real time now - // // Banks have inner transactions has a list inside the details view - // key: 'acctsvcrref-005', - // amount: 'EUR:48.42', - // creditDebitIndicator: 'DBIT', - // status: 'BOOK', - // bankTransactionCode: 'PMNT-ICDT-ESCT', - // valueDate: '2020-07-07', - // bookingDate: '2020-07-07', - // accountServicerRef: 'acctsvcrref-005', - // batches: [ - // // one entry can have batches of transactions (collection) - // { - // batchTransactions: [ - // // batch transaction should show as one entry and then clicking on the details section show all transactions inside it - // { - // amount: 'EUR:46.3', - // creditDebitIndicator: 'DBIT', - // details: { - // creditor: { - // name: 'Zahlungsempfaenger 23, ZA 5, DE', - // postalAddress: { - // country: 'DE', - // addressLines: ['DE Adresszeile 1', 'DE Adresszeile 2'], - // }, - // }, - // creditorAccount: { - // iban: 'DE32733516350012345678', - // }, - // creditorAgent: { - // bic: 'BYLADEM1ALR', - // }, - // unstructuredRemittanceInformation: '', - // }, - // }, - // { - // amount: 'EUR:46.3', - // creditDebitIndicator: 'DBIT', - // details: { - // creditor: { - // name: 'Zahlungsempfaenger 23, ZA 5, AT', - // postalAddress: { - // country: 'AT', - // addressLines: ['AT Adresszeile 1', 'AT Adresszeile 2'], - // }, - // }, - // creditorAccount: { - // iban: 'AT071100000012345678', - // }, - // creditorAgent: { - // bic: 'BKAUATWW', - // }, - // endToEndId: 'jh45k34h5l', - // paymentInformationId: '6j564l56', - // messageId: 'asdfasdf', - // unstructuredRemittanceInformation: '', - // }, - // }, - // ], - // }, - // ], - // }, - ]; - - let transactions = mapKeysDeep(tempTransactions, (value, key) => { - if (key === 'key') { - return key; - } - return _.startCase(key); - }); - - return ( - <> - <div className="activity-buttons-row"> - <RangePicker /> - </div> - <Table - columns={mainColumns} - dataSource={transactions} - expandable={{ - expandedRowRender: (record) => ( - <JSONTree data={record['Details']} theme={theme} /> - ), - }} - /> - </> - ); -}; - -export default TransactionsList; diff --git a/frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx b/frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx deleted file mode 100644 index ac0a839c..00000000 --- a/frontend/src/components/bank-accounts/AddBankConnectionDrawer.tsx +++ /dev/null @@ -1,283 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { message, Button, Drawer, Input, Form, Steps } from 'antd'; -const { Step } = Steps; - -const layout = { - labelCol: { span: 4 }, -}; - -const AddBankConnectionDrawer = (props) => { - const { visible, onClose } = props; - const [currentStep, setCurrentStep] = useState(0); - const [printLink, setPrintLink] = useState(''); - - const [name, setName] = useState(''); - const [serverURL, setServerURL] = useState(''); - const [hostID, setHostID] = useState(''); - const [partnerID, setPartnerID] = useState(''); - const [userID, setUserID] = useState(''); - const [systemID, setSystemID] = useState(''); - - const steps = [{ title: 'Fill up details' }, { title: 'Print document' }]; - - const showError = (err) => { - message.error(String(err)); - }; - - const createBankConnection = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-connections`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - 'Content-Type': 'application/json', - }), - method: 'POST', - body: JSON.stringify({ - name: name, - source: 'new', - type: 'ebics', - data: { - ebicsURL: serverURL, - hostID: hostID, - partnerID: partnerID, - userID: userID, - }, - }), - }) - .then((response) => { - if (!response.ok) { - throw 'Cannot create bank connection'; - } - }) - .catch((err) => { - throw new Error(err); - }); - }; - - const connectBankConnection = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-connections/${name}/connect`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - method: 'POST', - }) - .then((response) => { - if (!response.ok) { - throw 'Cannot connect bank connection'; - } - }) - .catch((err) => { - throw new Error(err); - }); - }; - - const fetchKeyLetter = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-connections/${name}/keyletter`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.blob(); - } - throw 'Cannot retrieve keyletter'; - }) - .then(async (blob) => { - const pdfLink = URL.createObjectURL(blob); - setPrintLink(pdfLink); - }) - .catch((err) => { - throw new Error(err); - }); - }; - - const updateBankAccounts = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-connections/${name}/fetch-accounts`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - method: 'POST', - }) - .then((response) => { - if (!response.ok) { - throw 'Cannot update bank accounts'; - } - }) - .catch((err) => { - throw new Error(err); - }); - }; - - const next = async () => { - let isError = true; - await createBankConnection() - .then(async () => { - await connectBankConnection() - .then(async () => { - await fetchKeyLetter() - .then(async () => { - await updateBankAccounts() - .then(() => { - isError = false; - }) - .catch((err) => showError(err)); - }) - .catch((err) => showError(err)); - }) - .catch((err) => showError(err)); - }) - .catch((err) => showError(err)); - - if (!isError) { - setServerURL(''); - setHostID(''); - setPartnerID(''); - setUserID(''); - setSystemID(''); - setCurrentStep(currentStep + 1); - } - }; - - const closeDrawer = () => { - setCurrentStep(0); - onClose(); - }; - - return ( - <Drawer - title="Add bank connection" - placement="right" - closable={false} - onClose={onClose} - visible={visible} - width={850} - > - <div className="steps-row"> - <Steps current={currentStep}> - {steps.map((item) => ( - <Step key={item.title} title={item.title} /> - ))} - </Steps> - </div> - <div> - {currentStep < steps.length - 1 ? ( - <Form {...layout} name="basic"> - <Form.Item - label="Server URL" - name="Server URL" - rules={[ - { required: true, message: 'Please input the Server URL!' }, - ]} - > - <Input onChange={(e) => setServerURL(e.target.value)} /> - </Form.Item> - <Form.Item - label="Name" - name="Name" - rules={[ - { - required: true, - message: 'Please input the name of the bank connection!', - }, - ]} - > - <Input onChange={(e) => setName(e.target.value)} /> - </Form.Item> - <Form.Item - label="Host ID" - name="Host ID" - rules={[{ required: true, message: 'Please input the Host ID!' }]} - > - <Input onChange={(e) => setHostID(e.target.value)} /> - </Form.Item> - <Form.Item - label="Partner ID" - name="Partner ID" - rules={[ - { required: true, message: 'Please input the Partner ID!' }, - ]} - > - <Input onChange={(e) => setPartnerID(e.target.value)} /> - </Form.Item> - <Form.Item - label="User ID" - name="User ID" - rules={[{ required: true, message: 'Please input the User ID!' }]} - > - <Input onChange={(e) => setUserID(e.target.value)} /> - </Form.Item> - <Form.Item label="System ID" name="System ID"> - <Input onChange={(e) => setSystemID(e.target.value)} /> - </Form.Item> - </Form> - ) : ( - <div - style={{ - fontSize: 24, - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - }} - > - <div>Please print out this document and send it to the bank.</div> - <div> - <a href={printLink} target="_blank"> - Link to document - </a>{' '} - </div> - </div> - )} - </div> - <div className="steps-action"> - <Button - style={{ marginRight: '20px' }} - size="large" - onClick={() => closeDrawer()} - > - Cancel - </Button> - {currentStep < steps.length - 1 ? ( - <Button - style={{ marginRight: '40px' }} - type="primary" - size="large" - onClick={() => next()} - > - Next - </Button> - ) : ( - <Button - style={{ marginRight: '40px' }} - type="primary" - size="large" - onClick={() => closeDrawer()} - > - Done - </Button> - )} - </div> - </Drawer> - ); -}; - -export default AddBankConnectionDrawer; diff --git a/frontend/src/components/bank-accounts/BankAccounts.less b/frontend/src/components/bank-accounts/BankAccounts.less deleted file mode 100644 index d628d0ca..00000000 --- a/frontend/src/components/bank-accounts/BankAccounts.less +++ /dev/null @@ -1,49 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -.bank-accounts { - margin-top: 50px; -} - -.buttons-row { - display: flex; - justify-content: flex-end; - width: 100%; -} - -.buttons-row button { - margin-left: 40px; - margin-bottom: 50px; -} - -.steps-row { - display: flex; - justify-content: center; - margin-bottom: 50px; -} - -.steps-row .ant-steps { - width: 50%; -} - -.steps-action { - display: flex; - justify-content: flex-end; - position: absolute; - right: 0; - bottom: 0; - margin-bottom: 40px; -} diff --git a/frontend/src/components/bank-accounts/BankConnectionCard.tsx b/frontend/src/components/bank-accounts/BankConnectionCard.tsx deleted file mode 100644 index 0d8a8edc..00000000 --- a/frontend/src/components/bank-accounts/BankConnectionCard.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { Card } from 'antd'; -import BankConnectionDrawer from './BankConnectionDrawer'; - -const BankConnectionCard = (props) => { - const { type, name, updateBankAccountsTab } = props; - const [visible, setVisible] = useState(false); - const showDrawer = () => { - setVisible(true); - }; - const onClose = () => { - setVisible(false); - }; - return ( - <> - <Card title={type} bordered={false} onClick={() => showDrawer()}> - <p>Name: {name}</p> - </Card> - <BankConnectionDrawer - updateBankAccountsTab={updateBankAccountsTab} - name={name} - visible={visible} - onClose={onClose} - /> - </> - ); -}; - -export default BankConnectionCard; diff --git a/frontend/src/components/bank-accounts/BankConnectionDrawer.tsx b/frontend/src/components/bank-accounts/BankConnectionDrawer.tsx deleted file mode 100644 index 92736efc..00000000 --- a/frontend/src/components/bank-accounts/BankConnectionDrawer.tsx +++ /dev/null @@ -1,189 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { message, Button, Drawer, Table } from 'antd'; - -const columns = [ - { - title: 'Account ID', - dataIndex: 'offeredAccountId', - }, - { - title: 'Owner name', - dataIndex: 'ownerName', - }, - { - title: 'IBAN', - dataIndex: 'iban', - }, - { - title: 'BIC', - dataIndex: 'bic', - }, -]; - -const BankConnectionDrawer = (props) => { - const { visible, onClose, name, updateBankAccountsTab } = props; - const [printLink, setPrintLink] = useState(''); - const [accountsList, setAccountsList] = useState([]); - const [selectedRowKeys, setSelectedRowKeys] = useState([]); - - const showError = (err) => { - message.error(String(err)); - }; - - const onSelectChange = (selectedRowKeys) => { - setSelectedRowKeys(selectedRowKeys); - }; - - const fetchKeyLetter = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-connections/${name}/keyletter`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.blob(); - } - throw 'Cannot retrieve keyletter'; - }) - .then(async (blob) => { - const pdfLink = URL.createObjectURL(blob); - setPrintLink(pdfLink); - }) - .catch((err) => { - showError(err); - }); - }; - - const fetchBankAccounts = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - - await fetch(`/bank-connections/${name}/accounts`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (!response.ok) { - throw 'Cannot retrieve bank accounts'; - } - return response.json(); - }) - .then((response) => { - setAccountsList( - response.accounts.map((account, index) => ({ - ...account, - key: index, - })) - ); - }) - .catch((err) => { - showError(err); - }); - }; - - const importBankAccounts = async () => { - for (let i = 0; i < selectedRowKeys.length; i++) { - const { offeredAccountId } = accountsList[i]; - await importBankAccount(offeredAccountId); - } - await updateBankAccountsTab(); // refresh bank accounts tab - onClose(); - }; - - const importBankAccount = async (offeredAccountId) => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-connections/${name}/import-account`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - 'Content-Type': 'application/json', - }), - method: 'POST', - body: JSON.stringify({ - offeredAccountId: offeredAccountId ? offeredAccountId : '', - nexusBankAccountId: offeredAccountId, - }), - }) - .then((response) => { - if (!response.ok) { - throw 'Cannot import bank account'; - } - }) - .catch((err) => { - showError(err); - }); - }; - - React.useEffect(() => { - fetchKeyLetter(); - fetchBankAccounts(); - }, []); - - return ( - <Drawer - title={name} - placement="right" - closable={false} - onClose={onClose} - visible={visible} - width={850} - > - <div - style={{ - display: 'flex', - justifyContent: 'flex-end', - marginBottom: 20, - fontSize: 18, - }} - > - <a href={printLink} target="_blank"> - Print document link - </a>{' '} - </div> - <h2>Import Bank Accounts</h2> - <Table - rowSelection={{ - selectedRowKeys, - onChange: onSelectChange, - }} - columns={columns} - dataSource={accountsList} - /> - <div className="steps-action"> - <Button - style={{ marginRight: '20px' }} - size="large" - onClick={() => onClose()} - > - Cancel - </Button> - <Button - style={{ marginRight: '20px' }} - size="large" - onClick={() => importBankAccounts()} - > - Import selected - </Button> - </div> - </Drawer> - ); -}; - -export default BankConnectionDrawer; diff --git a/frontend/src/components/bank-accounts/Index.tsx b/frontend/src/components/bank-accounts/Index.tsx deleted file mode 100644 index 26e50051..00000000 --- a/frontend/src/components/bank-accounts/Index.tsx +++ /dev/null @@ -1,152 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { message, Button, Card, Col, Collapse, Row, Tabs } from 'antd'; -import './BankAccounts.less'; -import AddBankConnectionDrawer from './AddBankConnectionDrawer'; -import BankConnectionCard from './BankConnectionCard'; - -const { TabPane } = Tabs; -const { Panel } = Collapse; - -const BankAccounts = () => { - const [connectionsList, setConnectionsList] = useState([]); - const [accountsList, setAccountsList] = useState([]); - - const showError = (err) => { - message.error(String(err)); - }; - - const fetchBankConnections = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-connections`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.json(); - } - throw 'Cannot retrieve bank connections'; - }) - .then((response) => { - setConnectionsList(response.bankConnections); - }) - .catch((err) => { - showError(err); - }); - }; - - const fetchBankAccounts = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-accounts`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.json(); - } - throw 'Cannot retrieve bank accounts'; - }) - .then((response) => { - setAccountsList(response.accounts); - }) - .catch((err) => { - showError(err); - }); - }; - - React.useEffect(() => { - fetchBankConnections(); - fetchBankAccounts(); - }, []); - - const [visible, setVisible] = useState(false); - const showDrawer = () => { - setVisible(true); - }; - const onClose = () => { - setVisible(false); - fetchBankConnections(); - fetchBankAccounts(); - }; - - const bankAccountsContent = - accountsList.length > 0 ? ( - <Row gutter={[40, 40]}> - {accountsList.map((bankAccount) => ( - <Col key={bankAccount['nexusBankAccountId']} span={8}> - <Card title={bankAccount['nexusBankAccountId']} bordered={false}> - <p>Holder: {bankAccount['ownerName']}</p> - <p>IBAN: {bankAccount['iban']}</p> - <p>BIC: {bankAccount['bic']}</p> - </Card> - </Col> - ))} - </Row> - ) : ( - <div style={{ display: 'flex', justifyContent: 'center' }}> - <b> - No bank accounts found. Import your bank accounts from a bank - connection. - </b> - </div> - ); - - return ( - <div className="bank-accounts"> - <Tabs defaultActiveKey="1" type="card" size="large"> - <TabPane tab="Your accounts" key="1"> - <Collapse defaultActiveKey="2"> - <Panel header="Bank connections" key="1"> - <div className="buttons-row"> - <Button type="primary" size="middle" onClick={showDrawer}> - Add bank connection - </Button> - <AddBankConnectionDrawer visible={visible} onClose={onClose} /> - </div> - <Row gutter={[40, 40]}> - {connectionsList - ? connectionsList.map((bankConnection) => ( - <Col key={bankConnection['name']} span={8}> - <BankConnectionCard - type={String(bankConnection['type']).toUpperCase()} - name={bankConnection['name']} - updateBankAccountsTab={() => fetchBankAccounts()} - /> - </Col> - )) - : null} - </Row> - </Panel> - <Panel header="Bank accounts" key="2"> - {bankAccountsContent} - </Panel> - </Collapse> - </TabPane> - <TabPane tab="Recipient accounts" key="2"> - Placeholder - </TabPane> - </Tabs> - </div> - ); -}; - -export default BankAccounts; diff --git a/frontend/src/components/footer/Footer.less b/frontend/src/components/footer/Footer.less deleted file mode 100644 index 02fa928c..00000000 --- a/frontend/src/components/footer/Footer.less +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -.footer { - height: 4rem; - background: #1890ff; - width: 100vw; - display: flex; - flex-direction: column; - align-items: flex-end; - justify-content: center; - position: fixed; - bottom: 0; -} - -.footer .text { - margin-left: 10px; - margin-right: 60px; - color: #ffffff; -} - -.copyright { - display: flex; - align-items: center; - color: #ffffff; -} diff --git a/frontend/src/components/footer/Index.tsx b/frontend/src/components/footer/Index.tsx deleted file mode 100644 index abeb5ea6..00000000 --- a/frontend/src/components/footer/Index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import * as React from 'react'; -import './Footer.less'; -import { CopyrightOutlined } from '@ant-design/icons'; - -const Footer = () => ( - <div className="footer"> - <div className="copyright"> - <CopyrightOutlined /> - <div className="text">Copyright</div> - </div> - </div> -); - -export default Footer; diff --git a/frontend/src/components/home/Home.less b/frontend/src/components/home/Home.less deleted file mode 100644 index bd89cb05..00000000 --- a/frontend/src/components/home/Home.less +++ /dev/null @@ -1,20 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -.home-bank-accounts { - display: flex; - margin-top: 50px; -} diff --git a/frontend/src/components/home/Index.tsx b/frontend/src/components/home/Index.tsx deleted file mode 100644 index 37b31d75..00000000 --- a/frontend/src/components/home/Index.tsx +++ /dev/null @@ -1,92 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import './Home.less'; -import { message, Button, Card, Col, Row } from 'antd'; -import { RightOutlined } from '@ant-design/icons'; - -import history from '../../history'; - -const Home = () => { - const [accountsList, setAccountsList] = useState([]); - - const showError = (err) => { - message.error(String(err)); - }; - - const fetchBankAccounts = async () => { - const authHeader = await window.localStorage.getItem('authHeader'); - await fetch(`/bank-accounts`, { - headers: new Headers({ - Authorization: `Basic ${authHeader}`, - }), - }) - .then((response) => { - if (response.ok) { - return response.json(); - } - throw 'Cannot retrieve bank accounts'; - }) - .then((response) => { - setAccountsList(response.accounts); - }) - .catch((err) => { - showError(err); - }); - }; - - React.useEffect(() => { - fetchBankAccounts(); - }, []); - - const clickHomeBankAccounts = () => { - history.push('/bank-accounts'); - }; - - const bankAccountsContent = - accountsList.length > 0 ? ( - <Row gutter={[40, 40]}> - {accountsList.map((bankAccount) => ( - <Col key={bankAccount['nexusBankAccountId']} span={8}> - <Card title={bankAccount['nexusBankAccountId']} bordered={false}> - <p>Holder: {bankAccount['ownerName']}</p> - <p>IBAN: {bankAccount['iban']}</p> - <p>BIC: {bankAccount['bic']}</p> - </Card> - </Col> - ))} - </Row> - ) : null; - - return ( - <> - <div className="home-bank-accounts"> - <h1 style={{ marginRight: 10 }}>Bank Accounts</h1> - <Button - type="primary" - shape="circle" - icon={<RightOutlined />} - size="large" - onClick={() => clickHomeBankAccounts()} - /> - </div> - {bankAccountsContent} - </> - ); -}; - -export default Home; diff --git a/frontend/src/components/login/Index.tsx b/frontend/src/components/login/Index.tsx deleted file mode 100644 index 218f8f6c..00000000 --- a/frontend/src/components/login/Index.tsx +++ /dev/null @@ -1,112 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React, { useState } from 'react'; -import { connect } from 'react-redux'; -import { Alert, Form, Input, Button } from 'antd'; -import { LoginOutlined } from '@ant-design/icons'; -import { login } from '../../actions/auth'; -import largeLogo from './libeufin-logo-large.png'; -import './Login.less'; - -interface Props { - loginConnect: (nexusURL: string, username: string, password: string) => any; -} - -const Login = ({ loginConnect }: Props) => { - const [nexusURL, setNexusURL] = useState('localhost:5000'); - const [username, setUsername] = useState('admin'); - const [password, setPassword] = useState('x'); - const [authenticationFailure, setAuthenticationFailure] = useState(false); - const [ - authenticationFailureMessage, - setAuthenticationFailureMessage, - ] = useState(''); - - const layout = { - wrapperCol: { span: 32 }, - }; - - const login = () => { - loginConnect(nexusURL, username, password) - .then(() => { - setAuthenticationFailure(false); - }) - .catch((err) => { - setAuthenticationFailure(true); - setAuthenticationFailureMessage(err); - }); - }; - - const enterPressed = (event) => { - let code = event.keyCode || event.which; - if (code === 13) { - login(); - } - }; - - return ( - <div className="login"> - {authenticationFailure ? ( - <Alert - message="Error" - description={String(authenticationFailureMessage)} - type="error" - showIcon - /> - ) : null} - <img className="img" src={largeLogo} alt="LibEuFin large logo" /> - <Form {...layout} size="large"> - <Form.Item> - <Input - placeholder="Nexus Server URL" - defaultValue="localhost:5000" - onChange={(e) => setNexusURL(e.target.value)} - /> - </Form.Item> - <Form.Item> - <Input - placeholder="Username" - onChange={(e) => setUsername(e.target.value)} - onKeyPress={(e) => enterPressed(e)} - /> - </Form.Item> - <Form.Item> - <Input.Password - placeholder="Password" - onChange={(e) => setPassword(e.target.value)} - onKeyPress={(e) => enterPressed(e)} - /> - </Form.Item> - <div className="button"> - <Button - type="primary" - icon={<LoginOutlined />} - onClick={() => login()} - > - Login - </Button> - </div> - </Form> - </div> - ); -}; - -const mapDispatchToProps = { - loginConnect: login, -}; - -export default connect(null, mapDispatchToProps)(Login); diff --git a/frontend/src/components/login/Login.less b/frontend/src/components/login/Login.less deleted file mode 100644 index 6a3233a6..00000000 --- a/frontend/src/components/login/Login.less +++ /dev/null @@ -1,35 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -.img { - margin-bottom: 24px; -} - -.login { - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); -} - -.button { - display: flex; - justify-content: flex-end; -} - -.login .ant-alert-with-description { - margin-bottom: 20px; -} diff --git a/frontend/src/components/login/libeufin-logo-large.png b/frontend/src/components/login/libeufin-logo-large.png Binary files differdeleted file mode 100644 index d9c6a701..00000000 --- a/frontend/src/components/login/libeufin-logo-large.png +++ /dev/null diff --git a/frontend/src/components/navbar/Index.tsx b/frontend/src/components/navbar/Index.tsx deleted file mode 100644 index f69b3bee..00000000 --- a/frontend/src/components/navbar/Index.tsx +++ /dev/null @@ -1,77 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import React from 'react'; -import { Menu, Button } from 'antd'; -import { connect } from 'react-redux'; -import { LogoutOutlined } from '@ant-design/icons'; -import normalLogo from './libeufin-logo-normal.png'; -import './NavBar.less'; -import { logout } from '../../actions/auth'; - -import history from '../../history'; - -interface Props { - logoutConnect: () => void; -} - -const NavBar = ({ logoutConnect }: Props) => { - const handleClick = (key) => { - switch (key) { - case '1': - history.push('/home'); - break; - case '2': - history.push('/activity'); - break; - case '3': - history.push('/bank-accounts'); - break; - default: - return undefined; - } - return undefined; - }; - - return ( - <div className="navBar"> - <img className="logo" src={normalLogo} alt="LibEuFin normal logo" /> - <Menu - className="menu" - mode="horizontal" - selectedKeys={[]} - onClick={({ key }) => handleClick(key)} - > - <Menu.Item key="1">Home</Menu.Item> - <Menu.Item key="2">Activity</Menu.Item> - <Menu.Item key="3">Bank Accounts</Menu.Item> - </Menu> - <Button - type="primary" - shape="circle" - icon={<LogoutOutlined />} - size="large" - onClick={logoutConnect} - /> - </div> - ); -}; - -const mapDispatchToProps = { - logoutConnect: logout, -}; - -export default connect(null, mapDispatchToProps)(NavBar); diff --git a/frontend/src/components/navbar/NavBar.less b/frontend/src/components/navbar/NavBar.less deleted file mode 100644 index 42be8f6c..00000000 --- a/frontend/src/components/navbar/NavBar.less +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -.navBar { - display: flex; - align-items: center; - justify-content: space-between; -} - -.logo { - height: 100%; -} - -.ant-menu-item { - font-family: 'Noto Sans'; -} diff --git a/frontend/src/components/navbar/libeufin-logo-normal.png b/frontend/src/components/navbar/libeufin-logo-normal.png Binary files differdeleted file mode 100644 index a1d62480..00000000 --- a/frontend/src/components/navbar/libeufin-logo-normal.png +++ /dev/null diff --git a/frontend/src/constants.tsx b/frontend/src/constants.tsx deleted file mode 100644 index f08fb475..00000000 --- a/frontend/src/constants.tsx +++ /dev/null @@ -1,20 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -export const AUTHENTICATE = 'AUTHENTICATE'; -export type AUTHENTICATE = typeof AUTHENTICATE; -export const UNAUTHENTICATE = 'UNAUTHENTICATE'; -export type UNAUTHENTICATE = typeof UNAUTHENTICATE; diff --git a/frontend/src/history.tsx b/frontend/src/history.tsx deleted file mode 100644 index 2b4b86f8..00000000 --- a/frontend/src/history.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { createBrowserHistory } from 'history'; - -declare global { - interface Window { - dataLayer: any; - } -} - -const history = createBrowserHistory(); - -export default history; diff --git a/frontend/src/import-png.d.ts b/frontend/src/import-png.d.ts deleted file mode 100644 index 7a857198..00000000 --- a/frontend/src/import-png.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -declare module '*.png' { - const value: any; - export default value; -} diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx deleted file mode 100644 index c46c477e..00000000 --- a/frontend/src/index.tsx +++ /dev/null @@ -1,49 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* eslint-disable @typescript-eslint/no-explicit-any */ -import React from 'react'; -import ReactDOM from 'react-dom'; -import { Provider } from 'react-redux'; -import { applyMiddleware, compose, createStore } from 'redux'; -import thunkMiddleware from 'redux-thunk-recursion-detect'; - -import App from './App'; -import rootReducer from './reducers/index'; -import { Store } from './types'; - -let composeEnhancers; -if ( - process.env.NODE_ENV !== 'production' && - (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ -) { - composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__; -} else { - composeEnhancers = compose; -} - -const store = createStore<Store, any, any, any>( - rootReducer, - undefined, - composeEnhancers(applyMiddleware(thunkMiddleware)) -); - -ReactDOM.render( - <Provider store={store}> - <App /> - </Provider>, - document.getElementById('root') -); diff --git a/frontend/src/react-app-env.d.ts b/frontend/src/react-app-env.d.ts deleted file mode 100644 index 30da8962..00000000 --- a/frontend/src/react-app-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -// / <reference types="react-scripts" /> diff --git a/frontend/src/reducers/index.tsx b/frontend/src/reducers/index.tsx deleted file mode 100644 index d4fadb68..00000000 --- a/frontend/src/reducers/index.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import { Authenticate, Unauthenticate } from '../actions/auth'; -import { AUTHENTICATE, UNAUTHENTICATE } from '../constants'; -import { Store } from '../types'; - -export default function rootReducer( - state: Store = { - isAuthenticated: false, - }, - action: Authenticate | Unauthenticate -): Store { - switch (action.type) { - case AUTHENTICATE: - return { - ...state, - isAuthenticated: true, - }; - case UNAUTHENTICATE: - return { ...state, isAuthenticated: false }; - default: - return state; - } -} diff --git a/frontend/src/routes/AuthenticatedRoute.tsx b/frontend/src/routes/AuthenticatedRoute.tsx deleted file mode 100644 index b53f9850..00000000 --- a/frontend/src/routes/AuthenticatedRoute.tsx +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* eslint-disable @typescript-eslint/no-explicit-any */ -import * as React from 'react'; -import { connect } from 'react-redux'; -import { Route } from 'react-router-dom'; -import history from '../history'; -import { Store } from '../types'; - -import './Layout.less'; -import NavBar from '../components/navbar/Index'; -import Footer from '../components/footer/Index'; - -interface Props { - exact?: boolean; - isAuthenticated: boolean | null; - path: string; - component: React.ComponentType<any>; -} - -const AuthenticatedRoute = ({ - component: Component, - isAuthenticated, - ...otherProps -}: Props) => { - if (isAuthenticated === false) { - history.push('/login'); - } - - return ( - <> - <div className="container"> - <NavBar /> - <Route - render={() => ( - <> - <Component {...otherProps} /> - </> - )} - /> - </div> - <Footer /> - </> - ); -}; - -const mapStateToProps = (state: Store) => ({ - ...state, - isAuthenticated: state.isAuthenticated, -}); - -export default connect(mapStateToProps)(AuthenticatedRoute); diff --git a/frontend/src/routes/Layout.less b/frontend/src/routes/Layout.less deleted file mode 100644 index 2e011f26..00000000 --- a/frontend/src/routes/Layout.less +++ /dev/null @@ -1,19 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -.container { - padding: 30px 60px 64px 60px; -} diff --git a/frontend/src/routes/Pages.tsx b/frontend/src/routes/Pages.tsx deleted file mode 100644 index 9d92f065..00000000 --- a/frontend/src/routes/Pages.tsx +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import * as React from 'react'; -import { Route, Switch } from 'react-router-dom'; - -import Login from '../components/login/Index'; -import NotFound from '../components/NotFound'; -import Home from '../components/home/Index'; -import Activity from '../components/activity/Index'; -import BankAccounts from '../components/bank-accounts/Index'; - -import AuthenticatedRoute from './AuthenticatedRoute'; -import UnauthenticatedRoute from './UnauthenticatedRoute'; - -const Pages = () => { - return ( - <Switch> - <UnauthenticatedRoute path="/" exact component={Login} /> - <UnauthenticatedRoute path="/login" exact component={Login} /> - <AuthenticatedRoute path="/" exact component={Home} /> - <AuthenticatedRoute path="/home" exact component={Home} /> - <AuthenticatedRoute path="/activity" exact component={Activity} /> - <AuthenticatedRoute - path="/bank-accounts" - exact - component={BankAccounts} - /> - <Route component={NotFound} /> - </Switch> - ); -}; - -export default Pages; diff --git a/frontend/src/routes/UnauthenticatedRoute.tsx b/frontend/src/routes/UnauthenticatedRoute.tsx deleted file mode 100644 index cc1b468f..00000000 --- a/frontend/src/routes/UnauthenticatedRoute.tsx +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* eslint-disable @typescript-eslint/no-explicit-any */ -import * as React from 'react'; -import { connect } from 'react-redux'; -import { Route } from 'react-router-dom'; - -import history from '../history'; -import { Store } from '../types'; - -interface Props { - exact?: boolean; - isAuthenticated: boolean | null; - path: string; - component: React.ComponentType<any>; -} - -const UnauthenticatedRoute = ({ - component: Component, - isAuthenticated, - ...otherProps -}: Props) => { - if (isAuthenticated === true) { - history.push('/home'); - } - - return ( - <> - <Route - render={() => ( - <> - <Component {...otherProps} /> - </> - )} - /> - </> - ); -}; - -const mapStateToProps = (state: Store) => ({ - ...state, - isAuthenticated: state.isAuthenticated, -}); - -export default connect(mapStateToProps)(UnauthenticatedRoute); diff --git a/frontend/src/types.tsx b/frontend/src/types.tsx deleted file mode 100644 index 8f9335d9..00000000 --- a/frontend/src/types.tsx +++ /dev/null @@ -1,19 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2020 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -export interface Store { - isAuthenticated: boolean | null; -} |