Skip to content

Commit 9567ed0

Browse files
committed
Setup typescript for dashboards
1 parent 3f1e7b3 commit 9567ed0

File tree

16 files changed

+42
-35
lines changed

16 files changed

+42
-35
lines changed

src/Dashboard/Dashboard.js renamed to src/Dashboard/Dashboard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import BasePageToolbar from '../_common/BasePageToolbar'
77

88
import DashboardActions from './DashboardActions'
99
import SubscriptionsHistory from './SubscriptionsHistory'
10-
import KeyNumbers from './KeyNumbers'
10+
import KeyMetrics from './KeyMetrics'
1111
import SubscriptionsRecent from './SubscriptionsRecent'
1212
import SubscriptionsBreakdown from './SubscriptionsBreakdown'
1313

@@ -19,7 +19,7 @@ const Dashboard = () => {
1919
actionsComponent={DashboardActions}
2020
></BasePageToolbar>
2121
<Grid container spacing={3}>
22-
<KeyNumbers />
22+
<KeyMetrics />
2323
<Grid item xs={12}>
2424
<SubscriptionsHistory />
2525
</Grid>

src/Dashboard/KeyNumbers/KeyNumbers.js renamed to src/Dashboard/KeyMetrics/KeyMetrics.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ const numbers = [
5050
chart: generateTrendChartData({
5151
name: 'Monthly Churn',
5252
from: 13,
53-
to: Math.random(13 / 1.1),
53+
to: Math.random() / 1.1,
5454
length: 15,
5555
}),
5656
},
5757
]
5858

59-
const KeyNumbers = (props) => {
59+
const KeyMetrics = () => {
6060
const classes = useStyles()
6161

6262
return (
@@ -87,7 +87,7 @@ const KeyNumbers = (props) => {
8787
<Grid item xs={6} sm={6} md={12} lg={6}>
8888
<Box height="100%" position="relative" minHeight={70}>
8989
<div className={classes.chartContainer}>
90-
<Line data={chart.data} options={chart.options} />
90+
<Line type="line" data={chart.data} options={chart.options} />
9191
</div>
9292
</Box>
9393
</Grid>
@@ -99,7 +99,7 @@ const KeyNumbers = (props) => {
9999
)
100100
}
101101

102-
KeyNumbers.propTypes = {}
102+
KeyMetrics.propTypes = {}
103103

104104
const useStyles = makeStyles((theme) => ({
105105
root: {
@@ -122,10 +122,10 @@ const useStyles = makeStyles((theme) => ({
122122
},
123123
valueChange: {},
124124
negative: {
125-
color: theme.palette.text.negative,
125+
color: theme.palette.error.main,
126126
},
127127
positive: {
128-
color: theme.palette.text.positive,
128+
color: theme.palette.success.main,
129129
},
130130
chartContainer: {
131131
position: 'absolute',
@@ -136,4 +136,4 @@ const useStyles = makeStyles((theme) => ({
136136
},
137137
}))
138138

139-
export default KeyNumbers
139+
export default KeyMetrics

src/Dashboard/KeyNumbers/data.js renamed to src/Dashboard/KeyMetrics/data.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ import moment from 'moment'
22
import theme from '../../_theme'
33
import utilsService from '../../_services/utilsService'
44

5-
export const generateTrendChartData = ({ name, from = 0, to = 1000, length = 30 }) => {
5+
export const generateTrendChartData = ({
6+
name = '',
7+
from = 0,
8+
to = 1000,
9+
length = 30,
10+
}) => {
611
return {
12+
type: 'line',
713
data: {
814
datasets: [
915
{
@@ -34,34 +40,32 @@ export const generateTrendChartData = ({ name, from = 0, to = 1000, length = 30
3440
bottom: 10,
3541
},
3642
},
37-
legend: {
38-
display: false,
39-
},
4043
scales: {
41-
xAxes: [
42-
{
43-
display: false,
44-
},
45-
],
46-
yAxes: [
47-
{
48-
display: false,
49-
},
50-
],
44+
x: {
45+
display: false,
46+
},
47+
y: {
48+
display: false,
49+
},
50+
},
51+
plugins: {
52+
legend: {
53+
display: false,
54+
},
5155
},
5256
tooltips: {
5357
mode: 'index',
5458
intersect: false,
5559
caretSize: 0,
5660
callbacks: {
57-
label: function (tooltipItem, data) {
61+
label: function (tooltipItem: any, data: any) {
5862
// var datasetLabel = ''
5963
// var label = data.labels[tooltipItem.index]
6064
return data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]
6165
},
6266
},
6367
},
64-
hover: {
68+
interaction: {
6569
mode: 'index',
6670
intersect: false,
6771
},

src/Dashboard/KeyMetrics/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './KeyMetrics'

src/Dashboard/KeyNumbers/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Dashboard/SubscriptionsBreakdown/SubscriptionsBreakdown.js renamed to src/Dashboard/SubscriptionsBreakdown/SubscriptionsBreakdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Bar } from 'react-chartjs-2'
1212

1313
import { chart } from './data'
1414

15-
const SubscriptionsBreakdown = (props) => {
15+
const SubscriptionsBreakdown = () => {
1616
const classes = useStyles()
1717

1818
return (
@@ -31,7 +31,7 @@ const SubscriptionsBreakdown = (props) => {
3131
<CardContent className={classes.cardContent}>
3232
<div className={classes.chartContainer}>
3333
<div className={classes.chart}>
34-
<Bar data={chart.data} options={chart.options} />
34+
<Bar type="bar" data={chart.data} options={chart.options} />
3535
</div>
3636
</div>
3737
</CardContent>

src/Dashboard/SubscriptionsHistory/SubscriptionsHistory.js renamed to src/Dashboard/SubscriptionsHistory/SubscriptionsHistory.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Line } from 'react-chartjs-2'
1414

1515
import { subscriptionsItems, subscriptionsHistoryChart } from './data'
1616

17-
const Subscriptions = (props) => {
17+
const Subscriptions = () => {
1818
const classes = useStyles()
1919

2020
return (
@@ -35,6 +35,7 @@ const Subscriptions = (props) => {
3535
<div className={classes.chartContainer}>
3636
<div className={classes.chart}>
3737
<Line
38+
type="line"
3839
data={subscriptionsHistoryChart.data}
3940
options={subscriptionsHistoryChart.options}
4041
/>

0 commit comments

Comments
 (0)