mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-25 20:44:49 -04:00
feat(explore): API methods for asking backend for explore page notes
Co-authored-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
f645cffcd5
commit
a60c7a6e10
6 changed files with 238 additions and 71 deletions
31
frontend/src/api/explore/utils.ts
Normal file
31
frontend/src/api/explore/utils.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { SortMode } from '../../components/explore-page/explore-notes-section/filters/sort-button'
|
||||
import type { NoteType } from '@hedgedoc/commons'
|
||||
|
||||
/**
|
||||
* Create the necessary url parameters for the api calls of the explore page.
|
||||
* @param sort
|
||||
* @param searchFilter
|
||||
* @param typeFilter
|
||||
* @return a string representation of the search parameter
|
||||
*/
|
||||
export const createURLSearchParams = (
|
||||
sort: SortMode,
|
||||
searchFilter: string | null,
|
||||
typeFilter: NoteType | null
|
||||
): string => {
|
||||
const params = new URLSearchParams()
|
||||
params.set('sort', sort)
|
||||
if (searchFilter) {
|
||||
params.set('search', searchFilter)
|
||||
}
|
||||
if (typeFilter) {
|
||||
params.set('type', typeFilter)
|
||||
}
|
||||
return params.toString()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue