summaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/components/CreateItem.js3
-rw-r--r--frontend/components/DeleteItem.js6
2 files changed, 5 insertions, 4 deletions
diff --git a/frontend/components/CreateItem.js b/frontend/components/CreateItem.js
index fbe9083..503b3cb 100644
--- a/frontend/components/CreateItem.js
+++ b/frontend/components/CreateItem.js
@@ -7,6 +7,7 @@ import Error from './ErrorMessage';
import Form from './styles/Form';
import formatMoney from '../lib/formatMoney';
import { ALL_ITEMS_QUERY } from './Items';
+import { PAGINATION_QUERY } from './Pagination';
const CREATE_ITEM_MUTATION = gql`
mutation CREATE_ITEM_MUTATION(
@@ -68,7 +69,7 @@ class CreateItem extends Component {
<Mutation
mutation={CREATE_ITEM_MUTATION}
variables={this.state}
- refetchQueries={[{ query: ALL_ITEMS_QUERY }]}
+ refetchQueries={[{ query: ALL_ITEMS_QUERY }, { query: PAGINATION_QUERY }]}
>
{(createItem, { loading, error }) => (
<Form
diff --git a/frontend/components/DeleteItem.js b/frontend/components/DeleteItem.js
index 21f559c..10567f8 100644
--- a/frontend/components/DeleteItem.js
+++ b/frontend/components/DeleteItem.js
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import gql from 'graphql-tag';
import { withRouter } from 'next/router';
import { ALL_ITEMS_QUERY } from './Items';
+import { PAGINATION_QUERY } from './Pagination';
import { perPage } from '../config';
const DELETE_ITEM_MUTATION = gql`
@@ -28,7 +29,6 @@ class DeleteItem extends React.Component {
const variables = { skip };
// TODO Expose Page Number here
const data = cache.readQuery({ query: ALL_ITEMS_QUERY, variables });
- console.log(data.items);
// filter this one out
data.items = data.items.filter(item => item.id !== deletedItem.id);
// write the data back to the cache
@@ -37,7 +37,6 @@ class DeleteItem extends React.Component {
};
render() {
- console.log(this.props.router.query);
return (
<Mutation
mutation={DELETE_ITEM_MUTATION}
@@ -45,8 +44,9 @@ class DeleteItem extends React.Component {
refetchQueries={[
{
query: ALL_ITEMS_QUERY,
- variables: { skip: this.props.router.query.page * perPage - perPage },
+ variables: { skip: (this.props.router.query.page || 1) * perPage - perPage },
},
+ { query: PAGINATION_QUERY },
]}
update={this.update}
>