How to use the apisearch.createEmptySortBy function in apisearch

To help you get started, we’ve selected a few apisearch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apisearch-io / search-ui / src / components / SortBy / SortByActions.ts View on Github external
export function onChangeSearchAction(
    environmentId: string,
    currentQuery: Query,
    repository: Repository,
    selectedOption: string,
) {
    const clonedQuery = cloneDeep(currentQuery);
    const filterData = splitQueryValue(selectedOption);

    clonedQuery
        .sortBy(Apisearch
            .createEmptySortBy()
            .byFieldValue(
                filterData.field,
                filterData.sort,
            ),
        );

    clonedQuery.page = 1;
    const dispatcher = container.get(`${APISEARCH_DISPATCHER}__${environmentId}`);

    repository
        .query(clonedQuery)
        .then((result) => {
            dispatcher.dispatch({
                type: "RENDER_FETCHED_DATA",
                payload: {