2021-08-09 15:27:13 +00:00
|
|
|
import { stringifyQs } from "@saleor/utils/urls";
|
2019-08-09 10:26:22 +00:00
|
|
|
import urlJoin from "url-join";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2021-05-11 12:26:17 +00:00
|
|
|
import {
|
|
|
|
BulkAction,
|
|
|
|
Dialog,
|
|
|
|
FiltersWithMultipleValues,
|
|
|
|
Pagination,
|
|
|
|
SingleAction,
|
|
|
|
Sort
|
|
|
|
} from "../types";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
export const pagesSection = "/pages/";
|
|
|
|
|
|
|
|
export const pageListPath = pagesSection;
|
|
|
|
export type PageListUrlDialog = "publish" | "unpublish" | "remove";
|
2019-12-17 17:13:56 +00:00
|
|
|
export enum PageListUrlSortField {
|
|
|
|
title = "title",
|
|
|
|
slug = "slug",
|
|
|
|
visible = "visible"
|
|
|
|
}
|
2021-05-11 12:26:17 +00:00
|
|
|
|
|
|
|
export enum PageListUrlFiltersWithMultipleValues {
|
|
|
|
pageTypes = "pageTypes"
|
|
|
|
}
|
|
|
|
|
|
|
|
export type PageListUrlFilters = FiltersWithMultipleValues<
|
|
|
|
PageListUrlFiltersWithMultipleValues
|
|
|
|
>;
|
2019-12-17 17:13:56 +00:00
|
|
|
export type PageListUrlSort = Sort<PageListUrlSortField>;
|
2019-06-19 14:40:52 +00:00
|
|
|
export type PageListUrlQueryParams = BulkAction &
|
2021-05-11 12:26:17 +00:00
|
|
|
PageListUrlFilters &
|
2019-06-19 14:40:52 +00:00
|
|
|
Dialog<PageListUrlDialog> &
|
2019-12-17 17:13:56 +00:00
|
|
|
PageListUrlSort &
|
2019-06-19 14:40:52 +00:00
|
|
|
Pagination;
|
|
|
|
export const pageListUrl = (params?: PageListUrlQueryParams) =>
|
|
|
|
pageListPath + "?" + stringifyQs(params);
|
|
|
|
|
|
|
|
export const pagePath = (id: string) => urlJoin(pagesSection, id);
|
2021-01-12 11:13:02 +00:00
|
|
|
export type PageUrlDialog = "remove" | "assign-attribute-value";
|
|
|
|
export type PageUrlQueryParams = Dialog<PageUrlDialog> & SingleAction;
|
2019-06-19 14:40:52 +00:00
|
|
|
export const pageUrl = (id: string, params?: PageUrlQueryParams) =>
|
|
|
|
pagePath(encodeURIComponent(id)) + "?" + stringifyQs(params);
|
|
|
|
|
|
|
|
export const pageCreatePath = urlJoin(pagesSection, "add");
|
2021-01-12 11:13:02 +00:00
|
|
|
export const pageCreateUrl = (params?: PageUrlQueryParams) =>
|
|
|
|
pageCreatePath + "?" + stringifyQs(params);
|