import React, {useEffect, useMemo} from 'react';
import styled from 'styled-components';
import {useParams} from 'react-router-dom';
import {useWallet} from 'use-wallet';
import {makeStyles} from '@material-ui/core/styles';
import {Box, Button, Card, CardContent, Typography, Grid} from '@material-ui/core';
import PageHeader from '../../components/PageHeader';
import Spacer from '../../components/Spacer';
import UnlockWallet from '../../components/UnlockWallet';
import Harvest from './components/Harvest';
import HarvestHermes from './components/HarvestHermes';
import Stake from './components/Stake';
import useBank from '../../hooks/useBank';
import useStatsForPool from '../../hooks/useStatsForPool';
import useRedeem from '../../hooks/useRedeem';
import {Bank as BankEntity} from '../../unicorn-finance';
import {Alert} from '@material-ui/lab';
import useModal from '../../hooks/useModal';
import StratModal from './components/StratModal';
import zone1 from '../../assets/img/1.jpg';
import zone2 from '../../assets/img/2.jpg';
import zone3 from '../../assets/img/3.jpg';
import wampStrat from '../../assets/img/wamp-strat.jpg';
import useCashPriceInLastTWAP from '../../hooks/useCashPriceInLastTWAP';
import usebShareStats from '../../hooks/useWingsStats';
const useStyles = makeStyles((theme) => ({
gridItem: {
height: '100%',
[theme.breakpoints.up('md')]: {
height: '90px',
},
},
}));
const Bank: React.FC = () => {
useEffect(() => window.scrollTo(0, 0));
const classes = useStyles();
// @ts-ignore
const {bankId} = useParams();
const bank = useBank(bankId);
const {account} = useWallet();
const {onRedeem} = useRedeem(bank);
const statsOnPool = useStatsForPool(bank);
const bShareStats = usebShareStats();
const cashPrice = useCashPriceInLastTWAP();
const bondScale = (Number(cashPrice) / 1e18).toFixed(2);
const bSharePriceInDollars = useMemo(
() => (bShareStats ? Number(bShareStats.priceInDollars).toFixed(2) : null),
[bShareStats],
);
let curStrat: string;
if (Number(bondScale) >= 2) {
curStrat = zone1;
} else if (Number(bondScale) < 2 && Number(bondScale) >= 1) {
curStrat = zone2;
} else {
curStrat = zone3;
}
console.log(bank.depositTokenName);
let name: string;
let vaultUrl: string;
let strat: string;
let stratText: string;
if (bank.depositTokenName.includes('UNICORN-WCRO')) {
name = 'Autocompound your UNICORN-WCRO on Magik to buy back & burn Unicorn';
vaultUrl = 'https://magik.farm/#/cronos';
strat = curStrat;
stratText = 'Click here to see the optimal strategy for this vault';
} else if (bank.depositTokenName.includes('WINGS-WCRO')) {
name = 'Autocompound your WINGS-WCRO on Magik to buy back & burn Unicorn';
vaultUrl = 'https://magik.farm/#/cronos';
strat = curStrat;
stratText = 'Click here to see the optimal strategy for this vault';
} else if (bank.depositTokenName.includes('UNICORN-WINGS')) {
name = 'Autocompound your UNICORN-WINGS on Magik to buy back & burn Unicorn';
vaultUrl = 'https://magik.farm/#/avax';
strat = curStrat;
stratText = 'Click here to see the optimal strategy for this vault';
} else if (bank.depositTokenName === 'UNICORN') {
name = 'Autocompound your UNICORN on Magik to buy back & burn Unicorn';
vaultUrl = 'https://magik.farm/#/avax';
strat = '';
stratText = '';
} else if (bank.depositTokenName === 'WINGS-POPS-LP') {
name = '';
vaultUrl = '';
strat = '';
stratText = '';
} else if (bank.depositTokenName === 'WAMP') {
name = 'Get WAMP to stake for WINGS here';
vaultUrl = 'https://app.asgarddao.fi/#/pledge';
strat = wampStrat;
stratText = 'Click here to see the optimal strategy for this vault';
}
const [onPresentDeposit, onDismissDeposit] = useModal(