saleor-dashboard/src/orders/urls.ts
Dawid Tarasiuk 08637b27fd
Introduce fulfillment creation API (#1241)
* Display warehouse name for each fulfillment (#1259)

* Hide no-stocks columns in fulfillment view (#1260)

* Hide no-stocks columns in fulfillment view

* Update tests

* Refactor

* Update tests

* Add fulfillment settings card (#1242)

* Add fulfillment setting card

* Make fulfillment approvement naming consistent

* Fix mutation bug

* Update types

* Trigger CI

* Handle fulfillment acceptance on order details page (#1255)

* Handle fulfillment acceptance on order details page

* Make fulfillment approvement naming consistent

* Update fulfillment schema and its usage

* Render history events regarding waiting fulfillments (#1265)

* Add awaiting for approval fulfillment order event

* Fix warehouse name

* Change fulfillment quantity calculation (#1267)

* Change fulfillment quantity calculation

* Fix warehouse name

* Update messages

* Trigger CI

* Refactor

* Fix refactor

* Fix fulfillment for no variant

* Allow creating fulfillments waiting for acceptance (#1248)

* Fix fulfillment page style and typescript classname types perfomance issue

* Allow creating fulfillments waiting for acceptance

* Make fulfillment approvement naming consistent

* Update schema

* Add tooltip to fulfillment savebar

* Update unpaid fulfillment creation restriction

* Update fulfillment cration restriction

* Update test snapshots

* Add possibility to cancel "waiting" fulfillments (#1288)

* Allow to cancel waiting fulfillments

* Add delete button to fulfillment card

* Update test snapshots

* Handle waiting fulfillments on refund page (#1290)

* Handle waiting fulfillments on refund page

* Trigger CI

* Trigger CI

* Calculate quantity to refund on quantityToFulfill

* Update changelog

* Update snapshots

Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-08-20 16:36:05 +02:00

136 lines
3.6 KiB
TypeScript

import { stringifyQs } from "@saleor/utils/urls";
import urlJoin from "url-join";
import {
ActiveTab,
BulkAction,
Dialog,
Filters,
FiltersWithMultipleValues,
Pagination,
SingleAction,
Sort,
TabActionDialog
} from "../types";
const orderSectionUrl = "/orders";
type CreateOrderDialog = "create-order";
export const orderListPath = orderSectionUrl;
export enum OrderListUrlFiltersEnum {
createdFrom = "createdFrom",
createdTo = "createdTo",
customer = "customer",
payment = "payment",
query = "query"
}
export enum OrderListUrlFiltersWithMultipleValues {
status = "status",
channel = "channel"
}
export type OrderListUrlFilters = Filters<OrderListUrlFiltersEnum> &
FiltersWithMultipleValues<OrderListUrlFiltersWithMultipleValues>;
export type OrderListUrlDialog = "cancel" | CreateOrderDialog | TabActionDialog;
export enum OrderListUrlSortField {
number = "number",
customer = "customer",
date = "date",
fulfillment = "status",
payment = "payment",
total = "total"
}
export type OrderListUrlSort = Sort<OrderListUrlSortField>;
export type OrderListUrlQueryParams = BulkAction &
Dialog<OrderListUrlDialog> &
OrderListUrlFilters &
OrderListUrlSort &
Pagination &
ActiveTab;
export const orderListUrl = (params?: OrderListUrlQueryParams): string => {
const orderList = orderListPath;
if (params === undefined) {
return orderList;
} else {
return urlJoin(orderList, "?" + stringifyQs(params));
}
};
export const orderDraftListPath = urlJoin(orderSectionUrl, "drafts");
export enum OrderDraftListUrlFiltersEnum {
createdFrom = "createdFrom",
createdTo = "createdTo",
customer = "customer",
query = "query"
}
export type OrderDraftListUrlFilters = Filters<OrderDraftListUrlFiltersEnum>;
export type OrderDraftListUrlDialog =
| "remove"
| CreateOrderDialog
| TabActionDialog;
export enum OrderDraftListUrlSortField {
number = "number",
customer = "customer",
date = "date",
total = "total"
}
export type OrderDraftListUrlSort = Sort<OrderDraftListUrlSortField>;
export type OrderDraftListUrlQueryParams = ActiveTab &
BulkAction &
Dialog<OrderDraftListUrlDialog> &
OrderDraftListUrlFilters &
OrderDraftListUrlSort &
Pagination;
export const orderDraftListUrl = (
params?: OrderDraftListUrlQueryParams
): string => {
const orderDraftList = orderDraftListPath;
if (params === undefined) {
return orderDraftList;
} else {
return urlJoin(orderDraftList, "?" + stringifyQs(params));
}
};
export const orderPath = (id: string) => urlJoin(orderSectionUrl, id);
export type OrderUrlDialog =
| "add-order-line"
| "approve-fulfillment"
| "cancel"
| "cancel-fulfillment"
| "capture"
| "customer-change"
| "edit-customer-addresses"
| "edit-billing-address"
| "edit-fulfillment"
| "edit-shipping"
| "edit-shipping-address"
| "finalize"
| "mark-paid"
| "void"
| "invoice-send";
export type OrderUrlQueryParams = Dialog<OrderUrlDialog> & SingleAction;
export const orderUrl = (id: string, params?: OrderUrlQueryParams) =>
orderPath(encodeURIComponent(id)) + "?" + stringifyQs(params);
export const orderFulfillPath = (id: string) =>
urlJoin(orderPath(id), "fulfill");
export const orderReturnPath = (id: string) => urlJoin(orderPath(id), "return");
export const orderFulfillUrl = (id: string) =>
orderFulfillPath(encodeURIComponent(id));
export const orderSettingsPath = urlJoin(orderSectionUrl, "settings");
export const orderRefundPath = (id: string) => urlJoin(orderPath(id), "refund");
export const orderRefundUrl = (id: string) =>
orderRefundPath(encodeURIComponent(id));
export const orderReturnUrl = (id: string) =>
orderReturnPath(encodeURIComponent(id));