Skip to content

Commit

Permalink
refactor wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
berezh committed Nov 25, 2020
1 parent 95c64f5 commit a0a1bae
Show file tree
Hide file tree
Showing 40 changed files with 718 additions and 514 deletions.
2 changes: 0 additions & 2 deletions .huskyrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"hooks": {
"commit-msg": "yarn lint",
"pre-push": "yarn test --no-watch"
}
}
1 change: 1 addition & 0 deletions jest/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export const TEST_STATE: RootState = {
wallets: {
list: [],
loading: false,
// deprecated
withdrawSuccess: false,
mobileWalletChosen: '',
selectedWalletCurrency: '',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"react-redux": "^7.2.1",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-string-format": "^0.0.6",
"react-string-format": "^0.1.0",
"recharts": "^1.8.5",
"redux": "^4.0.5",
"redux-saga": "^1.1.3",
Expand Down Expand Up @@ -105,6 +105,7 @@
"@types/jquery": "^3.3.6",
"@types/mini-css-extract-plugin": "^0.9.1",
"@types/node": "^10.9.4",
"@types/numeral": "^0.0.28",
"@types/qrcode.react": "^1.0.1",
"@types/react": "^16.9.14",
"@types/react-dom": "^16.9.4",
Expand Down Expand Up @@ -148,6 +149,7 @@
"js-combinatorics": "0.5.0",
"mini-css-extract-plugin": "^0.10.0",
"npm-run-all": "^4.1.5",
"numeral": "^2.0.6",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss": "^8.1.4",
"postcss-autoreset": "^2.0.2",
Expand Down
3 changes: 0 additions & 3 deletions src/components/CryptoIcon/CryptoIcon.pcss

This file was deleted.

5 changes: 5 additions & 0 deletions src/components/CryptoIcon/index.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.n-crypto-icon{
display: inline-block;
width: 20px;
height: 20px;
}
15 changes: 6 additions & 9 deletions src/components/CryptoIcon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import cx from 'classnames';
import classNames from 'classnames';
import React from 'react';

import './index.pcss';

export interface CryptoIconProps {
code: string;
imageUrl?: string;
className?: string;
children?: React.ReactNode;
}
Expand All @@ -17,14 +20,8 @@ const findIcon = (code: string): string => {
};
/* eslint-enable @typescript-eslint/no-var-requires */

export const CryptoIcon: React.FunctionComponent<CryptoIconProps> = (props) => {
const { code, className = '', children } = props;

const icon = findIcon(code);

export const CryptoIcon: React.FC<CryptoIconProps> = ({ code, className, imageUrl }) => {
return (
<span className={cx('cr-crypto-icon', className)}>
<img src={icon} alt="crypto-icon" /> {children}
</span>
<img className={classNames('n-crypto-icon', className)} src={imageUrl || findIcon(code)} alt="crypto-icon" />
);
};
6 changes: 5 additions & 1 deletion src/components/Decimal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export interface DecimalProps {
* Children's previous value.
* If undefined, only integer part of the number is highlighted
*/
prevValue?: string | number;
prevValue?: string | number;
/**
* Content placed at the end.
*/
end?: string;
}

const handleRemoveExponent = (value: DecimalProps['children']) => {
Expand Down
3 changes: 3 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { DropdownElem } from '../components/Order';

export * from './modals';
export * from './loading';

export const PG_TITLE_PREFIX = 'Cryptobase';

export const pgRoutes = (isLoggedIn: boolean, isLight?: boolean): string[][] => {
Expand Down
3 changes: 3 additions & 0 deletions src/constants/loading.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const LoadingNames = {
Wallet: 'Wallet',
};
4 changes: 4 additions & 0 deletions src/constants/modals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const ModalNames = {
WithdrawSubmit: 'WithdrawSubmit',
WithdrawConfirmation: 'WithdrawConfirmation',
};

This file was deleted.

87 changes: 0 additions & 87 deletions src/containers/ModalWithdrawConfirmation/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/containers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export * from './LegalDocuments';
export * from './MarketDepth';
export * from './Markets';
export * from './MarketsTable';
export * from './ModalWithdrawConfirmation';
export * from './ModalWithdrawSubmit';
export * from './NavBar';
export * from './OpenOrders';
Expand Down
1 change: 0 additions & 1 deletion src/containers/style.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
@import "./LegalDocuments/LegalDocuments.pcss";
@import "./RecentTrades/RecentTrades.pcss";
@import "./Alerts/Alerts.pcss";
@import "./ModalWithdrawConfirmation/ModalWithdrawConfirmation.pcss";
@import "./ModalWithdrawSubmit/ModalWithdrawSubmit.pcss";
@import "./ProfileAccountActivity/ProfileAccountActivity.pcss";
@import "./ToolBar/ToolBar.pcss";
Expand Down
14 changes: 14 additions & 0 deletions src/lib/modal/common/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import "../../style/base.scss";

.n-base-dialog {
&__content {
text-align: center;
}

&__footer {
@include children-row-margin(1em);
display: flex;
flex-direction: row;
justify-content: center;
}
}
78 changes: 78 additions & 0 deletions src/lib/modal/common/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, { useCallback, useMemo } from 'react';
import { Button } from 'react-bootstrap';
import { useDispatch } from 'react-redux';
import classNames from 'classnames';

import './index.scss';

import { generalShowDialog } from 'src/modules/general';
import { Modal } from '../../../components';

interface Props {
onOk: () => void;
okText?: string;
cancelText?: string;
hideOk?: boolean;
hideCancel?: boolean;
header?: string;
children: React.ReactNode;
name: string;
}

export const BaseModal: React.FC<Props> = ({
header,
children,
onOk,
okText,
cancelText,
hideOk,
hideCancel,
name,
}) => {
const dispatch = useDispatch();

const handleCancel = useCallback(() => {
dispatch(generalShowDialog(name, undefined));
}, [name]);

const headerContent = useMemo(() => {
return <div className={classNames('pg-exchange-modal-submit-header')}>{header}</div>;
}, [header]);

const childrenContent = useMemo(() => {
return <div className={classNames('pg-exchange-modal-submit-body', 'n-base-dialog__content')}>{children}</div>;
}, [children]);

const footerContent = useMemo(() => {
return (
<div className={classNames('pg-exchange-modal-submit-footer', 'n-base-dialog__footer')}>
{hideCancel !== true ? (
<div>
<Button
block={true}
className="btn-block mr-1 mt-1 btn-lg"
onClick={handleCancel}
size="lg"
variant="secondary">
{cancelText}
</Button>
</div>
) : null}
{hideOk !== true ? (
<div>
<Button
block={true}
className="btn-block mr-1 mt-1 btn-lg"
onClick={onOk}
size="lg"
variant="primary">
{okText}
</Button>
</div>
) : null}
</div>
);
}, [hideOk, cancelText, hideCancel, okText, onOk]);

return <Modal show={true} header={headerContent} content={childrenContent} footer={footerContent} />;
};
2 changes: 2 additions & 0 deletions src/lib/modal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './common';
export * from './wrapper';
13 changes: 13 additions & 0 deletions src/lib/modal/wrapper/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

import { useReduxSelector } from 'src/hooks';

interface Props {
name: string;
children: (options: any) => React.ReactElement;
}

export const ModalWrapper: React.FC<Props> = ({ name, children }) => {
const options = useReduxSelector((x) => x.general.dialog[name]);
return options ? children(options) : null;
};

0 comments on commit a0a1bae

Please sign in to comment.