updated breakcore theme
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { deletePost } from '../../lib/api';
|
||||
import { confirmDialog, notify } from '../../lib/confirm';
|
||||
|
||||
const PAGE_SIZE = 9;
|
||||
|
||||
@@ -66,13 +67,19 @@ export default function PostList({ posts: initialPosts, isAdmin = false }: Props
|
||||
|
||||
async function handleDelete(slug: string, title: string) {
|
||||
if (deleting) return;
|
||||
if (!window.confirm(`Take "${title}" off the wall? This cannot be undone.`)) return;
|
||||
const ok = await confirmDialog({
|
||||
title: 'Take this off the wall?',
|
||||
message: `“${title}” will be removed from the catalogue. This cannot be undone.`,
|
||||
confirmLabel: 'Remove',
|
||||
cancelLabel: 'Keep',
|
||||
});
|
||||
if (!ok) return;
|
||||
setDeleting(slug);
|
||||
try {
|
||||
await deletePost(slug);
|
||||
setPosts(p => p.filter(x => x.slug !== slug));
|
||||
} catch (e) {
|
||||
window.alert(`Failed to remove: ${e instanceof Error ? e.message : 'unknown error'}`);
|
||||
notify(`Failed to remove: ${e instanceof Error ? e.message : 'unknown error'}`);
|
||||
} finally {
|
||||
setDeleting(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user