feat(phone/bank): remove alert component

This commit is contained in:
Christopher committed 2021-02-26 12:10:47 +01:00
1 parent cea0bd653b
commit 1afca13862
3 files changed
-53

No files matched your search

@@ -14,7 +14,6 @@ import { NavigationBar } from './navigation/NavigationBar';
import { BankHome } from './home/BankHome';
import { BankAccount } from './account/BankAccount';
import { TransactionList } from './transactions/TransactionList';
import { BankAlert } from './alert/BankAlert';
import InjectDebugData from '../../../os/debug/InjectDebugData';
InjectDebugData([
@@ -110,7 +109,6 @@ export const BankApp = () => {
<Route path='/bank/account' exact component={BankAccount} />
<Route path='/bank/transactions' exact component={TransactionList} />
</Switch>
<BankAlert />
</AppContent>
<NavigationBar />
</AppWrapper>
@@ -1,8 +0,0 @@
import React from 'react';
import MuiAlert from '@material-ui/lab/Alert';
export function Alert(props) {
return <MuiAlert elevation={6} variant='filled' {...props} />;
}
export default Alert;
@@ -1,43 +0,0 @@
import React, { useState, useEffect } from 'react';
import { useBankAlert } from '../../hooks/useBankAlert';
import Snackbar from '@material-ui/core/Snackbar';
import Alert from './Alert';
import { useTranslation } from 'react-i18next';
export const BankAlert = () => {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const { bankAlert, setBankAlert } = useBankAlert();
const [message, setMessage] = useState(null);
const [severity, setSeverity] = useState('');
const _handleClose = () => {
setOpen(false);
setBankAlert(null);
};
useEffect(() => {
if (bankAlert === true) {
setOpen(true);
setMessage(t('APPS_BANK_ALERT_TRANSFER_SUCCESS'));
setSeverity('success');
} else if (bankAlert === false) {
setOpen(true);
setMessage(t('APPS_BANK_ALERT_TRANSFER_FAILURE'));
setSeverity('error');
}
}, [bankAlert, t]);
return (
<Snackbar
style={{ width: '80%' }}
open={open}
autoHideDuration={6000}
onClose={_handleClose}
>
<Alert onClose={_handleClose} severity={severity}>
{message}
</Alert>
</Snackbar>
);
};