diff --git a/app/admin/recipes/page.tsx b/app/admin/recipes/page.tsx index c70d03e7..7ab25aea 100644 --- a/app/admin/recipes/page.tsx +++ b/app/admin/recipes/page.tsx @@ -1,16 +1,16 @@ -import AdminTagTable from '@/admin/AdminTagTable'; +import AdminRecipeTable from '@/admin/AdminRecipeTable'; import SiteGrid from '@/components/SiteGrid'; -import { getUniqueTagsHiddenCached } from '@/photo/cache'; +import { getUniqueRecipesCached } from '@/photo/cache'; export default async function AdminTagsPage() { - const tags = await getUniqueTagsHiddenCached().catch(() => []); + const recipes = await getUniqueRecipesCached().catch(() => []); return (
- +
} /> diff --git a/src/admin/AdminRecipeBadge.tsx b/src/admin/AdminRecipeBadge.tsx new file mode 100644 index 00000000..0f82213a --- /dev/null +++ b/src/admin/AdminRecipeBadge.tsx @@ -0,0 +1,35 @@ +import { photoLabelForCount } from '@/photo'; +import { clsx } from 'clsx/lite'; +import Badge from '@/components/Badge'; +import PhotoRecipe from '@/recipe/PhotoRecipe'; + +export default function AdminRecipeBadge({ + recipe, + count, + hideBadge, +}: { + recipe: string, + count: number, + hideBadge?: boolean, +}) { + const renderBadgeContent = () => +
+ +
+ {count} + +   + {photoLabelForCount(count)} + +
+
; + + return ( + hideBadge + ? renderBadgeContent() + : {renderBadgeContent()} + ); +} \ No newline at end of file diff --git a/src/admin/AdminRecipeTable.tsx b/src/admin/AdminRecipeTable.tsx new file mode 100644 index 00000000..ff4dece4 --- /dev/null +++ b/src/admin/AdminRecipeTable.tsx @@ -0,0 +1,43 @@ +import FormWithConfirm from '@/components/FormWithConfirm'; +import { deletePhotoTagGloballyAction } from '@/photo/actions'; +import AdminTable from '@/admin/AdminTable'; +import { Fragment } from 'react'; +import DeleteFormButton from '@/admin/DeleteFormButton'; +import { photoQuantityText } from '@/photo'; +import EditButton from '@/admin/EditButton'; +import { pathForAdminRecipeEdit } from '@/app/paths'; +import { clsx } from 'clsx/lite'; +import { formatRecipe, Recipes, sortRecipesWithCount } from '@/recipe'; +import AdminRecipeBadge from './AdminRecipeBadge'; + +export default function AdminRecipeTable({ + recipes, +}: { + recipes: Recipes +}) { + return ( + + {sortRecipesWithCount(recipes).map(({ recipe, count }) => + +
+ +
+
+ + + + + +
+
)} +
+ ); +} diff --git a/src/app/paths.ts b/src/app/paths.ts index 77939527..3a6a2627 100644 --- a/src/app/paths.ts +++ b/src/app/paths.ts @@ -100,6 +100,9 @@ export const pathForAdminPhotoEdit = (photo: PhotoOrPhotoId) => export const pathForAdminTagEdit = (tag: string) => `${PATH_ADMIN_TAGS}/${tag}/${EDIT}`; +export const pathForAdminRecipeEdit = (recipe: string) => + `${PATH_ADMIN_RECIPES}/${recipe}/${EDIT}`; + type PhotoOrPhotoId = Photo | string; const getPhotoId = (photoOrPhotoId: PhotoOrPhotoId) =>