Skip to content

Commit

Permalink
Merge pull request #121 from DistributedCollective/fix/active-loan-table
Browse files Browse the repository at this point in the history
Fix/active loan table
  • Loading branch information
creed-victor authored Dec 17, 2020
2 parents 109006c + 743f1fc commit b610241
Show file tree
Hide file tree
Showing 25 changed files with 1,169 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,21 @@ export function ActiveLoanTableContainer(props: Props) {
const currentPrice = isLong ? 1 / currentRate : currentRate;

const profit = calculateProfit(
startPrice,
currentPrice,
isLong,
item.collateral,
item.startRate,
currentPrice,
isLong,
);

return {
id: item.loanId,
pair: AssetsDictionary.get(loanAsset).symbol,
pair: isLong
? `${AssetsDictionary.get(collateralAsset).symbol} / ${
AssetsDictionary.get(loanAsset).symbol
}`
: `${AssetsDictionary.get(loanAsset).symbol} / ${
AssetsDictionary.get(collateralAsset).symbol
}`,
currency: currency,
icon: isLong ? 'LONG' : 'SHORT',
positionSize: formatAsNumber(item.collateral, 4),
Expand Down
1 change: 1 addition & 0 deletions src/app/components/TutorialDialog/container/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function TutorialDialog() {
// window.localStorage.getItem('connectedToRskBefore') === 'true',
connected: useIsConnected(),
closedBefore: storage.session.getItem('closedRskTutorial') === 'true',
onNetwork: onNetwork && storage.local.getItem('tutorial_active') !== 'true',
};

const handleWalletConnection = useCallback(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/containers/SandboxPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/

import React from 'react';
import { TutorialDialog } from '../../components/TutorialDialog/container';
import { TutorialDialogModal } from '../../containers/TutorialDialogModal/Loadable';

interface Props {}

export function SandboxPage(props: Props) {
return (
<div className="bg-blue">
<TutorialDialog />
<TutorialDialogModal />
</div>
);
}
15 changes: 15 additions & 0 deletions src/app/containers/TutorialDialogModal/Loadable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
*
* Asynchronously loads the component for TutorialDialogModal
*
*/

import React from 'react';
import { lazyLoad } from 'utils/loadable';
import { PageSkeleton } from 'app/components/PageSkeleton';

export const TutorialDialogModal = lazyLoad(
() => import('./index'),
module => module.TutorialDialogModal,
{ fallback: <PageSkeleton /> },
);
111 changes: 111 additions & 0 deletions src/app/containers/TutorialDialogModal/component/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React, { useState } from 'react';
import { reactLocalStorage } from 'reactjs-localstorage';
import { useTranslation } from 'react-i18next';
import background from 'assets/images/tutorial/test.svg';
import close from 'assets/images/tutorial/close.svg';
import { translations } from 'locales/i18n';
import { Screen1 } from './screen1';
import { Screen2 } from './screen2';
import { Screen3 } from './screen3';
import { Screen4 } from './screen4';

export function TutorialDialogComponent(props) {
const { t } = useTranslation();
const [mouseLeave, setMouseLeave] = useState(false);
const activeTutorial =
reactLocalStorage.get('tutorial_active') === 'true' &&
props.onNetwork === true
? true
: false;
const [screen, setScreen] = useState(activeTutorial ? 2 : 1);

function changeScreen(num) {
setScreen(num);
}

function back() {
screen === 3 ? setScreen(4) : setScreen(1);
}

return (
<>
<div
className="wallet-tutorial_container position-absolute mx-auto"
onMouseLeave={() => {
console.log('Mouse out');
if (screen === 2) {
setMouseLeave(true);
} else {
setMouseLeave(false);
}
}}
>
<div className={`${screen === 2 && 'left'} position-absolute`}>
<div className="background position-relative w-100">
<img src={background} alt="" className="w-100 h-100" />
</div>
<div className="close" onClick={props.handleClose}>
<img src={close} alt="close" />
</div>
{screen !== 1 && (
<div className="back position-absolute" onClick={() => back()}>
<button>{t(translations.common.back)}</button>
</div>
)}
<div className="title position-absolute">
<h1>
{t(
translations.rskConnectTutorial.screens[screen.toString()]
.title,
)}
</h1>
</div>
<div className="banner">
<p>
{t(
translations.rskConnectTutorial.screens[screen.toString()]
.banner,
)}{' '}
{screen === 1 && (
<a
href="https://metamask.io/"
target="_blank"
rel="noopener noreferrer"
>
Metamask.io
</a>
)}
{screen !== 1 && (
<a
href="https://discord.com/invite/J22WS6z"
target="_blank"
rel="noopener noreferrer"
>
https://discord.com/invite/J22WS6z
</a>
)}
</p>
</div>
{/* <Screen3 /> */}
{screen === 1 && (
<Screen1
handleClick={changeScreen}
onNetwork={props.onNetwork}
handleEngage={props.handleEngage}
/>
)}
{screen === 2 && (
<Screen2
onNetwork={props.onNetwork}
handleEngage={props.handleEngage}
mouseLeave={mouseLeave}
activeTutorial={activeTutorial}
/>
)}
{screen === 3 && <Screen3 />}
{screen === 4 && <Screen4 handleClick={changeScreen} />}
</div>
</div>
</>
);
}
85 changes: 85 additions & 0 deletions src/app/containers/TutorialDialogModal/component/screen1/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React from 'react';
import rectangle from 'assets/images/tutorial/screen1_rectangle.svg';
import browserIcon from 'assets/images/tutorial/brower_icon.svg';
import mobileIcon from 'assets/images/tutorial/mobile_icon.svg';
import hardwareIcon from 'assets/images/tutorial/hardware_icon.svg';
import badger1 from 'assets/images/tutorial/badger_1.svg';
import planet from 'assets/images/tutorial/planet.svg';
import { translations } from 'locales/i18n';
import { useTranslation } from 'react-i18next';

interface Props {
handleClick: (num: Number) => void;
onNetwork: boolean;
handleEngage: () => void;
}

export function Screen1(props: Props) {
const { t } = useTranslation();

function handleBrowserClick() {
if (props.onNetwork === true) {
props.handleEngage();
} else {
props.handleClick(2);
}
}

return (
<>
<div className="screen1">
<div className="badger1 position-absolute">
<img src={badger1} alt="" className="h-100 w-100" />
</div>
<div className="planet position-absolute">
<img src={planet} alt="" className="h-100 w-100" />
</div>
<div className="browser-wallet" onClick={handleBrowserClick}>
<div className="rectangle1">
<img src={rectangle} alt="" />
</div>
<div className="browser-icon position-absolute">
<img
src={browserIcon}
alt="browser wallet icon"
className="h-100 w-100"
/>
</div>
<div className="browser-wallet-text position-absolute">
<p>{t(translations.rskConnectTutorial.browser_wallet)}t</p>
</div>
</div>
<div className="mobile-wallet" onClick={() => props.handleClick(4)}>
<div className="rectangle2">
<img src={rectangle} alt="" />
</div>
<div className="mobile-icon position-absolute">
<img
src={mobileIcon}
alt="browser wallet icon"
className="h-100 w-100"
/>
</div>
<div className="mobile-wallet-text position-absolute">
<p>{t(translations.rskConnectTutorial.mobile_wallet)}</p>
</div>
</div>
<div className="hardware-wallet">
<div className="rectangle3">
<img src={rectangle} alt="" />
</div>
<div className="hardware-icon position-absolute">
<img
src={hardwareIcon}
alt="browser wallet icon"
className="h-100 w-100"
/>
</div>
<div className="hardware-wallet-text position-absolute">
<p>{t(translations.rskConnectTutorial.hardware_wallet)}</p>
</div>
</div>
</div>
</>
);
}
Loading

0 comments on commit b610241

Please sign in to comment.