mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 07:34:55 -06:00
33 lines
709 B
JavaScript
33 lines
709 B
JavaScript
// @flow
|
|
import { curry, pipe, pathOr } from 'ramda';
|
|
import queryString from 'query-string';
|
|
|
|
type RouteTo = {
|
|
pathname: string,
|
|
search?: string,
|
|
hash?: string,
|
|
state?: { [string]: string },
|
|
};
|
|
|
|
export const routeWithQuery = curry(
|
|
(pathname: string, queryParams?: { [string]: any }): RouteTo => {
|
|
return {
|
|
pathname,
|
|
search: queryString.stringify(queryParams),
|
|
};
|
|
}
|
|
);
|
|
|
|
export const routeWithTitle = curry(
|
|
(pathname: string, routeTitle: string): RouteTo => routeWithQuery(pathname, { routeTitle })
|
|
);
|
|
|
|
export const getSearch = pipe(
|
|
pathOr('', ['router', 'route', 'location', 'search']),
|
|
queryString.parse
|
|
);
|
|
|
|
export const getViewMode = pipe(
|
|
getSearch,
|
|
pathOr('list', ['viewMode'])
|
|
);
|