Skip to content

Commit

Permalink
Fixed issue with status and PCDM type not being passed to the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalker2398 committed Feb 14, 2024
1 parent 27e1647 commit 3e42bfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
9 changes: 4 additions & 5 deletions app/controllers/api/v1/resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,17 @@ def index

per_page = 50
status = statuses.include?(params[:status].downcase) ? statuses.index(params[:status].downcase) : params[:status]
status = status.is_a?(String) ? status.downcase : status
page = Integer(params[:page])
identifier = params[:identifier]

resources = Resource
identifier && resources = resources.where(identifier: identifier)
status && status.downcase != 'any' && resources = resources.where(status: status)
status && status != 'any' && resources = resources.where(status: status)
resources = resources.limit(per_page).offset((page - 1) * per_page)
status && status.downcase != 'any' && resources = resources.order(status)
puts resources[0].inspect
status && status != 'any' && resources = resources.order(:status)
render json:
resources

resources.map(&:attributes)
end

private
Expand Down
8 changes: 0 additions & 8 deletions app/javascript/components/resources/ResourceList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ export default function ResourceList() {
if (pageState.identifier) {fetch_url += `identifier=${pageState.identifier}&`;}
if (pageState.status) {fetch_url += `status=${pageState.status}&`;}
fetch_url += `page=${pageState.pageNumber ? pageState.pageNumber : 1}`;
console.log(fetch_url);
(async () => {
const response = await fetch(fetch_url);
const data = await response.json();
// setFilteredResources(data.concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data).concat(data));
console.log('data:');
console.log(data);
data.forEach(entry => {
console.log(entry);
})
console.log();
setFilteredResources(data);
})();
}, [searchParams]);
Expand Down

0 comments on commit 3e42bfb

Please sign in to comment.