|
| 1 | +import { Text } from "@deriv-com/quill-ui"; |
| 2 | +import { observer } from "mobx-react-lite"; |
| 3 | +import { tradingPanelStore } from "../../../stores/TradingPanelStore"; |
| 4 | + |
| 5 | +export const ContractItem = observer(() => { |
| 6 | + const { openContracts } = tradingPanelStore; |
| 7 | + |
| 8 | + if (openContracts.length === 0) { |
| 9 | + return ( |
| 10 | + <div className="contract-item"> |
| 11 | + <Text as="p" size="sm"> |
| 12 | + No open contracts |
| 13 | + </Text> |
| 14 | + </div> |
| 15 | + ); |
| 16 | + } |
| 17 | + |
| 18 | + return openContracts.map((contract) => ( |
| 19 | + <div key={contract.contract_id} className="contract-item"> |
| 20 | + <Text as="p" size="sm" className="text-bold"> |
| 21 | + {contract.display_name} - {contract.contract_type} |
| 22 | + </Text> |
| 23 | + <div className="contract-details"> |
| 24 | + <div className="detail-row"> |
| 25 | + <Text as="span" size="sm"> |
| 26 | + Entry Price: |
| 27 | + </Text> |
| 28 | + <Text as="span" size="sm"> |
| 29 | + {contract.entry_spot_display_value} |
| 30 | + </Text> |
| 31 | + </div> |
| 32 | + <div className="detail-row"> |
| 33 | + <Text as="span" size="sm"> |
| 34 | + Current Price: |
| 35 | + </Text> |
| 36 | + <Text as="span" size="sm"> |
| 37 | + {contract.current_spot_display_value} |
| 38 | + </Text> |
| 39 | + </div> |
| 40 | + <div className="detail-row"> |
| 41 | + <Text as="span" size="sm"> |
| 42 | + Buy Price: |
| 43 | + </Text> |
| 44 | + <Text as="span" size="sm"> |
| 45 | + {contract.buy_price} {contract.currency} |
| 46 | + </Text> |
| 47 | + </div> |
| 48 | + <div className="detail-row"> |
| 49 | + <Text as="span" size="sm"> |
| 50 | + Payout: |
| 51 | + </Text> |
| 52 | + <Text as="span" size="sm"> |
| 53 | + {contract.payout} {contract.currency} |
| 54 | + </Text> |
| 55 | + </div> |
| 56 | + <div className="detail-row"> |
| 57 | + <Text as="span" size="sm"> |
| 58 | + Profit/Loss: |
| 59 | + </Text> |
| 60 | + <Text |
| 61 | + as="span" |
| 62 | + size="sm" |
| 63 | + className={contract.profit >= 0 ? "profit" : "loss"} |
| 64 | + > |
| 65 | + {contract.profit.toFixed(2)} {contract.currency} ( |
| 66 | + {contract.profit_percentage.toFixed(2)}%) |
| 67 | + </Text> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + )); |
| 72 | +}); |
0 commit comments