
* 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
81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
import { Card, CardContent, Typography } from "@material-ui/core";
|
|
import CardTitle from "@saleor/components/CardTitle";
|
|
import Hr from "@saleor/components/Hr";
|
|
import RequirePermissions from "@saleor/components/RequirePermissions";
|
|
import { PermissionEnum } from "@saleor/graphql";
|
|
import { Button } from "@saleor/macaw-ui";
|
|
import React from "react";
|
|
import { useIntl } from "react-intl";
|
|
|
|
import { useStyles } from "./styles";
|
|
|
|
export interface ChannelsAvailabilityWrapperProps {
|
|
selectedChannelsCount: number;
|
|
allChannelsCount: number;
|
|
children: React.ReactNode;
|
|
managePermissions: PermissionEnum[];
|
|
openModal: () => void;
|
|
}
|
|
|
|
export const ChannelsAvailabilityWrapper: React.FC<ChannelsAvailabilityWrapperProps> = props => {
|
|
const {
|
|
selectedChannelsCount,
|
|
allChannelsCount,
|
|
children,
|
|
managePermissions,
|
|
openModal
|
|
} = props;
|
|
const intl = useIntl();
|
|
const classes = useStyles({});
|
|
const channelsAvailabilityText = intl.formatMessage(
|
|
{
|
|
defaultMessage:
|
|
"Available at {selectedChannelsCount} out of {allChannelsCount, plural, one {# channel} other {# channels}}",
|
|
|
|
description: "channels availability text"
|
|
},
|
|
{
|
|
allChannelsCount,
|
|
selectedChannelsCount
|
|
}
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<Card>
|
|
<CardTitle
|
|
title={intl.formatMessage({
|
|
defaultMessage: "Availability",
|
|
description: "section header"
|
|
})}
|
|
toolbar={
|
|
<RequirePermissions requiredPermissions={managePermissions}>
|
|
<Button
|
|
onClick={openModal}
|
|
data-test-id="channels-availability-manage-button"
|
|
>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Manage",
|
|
description: "section header button"
|
|
})}
|
|
</Button>
|
|
</RequirePermissions>
|
|
}
|
|
/>
|
|
<CardContent className={classes.card}>
|
|
{!!channelsAvailabilityText && (
|
|
<>
|
|
<Typography className={classes.channelInfo}>
|
|
{channelsAvailabilityText}
|
|
</Typography>
|
|
<Hr className={classes.hr} />
|
|
</>
|
|
)}
|
|
{children}
|
|
</CardContent>
|
|
</Card>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default ChannelsAvailabilityWrapper;
|