saleor-dashboard/src/pages/urls.ts

24 lines
892 B
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import { stringify as stringifyQs } from "qs";
2019-08-09 10:26:22 +00:00
import urlJoin from "url-join";
2019-06-19 14:40:52 +00:00
import { BulkAction, Dialog, Pagination } from "../types";
export const pagesSection = "/pages/";
export const pageListPath = pagesSection;
export type PageListUrlDialog = "publish" | "unpublish" | "remove";
export type PageListUrlQueryParams = BulkAction &
Dialog<PageListUrlDialog> &
Pagination;
export const pageListUrl = (params?: PageListUrlQueryParams) =>
pageListPath + "?" + stringifyQs(params);
export const pagePath = (id: string) => urlJoin(pagesSection, id);
export type PageUrlDialog = "remove";
export type PageUrlQueryParams = Dialog<PageUrlDialog>;
export const pageUrl = (id: string, params?: PageUrlQueryParams) =>
pagePath(encodeURIComponent(id)) + "?" + stringifyQs(params);
export const pageCreatePath = urlJoin(pagesSection, "add");
export const pageCreateUrl = pageCreatePath;