2019-08-09 10:17:04 +00:00
|
|
|
import Button from "@material-ui/core/Button";
|
|
|
|
import Card from "@material-ui/core/Card";
|
2020-05-14 09:30:32 +00:00
|
|
|
import { AttributeListUrlSortField } from "@saleor/attributes/urls";
|
2019-09-30 13:14:11 +00:00
|
|
|
import AppHeader from "@saleor/components/AppHeader";
|
2020-01-10 11:34:49 +00:00
|
|
|
import FilterBar from "@saleor/components/FilterBar";
|
2019-08-16 11:47:30 +00:00
|
|
|
import { sectionNames } from "@saleor/intl";
|
2020-05-14 09:30:32 +00:00
|
|
|
import React from "react";
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
2019-08-09 10:17:04 +00:00
|
|
|
import Container from "../../../components/Container";
|
|
|
|
import PageHeader from "../../../components/PageHeader";
|
2019-09-10 15:32:47 +00:00
|
|
|
import {
|
2020-05-14 09:30:32 +00:00
|
|
|
FilterPageProps,
|
2019-09-10 15:32:47 +00:00
|
|
|
ListActions,
|
|
|
|
PageListProps,
|
2020-05-14 09:30:32 +00:00
|
|
|
SortPage,
|
|
|
|
TabPageProps
|
2019-09-10 15:32:47 +00:00
|
|
|
} from "../../../types";
|
2019-08-09 10:17:04 +00:00
|
|
|
import { AttributeList_attributes_edges_node } from "../../types/AttributeList";
|
|
|
|
import AttributeList from "../AttributeList/AttributeList";
|
2020-01-10 14:27:44 +00:00
|
|
|
import {
|
2020-05-14 09:30:32 +00:00
|
|
|
AttributeFilterKeys,
|
2020-01-10 14:27:44 +00:00
|
|
|
AttributeListFilterOpts,
|
2020-05-14 09:30:32 +00:00
|
|
|
createFilterStructure
|
2020-01-10 14:27:44 +00:00
|
|
|
} from "./filters";
|
2019-08-09 10:17:04 +00:00
|
|
|
|
2019-09-10 15:32:47 +00:00
|
|
|
export interface AttributeListPageProps
|
|
|
|
extends PageListProps,
|
|
|
|
ListActions,
|
2020-01-10 11:34:49 +00:00
|
|
|
FilterPageProps<AttributeFilterKeys, AttributeListFilterOpts>,
|
2019-12-17 17:13:56 +00:00
|
|
|
SortPage<AttributeListUrlSortField>,
|
2019-09-10 15:32:47 +00:00
|
|
|
TabPageProps {
|
2019-08-09 10:17:04 +00:00
|
|
|
attributes: AttributeList_attributes_edges_node[];
|
2019-09-30 13:14:11 +00:00
|
|
|
onBack: () => void;
|
2019-08-09 10:17:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const AttributeListPage: React.FC<AttributeListPageProps> = ({
|
2020-01-10 11:34:49 +00:00
|
|
|
filterOpts,
|
|
|
|
initialSearch,
|
2019-08-09 10:17:04 +00:00
|
|
|
onAdd,
|
2019-09-30 13:14:11 +00:00
|
|
|
onBack,
|
2020-01-10 11:34:49 +00:00
|
|
|
onFilterChange,
|
2019-09-10 15:32:47 +00:00
|
|
|
onSearchChange,
|
|
|
|
currentTab,
|
|
|
|
onAll,
|
|
|
|
onTabChange,
|
|
|
|
onTabDelete,
|
|
|
|
onTabSave,
|
|
|
|
tabs,
|
2019-08-09 10:17:04 +00:00
|
|
|
...listProps
|
2019-08-16 11:47:30 +00:00
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
2020-01-10 11:34:49 +00:00
|
|
|
const structure = createFilterStructure(intl, filterOpts);
|
|
|
|
|
2019-08-16 11:47:30 +00:00
|
|
|
return (
|
|
|
|
<Container>
|
2019-09-30 13:14:11 +00:00
|
|
|
<AppHeader onBack={onBack}>
|
|
|
|
<FormattedMessage {...sectionNames.configuration} />
|
|
|
|
</AppHeader>
|
2019-08-22 16:19:16 +00:00
|
|
|
<PageHeader title={intl.formatMessage(sectionNames.attributes)}>
|
2019-08-16 11:47:30 +00:00
|
|
|
<Button onClick={onAdd} color="primary" variant="contained">
|
|
|
|
<FormattedMessage
|
2019-09-05 13:33:50 +00:00
|
|
|
defaultMessage="Create attribute"
|
2019-08-16 11:47:30 +00:00
|
|
|
description="button"
|
|
|
|
/>
|
|
|
|
</Button>
|
|
|
|
</PageHeader>
|
|
|
|
<Card>
|
2020-01-10 11:34:49 +00:00
|
|
|
<FilterBar
|
2019-09-11 15:56:00 +00:00
|
|
|
allTabLabel={intl.formatMessage({
|
|
|
|
defaultMessage: "All Attributes",
|
|
|
|
description: "tab name"
|
|
|
|
})}
|
2019-09-10 15:32:47 +00:00
|
|
|
currentTab={currentTab}
|
2020-01-10 11:34:49 +00:00
|
|
|
filterStructure={structure}
|
2019-09-10 15:32:47 +00:00
|
|
|
initialSearch={initialSearch}
|
|
|
|
searchPlaceholder={intl.formatMessage({
|
|
|
|
defaultMessage: "Search Attribute"
|
|
|
|
})}
|
|
|
|
tabs={tabs}
|
|
|
|
onAll={onAll}
|
2020-01-10 11:34:49 +00:00
|
|
|
onFilterChange={onFilterChange}
|
2019-09-10 15:32:47 +00:00
|
|
|
onSearchChange={onSearchChange}
|
|
|
|
onTabChange={onTabChange}
|
|
|
|
onTabDelete={onTabDelete}
|
|
|
|
onTabSave={onTabSave}
|
|
|
|
/>
|
2019-08-16 11:47:30 +00:00
|
|
|
<AttributeList {...listProps} />
|
|
|
|
</Card>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
2019-08-09 10:17:04 +00:00
|
|
|
AttributeListPage.displayName = "AttributeListPage";
|
|
|
|
export default AttributeListPage;
|