Skip to content

Add month view for bazaar and validate range parameter#1487

Merged
Ekwav merged 4 commits intodevelopfrom
copilot/add-month-view-to-bazaar
Apr 8, 2026
Merged

Add month view for bazaar and validate range parameter#1487
Ekwav merged 4 commits intodevelopfrom
copilot/add-month-view-to-bazaar

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Bazaar has no /history/month endpoint, so ?range=month (valid for auctions) breaks bazaar items. Additionally, arbitrary invalid range values were passed through unchecked.

Bazaar month support

  • Add DateRange.MONTH to bazaar's dateRangesToDisplay so the button renders
  • Handle month in both client (loadBazaarPrices) and server (fetchPrices) by using getBazaarPricesByRange with start/end dates, same pattern already used for "All Time":
} else if (fetchspan === DateRange.MONTH) {
    let monthAgo = new Date()
    monthAgo.setMonth(monthAgo.getMonth() - 1)
    return api.getBazaarPricesByRange(tag, monthAgo, new Date())
}

Range parameter validation

  • Server-side (getItemData): validate against known range values, default to 'day'
  • Client-side (ItemPriceRange, BazaarPriceGraph, AuctionHousePriceGraph): validate URL range before using it as initial state — invalid values fall through to DEFAULT_DATE_RANGE without triggering URL updates, avoiding redirect loops

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 1, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 1, 2026 17:09
- Add DateRange.MONTH to bazaar's dateRangesToDisplay
- Handle month range in loadBazaarPrices using getBazaarPricesByRange with start/end dates
- Handle month range in server-side fetchPrices for bazaar items
- Validate URL range parameter against valid DateRange values in all components
- Invalid range parameters now default to the default range instead of breaking

Agent-Logs-Url: https://github.com/Coflnet/hypixel-react/sessions/29e88e89-178b-472f-88a8-04d2821714e7

Co-authored-by: Ekwav <[email protected]>
Copilot AI changed the title [WIP] Add month view to bazaar auctions Add month view for bazaar and validate range parameter Apr 1, 2026
Copilot finished work on behalf of Ekwav April 1, 2026 17:15
Copilot AI requested a review from Ekwav April 1, 2026 17:15
@Ekwav Ekwav requested a review from matthias-luger April 1, 2026 20:56
let router = useRouter()
let searchParams = useSearchParams()
let [selectedDateRange, _setSelectedDateRange] = useState(searchParams.get('range') || DEFAULT_DATE_RANGE)
let validRanges = Object.values(DateRange) as string[]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a contant value, i would move this outside the component to the top of the page

Comment on lines +42 to +43
let urlRange = searchParams.get('range')
let [selectedDateRange, _setSelectedDateRange] = useState(urlRange && validRanges.includes(urlRange) ? urlRange : DEFAULT_DATE_RANGE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would write the default-parameter here as a function so you can move the "urlRange" inside an dit only runs once

Comment on lines +85 to +87
let validRanges = Object.values(DateRange) as string[]
let urlRange = searchParams.get('range')
let [fetchspan, setFetchspan] = useState(urlRange && validRanges.includes(urlRange) ? (urlRange as DateRange) : DEFAULT_DATE_RANGE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above and as you use it multiple times, i would move it into its own hook "useValidRanges" for example

Comment on lines +95 to +97
let urlRange = getURLSearchParam('range')
let validRanges = Object.values(DateRange) as string[]
fetchspan = (urlRange && validRanges.includes(urlRange) ? (urlRange as DateRange) : DEFAULT_DATE_RANGE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@Ekwav Ekwav marked this pull request as ready for review April 8, 2026 20:26
@Ekwav Ekwav merged commit 26f83cc into develop Apr 8, 2026
1 check failed
@Ekwav Ekwav deleted the copilot/add-month-view-to-bazaar branch April 8, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Month view for bazaar breaking

3 participants