diff --git a/app/admin/recipes/[recipe]/edit/page.tsx b/app/admin/recipes/[recipe]/edit/page.tsx
index 5cdfc425..dc289b03 100644
--- a/app/admin/recipes/[recipe]/edit/page.tsx
+++ b/app/admin/recipes/[recipe]/edit/page.tsx
@@ -1,31 +1,31 @@
import AdminChildPage from '@/components/AdminChildPage';
import { redirect } from 'next/navigation';
import { getPhotosCached } from '@/photo/cache';
-import TagForm from '@/tag/TagForm';
-import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/app/paths';
+import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForRecipe } from '@/app/paths';
import PhotoLightbox from '@/photo/PhotoLightbox';
import { getPhotosMeta } from '@/photo/db/query';
-import AdminTagBadge from '@/admin/AdminTagBadge';
+import AdminRecipeBadge from '@/admin/AdminRecipeBadge';
+import AdminRecipeForm from '@/admin/AdminRecipeForm';
const MAX_PHOTO_TO_SHOW = 6;
interface Props {
- params: Promise<{ tag: string }>
+ params: Promise<{ recipe: string }>
}
-export default async function PhotoPageEdit({
+export default async function RecipePageEdit({
params,
}: Props) {
- const { tag: tagFromParams } = await params;
+ const { recipe: recipeFromParams } = await params;
- const tag = decodeURIComponent(tagFromParams);
+ const recipe = decodeURIComponent(recipeFromParams);
const [
{ count },
photos,
] = await Promise.all([
- getPhotosMeta({ tag }),
- getPhotosCached({ tag, limit: MAX_PHOTO_TO_SHOW }),
+ getPhotosMeta({ recipe }),
+ getPhotosCached({ recipe, limit: MAX_PHOTO_TO_SHOW }),
]);
if (count === 0) { redirect(PATH_ADMIN); }
@@ -34,15 +34,15 @@ export default async function PhotoPageEdit({
}
+ breadcrumb={}
>
-
+
-
+
);
};
diff --git a/app/admin/tags/[tag]/edit/page.tsx b/app/admin/tags/[tag]/edit/page.tsx
index 5cdfc425..747dc180 100644
--- a/app/admin/tags/[tag]/edit/page.tsx
+++ b/app/admin/tags/[tag]/edit/page.tsx
@@ -1,7 +1,7 @@
import AdminChildPage from '@/components/AdminChildPage';
import { redirect } from 'next/navigation';
import { getPhotosCached } from '@/photo/cache';
-import TagForm from '@/tag/TagForm';
+import AdminTagForm from '@/admin/AdminTagForm';
import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/app/paths';
import PhotoLightbox from '@/photo/PhotoLightbox';
import { getPhotosMeta } from '@/photo/db/query';
@@ -36,13 +36,13 @@ export default async function PhotoPageEdit({
backLabel="Tags"
breadcrumb={}
>
-
+
-
+
);
};
diff --git a/src/admin/AdminRecipeForm.tsx b/src/admin/AdminRecipeForm.tsx
new file mode 100644
index 00000000..f423e44d
--- /dev/null
+++ b/src/admin/AdminRecipeForm.tsx
@@ -0,0 +1,74 @@
+'use client';
+
+import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus';
+import Link from 'next/link';
+import { PATH_ADMIN_RECIPES } from '@/app/paths';
+import FieldSetWithStatus from '@/components/FieldSetWithStatus';
+import { ReactNode, useMemo, useState } from 'react';
+import { renamePhotoTagGloballyAction } from '@/photo/actions';
+import { parameterize } from '@/utility/string';
+import { useAppState } from '@/state/AppState';
+
+export default function AdminRecipeForm({
+ recipe,
+ children,
+}: {
+ recipe: string
+ children?: ReactNode
+}) {
+ const { invalidateSwr } = useAppState();
+
+ const [updatedRecipeRaw, setUpdatedRecipeRaw] = useState(recipe);
+
+ const updatedRecipe = useMemo(() =>
+ parameterize(updatedRecipeRaw)
+ , [updatedRecipeRaw]);
+
+ const isFormValid = (
+ updatedRecipe &&
+ updatedRecipe !== recipe
+ );
+
+ return (
+
+ );
+}
diff --git a/src/tag/TagForm.tsx b/src/admin/AdminTagForm.tsx
similarity index 97%
rename from src/tag/TagForm.tsx
rename to src/admin/AdminTagForm.tsx
index 9be11e8d..9023a30b 100644
--- a/src/tag/TagForm.tsx
+++ b/src/admin/AdminTagForm.tsx
@@ -9,7 +9,7 @@ import { renamePhotoTagGloballyAction } from '@/photo/actions';
import { parameterize } from '@/utility/string';
import { useAppState } from '@/state/AppState';
-export default function TagForm({
+export default function AdminTagForm({
tag,
children,
}: {