-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile-dialog.tsx
78 lines (73 loc) · 2.9 KB
/
profile-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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"use client"
import { useState } from "react"
import { format } from "date-fns"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"
import { ScrollArea } from "@/components/ui/scroll-area"
import { Trash2, Download, User } from "lucide-react"
import type { SavedMeme } from "./types"
interface ProfileDialogProps {
savedMemes: SavedMeme[]
onDeleteMeme: (id: string) => void
onDownloadMeme: (meme: SavedMeme) => void
}
export function ProfileDialog({ savedMemes, onDeleteMeme, onDownloadMeme }: ProfileDialogProps) {
const [open, setOpen] = useState(false)
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button variant="outline" size="icon">
<User className="h-4 w-4" />
</Button>
</DialogTrigger>
<DialogContent className="max-w-3xl h-[80vh]">
<DialogHeader>
<DialogTitle>My Memes</DialogTitle>
<DialogDescription>View and manage your saved memes</DialogDescription>
</DialogHeader>
<ScrollArea className="h-full pr-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 pb-4">
{savedMemes.length === 0 ? (
<div className="col-span-full text-center py-8 text-muted-foreground">
No saved memes yet. Create and save some memes to see them here!
</div>
) : (
savedMemes.map((meme) => (
<div key={meme.id} className="border rounded-lg p-4 space-y-4">
<div className="aspect-video relative group">
<img
src={meme.imageUrl || "/placeholder.svg"}
alt={meme.name}
className="rounded-md w-full h-full object-cover"
/>
<div className="absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2">
<Button size="icon" variant="secondary" onClick={() => onDownloadMeme(meme)}>
<Download className="h-4 w-4" />
</Button>
<Button size="icon" variant="destructive" onClick={() => onDeleteMeme(meme.id)}>
<Trash2 className="h-4 w-4" />
</Button>
</div>
</div>
<div className="flex items-center justify-between">
<div>
<h3 className="font-medium">{meme.name}</h3>
<p className="text-sm text-muted-foreground">{format(new Date(meme.createdAt), "PPP")}</p>
</div>
</div>
</div>
))
)}
</div>
</ScrollArea>
</DialogContent>
</Dialog>
)
}