Separate visual and app layer in orders
This commit is contained in:
parent
7c69c81ce6
commit
cde1735869
5 changed files with 81 additions and 102 deletions
|
@ -14,14 +14,14 @@ import {
|
||||||
SortPage
|
SortPage
|
||||||
} from "@saleor/types";
|
} from "@saleor/types";
|
||||||
import { OrderListUrlSortField } from "@saleor/orders/urls";
|
import { OrderListUrlSortField } from "@saleor/orders/urls";
|
||||||
import {
|
|
||||||
OrderFilterKeys,
|
|
||||||
createFilterStructure
|
|
||||||
} from "@saleor/orders/views/OrderList/filters";
|
|
||||||
import FilterBar from "@saleor/components/FilterBar";
|
import FilterBar from "@saleor/components/FilterBar";
|
||||||
import { OrderList_orders_edges_node } from "../../types/OrderList";
|
import { OrderList_orders_edges_node } from "../../types/OrderList";
|
||||||
import OrderList from "../OrderList";
|
import OrderList from "../OrderList";
|
||||||
import { OrderListFilterOpts } from "../../types";
|
import {
|
||||||
|
createFilterStructure,
|
||||||
|
OrderListFilterOpts,
|
||||||
|
OrderFilterKeys
|
||||||
|
} from "./filters";
|
||||||
|
|
||||||
export interface OrderListPageProps
|
export interface OrderListPageProps
|
||||||
extends PageListProps,
|
extends PageListProps,
|
||||||
|
|
71
src/orders/components/OrderListPage/filters.ts
Normal file
71
src/orders/components/OrderListPage/filters.ts
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
import { defineMessages, IntlShape } from "react-intl";
|
||||||
|
|
||||||
|
import { FilterOpts, MinMax } from "@saleor/types";
|
||||||
|
import { OrderStatusFilter } from "@saleor/types/globalTypes";
|
||||||
|
import {
|
||||||
|
createDateField,
|
||||||
|
createOptionsField
|
||||||
|
} from "@saleor/utils/filters/fields";
|
||||||
|
import { IFilter } from "@saleor/components/Filter";
|
||||||
|
import { orderStatusMessages } from "@saleor/misc";
|
||||||
|
import { commonMessages } from "@saleor/intl";
|
||||||
|
|
||||||
|
export enum OrderFilterKeys {
|
||||||
|
created = "created",
|
||||||
|
status = "status"
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OrderListFilterOpts {
|
||||||
|
created: FilterOpts<MinMax>;
|
||||||
|
status: FilterOpts<OrderStatusFilter[]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
placed: {
|
||||||
|
defaultMessage: "Placed",
|
||||||
|
description: "order"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function createFilterStructure(
|
||||||
|
intl: IntlShape,
|
||||||
|
opts: OrderListFilterOpts
|
||||||
|
): IFilter<OrderFilterKeys> {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...createDateField(
|
||||||
|
OrderFilterKeys.created,
|
||||||
|
intl.formatMessage(messages.placed),
|
||||||
|
opts.created.value
|
||||||
|
),
|
||||||
|
active: opts.created.active
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...createOptionsField(
|
||||||
|
OrderFilterKeys.status,
|
||||||
|
intl.formatMessage(commonMessages.status),
|
||||||
|
opts.status.value,
|
||||||
|
true,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
label: intl.formatMessage(orderStatusMessages.cancelled),
|
||||||
|
value: OrderStatusFilter.CANCELED
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: intl.formatMessage(orderStatusMessages.fulfilled),
|
||||||
|
value: OrderStatusFilter.FULFILLED
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: intl.formatMessage(orderStatusMessages.partiallyFulfilled),
|
||||||
|
value: OrderStatusFilter.PARTIALLY_FULFILLED
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: intl.formatMessage(orderStatusMessages.unfulfilled),
|
||||||
|
value: OrderStatusFilter.UNFULFILLED
|
||||||
|
}
|
||||||
|
]
|
||||||
|
),
|
||||||
|
active: opts.status.active
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,10 +1,4 @@
|
||||||
import { FilterOpts, MinMax } from "@saleor/types";
|
import { FilterOpts, MinMax } from "@saleor/types";
|
||||||
import { OrderStatusFilter } from "@saleor/types/globalTypes";
|
|
||||||
|
|
||||||
export interface OrderListFilterOpts {
|
|
||||||
created: FilterOpts<MinMax>;
|
|
||||||
status: FilterOpts<OrderStatusFilter[]>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OrderDraftListFilterOpts {
|
export interface OrderDraftListFilterOpts {
|
||||||
created: FilterOpts<MinMax>;
|
created: FilterOpts<MinMax>;
|
||||||
|
|
|
@ -1,16 +1,9 @@
|
||||||
import { IntlShape } from "react-intl";
|
import { findInEnum, maybe, findValueInEnum } from "@saleor/misc";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
findInEnum,
|
OrderListFilterOpts,
|
||||||
maybe,
|
OrderFilterKeys
|
||||||
orderStatusMessages,
|
} from "@saleor/orders/components/OrderListPage/filters";
|
||||||
findValueInEnum
|
import { IFilterElement } from "../../../components/Filter";
|
||||||
} from "@saleor/misc";
|
|
||||||
import {
|
|
||||||
createDateField,
|
|
||||||
createOptionsField
|
|
||||||
} from "@saleor/utils/filters/fields";
|
|
||||||
import { IFilter, IFilterElement } from "../../../components/Filter";
|
|
||||||
import {
|
import {
|
||||||
OrderFilterInput,
|
OrderFilterInput,
|
||||||
OrderStatusFilter,
|
OrderStatusFilter,
|
||||||
|
@ -27,16 +20,9 @@ import {
|
||||||
OrderListUrlFiltersWithMultipleValuesEnum,
|
OrderListUrlFiltersWithMultipleValuesEnum,
|
||||||
OrderListUrlQueryParams
|
OrderListUrlQueryParams
|
||||||
} from "../../urls";
|
} from "../../urls";
|
||||||
import { OrderListFilterOpts } from "../../types";
|
|
||||||
import messages from "./messages";
|
|
||||||
|
|
||||||
export const ORDER_FILTERS_KEY = "orderFilters";
|
export const ORDER_FILTERS_KEY = "orderFilters";
|
||||||
|
|
||||||
export enum OrderFilterKeys {
|
|
||||||
created = "created",
|
|
||||||
status = "status"
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFilterOpts(
|
export function getFilterOpts(
|
||||||
params: OrderListUrlFilters
|
params: OrderListUrlFilters
|
||||||
): OrderListFilterOpts {
|
): OrderListFilterOpts {
|
||||||
|
@ -69,49 +55,6 @@ export function getFilterOpts(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createFilterStructure(
|
|
||||||
intl: IntlShape,
|
|
||||||
opts: OrderListFilterOpts
|
|
||||||
): IFilter<OrderFilterKeys> {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
...createDateField(
|
|
||||||
OrderFilterKeys.created,
|
|
||||||
intl.formatMessage(messages.placed),
|
|
||||||
opts.created.value
|
|
||||||
),
|
|
||||||
active: opts.created.active
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...createOptionsField(
|
|
||||||
OrderFilterKeys.status,
|
|
||||||
intl.formatMessage(messages.status),
|
|
||||||
opts.status.value,
|
|
||||||
true,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
label: intl.formatMessage(orderStatusMessages.cancelled),
|
|
||||||
value: OrderStatusFilter.CANCELED
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: intl.formatMessage(orderStatusMessages.fulfilled),
|
|
||||||
value: OrderStatusFilter.FULFILLED
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: intl.formatMessage(orderStatusMessages.partiallyFulfilled),
|
|
||||||
value: OrderStatusFilter.PARTIALLY_FULFILLED
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: intl.formatMessage(orderStatusMessages.unfulfilled),
|
|
||||||
value: OrderStatusFilter.UNFULFILLED
|
|
||||||
}
|
|
||||||
]
|
|
||||||
),
|
|
||||||
active: opts.status.active
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFilterVariables(
|
export function getFilterVariables(
|
||||||
params: OrderListUrlFilters
|
params: OrderListUrlFilters
|
||||||
): OrderFilterInput {
|
): OrderFilterInput {
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
import { defineMessages } from "react-intl";
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
fulfilled: {
|
|
||||||
defaultMessage: "Fulfilled",
|
|
||||||
description: "order status"
|
|
||||||
},
|
|
||||||
partiallyFulfilled: {
|
|
||||||
defaultMessage: "Partially Fulfilled",
|
|
||||||
description: "order status"
|
|
||||||
},
|
|
||||||
placed: {
|
|
||||||
defaultMessage: "Placed",
|
|
||||||
description: "order"
|
|
||||||
},
|
|
||||||
readyToCapture: {
|
|
||||||
defaultMessage: "Ready to Capture",
|
|
||||||
description: "order status"
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
defaultMessage: "Order Status"
|
|
||||||
},
|
|
||||||
unfulfilled: {
|
|
||||||
defaultMessage: "Unfulfilled",
|
|
||||||
description: "order status"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default messages;
|
|
Loading…
Reference in a new issue