saleor-dashboard/src/webhooks/urls.ts

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-10-09 06:01:52 +00:00
import { stringify as stringifyQs } from "qs";
import urlJoin from "url-join";
import {
ActiveTab,
Dialog,
Filters,
Pagination,
SingleAction,
2019-12-17 17:13:56 +00:00
TabActionDialog,
Sort
} from "../types";
2019-10-09 06:01:52 +00:00
2019-12-06 14:58:28 +00:00
export const webhookSection = "/webhooks/";
2019-10-09 06:01:52 +00:00
2019-12-06 14:58:28 +00:00
export const webhookListPath = webhookSection;
export enum WebhookListUrlFiltersEnum {
2020-01-10 15:38:33 +00:00
active = "active",
query = "query"
}
export type WebhookListUrlFilters = Filters<WebhookListUrlFiltersEnum>;
export type WebhookListUrlDialog = "remove" | TabActionDialog;
2019-12-17 17:13:56 +00:00
export enum WebhookListUrlSortField {
name = "name",
serviceAccount = "account"
}
export type WebhookListUrlSort = Sort<WebhookListUrlSortField>;
export type WebhookListUrlQueryParams = ActiveTab &
Dialog<WebhookListUrlDialog> &
2019-10-10 05:38:21 +00:00
Pagination &
2019-12-17 17:13:56 +00:00
SingleAction &
WebhookListUrlFilters &
WebhookListUrlSort;
2019-12-06 14:58:28 +00:00
export const webhookListUrl = (params?: WebhookListUrlQueryParams) =>
webhookListPath + "?" + stringifyQs(params);
2019-10-09 06:01:52 +00:00
2019-12-06 14:58:28 +00:00
export const webhookPath = (id: string) => urlJoin(webhookSection, id);
2019-10-10 05:38:21 +00:00
export type WebhookUrlDialog = "remove";
2019-12-06 14:58:28 +00:00
export type WebhookUrlQueryParams = Dialog<WebhookUrlDialog> & SingleAction;
export const webhookUrl = (id: string, params?: WebhookUrlQueryParams) =>
webhookPath(encodeURIComponent(id)) + "?" + stringifyQs(params);
2019-10-09 20:50:03 +00:00
2019-12-06 14:58:28 +00:00
export const webhookAddPath = urlJoin(webhookSection, "add");
export const webhookAddUrl = webhookAddPath;