import { Button, Text } from "@saleor/macaw-ui/next"; import { Modal } from "../ui/modal"; import { AddConnectionForm, AddConnectionFormID, AddConnectionFormSchema, } from "./add-connection-form"; import { trpcClient } from "../trpc/trpc-client"; import { ButtonsBox, SkeletonLayout } from "@saleor/apps-ui"; const defaultValues: AddConnectionFormSchema = { channelSlug: "", providerId: "" }; export const AddConnectionModal = (props: { onSuccess(): void; onClose(): void }) => { const { data: providers } = trpcClient.providersConfigs.getAll.useQuery(); if (!providers) { return ; } const { mutateAsync: addProviderMutate, isLoading } = trpcClient.channelsProvidersConnection.addConnection.useMutation({ onSuccess() { props.onSuccess(); }, }); const handleFormSubmit = async (values: AddConnectionFormSchema) => { const providerType = providers.find((p) => p.id === values.providerId)?.type; if (!providerType) { throw new Error("Provider not found"); } return addProviderMutate({ ...values, providerType, }); }; return ( Connect channel with Provider Once connected, operations on product variants on this channel will be sent to selected CMS platform. ); };