Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrated indicative cell to tsx #44

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Icon, Money, DesktopWrapper, ContractCard } from '@deriv/components';
import { getCardLabels } from '_common/contract';
import { connect } from 'Stores/connect';
import { TRootStore } from 'Stores/index';

const IndicativeCell = ({ amount, currency, contract_info, is_footer, onClickSell, is_sell_requested }) => {
const [movement, setMovement] = React.useState(null);
type TIndicativeCell = {
amount: number;
contract_info: object;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please expand this object type due to the contract_info object

currency: string;
status: string;
is_footer: boolean;
is_sell_requested: () => void;
Copy link
Collaborator

@sergei-deriv sergei-deriv Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have doubts about 'is_sell_requested'. In my opinion it's boolean or function which returns boolean: "() => boolean"

Copy link

@akmal-deriv akmal-deriv Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a function, should be just boolean.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally, we use camelCase for functions and snake_case for normal variables

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a look at this thank you for pointing it out 🙏🏼

onClickSell: () => void;
};

const IndicativeCell = ({
amount,
currency,
contract_info,
is_footer,
onClickSell,
is_sell_requested,
}: TIndicativeCell) => {
const [movement, setMovement] = React.useState<string | null>(null);
const [amount_state, setAmountState] = React.useState(0);

React.useEffect(() => {
Expand Down Expand Up @@ -40,16 +57,6 @@ const IndicativeCell = ({ amount, currency, contract_info, is_footer, onClickSel
);
};

IndicativeCell.propTypes = {
amount: PropTypes.number,
contract_info: PropTypes.object,
currency: PropTypes.string,
status: PropTypes.string,
is_footer: PropTypes.bool,
is_sell_requested: PropTypes.func,
onClickSell: PropTypes.func,
};

export default connect(({ portfolio }) => ({
export default connect(({ portfolio }: TRootStore) => ({
onClickSell: portfolio.onClickSell,
}))(IndicativeCell);
2 changes: 1 addition & 1 deletion packages/reports/src/Constants/data-table-constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ProgressSliderStream from '../Containers/progress-slider-stream.jsx';

import { getCardLabels } from '_common/contract';
import { getProfitOrLoss } from '../Helpers/profit-loss';
import IndicativeCell from '../Components/indicative-cell.jsx';
import IndicativeCell from '../Components/indicative-cell';
import MarketSymbolIconRow from '../Components/market-symbol-icon-row';
import ProfitLossCell from '../Components/profit_loss_cell.jsx';
import CurrencyWrapper from '../Components/currency-wrapper';
Expand Down