diff --git a/package-lock.json b/package-lock.json index e8f6f45..33cf78b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -213,6 +213,15 @@ "@types/mime": "*" } }, + "@types/uuid": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz", + "integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@uifabric/azure-themes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@uifabric/azure-themes/-/azure-themes-0.1.1.tgz", diff --git a/package.json b/package.json index dff7965..bc0b93f 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@types/react-redux": "^7.0.0", "@types/redux": "^3.6.0", "@types/cors": "^2.8.4", + "@types/uuid": "^3.4.4", "body-parser": "^1.18.3", "cors": "^2.8.5", "html-webpack-plugin": "^3.2.0", @@ -34,7 +35,8 @@ "webpack-cli": "^3.2.1", "webpack-dev-server": "^3.1.14", "npm-run-all": "^4.1.5", - "nodemon": "^1.18.9" + "nodemon": "^1.18.9", + "uuid": "^3.3.2" }, "dependencies": { "@uifabric/experiments": "^6.51.1", diff --git a/playground/src/actions/index.ts b/playground/src/actions/index.ts index 2827304..603bc0f 100644 --- a/playground/src/actions/index.ts +++ b/playground/src/actions/index.ts @@ -1,12 +1,11 @@ import { action, GenericActionTypes, GenericAction, GenericActionLookup } from '../redux-utils/action'; import { Dispatch } from 'redux'; import { Store } from '../store'; +import uuid from 'uuid/v4'; import * as todosService from '../service/todosService'; -let counter = 0; - export const actions = { - add: (label: string) => action('add', { id: String(counter++), label }), + add: (label: string) => action('add', { id: uuid(), label }), remove: (id: string) => action('remove', { id }), edit: (id: string, label: string) => action('edit', { id, label }), complete: (id: string) => action('complete', { id }), diff --git a/playground/src/components/TodoAppContainer.tsx b/playground/src/components/TodoAppContainer.tsx index bd57851..4cc2935 100644 --- a/playground/src/components/TodoAppContainer.tsx +++ b/playground/src/components/TodoAppContainer.tsx @@ -17,7 +17,7 @@ export function mapDispatchToProps(dispatch: any) { remove: (id: string) => dispatch(actionsWithService.remove(id)), complete: (id: string) => dispatch(actionsWithService.complete(id)), edit: (id: string, label: string) => dispatch(actionsWithService.edit(id, label)), - clear: () => dispatch(actions.clear()), + clear: () => dispatch(actionsWithService.clear()), setFilter: (filter: FilterTypes) => dispatch(actions.filter(filter)) }; } diff --git a/server/index.js b/server/index.js index 7b8a4d8..1f0e128 100644 --- a/server/index.js +++ b/server/index.js @@ -29,7 +29,7 @@ app.delete('/todos/:id', (req, res) => { delete store.todos[req.body.id]; }); -app.post('/todos', (req, res) => { +app.post('/todos', req => { store.todos = req.body; });