Separate visual and app layer in customers
This commit is contained in:
parent
02a24de103
commit
4df5a99a68
7 changed files with 77 additions and 77 deletions
|
@ -14,14 +14,14 @@ import {
|
||||||
FilterPageProps
|
FilterPageProps
|
||||||
} from "@saleor/types";
|
} from "@saleor/types";
|
||||||
import { CustomerListUrlSortField } from "@saleor/customers/urls";
|
import { CustomerListUrlSortField } from "@saleor/customers/urls";
|
||||||
import {
|
|
||||||
CustomerFilterKeys,
|
|
||||||
createFilterStructure
|
|
||||||
} from "@saleor/customers/views/CustomerList/filter";
|
|
||||||
import { CustomerListFilterOpts } from "@saleor/customers/types";
|
|
||||||
import FilterBar from "@saleor/components/FilterBar";
|
import FilterBar from "@saleor/components/FilterBar";
|
||||||
import CustomerList from "../CustomerList/CustomerList";
|
import CustomerList from "../CustomerList/CustomerList";
|
||||||
import { ListCustomers_customers_edges_node } from "../../types/ListCustomers";
|
import { ListCustomers_customers_edges_node } from "../../types/ListCustomers";
|
||||||
|
import {
|
||||||
|
CustomerFilterKeys,
|
||||||
|
CustomerListFilterOpts,
|
||||||
|
createFilterStructure
|
||||||
|
} from "./filters";
|
||||||
|
|
||||||
export interface CustomerListPageProps
|
export interface CustomerListPageProps
|
||||||
extends PageListProps,
|
extends PageListProps,
|
||||||
|
|
66
src/customers/components/CustomerListPage/filters.ts
Normal file
66
src/customers/components/CustomerListPage/filters.ts
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
import { IntlShape, defineMessages } from "react-intl";
|
||||||
|
|
||||||
|
import { FilterOpts, MinMax } from "@saleor/types";
|
||||||
|
import { IFilter } from "@saleor/components/Filter";
|
||||||
|
import {
|
||||||
|
createDateField,
|
||||||
|
createNumberField
|
||||||
|
} from "@saleor/utils/filters/fields";
|
||||||
|
|
||||||
|
export enum CustomerFilterKeys {
|
||||||
|
joined = "joined",
|
||||||
|
moneySpent = "spent",
|
||||||
|
numberOfOrders = "orders"
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CustomerListFilterOpts {
|
||||||
|
joined: FilterOpts<MinMax>;
|
||||||
|
moneySpent: FilterOpts<MinMax>;
|
||||||
|
numberOfOrders: FilterOpts<MinMax>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
joinDate: {
|
||||||
|
defaultMessage: "Join Date",
|
||||||
|
description: "customer"
|
||||||
|
},
|
||||||
|
moneySpent: {
|
||||||
|
defaultMessage: "Money Spent",
|
||||||
|
description: "customer"
|
||||||
|
},
|
||||||
|
numberOfOrders: {
|
||||||
|
defaultMessage: "Number of Orders"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function createFilterStructure(
|
||||||
|
intl: IntlShape,
|
||||||
|
opts: CustomerListFilterOpts
|
||||||
|
): IFilter<CustomerFilterKeys> {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...createDateField(
|
||||||
|
CustomerFilterKeys.joined,
|
||||||
|
intl.formatMessage(messages.joinDate),
|
||||||
|
opts.joined.value
|
||||||
|
),
|
||||||
|
active: opts.joined.active
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...createNumberField(
|
||||||
|
CustomerFilterKeys.moneySpent,
|
||||||
|
intl.formatMessage(messages.moneySpent),
|
||||||
|
opts.moneySpent.value
|
||||||
|
),
|
||||||
|
active: opts.moneySpent.active
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...createNumberField(
|
||||||
|
CustomerFilterKeys.numberOfOrders,
|
||||||
|
intl.formatMessage(messages.numberOfOrders),
|
||||||
|
opts.numberOfOrders.value
|
||||||
|
),
|
||||||
|
active: opts.numberOfOrders.active
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
export { default } from "./CustomerListPage";
|
export { default } from "./CustomerListPage";
|
||||||
export * from "./CustomerListPage";
|
export * from "./CustomerListPage";
|
||||||
|
export * from "./filters";
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
import { FilterOpts, MinMax } from "@saleor/types";
|
|
||||||
|
|
||||||
export interface CustomerListFilterOpts {
|
|
||||||
joined: FilterOpts<MinMax>;
|
|
||||||
moneySpent: FilterOpts<MinMax>;
|
|
||||||
numberOfOrders: FilterOpts<MinMax>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AddressTypeInput {
|
export interface AddressTypeInput {
|
||||||
city: string;
|
city: string;
|
||||||
cityArea?: string;
|
cityArea?: string;
|
||||||
|
|
|
@ -44,7 +44,7 @@ import {
|
||||||
saveFilterTab,
|
saveFilterTab,
|
||||||
getFilterQueryParam,
|
getFilterQueryParam,
|
||||||
getFilterOpts
|
getFilterOpts
|
||||||
} from "./filter";
|
} from "./filters";
|
||||||
import { getSortQueryVariables } from "./sort";
|
import { getSortQueryVariables } from "./sort";
|
||||||
|
|
||||||
interface CustomerListProps {
|
interface CustomerListProps {
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import { IntlShape } from "react-intl";
|
|
||||||
|
|
||||||
import { CustomerFilterInput } from "@saleor/types/globalTypes";
|
import { CustomerFilterInput } from "@saleor/types/globalTypes";
|
||||||
import { maybe } from "@saleor/misc";
|
import { maybe } from "@saleor/misc";
|
||||||
|
import { IFilterElement } from "@saleor/components/Filter";
|
||||||
import {
|
import {
|
||||||
createDateField,
|
CustomerFilterKeys,
|
||||||
createNumberField
|
CustomerListFilterOpts
|
||||||
} from "@saleor/utils/filters/fields";
|
} from "@saleor/customers/components/CustomerListPage";
|
||||||
import { IFilter, IFilterElement } from "@saleor/components/Filter";
|
|
||||||
import {
|
import {
|
||||||
createFilterTabUtils,
|
createFilterTabUtils,
|
||||||
createFilterUtils
|
createFilterUtils
|
||||||
|
@ -16,17 +14,9 @@ import {
|
||||||
CustomerListUrlFiltersEnum,
|
CustomerListUrlFiltersEnum,
|
||||||
CustomerListUrlQueryParams
|
CustomerListUrlQueryParams
|
||||||
} from "../../urls";
|
} from "../../urls";
|
||||||
import { CustomerListFilterOpts } from "../../types";
|
|
||||||
import messages from "./messages";
|
|
||||||
|
|
||||||
export const CUSTOMER_FILTERS_KEY = "customerFilters";
|
export const CUSTOMER_FILTERS_KEY = "customerFilters";
|
||||||
|
|
||||||
export enum CustomerFilterKeys {
|
|
||||||
joined = "joined",
|
|
||||||
moneySpent = "spent",
|
|
||||||
numberOfOrders = "orders"
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFilterOpts(
|
export function getFilterOpts(
|
||||||
params: CustomerListUrlFilters
|
params: CustomerListUrlFilters
|
||||||
): CustomerListFilterOpts {
|
): CustomerListFilterOpts {
|
||||||
|
@ -73,38 +63,6 @@ export function getFilterOpts(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createFilterStructure(
|
|
||||||
intl: IntlShape,
|
|
||||||
opts: CustomerListFilterOpts
|
|
||||||
): IFilter<CustomerFilterKeys> {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
...createDateField(
|
|
||||||
CustomerFilterKeys.joined,
|
|
||||||
intl.formatMessage(messages.joinDate),
|
|
||||||
opts.joined.value
|
|
||||||
),
|
|
||||||
active: opts.joined.active
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...createNumberField(
|
|
||||||
CustomerFilterKeys.moneySpent,
|
|
||||||
intl.formatMessage(messages.moneySpent),
|
|
||||||
opts.moneySpent.value
|
|
||||||
),
|
|
||||||
active: opts.moneySpent.active
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...createNumberField(
|
|
||||||
CustomerFilterKeys.numberOfOrders,
|
|
||||||
intl.formatMessage(messages.numberOfOrders),
|
|
||||||
opts.numberOfOrders.value
|
|
||||||
),
|
|
||||||
active: opts.numberOfOrders.active
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFilterVariables(
|
export function getFilterVariables(
|
||||||
params: CustomerListUrlFilters
|
params: CustomerListUrlFilters
|
||||||
): CustomerFilterInput {
|
): CustomerFilterInput {
|
|
@ -1,17 +0,0 @@
|
||||||
import { defineMessages } from "react-intl";
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
joinDate: {
|
|
||||||
defaultMessage: "Join Date",
|
|
||||||
description: "customer"
|
|
||||||
},
|
|
||||||
moneySpent: {
|
|
||||||
defaultMessage: "Money Spent",
|
|
||||||
description: "customer"
|
|
||||||
},
|
|
||||||
numberOfOrders: {
|
|
||||||
defaultMessage: "Number of Orders"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default messages;
|
|
Loading…
Reference in a new issue