Skip to content

Commit

Permalink
feat: Pagination not updating after last item deletion (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
chatiti authored Aug 13, 2024
1 parent 95331b8 commit 778df9d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
8 changes: 6 additions & 2 deletions web/src/CertListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class CertListPage extends BaseListPage {
this.setState({
data: Setting.prependRow(this.state.data, newCert),
});
this.fetch();
}
}
)
Expand All @@ -79,8 +80,11 @@ class CertListPage extends BaseListPage {
Setting.showMessage("error", `Failed to delete: ${res.msg}`);
} else {
Setting.showMessage("success", "Cert deleted successfully");
this.setState({
data: Setting.deleteRow(this.state.data, i),
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
}
}
Expand Down
7 changes: 5 additions & 2 deletions web/src/RecordListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ class RecordListPage extends BaseListPage {
Setting.showMessage("error", `Failed to delete: ${res.msg}`);
} else {
Setting.showMessage("success", "Record deleted successfully");
this.setState({
data: Setting.deleteRow(this.state.data, i),
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
}
}
Expand Down
8 changes: 6 additions & 2 deletions web/src/RuleListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class RuleListPage extends BaseListPage {
this.setState({
data: Setting.prependRow(this.state.data, newRule),
});
this.fetch();
}
});
}
Expand All @@ -78,8 +79,11 @@ class RuleListPage extends BaseListPage {
Setting.showMessage("error", `Failed to delete: ${res.msg}`);
} else {
Setting.showMessage("success", "Deleted successfully");
this.setState({
data: Setting.deleteRow(this.state.data, i),
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
}
});
Expand Down
7 changes: 5 additions & 2 deletions web/src/SiteListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ class SiteListPage extends BaseListPage {
Setting.showMessage("error", `Failed to delete: ${res.msg}`);
} else {
Setting.showMessage("success", "Site deleted successfully");
this.setState({
data: Setting.deleteRow(this.state.data, i),
this.fetch({
pagination: {
...this.state.pagination,
current: this.state.pagination.current > 1 && this.state.data.length === 1 ? this.state.pagination.current - 1 : this.state.pagination.current,
},
});
}
}
Expand Down

0 comments on commit 778df9d

Please sign in to comment.