-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave-dialog.tsx
60 lines (54 loc) · 1.57 KB
/
save-dialog.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"use client"
import { useState } from "react"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogFooter,
} from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
interface SaveDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
onSave: (name: string) => void
}
export function SaveDialog({ open, onOpenChange, onSave }: SaveDialogProps) {
const [memeName, setMemeName] = useState("")
const handleSave = () => {
if (!memeName.trim()) return
onSave(memeName)
setMemeName("")
onOpenChange(false)
}
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent>
<DialogHeader>
<DialogTitle>Save Meme</DialogTitle>
<DialogDescription>Give your meme a name to save it to your profile</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid gap-2">
<Label htmlFor="name">Meme Name</Label>
<Input
id="name"
value={memeName}
onChange={(e) => setMemeName(e.target.value)}
placeholder="Enter a name for your meme"
/>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button onClick={handleSave}>Save Meme</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}