2019-06-19 14:40:52 +00:00
|
|
|
import Button from "@material-ui/core/Button";
|
2019-09-11 14:39:52 +00:00
|
|
|
import Card from "@material-ui/core/Card";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-23 12:23:59 +00:00
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
import Container from "@saleor/components/Container";
|
|
|
|
import PageHeader from "@saleor/components/PageHeader";
|
2019-09-11 14:39:52 +00:00
|
|
|
import SearchBar from "@saleor/components/SearchBar";
|
2019-08-23 12:23:59 +00:00
|
|
|
import { sectionNames } from "@saleor/intl";
|
2019-09-11 14:39:52 +00:00
|
|
|
import {
|
|
|
|
ListActions,
|
|
|
|
PageListProps,
|
|
|
|
SearchPageProps,
|
|
|
|
TabPageProps
|
|
|
|
} from "@saleor/types";
|
2019-06-19 14:40:52 +00:00
|
|
|
import { ListCustomers_customers_edges_node } from "../../types/ListCustomers";
|
|
|
|
import CustomerList from "../CustomerList/CustomerList";
|
|
|
|
|
2019-09-11 14:39:52 +00:00
|
|
|
export interface CustomerListPageProps
|
|
|
|
extends PageListProps,
|
|
|
|
ListActions,
|
|
|
|
SearchPageProps,
|
|
|
|
TabPageProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
customers: ListCustomers_customers_edges_node[];
|
|
|
|
}
|
|
|
|
|
|
|
|
const CustomerListPage: React.StatelessComponent<CustomerListPageProps> = ({
|
2019-09-11 14:39:52 +00:00
|
|
|
currentTab,
|
2019-06-19 14:40:52 +00:00
|
|
|
customers,
|
|
|
|
disabled,
|
2019-09-11 14:39:52 +00:00
|
|
|
initialSearch,
|
2019-06-19 14:40:52 +00:00
|
|
|
onAdd,
|
2019-09-11 14:39:52 +00:00
|
|
|
onAll,
|
|
|
|
onSearchChange,
|
|
|
|
onTabChange,
|
|
|
|
onTabDelete,
|
|
|
|
onTabSave,
|
|
|
|
tabs,
|
2019-06-19 14:40:52 +00:00
|
|
|
...customerListProps
|
2019-08-23 12:23:59 +00:00
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<PageHeader title={intl.formatMessage(sectionNames.customers)}>
|
|
|
|
<Button
|
|
|
|
color="primary"
|
|
|
|
variant="contained"
|
|
|
|
disabled={disabled}
|
|
|
|
onClick={onAdd}
|
|
|
|
>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Add customer"
|
|
|
|
description="button"
|
|
|
|
/>
|
|
|
|
</Button>
|
|
|
|
</PageHeader>
|
2019-09-11 14:39:52 +00:00
|
|
|
<Card>
|
|
|
|
<SearchBar
|
2019-09-11 15:56:00 +00:00
|
|
|
allTabLabel={intl.formatMessage({
|
|
|
|
defaultMessage: "All Customers",
|
|
|
|
description: "tab name"
|
|
|
|
})}
|
2019-09-11 14:39:52 +00:00
|
|
|
currentTab={currentTab}
|
|
|
|
initialSearch={initialSearch}
|
|
|
|
searchPlaceholder={intl.formatMessage({
|
|
|
|
defaultMessage: "Search Customer"
|
|
|
|
})}
|
|
|
|
tabs={tabs}
|
|
|
|
onAll={onAll}
|
|
|
|
onSearchChange={onSearchChange}
|
|
|
|
onTabChange={onTabChange}
|
|
|
|
onTabDelete={onTabDelete}
|
|
|
|
onTabSave={onTabSave}
|
|
|
|
/>
|
|
|
|
<CustomerList
|
|
|
|
customers={customers}
|
|
|
|
disabled={disabled}
|
|
|
|
{...customerListProps}
|
|
|
|
/>
|
|
|
|
</Card>
|
2019-08-23 12:23:59 +00:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
CustomerListPage.displayName = "CustomerListPage";
|
|
|
|
export default CustomerListPage;
|