saleor-dashboard/src/pages/urls.ts
mmarkusik bb441ea11a
Add product / page delete warning (#1095)
* Add Delete button component

* Add product / page type delete warning dialog

* Replace old product types delete dialog with new one, add products total count query

* Update schema, types and queries for pages, add use page count query and add warning delete dialog to page types

* Move type delete warning dialog data to proper hooks, refactor

* Remove unused components and stories

* Add plural forms to messages for product / page type delete warning, refactor

* Add type delete warning dialog stories

* Move type delete hooks to proper directiories, fix imports

* Fix imports

* Remove countallproducts query and instead use useproductcountquery

* Remove unnecessary types and imports
2021-05-11 14:26:17 +02:00

47 lines
1.4 KiB
TypeScript

import { stringify as stringifyQs } from "qs";
import urlJoin from "url-join";
import {
BulkAction,
Dialog,
FiltersWithMultipleValues,
Pagination,
SingleAction,
Sort
} from "../types";
export const pagesSection = "/pages/";
export const pageListPath = pagesSection;
export type PageListUrlDialog = "publish" | "unpublish" | "remove";
export enum PageListUrlSortField {
title = "title",
slug = "slug",
visible = "visible"
}
export enum PageListUrlFiltersWithMultipleValues {
pageTypes = "pageTypes"
}
export type PageListUrlFilters = FiltersWithMultipleValues<
PageListUrlFiltersWithMultipleValues
>;
export type PageListUrlSort = Sort<PageListUrlSortField>;
export type PageListUrlQueryParams = BulkAction &
PageListUrlFilters &
Dialog<PageListUrlDialog> &
PageListUrlSort &
Pagination;
export const pageListUrl = (params?: PageListUrlQueryParams) =>
pageListPath + "?" + stringifyQs(params);
export const pagePath = (id: string) => urlJoin(pagesSection, id);
export type PageUrlDialog = "remove" | "assign-attribute-value";
export type PageUrlQueryParams = Dialog<PageUrlDialog> & SingleAction;
export const pageUrl = (id: string, params?: PageUrlQueryParams) =>
pagePath(encodeURIComponent(id)) + "?" + stringifyQs(params);
export const pageCreatePath = urlJoin(pagesSection, "add");
export const pageCreateUrl = (params?: PageUrlQueryParams) =>
pageCreatePath + "?" + stringifyQs(params);