Use available channels from context (#1115)
* Use available channels from context * Allow to specify manage channel availability permissions
This commit is contained in:
parent
9f71106f32
commit
1a9b55715f
27 changed files with 89 additions and 58 deletions
|
@ -18,6 +18,7 @@ import {
|
||||||
areAnyChannelVariantsSelected,
|
areAnyChannelVariantsSelected,
|
||||||
getTotalSelectedChannelsCount
|
getTotalSelectedChannelsCount
|
||||||
} from "@saleor/products/views/ProductUpdate/utils";
|
} from "@saleor/products/views/ProductUpdate/utils";
|
||||||
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -25,7 +26,10 @@ import ChannelWithVariantsAvailabilityItemWrapper from "./ChannelWithVariantAvai
|
||||||
|
|
||||||
type CommonChannelsAvailabilityProps = Omit<
|
type CommonChannelsAvailabilityProps = Omit<
|
||||||
ChannelsAvailabilityWrapperProps,
|
ChannelsAvailabilityWrapperProps,
|
||||||
"children" | "selectedChannelsCount" | "allChannelsCount"
|
| "children"
|
||||||
|
| "selectedChannelsCount"
|
||||||
|
| "allChannelsCount"
|
||||||
|
| "managePermissions"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export interface ChannelsWithVariantsAvailabilityCardProps
|
export interface ChannelsWithVariantsAvailabilityCardProps
|
||||||
|
@ -69,6 +73,7 @@ const ChannelsWithVariantsAvailabilityCard: React.FC<ChannelsWithVariantsAvailab
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ChannelsAvailabilityCardWrapper
|
<ChannelsAvailabilityCardWrapper
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_PRODUCTS]}
|
||||||
selectedChannelsCount={selectedChannelsCount}
|
selectedChannelsCount={selectedChannelsCount}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
openModal={openModal}
|
openModal={openModal}
|
||||||
|
|
|
@ -15,6 +15,8 @@ import {
|
||||||
import { mapNodeToChoice } from "@saleor/utils/maps";
|
import { mapNodeToChoice } from "@saleor/utils/maps";
|
||||||
import uniqBy from "lodash/uniqBy";
|
import uniqBy from "lodash/uniqBy";
|
||||||
|
|
||||||
|
import { BaseChannels_channels } from "./types/BaseChannels";
|
||||||
|
|
||||||
export interface Channel {
|
export interface Channel {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -73,7 +75,7 @@ export interface ChannelCollectionData {
|
||||||
publicationDate: string | null;
|
publicationDate: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createCollectionChannels = (data?: Channels_channels[]) =>
|
export const createCollectionChannels = (data?: BaseChannels_channels[]) =>
|
||||||
data?.map(channel => ({
|
data?.map(channel => ({
|
||||||
id: channel.id,
|
id: channel.id,
|
||||||
isPublished: false,
|
isPublished: false,
|
||||||
|
@ -81,7 +83,7 @@ export const createCollectionChannels = (data?: Channels_channels[]) =>
|
||||||
publicationDate: null
|
publicationDate: null
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const createVoucherChannels = (data?: Channels_channels[]) =>
|
export const createVoucherChannels = (data?: BaseChannels_channels[]) =>
|
||||||
data?.map(channel => ({
|
data?.map(channel => ({
|
||||||
currency: channel.currencyCode,
|
currency: channel.currencyCode,
|
||||||
discountValue: "",
|
discountValue: "",
|
||||||
|
@ -90,7 +92,7 @@ export const createVoucherChannels = (data?: Channels_channels[]) =>
|
||||||
name: channel.name
|
name: channel.name
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const createSaleChannels = (data?: Channels_channels[]) =>
|
export const createSaleChannels = (data?: BaseChannels_channels[]) =>
|
||||||
data?.map(channel => ({
|
data?.map(channel => ({
|
||||||
currency: channel.currencyCode,
|
currency: channel.currencyCode,
|
||||||
discountValue: "",
|
discountValue: "",
|
||||||
|
@ -115,7 +117,7 @@ export const createVariantChannels = (
|
||||||
|
|
||||||
export const createChannelsDataWithSaleDiscountPrice = (
|
export const createChannelsDataWithSaleDiscountPrice = (
|
||||||
saleData?: SaleDetails_sale,
|
saleData?: SaleDetails_sale,
|
||||||
data?: Channels_channels[]
|
data?: BaseChannels_channels[]
|
||||||
): ChannelSaleData[] => {
|
): ChannelSaleData[] => {
|
||||||
if (data && saleData?.channelListings) {
|
if (data && saleData?.channelListings) {
|
||||||
const dataArr = createSaleChannels(data);
|
const dataArr = createSaleChannels(data);
|
||||||
|
@ -128,7 +130,7 @@ export const createChannelsDataWithSaleDiscountPrice = (
|
||||||
|
|
||||||
export const createChannelsDataWithDiscountPrice = (
|
export const createChannelsDataWithDiscountPrice = (
|
||||||
voucherData?: VoucherDetails_voucher,
|
voucherData?: VoucherDetails_voucher,
|
||||||
data?: Channels_channels[]
|
data?: BaseChannels_channels[]
|
||||||
): ChannelVoucherData[] => {
|
): ChannelVoucherData[] => {
|
||||||
if (data && voucherData?.channelListings) {
|
if (data && voucherData?.channelListings) {
|
||||||
const dataArr = createVoucherChannels(data);
|
const dataArr = createVoucherChannels(data);
|
||||||
|
@ -139,7 +141,9 @@ export const createChannelsDataWithDiscountPrice = (
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createChannelsData = (data?: Channels_channels[]): ChannelData[] =>
|
export const createChannelsData = (
|
||||||
|
data?: BaseChannels_channels[]
|
||||||
|
): ChannelData[] =>
|
||||||
data?.map(channel => ({
|
data?.map(channel => ({
|
||||||
availableForPurchase: null,
|
availableForPurchase: null,
|
||||||
costPrice: "",
|
costPrice: "",
|
||||||
|
@ -156,7 +160,7 @@ export const createChannelsData = (data?: Channels_channels[]): ChannelData[] =>
|
||||||
|
|
||||||
export const createChannelsDataWithPrice = (
|
export const createChannelsDataWithPrice = (
|
||||||
productData?: ProductDetails_product,
|
productData?: ProductDetails_product,
|
||||||
data?: Channels_channels[]
|
data?: BaseChannels_channels[]
|
||||||
): ChannelData[] => {
|
): ChannelData[] => {
|
||||||
if (data && productData?.channelListings) {
|
if (data && productData?.channelListings) {
|
||||||
const dataArr = createChannelsData(data);
|
const dataArr = createChannelsData(data);
|
||||||
|
@ -292,7 +296,7 @@ export const createSortedChannelsDataFromProduct = (
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const createSortedChannelsData = (data?: Channels_channels[]) =>
|
export const createSortedChannelsData = (data?: BaseChannels_channels[]) =>
|
||||||
createChannelsData(data)?.sort((channel, nextChannel) =>
|
createChannelsData(data)?.sort((channel, nextChannel) =>
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
@ -311,12 +315,12 @@ export const createSortedShippingChannelsFromRate = (
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const createSortedVoucherData = (data?: Channels_channels[]) =>
|
export const createSortedVoucherData = (data?: BaseChannels_channels[]) =>
|
||||||
createVoucherChannels(data)?.sort((channel, nextChannel) =>
|
createVoucherChannels(data)?.sort((channel, nextChannel) =>
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const createSortedSaleData = (data?: Channels_channels[]) =>
|
export const createSortedSaleData = (data?: BaseChannels_channels[]) =>
|
||||||
createSaleChannels(data)?.sort((channel, nextChannel) =>
|
createSaleChannels(data)?.sort((channel, nextChannel) =>
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { CollectionChannelListingErrorFragment } from "@saleor/fragments/types/C
|
||||||
import { CollectionErrorFragment } from "@saleor/fragments/types/CollectionErrorFragment";
|
import { CollectionErrorFragment } from "@saleor/fragments/types/CollectionErrorFragment";
|
||||||
import { SubmitPromise } from "@saleor/hooks/useForm";
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@ const CollectionCreatePage: React.FC<CollectionCreatePageProps> = ({
|
||||||
description: "collection label"
|
description: "collection label"
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_PRODUCTS]}
|
||||||
errors={channelsErrors}
|
errors={channelsErrors}
|
||||||
selectedChannelsCount={data.channelListings.length}
|
selectedChannelsCount={data.channelListings.length}
|
||||||
allChannelsCount={channelsCount}
|
allChannelsCount={channelsCount}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { CollectionChannelListingErrorFragment } from "@saleor/fragments/types/C
|
||||||
import { CollectionErrorFragment } from "@saleor/fragments/types/CollectionErrorFragment";
|
import { CollectionErrorFragment } from "@saleor/fragments/types/CollectionErrorFragment";
|
||||||
import { SubmitPromise } from "@saleor/hooks/useForm";
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -125,6 +126,7 @@ const CollectionDetailsPage: React.FC<CollectionDetailsPageProps> = ({
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_PRODUCTS]}
|
||||||
messages={{
|
messages={{
|
||||||
hiddenLabel: intl.formatMessage({
|
hiddenLabel: intl.formatMessage({
|
||||||
defaultMessage: "Hidden",
|
defaultMessage: "Hidden",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import { ChannelsAction } from "@saleor/channels/urls";
|
import { ChannelsAction } from "@saleor/channels/urls";
|
||||||
import { createCollectionChannels } from "@saleor/channels/utils";
|
import { createCollectionChannels } from "@saleor/channels/utils";
|
||||||
|
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
||||||
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
||||||
import { WindowTitle } from "@saleor/components/WindowTitle";
|
import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||||
import useChannels from "@saleor/hooks/useChannels";
|
import useChannels from "@saleor/hooks/useChannels";
|
||||||
|
@ -53,10 +53,10 @@ export const CollectionCreate: React.FC<CollectionCreateProps> = ({
|
||||||
updateChannels,
|
updateChannels,
|
||||||
updateChannelsOpts
|
updateChannelsOpts
|
||||||
] = useCollectionChannelListingUpdate({});
|
] = useCollectionChannelListingUpdate({});
|
||||||
const { data: channelsData } = useChannelsList({});
|
const { availableChannels } = useAppChannel(false);
|
||||||
|
|
||||||
const allChannels = createCollectionChannels(
|
const allChannels = createCollectionChannels(
|
||||||
channelsData?.channels
|
availableChannels
|
||||||
)?.sort((channel, nextChannel) =>
|
)?.sort((channel, nextChannel) =>
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
@ -170,7 +170,7 @@ export const CollectionCreate: React.FC<CollectionCreateProps> = ({
|
||||||
updateChannelsOpts?.data?.collectionChannelListingUpdate.errors || []
|
updateChannelsOpts?.data?.collectionChannelListingUpdate.errors || []
|
||||||
}
|
}
|
||||||
currentChannels={currentChannels}
|
currentChannels={currentChannels}
|
||||||
channelsCount={channelsData?.channels?.length}
|
channelsCount={availableChannels.length}
|
||||||
openChannelsModal={handleChannelsModalOpen}
|
openChannelsModal={handleChannelsModalOpen}
|
||||||
onChannelsChange={setCurrentChannels}
|
onChannelsChange={setCurrentChannels}
|
||||||
onBack={() => navigate(collectionListUrl())}
|
onBack={() => navigate(collectionListUrl())}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Button, DialogContentText } from "@material-ui/core";
|
import { Button, DialogContentText } from "@material-ui/core";
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import {
|
import {
|
||||||
createCollectionChannels,
|
createCollectionChannels,
|
||||||
createCollectionChannelsData
|
createCollectionChannelsData
|
||||||
} from "@saleor/channels/utils";
|
} from "@saleor/channels/utils";
|
||||||
import ActionDialog from "@saleor/components/ActionDialog";
|
import ActionDialog from "@saleor/components/ActionDialog";
|
||||||
|
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
||||||
import AssignProductDialog from "@saleor/components/AssignProductDialog";
|
import AssignProductDialog from "@saleor/components/AssignProductDialog";
|
||||||
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
||||||
import NotFoundPage from "@saleor/components/NotFoundPage";
|
import NotFoundPage from "@saleor/components/NotFoundPage";
|
||||||
|
@ -84,7 +84,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
|
||||||
updateChannels,
|
updateChannels,
|
||||||
updateChannelsOpts
|
updateChannelsOpts
|
||||||
] = useCollectionChannelListingUpdate({});
|
] = useCollectionChannelListingUpdate({});
|
||||||
const { data: channelsData } = useChannelsList({});
|
const { availableChannels } = useAppChannel(false);
|
||||||
|
|
||||||
const handleCollectionUpdate = (data: CollectionUpdate) => {
|
const handleCollectionUpdate = (data: CollectionUpdate) => {
|
||||||
if (data.collectionUpdate.errors.length === 0) {
|
if (data.collectionUpdate.errors.length === 0) {
|
||||||
|
@ -173,7 +173,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
|
||||||
return <NotFoundPage onBack={handleBack} />;
|
return <NotFoundPage onBack={handleBack} />;
|
||||||
}
|
}
|
||||||
const allChannels = createCollectionChannels(
|
const allChannels = createCollectionChannels(
|
||||||
channelsData?.channels
|
availableChannels
|
||||||
)?.sort((channel, nextChannel) =>
|
)?.sort((channel, nextChannel) =>
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
@ -339,7 +339,7 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
|
||||||
hasChannelChanged={
|
hasChannelChanged={
|
||||||
collectionChannelsChoices?.length !== currentChannels?.length
|
collectionChannelsChoices?.length !== currentChannels?.length
|
||||||
}
|
}
|
||||||
channelsCount={channelsData?.channels?.length}
|
channelsCount={availableChannels.length}
|
||||||
selectedChannelId={selectedChannel}
|
selectedChannelId={selectedChannel}
|
||||||
openChannelsModal={handleChannelsModalOpen}
|
openChannelsModal={handleChannelsModalOpen}
|
||||||
onChannelsChange={setCurrentChannels}
|
onChannelsChange={setCurrentChannels}
|
||||||
|
|
|
@ -33,6 +33,7 @@ const productChannels = createChannelsDataFromProduct(product(""));
|
||||||
|
|
||||||
const props: ChannelsAvailabilityCardProps = {
|
const props: ChannelsAvailabilityCardProps = {
|
||||||
allChannelsCount: 4,
|
allChannelsCount: 4,
|
||||||
|
managePermissions: [PermissionEnum.MANAGE_CHANNELS],
|
||||||
channelsList: productChannels.map(channel => ({
|
channelsList: productChannels.map(channel => ({
|
||||||
id: channel.id,
|
id: channel.id,
|
||||||
name: channel.name
|
name: channel.name
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Channel as ChannelList, ChannelData } from "@saleor/channels/utils";
|
||||||
import Hr from "@saleor/components/Hr";
|
import Hr from "@saleor/components/Hr";
|
||||||
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
||||||
import { RequireOnlyOne } from "@saleor/misc";
|
import { RequireOnlyOne } from "@saleor/misc";
|
||||||
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ export interface ChannelsAvailability
|
||||||
errors?: ChannelsAvailabilityError[];
|
errors?: ChannelsAvailabilityError[];
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
messages?: Messages;
|
messages?: Messages;
|
||||||
|
managePermissions: PermissionEnum[];
|
||||||
onChange?: (id: string, data: ChannelOpts) => void;
|
onChange?: (id: string, data: ChannelOpts) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ export const ChannelsAvailability: React.FC<ChannelsAvailabilityCardProps> = pro
|
||||||
allChannelsCount = 0,
|
allChannelsCount = 0,
|
||||||
channels,
|
channels,
|
||||||
messages,
|
messages,
|
||||||
|
managePermissions,
|
||||||
onChange,
|
onChange,
|
||||||
openModal
|
openModal
|
||||||
} = props;
|
} = props;
|
||||||
|
@ -56,6 +59,7 @@ export const ChannelsAvailability: React.FC<ChannelsAvailabilityCardProps> = pro
|
||||||
<ChannelsAvailabilityCardWrapper
|
<ChannelsAvailabilityCardWrapper
|
||||||
selectedChannelsCount={selectedChannelsCount}
|
selectedChannelsCount={selectedChannelsCount}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
|
managePermissions={managePermissions}
|
||||||
openModal={openModal}
|
openModal={openModal}
|
||||||
>
|
>
|
||||||
{channels
|
{channels
|
||||||
|
|
|
@ -12,16 +12,18 @@ import { useStyles } from "./styles";
|
||||||
export interface ChannelsAvailabilityWrapperProps {
|
export interface ChannelsAvailabilityWrapperProps {
|
||||||
selectedChannelsCount: number;
|
selectedChannelsCount: number;
|
||||||
allChannelsCount: number;
|
allChannelsCount: number;
|
||||||
openModal: () => void;
|
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
managePermissions: PermissionEnum[];
|
||||||
|
openModal: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChannelsAvailabilityWrapper: React.FC<ChannelsAvailabilityWrapperProps> = props => {
|
export const ChannelsAvailabilityWrapper: React.FC<ChannelsAvailabilityWrapperProps> = props => {
|
||||||
const {
|
const {
|
||||||
selectedChannelsCount,
|
selectedChannelsCount,
|
||||||
allChannelsCount,
|
allChannelsCount,
|
||||||
openModal,
|
children,
|
||||||
children
|
managePermissions,
|
||||||
|
openModal
|
||||||
} = props;
|
} = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const classes = useStyles({});
|
const classes = useStyles({});
|
||||||
|
@ -50,7 +52,7 @@ export const ChannelsAvailabilityWrapper: React.FC<ChannelsAvailabilityWrapperPr
|
||||||
toolbar={
|
toolbar={
|
||||||
<RequirePermissions
|
<RequirePermissions
|
||||||
userPermissions={user?.userPermissions || []}
|
userPermissions={user?.userPermissions || []}
|
||||||
requiredPermissions={[PermissionEnum.MANAGE_PRODUCTS]}
|
requiredPermissions={managePermissions}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|
|
@ -15,7 +15,10 @@ import { validatePrice } from "@saleor/products/utils/validation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import { SaleType as SaleTypeEnum } from "../../../types/globalTypes";
|
import {
|
||||||
|
PermissionEnum,
|
||||||
|
SaleType as SaleTypeEnum
|
||||||
|
} from "../../../types/globalTypes";
|
||||||
import DiscountDates from "../DiscountDates";
|
import DiscountDates from "../DiscountDates";
|
||||||
import SaleInfo from "../SaleInfo";
|
import SaleInfo from "../SaleInfo";
|
||||||
import SaleType from "../SaleType";
|
import SaleType from "../SaleType";
|
||||||
|
@ -118,6 +121,7 @@ const SaleCreatePage: React.FC<SaleCreatePageProps> = ({
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_DISCOUNTS]}
|
||||||
selectedChannelsCount={data.channelListings.length}
|
selectedChannelsCount={data.channelListings.length}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
channelsList={data.channelListings.map(channel => ({
|
channelsList={data.channelListings.map(channel => ({
|
||||||
|
|
|
@ -18,7 +18,10 @@ import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import { maybe, splitDateTime } from "../../../misc";
|
import { maybe, splitDateTime } from "../../../misc";
|
||||||
import { ChannelProps, ListProps, TabListActions } from "../../../types";
|
import { ChannelProps, ListProps, TabListActions } from "../../../types";
|
||||||
import { SaleType as SaleTypeEnum } from "../../../types/globalTypes";
|
import {
|
||||||
|
PermissionEnum,
|
||||||
|
SaleType as SaleTypeEnum
|
||||||
|
} from "../../../types/globalTypes";
|
||||||
import { SaleDetails_sale } from "../../types/SaleDetails";
|
import { SaleDetails_sale } from "../../types/SaleDetails";
|
||||||
import DiscountCategories from "../DiscountCategories";
|
import DiscountCategories from "../DiscountCategories";
|
||||||
import DiscountCollections from "../DiscountCollections";
|
import DiscountCollections from "../DiscountCollections";
|
||||||
|
@ -294,6 +297,7 @@ const SaleDetailsPage: React.FC<SaleDetailsPageProps> = ({
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_DISCOUNTS]}
|
||||||
selectedChannelsCount={data.channelListings.length}
|
selectedChannelsCount={data.channelListings.length}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
channelsList={data.channelListings.map(channel => ({
|
channelsList={data.channelListings.map(channel => ({
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { validatePrice } from "@saleor/products/utils/validation";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import { VoucherTypeEnum } from "../../../types/globalTypes";
|
import { PermissionEnum, VoucherTypeEnum } from "../../../types/globalTypes";
|
||||||
import { DiscountTypeEnum, RequirementsPicker } from "../../types";
|
import { DiscountTypeEnum, RequirementsPicker } from "../../types";
|
||||||
import VoucherDates from "../VoucherDates";
|
import VoucherDates from "../VoucherDates";
|
||||||
import VoucherInfo from "../VoucherInfo";
|
import VoucherInfo from "../VoucherInfo";
|
||||||
|
@ -176,6 +176,7 @@ const VoucherCreatePage: React.FC<VoucherCreatePageProps> = ({
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_DISCOUNTS]}
|
||||||
selectedChannelsCount={data.channelListings.length}
|
selectedChannelsCount={data.channelListings.length}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
channelsList={data.channelListings.map(channel => ({
|
channelsList={data.channelListings.map(channel => ({
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { maybe, splitDateTime } from "../../../misc";
|
||||||
import { ChannelProps, ListProps, TabListActions } from "../../../types";
|
import { ChannelProps, ListProps, TabListActions } from "../../../types";
|
||||||
import {
|
import {
|
||||||
DiscountValueTypeEnum,
|
DiscountValueTypeEnum,
|
||||||
|
PermissionEnum,
|
||||||
VoucherTypeEnum
|
VoucherTypeEnum
|
||||||
} from "../../../types/globalTypes";
|
} from "../../../types/globalTypes";
|
||||||
import { VoucherDetails_voucher } from "../../types/VoucherDetails";
|
import { VoucherDetails_voucher } from "../../types/VoucherDetails";
|
||||||
|
@ -407,6 +408,7 @@ const VoucherDetailsPage: React.FC<VoucherDetailsPageProps> = ({
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_DISCOUNTS]}
|
||||||
selectedChannelsCount={data.channelListings.length}
|
selectedChannelsCount={data.channelListings.length}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
channelsList={data.channelListings.map(channel => ({
|
channelsList={data.channelListings.map(channel => ({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import { ChannelsAction } from "@saleor/channels/urls";
|
import { ChannelsAction } from "@saleor/channels/urls";
|
||||||
import { ChannelSaleData, createSortedSaleData } from "@saleor/channels/utils";
|
import { ChannelSaleData, createSortedSaleData } from "@saleor/channels/utils";
|
||||||
|
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
||||||
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
||||||
import { WindowTitle } from "@saleor/components/WindowTitle";
|
import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||||
import SaleCreatePage from "@saleor/discounts/components/SaleCreatePage";
|
import SaleCreatePage from "@saleor/discounts/components/SaleCreatePage";
|
||||||
|
@ -39,9 +39,9 @@ export const SaleCreateView: React.FC<SaleCreateProps> = ({ params }) => {
|
||||||
SaleCreateUrlQueryParams
|
SaleCreateUrlQueryParams
|
||||||
>(navigate, params => saleAddUrl(params), params);
|
>(navigate, params => saleAddUrl(params), params);
|
||||||
|
|
||||||
const { data: channelsData } = useChannelsList({});
|
const { availableChannels } = useAppChannel(false);
|
||||||
const allChannels: ChannelSaleData[] = createSortedSaleData(
|
const allChannels: ChannelSaleData[] = createSortedSaleData(
|
||||||
channelsData?.channels
|
availableChannels
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { Button, DialogContentText } from "@material-ui/core";
|
import { Button, DialogContentText } from "@material-ui/core";
|
||||||
import { categoryUrl } from "@saleor/categories/urls";
|
import { categoryUrl } from "@saleor/categories/urls";
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import {
|
import {
|
||||||
ChannelSaleData,
|
ChannelSaleData,
|
||||||
createChannelsDataWithSaleDiscountPrice,
|
createChannelsDataWithSaleDiscountPrice,
|
||||||
|
@ -8,6 +7,7 @@ import {
|
||||||
} from "@saleor/channels/utils";
|
} from "@saleor/channels/utils";
|
||||||
import { collectionUrl } from "@saleor/collections/urls";
|
import { collectionUrl } from "@saleor/collections/urls";
|
||||||
import ActionDialog from "@saleor/components/ActionDialog";
|
import ActionDialog from "@saleor/components/ActionDialog";
|
||||||
|
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
||||||
import AssignCategoriesDialog from "@saleor/components/AssignCategoryDialog";
|
import AssignCategoriesDialog from "@saleor/components/AssignCategoryDialog";
|
||||||
import AssignCollectionDialog from "@saleor/components/AssignCollectionDialog";
|
import AssignCollectionDialog from "@saleor/components/AssignCollectionDialog";
|
||||||
import AssignProductDialog from "@saleor/components/AssignProductDialog";
|
import AssignProductDialog from "@saleor/components/AssignProductDialog";
|
||||||
|
@ -91,7 +91,7 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
|
||||||
variables: DEFAULT_INITIAL_SEARCH_DATA
|
variables: DEFAULT_INITIAL_SEARCH_DATA
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: channelsData } = useChannelsList({});
|
const { availableChannels } = useAppChannel(false);
|
||||||
|
|
||||||
const paginationState = createPaginationState(PAGINATE_BY, params);
|
const paginationState = createPaginationState(PAGINATE_BY, params);
|
||||||
const changeTab = (tab: SaleDetailsPageTab) => {
|
const changeTab = (tab: SaleDetailsPageTab) => {
|
||||||
|
@ -118,7 +118,7 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
|
||||||
|
|
||||||
const allChannels: ChannelSaleData[] = createChannelsDataWithSaleDiscountPrice(
|
const allChannels: ChannelSaleData[] = createChannelsDataWithSaleDiscountPrice(
|
||||||
data?.sale,
|
data?.sale,
|
||||||
channelsData?.channels
|
availableChannels
|
||||||
);
|
);
|
||||||
const saleChannelsChoices: ChannelSaleData[] = createSortedChannelsDataFromSale(
|
const saleChannelsChoices: ChannelSaleData[] = createSortedChannelsDataFromSale(
|
||||||
data?.sale
|
data?.sale
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import { ChannelsAction } from "@saleor/channels/urls";
|
import { ChannelsAction } from "@saleor/channels/urls";
|
||||||
import {
|
import {
|
||||||
ChannelVoucherData,
|
ChannelVoucherData,
|
||||||
createSortedVoucherData
|
createSortedVoucherData
|
||||||
} from "@saleor/channels/utils";
|
} from "@saleor/channels/utils";
|
||||||
|
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
||||||
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
||||||
import { WindowTitle } from "@saleor/components/WindowTitle";
|
import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||||
import useChannels from "@saleor/hooks/useChannels";
|
import useChannels from "@saleor/hooks/useChannels";
|
||||||
|
@ -42,9 +42,9 @@ export const VoucherCreateView: React.FC<VoucherCreateProps> = ({ params }) => {
|
||||||
VoucherCreateUrlQueryParams
|
VoucherCreateUrlQueryParams
|
||||||
>(navigate, params => voucherAddUrl(params), params);
|
>(navigate, params => voucherAddUrl(params), params);
|
||||||
|
|
||||||
const { data: channelsData } = useChannelsList({});
|
const { availableChannels } = useAppChannel(false);
|
||||||
const allChannels: ChannelVoucherData[] = createSortedVoucherData(
|
const allChannels: ChannelVoucherData[] = createSortedVoucherData(
|
||||||
channelsData?.channels
|
availableChannels
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Button, DialogContentText } from "@material-ui/core";
|
import { Button, DialogContentText } from "@material-ui/core";
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import {
|
import {
|
||||||
ChannelVoucherData,
|
ChannelVoucherData,
|
||||||
createChannelsDataWithDiscountPrice,
|
createChannelsDataWithDiscountPrice,
|
||||||
|
@ -120,11 +119,11 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
|
||||||
VoucherUrlQueryParams
|
VoucherUrlQueryParams
|
||||||
>(navigate, params => voucherUrl(id, params), params);
|
>(navigate, params => voucherUrl(id, params), params);
|
||||||
|
|
||||||
const { data: channelsData } = useChannelsList({});
|
const { channel, availableChannels } = useAppChannel();
|
||||||
|
|
||||||
const allChannels: ChannelVoucherData[] = createChannelsDataWithDiscountPrice(
|
const allChannels: ChannelVoucherData[] = createChannelsDataWithDiscountPrice(
|
||||||
data?.voucher,
|
data?.voucher,
|
||||||
channelsData?.channels
|
availableChannels
|
||||||
);
|
);
|
||||||
const voucherChannelsChoices: ChannelVoucherData[] = createSortedChannelsDataFromVoucher(
|
const voucherChannelsChoices: ChannelVoucherData[] = createSortedChannelsDataFromVoucher(
|
||||||
data?.voucher
|
data?.voucher
|
||||||
|
@ -154,7 +153,6 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
|
||||||
const [updateChannels, updateChannelsOpts] = useVoucherChannelListingUpdate(
|
const [updateChannels, updateChannelsOpts] = useVoucherChannelListingUpdate(
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
const { channel } = useAppChannel();
|
|
||||||
|
|
||||||
const handleVoucherDelete = (data: VoucherDelete) => {
|
const handleVoucherDelete = (data: VoucherDelete) => {
|
||||||
if (data.voucherDelete.errors.length === 0) {
|
if (data.voucherDelete.errors.length === 0) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { SearchPages_search_edges_node } from "@saleor/searches/types/SearchPage
|
||||||
import { SearchProducts_search_edges_node } from "@saleor/searches/types/SearchProducts";
|
import { SearchProducts_search_edges_node } from "@saleor/searches/types/SearchProducts";
|
||||||
import { SearchProductTypes_search_edges_node } from "@saleor/searches/types/SearchProductTypes";
|
import { SearchProductTypes_search_edges_node } from "@saleor/searches/types/SearchProductTypes";
|
||||||
import { SearchWarehouses_search_edges_node } from "@saleor/searches/types/SearchWarehouses";
|
import { SearchWarehouses_search_edges_node } from "@saleor/searches/types/SearchWarehouses";
|
||||||
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -310,6 +311,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
{isSimpleProduct ? (
|
{isSimpleProduct ? (
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_PRODUCTS]}
|
||||||
messages={{
|
messages={{
|
||||||
hiddenLabel: intl.formatMessage({
|
hiddenLabel: intl.formatMessage({
|
||||||
defaultMessage: "Not published",
|
defaultMessage: "Not published",
|
||||||
|
|
|
@ -39,6 +39,7 @@ import {
|
||||||
ListActions,
|
ListActions,
|
||||||
ReorderAction
|
ReorderAction
|
||||||
} from "@saleor/types";
|
} from "@saleor/types";
|
||||||
|
import { PermissionEnum } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -404,6 +405,7 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
{isSimpleProduct ? (
|
{isSimpleProduct ? (
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_PRODUCTS]}
|
||||||
messages={{
|
messages={{
|
||||||
hiddenLabel: intl.formatMessage({
|
hiddenLabel: intl.formatMessage({
|
||||||
defaultMessage: "Not published",
|
defaultMessage: "Not published",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import { ChannelData, createSortedChannelsData } from "@saleor/channels/utils";
|
import { ChannelData, createSortedChannelsData } from "@saleor/channels/utils";
|
||||||
|
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
||||||
import { AttributeInput } from "@saleor/components/Attributes";
|
import { AttributeInput } from "@saleor/components/Attributes";
|
||||||
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
|
||||||
import { WindowTitle } from "@saleor/components/WindowTitle";
|
import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||||
|
@ -120,9 +120,9 @@ export const ProductCreateView: React.FC<ProductCreateProps> = ({ params }) => {
|
||||||
|
|
||||||
const productTypes = mapEdgesToItems(searchProductTypesOpts?.data?.search);
|
const productTypes = mapEdgesToItems(searchProductTypesOpts?.data?.search);
|
||||||
|
|
||||||
const { data: channelsData } = useChannelsList({});
|
const { availableChannels } = useAppChannel(false);
|
||||||
const allChannels: ChannelData[] = createSortedChannelsData(
|
const allChannels: ChannelData[] = createSortedChannelsData(
|
||||||
channelsData?.channels
|
availableChannels
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { DialogContentText, IconButton } from "@material-ui/core";
|
||||||
import DeleteIcon from "@material-ui/icons/Delete";
|
import DeleteIcon from "@material-ui/icons/Delete";
|
||||||
import { useAttributeValueDeleteMutation } from "@saleor/attributes/mutations";
|
import { useAttributeValueDeleteMutation } from "@saleor/attributes/mutations";
|
||||||
import ChannelsWithVariantsAvailabilityDialog from "@saleor/channels/components/ChannelsWithVariantsAvailabilityDialog";
|
import ChannelsWithVariantsAvailabilityDialog from "@saleor/channels/components/ChannelsWithVariantsAvailabilityDialog";
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import {
|
import {
|
||||||
ChannelData,
|
ChannelData,
|
||||||
createChannelsDataWithPrice,
|
createChannelsDataWithPrice,
|
||||||
|
@ -155,13 +154,11 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
||||||
productVariantCreateOpts
|
productVariantCreateOpts
|
||||||
] = useVariantCreateMutation({});
|
] = useVariantCreateMutation({});
|
||||||
|
|
||||||
const { data: channelsListData } = useChannelsList({});
|
const { availableChannels, channel } = useAppChannel();
|
||||||
|
|
||||||
const { data, loading, refetch } = useProductDetails({
|
const { data, loading, refetch } = useProductDetails({
|
||||||
displayLoader: true,
|
displayLoader: true,
|
||||||
variables: { id }
|
variables: { id }
|
||||||
});
|
});
|
||||||
const { channel } = useAppChannel();
|
|
||||||
const limitOpts = useShopLimitsQuery({
|
const limitOpts = useShopLimitsQuery({
|
||||||
variables: {
|
variables: {
|
||||||
productVariants: true
|
productVariants: true
|
||||||
|
@ -253,7 +250,7 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
||||||
|
|
||||||
const allChannels: ChannelData[] = createChannelsDataWithPrice(
|
const allChannels: ChannelData[] = createChannelsDataWithPrice(
|
||||||
product,
|
product,
|
||||||
channelsListData?.channels
|
availableChannels
|
||||||
).sort((channel, nextChannel) =>
|
).sort((channel, nextChannel) =>
|
||||||
channel.name.localeCompare(nextChannel.name)
|
channel.name.localeCompare(nextChannel.name)
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Channels_channels } from "@saleor/channels/types/Channels";
|
import { BaseChannels_channels } from "@saleor/channels/types/BaseChannels";
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
import CardSpacer from "@saleor/components/CardSpacer";
|
import CardSpacer from "@saleor/components/CardSpacer";
|
||||||
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
||||||
|
@ -70,7 +70,7 @@ export interface ShippingZoneDetailsPageProps
|
||||||
onWarehouseAdd: () => void;
|
onWarehouseAdd: () => void;
|
||||||
onWeightRateAdd: () => void;
|
onWeightRateAdd: () => void;
|
||||||
onWeightRateEdit: (id: string) => void;
|
onWeightRateEdit: (id: string) => void;
|
||||||
allChannels?: Channels_channels[];
|
allChannels?: BaseChannels_channels[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function warehouseToChoice(
|
function warehouseToChoice(
|
||||||
|
|
|
@ -19,6 +19,7 @@ import PricingCard from "@saleor/shipping/components/PricingCard";
|
||||||
import ShippingRateInfo from "@saleor/shipping/components/ShippingRateInfo";
|
import ShippingRateInfo from "@saleor/shipping/components/ShippingRateInfo";
|
||||||
import { createChannelsChangeHandler } from "@saleor/shipping/handlers";
|
import { createChannelsChangeHandler } from "@saleor/shipping/handlers";
|
||||||
import {
|
import {
|
||||||
|
PermissionEnum,
|
||||||
PostalCodeRuleInclusionTypeEnum,
|
PostalCodeRuleInclusionTypeEnum,
|
||||||
ShippingMethodTypeEnum
|
ShippingMethodTypeEnum
|
||||||
} from "@saleor/types/globalTypes";
|
} from "@saleor/types/globalTypes";
|
||||||
|
@ -175,6 +176,7 @@ export const ShippingZoneRatesCreatePage: React.FC<ShippingZoneRatesCreatePagePr
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_SHIPPING]}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
selectedChannelsCount={shippingChannels?.length}
|
selectedChannelsCount={shippingChannels?.length}
|
||||||
channelsList={data.channelListings}
|
channelsList={data.channelListings}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import {
|
||||||
} from "@saleor/shipping/types/ShippingZone";
|
} from "@saleor/shipping/types/ShippingZone";
|
||||||
import { ListActions, ListProps } from "@saleor/types";
|
import { ListActions, ListProps } from "@saleor/types";
|
||||||
import {
|
import {
|
||||||
|
PermissionEnum,
|
||||||
PostalCodeRuleInclusionTypeEnum,
|
PostalCodeRuleInclusionTypeEnum,
|
||||||
ShippingMethodTypeEnum
|
ShippingMethodTypeEnum
|
||||||
} from "@saleor/types/globalTypes";
|
} from "@saleor/types/globalTypes";
|
||||||
|
@ -203,6 +204,7 @@ export const ShippingZoneRatesPage: React.FC<ShippingZoneRatesPageProps> = ({
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ChannelsAvailabilityCard
|
<ChannelsAvailabilityCard
|
||||||
|
managePermissions={[PermissionEnum.MANAGE_SHIPPING]}
|
||||||
allChannelsCount={allChannelsCount}
|
allChannelsCount={allChannelsCount}
|
||||||
selectedChannelsCount={shippingChannels?.length}
|
selectedChannelsCount={shippingChannels?.length}
|
||||||
channelsList={data.channelListings.map(channel => ({
|
channelsList={data.channelListings.map(channel => ({
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Channels_channels } from "@saleor/channels/types/Channels";
|
import { BaseChannels_channels } from "@saleor/channels/types/BaseChannels";
|
||||||
import CardSpacer from "@saleor/components/CardSpacer";
|
import CardSpacer from "@saleor/components/CardSpacer";
|
||||||
import MultiAutocompleteSelectField, {
|
import MultiAutocompleteSelectField, {
|
||||||
MultiAutocompleteChoiceType
|
MultiAutocompleteChoiceType
|
||||||
|
@ -30,7 +30,7 @@ const messages = defineMessages({
|
||||||
interface ChannelsSectionProps {
|
interface ChannelsSectionProps {
|
||||||
onChange: FormChange;
|
onChange: FormChange;
|
||||||
selectedChannels: string[];
|
selectedChannels: string[];
|
||||||
allChannels?: Channels_channels[];
|
allChannels?: BaseChannels_channels[];
|
||||||
channelsDisplayValues: MultiAutocompleteChoiceType[];
|
channelsDisplayValues: MultiAutocompleteChoiceType[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Card, CardContent, Divider } from "@material-ui/core";
|
import { Card, CardContent, Divider } from "@material-ui/core";
|
||||||
import { Channels_channels } from "@saleor/channels/types/Channels";
|
import { BaseChannels_channels } from "@saleor/channels/types/BaseChannels";
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
|
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
|
||||||
import Skeleton from "@saleor/components/Skeleton";
|
import Skeleton from "@saleor/components/Skeleton";
|
||||||
|
@ -29,7 +29,7 @@ export interface ShippingZoneSettingsCardProps {
|
||||||
onWarehousesSearchChange: (query: string) => void;
|
onWarehousesSearchChange: (query: string) => void;
|
||||||
channelsDisplayValues: MultiAutocompleteChoiceType[];
|
channelsDisplayValues: MultiAutocompleteChoiceType[];
|
||||||
onChannelChange: FormChange;
|
onChannelChange: FormChange;
|
||||||
allChannels?: Channels_channels[];
|
allChannels?: BaseChannels_channels[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { DialogContentText } from "@material-ui/core";
|
import { DialogContentText } from "@material-ui/core";
|
||||||
import { useChannelsList } from "@saleor/channels/queries";
|
|
||||||
import ActionDialog from "@saleor/components/ActionDialog";
|
import ActionDialog from "@saleor/components/ActionDialog";
|
||||||
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
import useAppChannel from "@saleor/components/AppLayout/AppChannelContext";
|
||||||
import NotFoundPage from "@saleor/components/NotFoundPage";
|
import NotFoundPage from "@saleor/components/NotFoundPage";
|
||||||
|
@ -70,13 +69,11 @@ const ShippingZoneDetails: React.FC<ShippingZoneDetailsProps> = ({
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: channelsList } = useChannelsList({});
|
|
||||||
|
|
||||||
const { data, loading } = useShippingZone({
|
const { data, loading } = useShippingZone({
|
||||||
displayLoader: true,
|
displayLoader: true,
|
||||||
variables: { id, ...paginationState }
|
variables: { id, ...paginationState }
|
||||||
});
|
});
|
||||||
const { channel } = useAppChannel();
|
const { availableChannels, channel } = useAppChannel();
|
||||||
|
|
||||||
const [openModal, closeModal] = createDialogActionHandlers<
|
const [openModal, closeModal] = createDialogActionHandlers<
|
||||||
ShippingZoneUrlDialog,
|
ShippingZoneUrlDialog,
|
||||||
|
@ -197,7 +194,7 @@ const ShippingZoneDetails: React.FC<ShippingZoneDetailsProps> = ({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
allChannels={channelsList?.channels}
|
allChannels={availableChannels}
|
||||||
onWarehouseAdd={() => openModal("add-warehouse")}
|
onWarehouseAdd={() => openModal("add-warehouse")}
|
||||||
onWeightRateAdd={() => navigate(shippingWeightRatesUrl(id))}
|
onWeightRateAdd={() => navigate(shippingWeightRatesUrl(id))}
|
||||||
onWeightRateEdit={rateId =>
|
onWeightRateEdit={rateId =>
|
||||||
|
|
Loading…
Reference in a new issue