Sort Explore and keep filters in the URL #32
Labels
No labels
bug
chore
data
feature
frontend
good first issue
intermediate
needs/docs
needs/research
needs/upstream
type/bug
type/external
type/feature
type/refactor
urgency
high
urgency
immediate
urgency
low
urgency
medium
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ScottyLabs/cal#32
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Let students sort Explore by "Soonest" or "Most saved", and keep the search, tag, and type filters in the URL so a filtered view can be bookmarked or shared.
What you'll learn
URL query params, React state, and passing filters to the API.
Resources
Where to start
web/src/app/components/SearchResultSidebar.tsx: search text, tags (multi-select), date, and event type are all held inuseState, so they reset on reload. Tag ids are sent toGET /api/events/?tags=1,2. The type and search filters run on the client.api/app/api/events.py,get_all_events: already acceptsterm,tags,date, andevent_type, and orders bystart_datetimeascending, so "Soonest" is today's default order.useSearchParams,useRouter, andusePathnamefromnext/navigation. Read the initial state from the URL, and callrouter.replacewhen a filter changes.Done when
saved_countdescending/explore?q=career&type=CAREER&tags=3&sort=savedrestores exactly that view on reload/exploreNotes
Depends on "Show how many people saved an event" for
saved_count. A tag filter already exists, so wire it to the URL instead of building a new one. Debounce the search box before writing it to the URL.