import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogSection, DialogSectionSeparator, DialogTitle, } from '@ui/components/shadcn/ui/dialog' import { SubmitHandler } from 'react-hook-form' import { toast } from 'sonner' import { Button } from 'ui' import NewAwsMarketplaceOrgForm, { CREATE_AWS_MANAGED_ORG_FORM_ID, NewMarketplaceOrgForm, } from './NewAwsMarketplaceOrgForm' import { useAwsManagedOrganizationCreateMutation } from '@/data/organizations/organization-create-mutation' interface Props { buyerId: string visible: boolean onSuccess: (newlyCreatedOrgSlug: string) => void onClose: () => void } const NewAwsMarketplaceOrgModal = ({ buyerId, visible, onSuccess, onClose }: Props) => { const { mutate: createOrganization, isPending: isCreatingOrganization } = useAwsManagedOrganizationCreateMutation({ onSuccess: (org) => { //TODO(thomas): send tracking event? onSuccess(org.slug) }, onError: (res) => { toast.error(res.message, { duration: 7_000, }) }, }) const onSubmit: SubmitHandler = async (values) => { createOrganization({ ...values, buyerId }) } return ( { if (!open) onClose() }} > event.preventDefault()} size="xlarge" onEscapeKeyDown={(e) => (isCreatingOrganization ? e.preventDefault() : onClose())} onPointerDownOutside={(e) => (isCreatingOrganization ? e.preventDefault() : onClose())} className="p-2" > Create a new organization A new organization will be created and linked to your AWS Marketplace subscription ) } export default NewAwsMarketplaceOrgModal