saleor-dashboard/src/attributes/components/AttributeListPage/AttributeListPage.tsx

85 lines
2.4 KiB
TypeScript
Raw Normal View History

2019-08-09 10:17:04 +00:00
import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
2019-08-09 10:17:04 +00:00
2019-09-30 13:14:11 +00:00
import AppHeader from "@saleor/components/AppHeader";
2019-09-10 15:32:47 +00:00
import SearchBar from "@saleor/components/SearchBar";
import { sectionNames } from "@saleor/intl";
2019-12-17 17:13:56 +00:00
import { AttributeListUrlSortField } from "@saleor/attributes/urls";
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 {
ListActions,
PageListProps,
SearchPageProps,
2019-12-17 17:13:56 +00:00
TabPageProps,
SortPage
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";
2019-09-10 15:32:47 +00:00
export interface AttributeListPageProps
extends PageListProps,
ListActions,
SearchPageProps,
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> = ({
onAdd,
2019-09-30 13:14:11 +00:00
onBack,
2019-09-10 15:32:47 +00:00
initialSearch,
onSearchChange,
currentTab,
onAll,
onTabChange,
onTabDelete,
onTabSave,
tabs,
2019-08-09 10:17:04 +00:00
...listProps
}) => {
const intl = useIntl();
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)}>
<Button onClick={onAdd} color="primary" variant="contained">
<FormattedMessage
2019-09-05 13:33:50 +00:00
defaultMessage="Create attribute"
description="button"
/>
</Button>
</PageHeader>
<Card>
2019-09-10 15:32:47 +00:00
<SearchBar
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}
initialSearch={initialSearch}
searchPlaceholder={intl.formatMessage({
defaultMessage: "Search Attribute"
})}
tabs={tabs}
onAll={onAll}
onSearchChange={onSearchChange}
onTabChange={onTabChange}
onTabDelete={onTabDelete}
onTabSave={onTabSave}
/>
<AttributeList {...listProps} />
</Card>
</Container>
);
};
2019-08-09 10:17:04 +00:00
AttributeListPage.displayName = "AttributeListPage";
export default AttributeListPage;