Skip to content

Commit e43be99

Browse files
committed
update(app): complete tradingview integration
1 parent d93c72b commit e43be99

File tree

6 files changed

+76
-16
lines changed

6 files changed

+76
-16
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
import { Row, Col, Card, Typography, Divider } from 'antd';
3+
4+
import TradingView from '../../TradingView';
5+
import { useMarketsContextValue } from '../../../contexts/MarketsContext';
6+
import { CHART_LABELS } from '../../../utils/data/chartDataUtils';
7+
8+
const { Title } = Typography;
9+
10+
const FinancialTimesStockExchange = () => {
11+
const { market: { marketCode } } = useMarketsContextValue();
12+
const { symbol, label } = CHART_LABELS[marketCode];
13+
return (
14+
<Row type="flex" gutter={16}>
15+
<Col className="pb-2 pb-sm-3" xs={24}>
16+
<Card className="p-3" style={{ height: '100%' }} bodyStyle={{ padding: 0 }}>
17+
<Title level={4}>{label}</Title>
18+
<Divider className="my-3" />
19+
<TradingView
20+
id="ftse-price-index"
21+
symbol={`${symbol}.${marketCode}`}
22+
/>
23+
</Card>
24+
</Col>
25+
</Row>
26+
);
27+
};
28+
29+
export default FinancialTimesStockExchange;

src/components/pages/dashboard/HeatMap.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useMarketsContextValue } from '../../../contexts/MarketsContext';
1010
import { useUserContextValue } from '../../../contexts/UserContext';
1111
import { useIntervalContext } from '../../../contexts/IntervalContext';
1212
import { HEAT_MAP } from '../../../apollo/queries/dashboard';
13-
import { HEAT_COLORS } from '../../../utils/data/chartDataUtils';
13+
import { HEATMAP_COLORS } from '../../../utils/data/chartDataUtils';
1414
import { truncateDecimals } from '../../../utils/numberUtils';
1515

1616
const { Title, Text } = Typography;
@@ -52,7 +52,7 @@ const HeatMapBar = ({ title, data }: IHeatMapBar) => {
5252
data.forEach(({ level, value }) => {
5353
progressPercent = progressPercent + value * 100;
5454
const numberKey = `${truncateDecimals(progressPercent).toString()}`;
55-
progressStrokeColors[`${numberKey}%`] = HEAT_COLORS[level + 2];
55+
progressStrokeColors[`${numberKey}%`] = HEATMAP_COLORS[level + 2];
5656
});
5757

5858
const derivedStrokeColor = Object.keys(progressStrokeColors).length > 1 ?

src/components/pages/dashboard/dashboard-heatmap/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useMarketsContextValue } from '../../../../contexts/MarketsContext';
88
import { useUserContextValue } from '../../../../contexts/UserContext';
99
import { useIntervalContext } from '../../../../contexts/IntervalContext';
1010
import { truncateDecimals } from '../../../../utils/numberUtils';
11-
import { HEAT_COLORS } from '../../../../utils/data/chartDataUtils';
11+
import { HEATMAP_COLORS } from '../../../../utils/data/chartDataUtils';
1212

1313
import DashboardSpinner from '../../../spinners/DashboardSpinner';
1414

@@ -40,7 +40,7 @@ const StyledDiv = styled.div`
4040
const HeatMapCard = ({ reit, level, priceChange }: IHeatmapDetail, innerIdx: number) => (
4141
<Col xs={24} md={4} className="my-1" key={reit.reitId}>
4242
<Card
43-
style={{ backgroundColor: HEAT_COLORS[level + 2] }}
43+
style={{ backgroundColor: HEATMAP_COLORS[level + 2] }}
4444
key={innerIdx}
4545
className="text-center"
4646
>

src/index.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ApolloClient from 'apollo-boost';
44
import { ApolloProvider } from 'react-apollo';
55
import { BrowserRouter } from 'react-router-dom';
66
import * as serviceWorker from './serviceWorker';
7-
import ClearCache from 'react-clear-cache';
7+
// import ClearCache from 'react-clear-cache';
88

99
import App from './App';
1010
import 'antd/dist/antd.css';
@@ -18,15 +18,20 @@ const client = new ApolloClient({
1818
});
1919

2020
ReactDOM.render(
21-
<ClearCache auto>
22-
{() => (
23-
<ApolloProvider client={client}>
24-
<BrowserRouter>
25-
<App />
26-
</BrowserRouter>
27-
</ApolloProvider>
28-
)}
29-
</ClearCache>,
21+
// <ClearCache auto>
22+
// {() => (
23+
// <ApolloProvider client={client}>
24+
// <BrowserRouter>
25+
// <App />
26+
// </BrowserRouter>
27+
// </ApolloProvider>
28+
// )}
29+
// </ClearCache>,
30+
<ApolloProvider client={client}>
31+
<BrowserRouter>
32+
<App />
33+
</BrowserRouter>
34+
</ApolloProvider>,
3035
document.getElementById('root'),
3136
);
3237

src/pages/Chart.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { UserConsumer } from '../contexts/UserContext';
33
import AppLayout from '../components/layout/AppLayout';
44

55
import PriceIndex from '../components/pages/charts/PriceIndex';
6+
import FinancialTimesStockExchange from '../components/pages/charts/FinancialTimesStockExchange';
67

78
class Chart extends React.Component<{ requireAuth: boolean }> {
89
render() {
@@ -12,7 +13,10 @@ class Chart extends React.Component<{ requireAuth: boolean }> {
1213
<UserConsumer>
1314
{(value) => {
1415
return (
15-
<PriceIndex />
16+
<>
17+
<PriceIndex />
18+
<FinancialTimesStockExchange />
19+
</>
1620
);
1721
}}
1822
</UserConsumer>

src/utils/data/chartDataUtils.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
interface IChartLabels {
2+
[key: string]: {
3+
label: string,
4+
symbol: string,
5+
},
6+
}
7+
18
export const CHART_COLORS = {
29
GREEN: '#52C41A',
310
BLUE: '#1890FF',
@@ -7,7 +14,7 @@ export const CHART_COLORS = {
714
CYAN: '#13C2C2',
815
};
916

10-
export const HEAT_COLORS = [
17+
export const HEATMAP_COLORS = [
1118
'#962328', // DARK_RED
1219
'#ED3F33', // LIGHT_RED
1320
'#868A8D', // GRAY
@@ -35,3 +42,18 @@ export const TRADING_VIEW_DEFAULT_CONFIG = {
3542
}],
3643
},
3744
};
45+
46+
export const CHART_LABELS: IChartLabels = {
47+
SGX: {
48+
label: 'FTSE ST Real Estate Investment',
49+
symbol: 'FTSE',
50+
},
51+
HKEX: {
52+
label: 'Hang Seng REIT Index',
53+
symbol: 'HANGSENG',
54+
},
55+
MYX: {
56+
label: 'MALAYSIA REIT Index',
57+
symbol: 'FTSE',
58+
},
59+
};

0 commit comments

Comments
 (0)