saleor-dashboard/src/staff/urls.ts

26 lines
898 B
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import { stringify as stringifyQs } from "qs";
import * as urlJoin from "url-join";
import { BulkAction, Dialog, Pagination } from "../types";
const staffSection = "/staff/";
export const staffListPath = staffSection;
export type StaffListUrlDialog = "add" | "remove";
export type StaffListUrlQueryParams = BulkAction &
Dialog<StaffListUrlDialog> &
Pagination;
export const staffListUrl = (params?: StaffListUrlQueryParams) =>
staffListPath + "?" + stringifyQs(params);
export const staffMemberDetailsPath = (id: string) => urlJoin(staffSection, id);
export type StaffMemberDetailsUrlDialog = "remove" | "remove-avatar";
export type StaffMemberDetailsUrlQueryParams = Dialog<
StaffMemberDetailsUrlDialog
>;
export const staffMemberDetailsUrl = (
id: string,
params?: StaffMemberDetailsUrlQueryParams
) => staffMemberDetailsPath(encodeURIComponent(id)) + "?" + stringifyQs(params);