Skip to content

Commit

Permalink
added dummy data
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-casey committed Nov 29, 2016
1 parent 0c65806 commit 13eeeee
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 30 deletions.
24 changes: 0 additions & 24 deletions src/App.css

This file was deleted.

5 changes: 3 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import * as React from 'react';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';

import './App.css';
import createStore from './createStore';
import { loadDummyData } from './mock-data/load-data';
import routes from './routes';

const store = createStore();
const RouterWithData = loadDummyData(Router);

class App extends React.Component<{}, {}> {
public render() {
return (
<Provider store={store}>
<Router history={browserHistory} routes={routes} />
<RouterWithData history={browserHistory} routes={routes} />
</Provider>
);
}
Expand Down
32 changes: 32 additions & 0 deletions src/mock-data/load-data.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import { connect } from 'react-redux';

import { AppState, tasks } from '../modules';
import taskData from './tasks';

interface ActionProps {
setTasks(tasks: tasks.Task[]): void;
}

interface Props {
history: any;
routes: any;
}

export const loadDummyData = (WrappedComponent: React.ComponentClass<{}>) => {
class LoadData extends React.Component<Props & ActionProps, {}> {
public componentDidMount() {
this.props.setTasks(taskData);
}

public render() {
return (<WrappedComponent {...this.props} />);
}
}

const mapActionsToProps = {
setTasks: tasks.actionCreators.setList,
};

return connect<{}, ActionProps, Props>(undefined, mapActionsToProps)(LoadData);
};
28 changes: 28 additions & 0 deletions src/mock-data/tasks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { tasks } from '../modules';

const data: tasks.Task[] = [{
id: 1,
name: 'Test Task One',
type: [
'dummy data',
],
tags: [
'example',
'test',
],
duration: 60,
startDate: 1480394079073,
endDate: 1480394079073,
location: {
latitude: 1111,
longitude: 1111,
},
notes: 'This is a note on how to complete this task',
steps: [{
name: 'Do this first',
template: 'template string',
data: {},
}],
}];

export default data;
8 changes: 4 additions & 4 deletions src/modules/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as reselect from 'reselect';

import { Action } from '../../redux/action';

type Activities = 'door knocking' | 'phone banking' | 'rally';
type Activities = 'door knocking' | 'phone banking' | 'rally' | string;

type Tags = 'open internet' | 'privacy';
type Tags = 'open internet' | 'privacy' | string;

type Location = {
latitude?: number;
Expand All @@ -23,8 +23,8 @@ export interface Task {
type: Activities[];
tags: Tags[];
duration: number;
startDate: Date;
endDate: Date;
startDate: number;
endDate: number;
location: Location;
notes: string;
steps: Step[];
Expand Down

0 comments on commit 13eeeee

Please sign in to comment.