({ open, onOpenChange, source, returnPath }: UpsellDialogProps)
| 35 | } |
| 36 | |
| 37 | export function UpsellDialog({ open, onOpenChange, source, returnPath }: UpsellDialogProps) { |
| 38 | const { data: offers, isPending, isError, refetch } = useOffers(); |
| 39 | const captureEvent = useCaptureEvent(); |
| 40 | |
| 41 | useEffect(() => { |
| 42 | if (open) { |
| 43 | captureEvent('wa_upsell_dialog_viewed', { source }); |
| 44 | } |
| 45 | }, [open, source, captureEvent]); |
| 46 | |
| 47 | return ( |
| 48 | <Dialog open={open} onOpenChange={onOpenChange}> |
| 49 | <DialogContent className="max-w-2xl gap-6 focus:outline-none"> |
| 50 | {isError ? ( |
| 51 | // Keep the dialog open with a recoverable error state rather than |
| 52 | // closing it out from under the user — the built-in close button |
| 53 | // is still the dismiss affordance. |
| 54 | <UpsellLoadError variant="dialog" onRetry={() => { void refetch(); }} /> |
| 55 | ) : isPending ? ( |
| 56 | <div className="flex items-center justify-center py-12"> |
| 57 | <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" /> |
| 58 | </div> |
| 59 | ) : ( |
| 60 | <UpsellPanelContent offers={offers} source={source} returnPath={returnPath} variant="dialog" licenseState="free" /> |
| 61 | )} |
| 62 | </DialogContent> |
| 63 | </Dialog> |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | interface UpsellLoadErrorProps { |
| 68 | variant: "dialog" | "inline"; |
nothing calls this directly
no test coverage detected