saleor-dashboard/src/discounts/components/VoucherListPage/VoucherListPage.tsx

77 lines
2 KiB
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import Button from "@material-ui/core/Button";
2019-09-12 10:06:28 +00:00
import Card from "@material-ui/core/Card";
2019-08-09 10:26:22 +00:00
import React from "react";
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-12 10:06:28 +00:00
import SearchBar from "@saleor/components/SearchBar";
import { sectionNames } from "@saleor/intl";
2019-09-12 10:06:28 +00:00
import {
ListActions,
PageListProps,
SearchPageProps,
TabPageProps
} from "@saleor/types";
2019-06-19 14:40:52 +00:00
import { VoucherList_vouchers_edges_node } from "../../types/VoucherList";
import VoucherList from "../VoucherList";
2019-09-12 10:06:28 +00:00
export interface VoucherListPageProps
extends PageListProps,
ListActions,
SearchPageProps,
TabPageProps {
2019-06-19 14:40:52 +00:00
defaultCurrency: string;
vouchers: VoucherList_vouchers_edges_node[];
}
const VoucherListPage: React.FC<VoucherListPageProps> = ({
2019-09-12 10:06:28 +00:00
currentTab,
initialSearch,
2019-06-19 14:40:52 +00:00
onAdd,
2019-09-12 10:06:28 +00:00
onAll,
onSearchChange,
onTabChange,
onTabDelete,
onTabSave,
tabs,
...listProps
}) => {
const intl = useIntl();
return (
<Container>
<PageHeader title={intl.formatMessage(sectionNames.vouchers)}>
<Button onClick={onAdd} variant="contained" color="primary">
2019-09-05 13:33:50 +00:00
<FormattedMessage
defaultMessage="Create voucher"
description="button"
/>
</Button>
</PageHeader>
2019-09-12 10:06:28 +00:00
<Card>
<SearchBar
allTabLabel={intl.formatMessage({
defaultMessage: "All Vouchers",
description: "tab name"
})}
currentTab={currentTab}
initialSearch={initialSearch}
searchPlaceholder={intl.formatMessage({
defaultMessage: "Search Voucher"
})}
tabs={tabs}
onAll={onAll}
onSearchChange={onSearchChange}
onTabChange={onTabChange}
onTabDelete={onTabDelete}
onTabSave={onTabSave}
/>
<VoucherList {...listProps} />
</Card>
</Container>
);
};
2019-06-19 14:40:52 +00:00
VoucherListPage.displayName = "VoucherListPage";
export default VoucherListPage;