This refactors the collection pages (teams, saved and profiles) into a bunch of hooks that handle various chunks of functionality. This way, the actual "pages" have significantly less logic and significantly less repeated code. * **useFavorites** handles favoriting teams * **useFilterState** handles the URL query filters * **usePaginationState** simply holds data pertaining to pagination * **useFetchTeams** handles fetching and parsing team data from the server * **useTeamFilter** pulls all other states together and handles some logic that is closest to the page Co-authored-by: Justin Edmund <383021+jedmund@users.noreply.github.com>
21 lines
556 B
TypeScript
21 lines
556 B
TypeScript
import cloneDeep from 'lodash.clonedeep'
|
|
|
|
export function convertAdvancedFilters(filters: FilterSet): ConvertedFilters {
|
|
let copy: FilterSet = cloneDeep(filters)
|
|
|
|
const includes: string = filterString(filters.includes || [])
|
|
const excludes: string = filterString(filters.excludes || [])
|
|
|
|
delete (copy as any).includes
|
|
delete (copy as any).excludes
|
|
|
|
return {
|
|
...copy,
|
|
includes,
|
|
excludes,
|
|
} as ConvertedFilters
|
|
}
|
|
|
|
export function filterString(list: MentionItem[]): string {
|
|
return list.map((item) => item.granblue_id).join(',')
|
|
}
|