|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | 3 | import React from 'react'; |
| 4 | +import { |
| 5 | + Dialog, |
| 6 | + DialogContent, |
| 7 | + DialogHeader, |
| 8 | + DialogTitle, |
| 9 | + DialogDescription, |
| 10 | + DialogFooter, |
| 11 | +} from '@/components/ui/dialog'; |
| 12 | +import { Button } from '@/components/ui/button'; |
4 | 13 |
|
5 | 14 | export interface UpgradeModalProps { |
6 | 15 | open: boolean; |
7 | 16 | onClose: () => void; |
| 17 | + onUpgrade?: () => void; |
8 | 18 | feature: string; |
9 | 19 | reason: string; |
10 | 20 | currentTier: string; |
11 | 21 | recommendedTier: string; |
12 | 22 | } |
13 | 23 |
|
14 | | -export function UpgradeModal({ open, onClose, feature, reason, currentTier, recommendedTier }: UpgradeModalProps) { |
15 | | - if (!open) return null; |
| 24 | +export function UpgradeModal({ |
| 25 | + open, |
| 26 | + onClose, |
| 27 | + onUpgrade, |
| 28 | + feature, |
| 29 | + reason, |
| 30 | + currentTier, |
| 31 | + recommendedTier, |
| 32 | +}: UpgradeModalProps) { |
16 | 33 | return ( |
17 | | - <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/30"> |
18 | | - <div className="bg-white rounded-lg border border-[#E5E5E0] shadow-lg w-full max-w-sm mx-4 p-4 space-y-3"> |
19 | | - <h3 className="text-base font-semibold text-[#171717]">Upgrade Required</h3> |
20 | | - <p className="text-sm text-[#404040] break-words">{reason}</p> |
21 | | - <div className="flex gap-2"> |
22 | | - <button onClick={onClose} className="flex-1 px-3 py-2 rounded-md border border-[#E5E5E0] text-sm font-medium text-[#171717]">Close</button> |
23 | | - <button onClick={onClose} className="flex-1 px-3 py-2 rounded-md bg-[#FF6B35] text-white text-sm font-medium">Upgrade to {recommendedTier}</button> |
24 | | - </div> |
25 | | - </div> |
26 | | - </div> |
| 34 | + <Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}> |
| 35 | + <DialogContent className="sm:max-w-sm"> |
| 36 | + <DialogHeader> |
| 37 | + <DialogTitle>Upgrade Required</DialogTitle> |
| 38 | + <DialogDescription> |
| 39 | + The <span className="font-medium text-ink-900">{feature}</span> feature |
| 40 | + requires a {recommendedTier} plan. You are currently on the {currentTier} plan. |
| 41 | + </DialogDescription> |
| 42 | + </DialogHeader> |
| 43 | + |
| 44 | + <p className="text-sm text-ink-500">{reason}</p> |
| 45 | + |
| 46 | + <DialogFooter> |
| 47 | + <Button variant="ghost" onClick={onClose}> |
| 48 | + Close |
| 49 | + </Button> |
| 50 | + <Button variant="primary" onClick={onUpgrade ?? onClose}> |
| 51 | + Upgrade to {recommendedTier} |
| 52 | + </Button> |
| 53 | + </DialogFooter> |
| 54 | + </DialogContent> |
| 55 | + </Dialog> |
27 | 56 | ); |
28 | 57 | } |
29 | 58 |
|
|
0 commit comments