saleor-dashboard/src/navigation/components/MenuListPage/MenuListPage.tsx

54 lines
1.6 KiB
TypeScript
Raw Normal View History

import {
borderHeight,
topBarHeight,
} from "@dashboard/components/AppLayout/consts";
import { TopNav } from "@dashboard/components/AppLayout/TopNav";
import { Button } from "@dashboard/components/Button";
import { configurationMenuUrl } from "@dashboard/configuration";
import { MenuFragment } from "@dashboard/graphql";
import { sectionNames } from "@dashboard/intl";
import { menuListUrl, MenuListUrlSortField } from "@dashboard/navigation/urls";
import { ListActions, PageListProps, SortPage } from "@dashboard/types";
import { Box } from "@saleor/macaw-ui/next";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
2019-06-19 14:40:52 +00:00
import MenuList from "../MenuList";
2019-12-17 17:13:56 +00:00
export interface MenuListPageProps
extends PageListProps,
ListActions,
SortPage<MenuListUrlSortField> {
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
menus: MenuFragment[];
2019-06-19 14:40:52 +00:00
onDelete: (id: string) => void;
}
const MenuListPage: React.FC<MenuListPageProps> = ({ ...listProps }) => {
const intl = useIntl();
const addUrl = menuListUrl({
action: "add",
});
return (
<>
<TopNav
href={configurationMenuUrl}
title={intl.formatMessage(sectionNames.navigation)}
>
<Button variant="primary" href={addUrl} data-test-id="add-menu">
<FormattedMessage
id="JXRYQg"
2019-09-05 13:33:50 +00:00
defaultMessage="Create Menu"
description="button"
/>
</Button>
</TopNav>
<Box __height={`calc(100vh - ${topBarHeight} - ${borderHeight})`}>
<MenuList {...listProps} />
</Box>
</>
);
};
2019-06-19 14:40:52 +00:00
MenuListPage.displayName = "MenuListPage";
export default MenuListPage;