@@ -9,6 +9,17 @@ import {
99 RotateCcw ,
1010} from 'lucide-react'
1111import { AdminPost , PostStatus } from '../../utils/types'
12+ import {
13+ AlertDialog ,
14+ AlertDialogAction ,
15+ AlertDialogCancel ,
16+ AlertDialogContent ,
17+ AlertDialogDescription ,
18+ AlertDialogFooter ,
19+ AlertDialogHeader ,
20+ AlertDialogTitle ,
21+ AlertDialogTrigger ,
22+ } from '@/components/ui/alert-dialog'
1223
1324interface PostsTableProps {
1425 posts : AdminPost [ ]
@@ -144,28 +155,65 @@ export const PostsTable = ({
144155 </ div >
145156 < div className = "flex flex-wrap gap-2 pt-2" >
146157 < button
158+ type = "button"
147159 onClick = { ( ) => onEdit ( post ) }
148160 className = "flex flex-1 items-center justify-center gap-1 rounded-md bg-[#6C63FF] px-3 py-2 text-sm font-semibold text-white shadow-sm transition hover:opacity-90"
149161 title = "Edit"
150162 >
151163 < Pencil className = "h-4 w-4" /> Edit
152164 </ button >
153165 { post . status !== PostStatus . PUBLISHED && (
154- < button
155- onClick = { ( ) => onPublish ( post . id ) }
156- className = "flex flex-1 items-center justify-center gap-1 rounded-md bg-[#06D6A0] px-3 py-2 text-sm font-semibold text-white shadow-sm transition hover:opacity-90"
157- title = "Publish"
158- >
159- < ArrowUpRight className = "h-4 w-4" /> Publish
160- </ button >
166+ < AlertDialog >
167+ < AlertDialogTrigger asChild >
168+ < button
169+ type = "button"
170+ className = "flex flex-1 items-center justify-center gap-1 rounded-md bg-[#06D6A0] px-3 py-2 text-sm font-semibold text-white shadow-sm transition hover:opacity-90"
171+ title = "Publish"
172+ >
173+ < ArrowUpRight className = "h-4 w-4" /> Publish
174+ </ button >
175+ </ AlertDialogTrigger >
176+ < AlertDialogContent >
177+ < AlertDialogHeader >
178+ < AlertDialogTitle > Publish this post?</ AlertDialogTitle >
179+ < AlertDialogDescription >
180+ This will make "{ post . title } " visible to all readers. You can unpublish it later if needed.
181+ </ AlertDialogDescription >
182+ </ AlertDialogHeader >
183+ < AlertDialogFooter >
184+ < AlertDialogCancel > Cancel</ AlertDialogCancel >
185+ < AlertDialogAction onClick = { ( ) => onPublish ( post . id ) } >
186+ Publish Now
187+ </ AlertDialogAction >
188+ </ AlertDialogFooter >
189+ </ AlertDialogContent >
190+ </ AlertDialog >
161191 ) }
162- < button
163- onClick = { ( ) => onDelete ( post . id ) }
164- className = "flex flex-1 items-center justify-center gap-1 rounded-md bg-[#FF5252] px-3 py-2 text-sm font-semibold text-white shadow-sm transition hover:opacity-90"
165- title = "Delete"
166- >
167- < Trash2 className = "h-4 w-4" /> Delete
168- </ button >
192+ < AlertDialog >
193+ < AlertDialogTrigger asChild >
194+ < button
195+ type = "button"
196+ className = "flex flex-1 items-center justify-center gap-1 rounded-md bg-[#FF5252] px-3 py-2 text-sm font-semibold text-white shadow-sm transition hover:opacity-90"
197+ title = "Delete"
198+ >
199+ < Trash2 className = "h-4 w-4" /> Delete
200+ </ button >
201+ </ AlertDialogTrigger >
202+ < AlertDialogContent >
203+ < AlertDialogHeader >
204+ < AlertDialogTitle > Are you absolutely sure?</ AlertDialogTitle >
205+ < AlertDialogDescription >
206+ This will permanently delete "{ post . title } ". This action cannot be undone and will remove all associated data.
207+ </ AlertDialogDescription >
208+ </ AlertDialogHeader >
209+ < AlertDialogFooter >
210+ < AlertDialogCancel > Cancel</ AlertDialogCancel >
211+ < AlertDialogAction onClick = { ( ) => onDelete ( post . id ) } >
212+ Delete Post
213+ </ AlertDialogAction >
214+ </ AlertDialogFooter >
215+ </ AlertDialogContent >
216+ </ AlertDialog >
169217 </ div >
170218 </ div >
171219 </ article >
@@ -232,28 +280,65 @@ export const PostsTable = ({
232280 < td className = "p-4" >
233281 < div className = "flex items-center justify-end gap-2" >
234282 < button
283+ type = "button"
235284 onClick = { ( ) => onEdit ( post ) }
236285 className = "rounded-md bg-[#6C63FF] p-2 text-white transition hover:opacity-90"
237286 title = "Edit"
238287 >
239288 < Pencil className = "h-4 w-4" />
240289 </ button >
241290 { post . status !== PostStatus . PUBLISHED && (
242- < button
243- onClick = { ( ) => onPublish ( post . id ) }
244- className = "rounded-md bg-[#06D6A0] p-2 text-white transition hover:opacity-90"
245- title = "Publish"
246- >
247- < ArrowUpRight className = "h-4 w-4" />
248- </ button >
291+ < AlertDialog >
292+ < AlertDialogTrigger asChild >
293+ < button
294+ type = "button"
295+ className = "rounded-md bg-[#06D6A0] p-2 text-white transition hover:opacity-90"
296+ title = "Publish"
297+ >
298+ < ArrowUpRight className = "h-4 w-4" />
299+ </ button >
300+ </ AlertDialogTrigger >
301+ < AlertDialogContent >
302+ < AlertDialogHeader >
303+ < AlertDialogTitle > Publish this post?</ AlertDialogTitle >
304+ < AlertDialogDescription >
305+ This will make "{ post . title } " visible to all readers. You can unpublish it later if needed.
306+ </ AlertDialogDescription >
307+ </ AlertDialogHeader >
308+ < AlertDialogFooter >
309+ < AlertDialogCancel > Cancel</ AlertDialogCancel >
310+ < AlertDialogAction onClick = { ( ) => onPublish ( post . id ) } >
311+ Publish Now
312+ </ AlertDialogAction >
313+ </ AlertDialogFooter >
314+ </ AlertDialogContent >
315+ </ AlertDialog >
249316 ) }
250- < button
251- onClick = { ( ) => onDelete ( post . id ) }
252- className = "rounded-md bg-[#FF5252] p-2 text-white transition hover:opacity-90"
253- title = "Delete"
254- >
255- < Trash2 className = "h-4 w-4" />
256- </ button >
317+ < AlertDialog >
318+ < AlertDialogTrigger asChild >
319+ < button
320+ type = "button"
321+ className = "rounded-md bg-[#FF5252] p-2 text-white transition hover:opacity-90"
322+ title = "Delete"
323+ >
324+ < Trash2 className = "h-4 w-4" />
325+ </ button >
326+ </ AlertDialogTrigger >
327+ < AlertDialogContent >
328+ < AlertDialogHeader >
329+ < AlertDialogTitle > Are you absolutely sure?</ AlertDialogTitle >
330+ < AlertDialogDescription >
331+ This will permanently delete "{ post . title } ". This action cannot be undone and will remove all associated data.
332+ </ AlertDialogDescription >
333+ </ AlertDialogHeader >
334+ < AlertDialogFooter >
335+ < AlertDialogCancel > Cancel</ AlertDialogCancel >
336+ < AlertDialogAction onClick = { ( ) => onDelete ( post . id ) } >
337+ Delete Post
338+ </ AlertDialogAction >
339+ </ AlertDialogFooter >
340+ </ AlertDialogContent >
341+ </ AlertDialog >
257342 </ div >
258343 </ td >
259344 </ tr >
0 commit comments