-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSidebar.js
More file actions
249 lines (237 loc) · 8.95 KB
/
Sidebar.js
File metadata and controls
249 lines (237 loc) · 8.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
import React, { Component } from "react";
import Logo from "../assets/bprotocol.svg";
import Github from "../assets/github.svg";
import Twitter from "../assets/twitter-icon.svg";
import Linkedin from "../assets/linkedin.svg";
import Discord from "../assets/discord.svg";
import AAVELogo from "../assets/aav-ewhite-logo.svg";
import CompoundLogo from "../assets/compound-logo.svg";
import LiquityLogo from "../assets/liquity-logo.svg";
import VestaLogo from "../assets/vesta-logo.svg";
import MakerLogo from "../assets/logo-maker-white.svg";
import HundredLogo from "../assets/hundred-logo.svg";
import MigrationModal from "./modals/MigrationModal";
import { numm } from "../lib/Utils";
import MakerMigrationButton from "./action-panels/MigrationButton";
import LeavUs from "../components/LeaveUs";
import * as qs from "qs";
import {observer} from "mobx-react"
import routerStore from "../stores/router.store"
import makerStoreManager from "../stores/maker.store"
import userStore from "../stores/user.store"
import styled from "styled-components"
import MigrateFromCompound from "./compound-components/MigrateFromCompound"
import {makerStoreNames} from "../stores/maker.store"
import {Transition} from 'react-spring/renderprops'
const MakerMigration = styled.div`
`
class Sidebar extends Component {
constructor (props) {
super(props)
this.state = {open: false}
}
handleItemSelect = (location) => {
routerStore.routeProps.history.push(`/${location}`);
this.setState({open: false})
};
getState(pathname) {
if(pathname === "/maker" || pathname === "/app"){
return "maker"
}
if(pathname === "/compound"){
return "compound"
}
}
render() {
const { history } = routerStore.routeProps;
const {search, pathname} = history.location
const { loggedIn, showConnect } = userStore
const {getMakerStore, storeChanges} = makerStoreManager
const { userInfo, symbol } = getMakerStore()
const params = qs.parse(search, { ignoreQueryPrefix: true })
const pathState = this.getState(pathname)
const lunchDate = new Date("8/4/2021 12:00:00 GMT+0300").getTime()
const now = new Date().getTime()
const notLunched = now < lunchDate
return (
<div className={`sidebar ${this.state.open ? "open" : ""}`}>
<div onClick={()=>this.setState({open: !this.state.open})} className="menu-toggle">
<div className={`hamburger hamburger--spin ${this.state.open ? "is-active" : ""}`}>
<div className="hamburger-box">
<div className="hamburger-inner"></div>
</div>
</div>
</div>
<div className="scroll-box">
<img className="logo" alt="Logo" src={Logo} />
<div className="sidebar-content">
{pathState == "maker"
?
<div >
<MakerMigration>
{ !params.export && userInfo && userInfo.makerdaoCdpInfo.hasCdp && (
<React.Fragment>
<div className="ln"> </div>
<div>
<div className="cdp-convert">
{makerStoreNames.map(makerCollType => <MakerMigrationButton key={makerCollType} makerCollType={makerCollType}/>)}
<div>
<p>
Import your Vault
<br />
from MakerDAO system <br />
to B.Protocol
</p>
<div className="even">
<div>
<small><b><u>{symbol}</u></b></small>
<p>{numm(userInfo.makerDaoDeposited, 4)} {symbol}</p>
</div>
<div>
<small><b><u>DAI Debt</u></b></small>
<p>{numm(userInfo.makerdaoCdpInfo.daiDebt, 2)} DAI</p>
</div>
</div>
</div>
</div>
</div>
</React.Fragment>
)}
{params.export &&
<div className="container">
<LeavUs show={params.export} userInfo={userInfo} showConnect={showConnect} />
</div>
}
</MakerMigration>
</div>
: pathState == "compound" ?
<div >
<MigrateFromCompound/>
</div>
:
<div>
{/* AAVE */}
<div></div>
</div>
}
<div className="products">
<div className="ln group">
<small>Backstop</small>
</div>
<div
className={`product link-accesible ${
pathname === "/liquity" &&
"selected"
}`}
onClick={() => this.handleItemSelect("liquity")}>
<img src={LiquityLogo} />
{false && <small>(test)</small>}
</div>
<div
className={`product link-accesible ${
pathname === "/vesta" &&
"selected"
}`}
onClick={() => this.handleItemSelect("vesta")}>
<img src={VestaLogo} />
<small>Arbitrum</small>
</div>
<div className="product">
<a href="https://hundred.finance" target="_blank">
<img src={HundredLogo} />
</a>
</div>
<div className="ln group">
<small>Legacy</small>
</div>
<div
className={`product link-accesible ${
(pathname === "/maker" || pathname === "/app") &&
"selected"
}`}
onClick={() => this.handleItemSelect("maker")}
>
<img src={MakerLogo} />
</div>
<div
className={`product link-accesible ${
pathname === "/compound" &&
"selected"
}`}
onClick={() => this.handleItemSelect("compound")}>
<img src={CompoundLogo} />
</div>
<div
className={`product link-accesible ${
pathname === "/liquity-leagacy" &&
"selected"
}`}
onClick={() => this.handleItemSelect("liquity-leagacy")}>
<img src={LiquityLogo} />
<small>(Deprecated)</small>
</div>
</div>
<div className="ln"> </div>
<div
className={`product link-accesible ${
pathname === "/farm-info" &&
"selected"
}`}
onClick={() => this.handleItemSelect("farm-info")}
>
<p className="menu-item">Farm Info</p>
<small>(Beta)</small>
</div>
<div className="ln"> </div>
<div
className={`product link-accesible ${
pathname === "/faq" &&
"selected"
}`}
onClick={() => this.handleItemSelect("faq")}
>
<p className="menu-item">FAQ</p>
</div>
<div
className={`product link-accesible ${
pathname === "/risk" &&
"selected"
}`}
onClick={() => this.handleItemSelect("risk")}
>
<p className="menu-item">Risks</p>
</div>
<div
className={`product link-accesible ${
pathname === "/terms" &&
"selected"
}`}
onClick={() => this.handleItemSelect("terms")}
>
<p className="menu-item">Terms of Use</p>
</div>
</div>
<div className="sidebar-footer">
<h3>B.Protocol community</h3>
<div className="social-icons">
<a href="https://github.com/backstop-protocol" target="_blank">
<img src={Github} />
</a>
<a href="https://twitter.com/bprotocoleth" target="_blank">
<img src={Twitter} />
</a>
<a href="https://medium.com/b-protocol" target="_blank">
<img src={require("../assets/medium-icon.svg")} />
</a>
<a href="https://discord.com/invite/bJ4guuw" target="_blank">
<img src={Discord} />
</a>
</div>
<p className="credits">© 2020 Smart Future Labs</p>
</div>
</div>
</div>
);
}
}
export default observer(Sidebar)