import { useAppBridge, withAuthorization } from "@saleor/app-sdk/app-bridge"; import { Box, Text } from "@saleor/macaw-ui/next"; import { AppLayout, AppLayoutRow } from "@/modules/ui/templates/AppLayout"; import { trpcClient } from "@/modules/trpc/trpc-client"; import { getErrorHandler } from "@/modules/trpc/utils"; import { useFetchChannelsQuery } from "generated/graphql"; import { StripeConfigurationsList } from "@/modules/ui/organisms/StripeConfigurationList/StripeConfigurationList"; import { ChannelToConfigurationList } from "@/modules/ui/organisms/ChannelToConfigurationList/ChannelToConfigurationList"; import { Skeleton } from "@/modules/ui/atoms/Skeleton/Skeleton"; function ListConfigurationPage() { const { appBridge } = useAppBridge(); const [allConfigurations, channelMappings] = trpcClient.useQueries((t) => [ t.paymentAppConfigurationRouter.paymentConfig.getAll(undefined, { onError: getErrorHandler({ appBridge, actionId: "list-all-configurations", message: "Error while fetching the list of configurations", title: "API Error", }), }), t.paymentAppConfigurationRouter.mapping.getAll(undefined, { onError: getErrorHandler({ appBridge, actionId: "channel-mappings-get-all", message: "Error while fetching the channel mappings", title: "API Error", }), }), ]); const [channels] = useFetchChannelsQuery(); const hasAnyConfigs = allConfigurations.data && allConfigurations.data.length > 0; const hasAnyMappings = Object.values(channelMappings.data || {}).filter(Boolean).length > 0; return ( {allConfigurations.isLoading ? ( ) : ( )} Assign Stripe configurations to Saleor channels. {!channelMappings.isLoading && !hasAnyMappings && ( No channels have configurations assigned. This means payments are not processed by Stripe. )} } > {channelMappings.isLoading ? ( ) : ( )} ); } export default withAuthorization()(ListConfigurationPage);