mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-25 12:34:45 -04:00

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>
31 lines
839 B
TypeScript
31 lines
839 B
TypeScript
/*
|
|
* 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()
|
|
}
|