| void,
}[]
className?: string
buttonClassName?: string
-}) {
+}){
const [isLoading, setIsLoading] = useState(false);
- const itemClass = clsx(
- 'block w-full',
- 'border-none min-h-0 bg-transparent',
- 'text-sm text-main text-left',
- 'px-3 py-1.5 rounded-[3px]',
- 'hover:text-main',
- 'hover:bg-gray-50 active:bg-gray-100',
- 'hover:dark:bg-gray-900/75 active:dark:bg-gray-900',
- 'whitespace-nowrap',
- 'shadow-none',
- isLoading && 'cursor-not-allowed opacity-50',
- );
-
const renderItemContent = (
label: ReactNode,
icon?: ReactNode,
@@ -43,57 +30,77 @@ export default function MoreMenu({
;
return (
-
-
-
+
+
+
);
-}
+};
diff --git a/src/photo/actions.ts b/src/photo/actions.ts
index 0f272b48..64bee19b 100644
--- a/src/photo/actions.ts
+++ b/src/photo/actions.ts
@@ -52,7 +52,7 @@ export async function updatePhotoAction(formData: FormData) {
redirect(PATH_ADMIN_PHOTOS);
}
-export async function toggleFavoritePhoto(
+export async function toggleFavoritePhotoAction(
photoId: string,
shouldRedirect?: boolean,
) {
@@ -70,13 +70,26 @@ export async function toggleFavoritePhoto(
}
}
-export async function deletePhotoAction(formData: FormData) {
+export async function deletePhotoAction(
+ photoId: string,
+ photoUrl: string,
+ shouldRedirect?: boolean,
+) {
await Promise.all([
- deleteStorageUrl(formData.get('url') as string),
- sqlDeletePhoto(formData.get('id') as string),
+ deleteStorageUrl(photoUrl),
+ sqlDeletePhoto(photoId),
]);
-
revalidateAllKeysAndPaths();
+ if (shouldRedirect) {
+ redirect(PATH_ROOT);
+ }
+};
+
+export async function deletePhotoFormAction(formData: FormData) {
+ return deletePhotoAction(
+ formData.get('url') as string,
+ formData.get('id') as string,
+ );
};
export async function deletePhotoTagGloballyAction(formData: FormData) {
diff --git a/src/photo/index.ts b/src/photo/index.ts
index 7da71787..108f6512 100644
--- a/src/photo/index.ts
+++ b/src/photo/index.ts
@@ -172,6 +172,9 @@ export const photoQuantityText = (count: number, includeParentheses = true) =>
? `(${count} ${photoLabelForCount(count)})`
: `${count} ${photoLabelForCount(count)}`;
+export const deleteConfirmationTextForPhoto = (photo: Photo) =>
+ `Are you sure you want to delete "${titleForPhoto(photo)}?"`;
+
export type PhotoDateRange = { start: string, end: string };
export const descriptionForPhotoSet = (