Skip to content

Commit

Permalink
Feedback listing pagination bug fix (#2073)
Browse files Browse the repository at this point in the history
* back end updates for feedback api

* update tests

* update feedback test

* add new migration files & update tests for backend

* update enums && lint

* update migrations

* add missing enum

* update tests

* update resource

* fix migration error

* add dropdown

* push updates

* touch ups to ui

* make button only visible to superusers

* fix import error

* add when component

* update front end tests

* update feedback modal test

* add use effect to reload when switching between archived & regular listing

* duplkicate imports

* update feedback
  • Loading branch information
djnunez-aot authored Aug 24, 2023
1 parent 461666b commit 78d601d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions met-api/migrations/versions/04e6c48187da_.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def upgrade():

op.add_column('feedback', sa.Column('status', sa.Enum(
'Unreviewed', 'Archived', name='feedbackstatustype'), nullable=True))
op.execute('UPDATE "feedback" SET status = \'Unreviewed\'')
# ### end Alembic commands ###


Expand Down
17 changes: 12 additions & 5 deletions met-web/src/components/feedback/listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const FeedbackListing = () => {
sort_key: nested_sort_key || sort_key,
sort_order,
});
setFeedbacks(response.items);
setFeedbacks(response.items.filter((feedback) => feedback.status == statusFilter));
setPageInfo({
total: response.total,
});
Expand Down Expand Up @@ -147,13 +147,20 @@ const FeedbackListing = () => {
>
<When condition={authorized}>
<PrimaryButton
onClick={() =>
onClick={() => {
setPaginationOptions({
page: 1,
size: 10,
sort_key: 'rating',
nested_sort_key: null,
sort_order: 'asc',
});
setStatusFilter(
statusFilter == FeedbackStatusEnum.NotReviewed
? FeedbackStatusEnum.Archived
: FeedbackStatusEnum.NotReviewed,
)
}
);
}}
>
{statusFilter == FeedbackStatusEnum.NotReviewed ? 'View Archive' : 'View Feedback'}
</PrimaryButton>
Expand All @@ -163,7 +170,7 @@ const FeedbackListing = () => {
<Grid item xs={12} lg={10}>
<MetTable
headCells={headCells}
rows={feedbacks.filter((feedback) => feedback.status == statusFilter)}
rows={feedbacks}
handleChangePagination={(paginationOptions: PaginationOptions<Feedback>) =>
setPaginationOptions(paginationOptions)
}
Expand Down

0 comments on commit 78d601d

Please sign in to comment.