summaryrefslogtreecommitdiffstats
path: root/frontend/components/DeleteItem.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-06-11 15:39:47 -0400
committerWes Bos <wesbos@gmail.com>2018-06-11 15:39:47 -0400
commit420774e164759dd52732a6f35c92f54aec6335e4 (patch)
tree6c022811ff357bfd80f1c4daf5c18c379e55ac49 /frontend/components/DeleteItem.js
parent748dc8f8acb3cdc94a4f98704504d221b085ccab (diff)
should I record?
Diffstat (limited to 'frontend/components/DeleteItem.js')
-rw-r--r--frontend/components/DeleteItem.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/frontend/components/DeleteItem.js b/frontend/components/DeleteItem.js
index 10567f8..4d68d5e 100644
--- a/frontend/components/DeleteItem.js
+++ b/frontend/components/DeleteItem.js
@@ -1,6 +1,6 @@
import React from 'react';
import { Mutation } from 'react-apollo';
-import PropTypes from 'prop-types';
+import PropTypes, { number } from 'prop-types';
import gql from 'graphql-tag';
import { withRouter } from 'next/router';
import { ALL_ITEMS_QUERY } from './Items';
@@ -24,16 +24,17 @@ class DeleteItem extends React.Component {
update = (cache, payload) => {
const deletedItem = payload.data.deleteItem;
- const { page = 1 } = this.props.router.query;
+ let { page = 1 } = this.props.router.query;
+ page = parseFloat(page);
const skip = page * perPage - perPage;
const variables = { skip };
- // TODO Expose Page Number here
const data = cache.readQuery({ query: ALL_ITEMS_QUERY, variables });
// filter this one out
data.items = data.items.filter(item => item.id !== deletedItem.id);
// write the data back to the cache
console.log(data.items);
cache.writeQuery({ query: ALL_ITEMS_QUERY, data, variables });
+ // FYI Pagination is broken with Apollo currently - will make a followup video
};
render() {