saleor-apps-redis_apl/apps/emails-and-messages/src/modules/channels/ui/assigned-channels-message.tsx
Krzysztof Wolski 44741aa74e Update E&M Provider UI (#459)
* update to macaw next
* update ui to new design
2023-05-24 13:25:05 +02:00

52 lines
1.3 KiB
TypeScript

import { ChannelConfiguration } from "../channel-configuration-schema";
import { Text } from "@saleor/macaw-ui/next";
interface OverrideMessageArgs {
availableChannels: string[];
channelConfiguration: ChannelConfiguration;
}
export const AssignedChannelsMessage = ({
availableChannels,
channelConfiguration: { channels, mode, override },
}: OverrideMessageArgs) => {
if (!override) {
return (
<Text>
Configuration will be used with <Text variant="bodyStrong"> all</Text> channels.
</Text>
);
}
if (mode === "exclude") {
const leftChannels = availableChannels.filter((channel) => !channels.includes(channel));
if (!leftChannels.length) {
return (
<Text variant="bodyStrong">
Theres no channel which will be used with this configuration.
</Text>
);
}
return (
<Text>
Configuration will be used with channels:{" "}
<Text variant="bodyStrong">{leftChannels.join(", ")}</Text>.
</Text>
);
}
if (channels.length === 0) {
return (
<Text>
<Text variant="bodyStrong">No channels assigned. The configuration will not be used!</Text>
</Text>
);
}
return (
<Text>
Configuration will be used with channels:{" "}
<Text variant="bodyStrong">{channels.join(", ")}</Text>.
</Text>
);
};