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

+2-2
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

+7-7
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

+20-16
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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './KeyMetrics'

src/Dashboard/KeyNumbers/index.js

-1
This file was deleted.

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

+2-2
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

+2-1
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
/>

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { FormattedDate } from 'react-intl'
2020

2121
import { recentSubscriptions } from './data'
2222

23-
const Subscriptions = (props) => {
23+
const Subscriptions = () => {
2424
const classes = useStyles()
2525

2626
return (
@@ -37,7 +37,7 @@ const Subscriptions = (props) => {
3737
title="Recent Subscriptions"
3838
/>
3939
<TableContainer component={Paper}>
40-
<Table className={classes.table} aria-label="simple table">
40+
<Table aria-label="simple table">
4141
<TableHead>
4242
<TableRow>
4343
<TableCell>Organization</TableCell>
File renamed without changes.

src/_theme/index.js renamed to src/_theme/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { createMuiTheme } from '@material-ui/core/styles'
22

3+
// Allow configuration using `createMuiTheme`
4+
// ref: https://material-ui.com/guides/typescript/
5+
declare module '@material-ui/core/styles/createMuiTheme' {
6+
interface ThemeOptions {}
7+
}
8+
39
const baseTheme = createMuiTheme({
410
props: {
511
MuiPaper: {
@@ -78,13 +84,9 @@ const baseTheme = createMuiTheme({
7884
},
7985
secondary: {
8086
main: '#ae59e3', //'#619f30',
81-
// main: '#9027d1', //'#619f30',
82-
// main: blue[600], //'#619f30',
8387
},
8488
text: {
8589
secondary: 'rgba(102, 102, 102, 0.83)',
86-
positive: '#8cd136',
87-
negative: '#e35959',
8890
},
8991
},
9092
typography: {

0 commit comments

Comments
 (0)