-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
Project: ServerRelated to the server workspaceRelated to the server workspaceProject: WebRelated to the web workspaceRelated to the web workspacesorting and filtering✅ Status: Dev ReadyThis is waiting to be startedThis is waiting to be started
Description
Problem
We currently use the category endpoint to serve resources by category (example category page). The issue with this endpoint is that it returns resources as groups of sub-categories, e.g.:
{
"subcategories": [
{
"name": "Meals",
"resources": [
{
"name": "Resource A",
},
{
"name": "Resource B",
}
],
},
{
"name": "Food Pantries",
"resources": [
{
"name": "Resource A",
},
{
"name": "Resource C",
}
],
}
]
}It's possible to have a resource listed under multiple sub-categories, as shown in the example above where "Resource A" provides both a meal and a food pantry.
This requires the client to filter out repeats of resources.
Solution
Ideally we'd like to have our current resources endpoint support filtering by category. That way, we can use one endpoint for fetching resources.
API Updates
- add an optional
categoriesquery param to the resources endpoint that accepts a string equaling a comma-separated list of categories we wish to filter resources by, e.g./resources?categories=food,shelter - update the useResourcesByCategory hook to consume resources using that updated endpoint
Tech Notes
- The current
/resourcesendpoint currently supports filtering resources by a list of comma-separated IDs. We'll need to make sure we also honor the current filtering byidthat exists on this endpoint. This means that if we provide bothidsandcategoriesas filters, we only return resources that match the passed ids AND belong to one or more of the passed categories.
jollyjerr
Metadata
Metadata
Assignees
Labels
Project: ServerRelated to the server workspaceRelated to the server workspaceProject: WebRelated to the web workspaceRelated to the web workspacesorting and filtering✅ Status: Dev ReadyThis is waiting to be startedThis is waiting to be started