signup-suggestion-dialog.tsx81 lines, 2.3 KB
| 1 | import { useRouter } from "next/navigation"; |
| 2 | import { |
| 3 | Dialog, |
| 4 | DialogContent, |
| 5 | DialogDescription, |
| 6 | DialogFooter, |
| 7 | DialogHeader, |
| 8 | DialogTitle, |
| 9 | } from "../ui/dialog"; |
| 10 | import { Button } from "../ui/button"; |
| 11 | |
| 12 | interface SignupSuggestionDialogProps { |
| 13 | isOpen: boolean; |
| 14 | onOpenChange: (isOpen: boolean) => void; |
| 15 | shortUrl: string; |
| 16 | } |
| 17 | |
| 18 | export function SignupSuggestionDialog({ |
| 19 | isOpen, |
| 20 | onOpenChange, |
| 21 | shortUrl, |
| 22 | }: SignupSuggestionDialogProps) { |
| 23 | const router = useRouter(); |
| 24 | |
| 25 | const handleSignup = () => { |
| 26 | onOpenChange(false); |
| 27 | router.push("/register"); |
| 28 | }; |
| 29 | |
| 30 | const handleSignin = () => { |
| 31 | onOpenChange(false); |
| 32 | router.push("/login"); |
| 33 | }; |
| 34 | |
| 35 | return ( |
| 36 | <Dialog open={isOpen} onOpenChange={onOpenChange}> |
| 37 | <DialogContent className="sm:max-w-md"> |
| 38 | <DialogHeader> |
| 39 | <DialogTitle>URL Shortened Successfully</DialogTitle> |
| 40 | <DialogDescription> |
| 41 | Your link has been shortened and is ready to use. Want to save and |
| 42 | track this link? |
| 43 | </DialogDescription> |
| 44 | </DialogHeader> |
| 45 | <div className="flex flex-col space-y-4 py-4"> |
| 46 | <div className="rounded-md bg-muted p-4"> |
| 47 | <p className="text-sm font-medium">Your shortened URL</p> |
| 48 | <p className="mt-1 break-all font-mono text-sm">{shortUrl}</p> |
| 49 | </div> |
| 50 | <div className="space-y-2"> |
| 51 | <h4 className="text-sm font-medium">Create an account to:</h4> |
| 52 | <ul className="ml-4 list-disc text-sm space-y-1"> |
| 53 | <li>Save all your shortened links</li> |
| 54 | <li>Track link analytics</li> |
| 55 | <li>Customize your shortened links</li> |
| 56 | </ul> |
| 57 | </div> |
| 58 | </div> |
| 59 | <DialogFooter className="flex flex-col sm:flex-row gap-2"> |
| 60 | <Button |
| 61 | variant={"outline"} |
| 62 | className="sm:w-auto w-full" |
| 63 | onClick={() => onOpenChange(false)} |
| 64 | > |
| 65 | Maybe Later |
| 66 | </Button> |
| 67 | <Button |
| 68 | variant={"outline"} |
| 69 | className="sm:w-auto w-full" |
| 70 | onClick={handleSignin} |
| 71 | > |
| 72 | Log In |
| 73 | </Button> |
| 74 | <Button className="sm:w-auto w-full" onClick={handleSignup}> |
| 75 | Sign Up |
| 76 | </Button> |
| 77 | </DialogFooter> |
| 78 | </DialogContent> |
| 79 | </Dialog> |
| 80 | ); |
| 81 | } |