Separate visual and app layer in staff members
This commit is contained in:
parent
0fb8a66b9a
commit
f6055709cb
8 changed files with 72 additions and 69 deletions
|
@ -5,7 +5,10 @@ import {
|
||||||
} from "@saleor/types/globalTypes";
|
} from "@saleor/types/globalTypes";
|
||||||
import { IFilterElement } from "@saleor/components/Filter";
|
import { IFilterElement } from "@saleor/components/Filter";
|
||||||
import { maybe, findValueInEnum } from "@saleor/misc";
|
import { maybe, findValueInEnum } from "@saleor/misc";
|
||||||
import { ProductTypeFilterKeys } from "@saleor/productTypes/components/ProductTypeListPage";
|
import {
|
||||||
|
ProductTypeFilterKeys,
|
||||||
|
ProductTypeListFilterOpts
|
||||||
|
} from "@saleor/productTypes/components/ProductTypeListPage";
|
||||||
import {
|
import {
|
||||||
createFilterTabUtils,
|
createFilterTabUtils,
|
||||||
createFilterUtils
|
createFilterUtils
|
||||||
|
@ -15,7 +18,6 @@ import {
|
||||||
ProductTypeListUrlFiltersEnum,
|
ProductTypeListUrlFiltersEnum,
|
||||||
ProductTypeListUrlQueryParams
|
ProductTypeListUrlQueryParams
|
||||||
} from "../../urls";
|
} from "../../urls";
|
||||||
import { ProductTypeListFilterOpts } from "../../types";
|
|
||||||
|
|
||||||
export const PRODUCT_TYPE_FILTERS_KEY = "productTypeFilters";
|
export const PRODUCT_TYPE_FILTERS_KEY = "productTypeFilters";
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@ import {
|
||||||
SortPage
|
SortPage
|
||||||
} from "@saleor/types";
|
} from "@saleor/types";
|
||||||
import { StaffListUrlSortField } from "@saleor/staff/urls";
|
import { StaffListUrlSortField } from "@saleor/staff/urls";
|
||||||
import {
|
|
||||||
StaffFilterKeys,
|
|
||||||
createFilterStructure
|
|
||||||
} from "@saleor/staff/views/StaffList/filter";
|
|
||||||
import { StaffListFilterOpts } from "@saleor/staff/types";
|
|
||||||
import { StaffList_staffUsers_edges_node } from "../../types/StaffList";
|
import { StaffList_staffUsers_edges_node } from "../../types/StaffList";
|
||||||
import StaffList from "../StaffList/StaffList";
|
import StaffList from "../StaffList/StaffList";
|
||||||
|
import {
|
||||||
|
createFilterStructure,
|
||||||
|
StaffFilterKeys,
|
||||||
|
StaffListFilterOpts
|
||||||
|
} from "./filters";
|
||||||
|
|
||||||
export interface StaffListPageProps
|
export interface StaffListPageProps
|
||||||
extends ListProps,
|
extends ListProps,
|
||||||
|
|
56
src/staff/components/StaffListPage/filters.ts
Normal file
56
src/staff/components/StaffListPage/filters.ts
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import { IntlShape, defineMessages } from "react-intl";
|
||||||
|
|
||||||
|
import { FilterOpts } from "@saleor/types";
|
||||||
|
import { StaffMemberStatus } from "@saleor/types/globalTypes";
|
||||||
|
import { IFilter } from "@saleor/components/Filter";
|
||||||
|
import { createOptionsField } from "@saleor/utils/filters/fields";
|
||||||
|
|
||||||
|
export enum StaffFilterKeys {
|
||||||
|
status = "status"
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StaffListFilterOpts {
|
||||||
|
status: FilterOpts<StaffMemberStatus>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
active: {
|
||||||
|
defaultMessage: "Active",
|
||||||
|
description: "staff member's account"
|
||||||
|
},
|
||||||
|
deactivated: {
|
||||||
|
defaultMessage: "Deactivated",
|
||||||
|
description: "staff member's account"
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
defaultMessage: "Status",
|
||||||
|
description: "staff member's account"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export function createFilterStructure(
|
||||||
|
intl: IntlShape,
|
||||||
|
opts: StaffListFilterOpts
|
||||||
|
): IFilter<StaffFilterKeys> {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...createOptionsField(
|
||||||
|
StaffFilterKeys.status,
|
||||||
|
intl.formatMessage(messages.status),
|
||||||
|
[opts.status.value],
|
||||||
|
false,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
label: intl.formatMessage(messages.active),
|
||||||
|
value: StaffMemberStatus.ACTIVE
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: intl.formatMessage(messages.deactivated),
|
||||||
|
value: StaffMemberStatus.DEACTIVATED
|
||||||
|
}
|
||||||
|
]
|
||||||
|
),
|
||||||
|
active: opts.status.active
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
export { default } from "./StaffListPage";
|
export { default } from "./StaffListPage";
|
||||||
export * from "./StaffListPage";
|
export * from "./StaffListPage";
|
||||||
|
export * from "./filters";
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
import { FilterOpts } from "@saleor/types";
|
|
||||||
import { StaffMemberStatus } from "@saleor/types/globalTypes";
|
|
||||||
|
|
||||||
export interface StaffListFilterOpts {
|
|
||||||
status: FilterOpts<StaffMemberStatus>;
|
|
||||||
}
|
|
|
@ -46,7 +46,7 @@ import {
|
||||||
saveFilterTab,
|
saveFilterTab,
|
||||||
getFilterQueryParam,
|
getFilterQueryParam,
|
||||||
getFilterOpts
|
getFilterOpts
|
||||||
} from "./filter";
|
} from "./filters";
|
||||||
import { getSortQueryVariables } from "./sort";
|
import { getSortQueryVariables } from "./sort";
|
||||||
|
|
||||||
interface StaffListProps {
|
interface StaffListProps {
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { IntlShape } from "react-intl";
|
|
||||||
|
|
||||||
import { StaffUserInput, StaffMemberStatus } from "@saleor/types/globalTypes";
|
import { StaffUserInput, StaffMemberStatus } from "@saleor/types/globalTypes";
|
||||||
import { maybe, findValueInEnum } from "@saleor/misc";
|
import { maybe, findValueInEnum } from "@saleor/misc";
|
||||||
import { IFilter, IFilterElement } from "@saleor/components/Filter";
|
import { IFilterElement } from "@saleor/components/Filter";
|
||||||
import { createOptionsField } from "@saleor/utils/filters/fields";
|
import {
|
||||||
|
StaffListFilterOpts,
|
||||||
|
StaffFilterKeys
|
||||||
|
} from "@saleor/staff/components/StaffListPage";
|
||||||
import {
|
import {
|
||||||
createFilterTabUtils,
|
createFilterTabUtils,
|
||||||
createFilterUtils
|
createFilterUtils
|
||||||
|
@ -13,15 +14,9 @@ import {
|
||||||
StaffListUrlFiltersEnum,
|
StaffListUrlFiltersEnum,
|
||||||
StaffListUrlQueryParams
|
StaffListUrlQueryParams
|
||||||
} from "../../urls";
|
} from "../../urls";
|
||||||
import { StaffListFilterOpts } from "../../types";
|
|
||||||
import messages from "./messages";
|
|
||||||
|
|
||||||
export const STAFF_FILTERS_KEY = "staffFilters";
|
export const STAFF_FILTERS_KEY = "staffFilters";
|
||||||
|
|
||||||
export enum StaffFilterKeys {
|
|
||||||
status = "status"
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFilterOpts(
|
export function getFilterOpts(
|
||||||
params: StaffListUrlFilters
|
params: StaffListUrlFilters
|
||||||
): StaffListFilterOpts {
|
): StaffListFilterOpts {
|
||||||
|
@ -33,33 +28,6 @@ export function getFilterOpts(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createFilterStructure(
|
|
||||||
intl: IntlShape,
|
|
||||||
opts: StaffListFilterOpts
|
|
||||||
): IFilter<StaffFilterKeys> {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
...createOptionsField(
|
|
||||||
StaffFilterKeys.status,
|
|
||||||
intl.formatMessage(messages.status),
|
|
||||||
[opts.status.value],
|
|
||||||
false,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
label: intl.formatMessage(messages.active),
|
|
||||||
value: StaffMemberStatus.ACTIVE
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: intl.formatMessage(messages.deactivated),
|
|
||||||
value: StaffMemberStatus.DEACTIVATED
|
|
||||||
}
|
|
||||||
]
|
|
||||||
),
|
|
||||||
active: opts.status.active
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFilterVariables(
|
export function getFilterVariables(
|
||||||
params: StaffListUrlFilters
|
params: StaffListUrlFilters
|
||||||
): StaffUserInput {
|
): StaffUserInput {
|
|
@ -1,18 +0,0 @@
|
||||||
import { defineMessages } from "react-intl";
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
active: {
|
|
||||||
defaultMessage: "Active",
|
|
||||||
description: "staff member's account"
|
|
||||||
},
|
|
||||||
deactivated: {
|
|
||||||
defaultMessage: "Deactivated",
|
|
||||||
description: "staff member's account"
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
defaultMessage: "Status",
|
|
||||||
description: "staff member's account"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default messages;
|
|
Loading…
Reference in a new issue