Skip to content

Commit d776463

Browse files
committed
Implement order mocks
1 parent 43a7b24 commit d776463

32 files changed

+304
-58
lines changed

docs/drafts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ The points below are still in progress
55

66
### Features
77

8-
- Static typecheckign with TypeScript for large scale projects
98
- Modular and scalable architecture
10-
- Function ready with pre-set REST API entities, sample data and a state management
9+
- Data driven and function ready with pre-set REST API entities, sample data and state management system
10+
- Static typechecking with TypeScript for large scale projects
1111
- Built in authentication with JWT
1212
- Typed data entities
1313
- Uses react hooks

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@types/react-redux": "^7.1.1",
2929
"@types/react-router-dom": "^4.3.4",
3030
"@types/store": "^2.0.2",
31+
"@types/uuid": "^3.4.5",
3132
"axios": "^0.19.0",
3233
"axios-mock-adapter": "^1.17.0",
3334
"chart.js": "^2.8.0",

src/App.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import config from './config'
88
import authService from './_services/authService'
99

1010
import api from './_api'
11-
import apiMocks from './_api/_mocks'
1211

1312
import store from './_store'
1413
import theme from './_theme'
@@ -21,11 +20,9 @@ authService.init({
2120
})
2221

2322
// Init rest API client
24-
const apiClient = api.init()
25-
26-
if (config.useSampleData) {
27-
apiMocks.init(apiClient)
28-
}
23+
api.init({
24+
useSampleData: config.useSampleData,
25+
})
2926

3027
const App: React.FC = () => {
3128
return (

src/Dashboard/Demo/Discuss/Discuss.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { makeStyles, createStyles } from '@material-ui/core/styles'
33
import Disqus from 'disqus-react'
4-
import Typography from '@material-ui/core/Typography'
4+
// import Typography from '@material-ui/core/Typography'
55
import Paper from '@material-ui/core/Paper'
66

77
import { Theme } from '_theme'

src/Dashboard/Sales/Locations/.gitkeep

Whitespace-only changes.

src/Dashboard/Sales/SalesDashboard/MainHistory.tsx renamed to src/Dashboard/Sales/SalesDashboard/OrdersHistory/OrdersHistory.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { useState, useEffect, useRef } from 'react'
1+
import React, { useEffect, useRef } from 'react' //useState
22
import { makeStyles } from '@material-ui/core/styles'
33
import Card from '@material-ui/core/Card'
44
import CardContent from '@material-ui/core/CardContent'
55
import { Chart } from 'chart.js'
66

7-
import mainHistoryService from './MainHistoryService'
7+
import mainHistoryService from './ordersHistoryService'
88

99
// ref: https://www.robinwieruch.de/react-hooks-fetch-data/
1010
const MainHistory = () => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './OrdersHistory'

src/Dashboard/Sales/SalesDashboard/MainHistoryService.tsx renamed to src/Dashboard/Sales/SalesDashboard/OrdersHistory/ordersHistoryService.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
// import rand from 'lodash/random'
1+
import { Chart } from 'chart.js'
22
import { random } from 'lodash'
33
import moment from 'moment'
44

5+
// import ordersData from '../../_api/_data/ordersData'
6+
import api from '../../_api'
7+
58
export default {
69
getRandomNumber(min = 0, max = 1): number {
710
return random(min, max)
811
},
9-
getChartData(): Chart.ChartData {
12+
async getChartData(): Promise<Chart.ChartData> {
1013
interface ChartDataSet extends Chart.ChartDataSets {
1114
data: number[]
1215
}
1316

17+
const orders = await api.orders.getList()
18+
19+
console.log('orders', orders)
20+
1421
const timeFormat = 'MM/DD/YYYY'
1522

1623
const today = moment().startOf('day')
@@ -112,11 +119,11 @@ export default {
112119
}
113120
},
114121
// In real life this would be an http call
115-
getChartConfiguration(): Promise<Chart.ChartConfiguration> {
122+
async getChartConfiguration(): Promise<Chart.ChartConfiguration> {
116123
const configuration = {
117124
type: 'bar',
118125
options: this.getChartOptions(),
119-
data: this.getChartData(),
126+
data: await this.getChartData(),
120127
}
121128

122129
return new Promise(resolve => setTimeout(() => resolve(configuration), 300))

src/Dashboard/Sales/SalesDashboard/MainOrders.tsx renamed to src/Dashboard/Sales/SalesDashboard/OrdersLatest/OrdersLatest.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import TableBody from '@material-ui/core/TableBody'
1010
import TableCell from '@material-ui/core/TableCell'
1111
import TableHead from '@material-ui/core/TableHead'
1212
import TableRow from '@material-ui/core/TableRow'
13-
import Title from './Title'
1413

1514
// Generate Order Data
1615
function createData(
@@ -51,7 +50,6 @@ const MainOrders: React.FC<any> = () => {
5150
return (
5251
<Card>
5352
<CardContent>
54-
<Title>Recent Orders</Title>
5553
<Table size="small">
5654
<TableHead>
5755
<TableRow>

0 commit comments

Comments
 (0)