>
& EntityLinkExternalProps) {
const { small, medium, large } = labelForFilm(film);
diff --git a/src/image-response/RecipeImageResponse.tsx b/src/image-response/RecipeImageResponse.tsx
index ba311a67..fd462ce9 100644
--- a/src/image-response/RecipeImageResponse.tsx
+++ b/src/image-response/RecipeImageResponse.tsx
@@ -4,7 +4,7 @@ import ImagePhotoGrid from './components/ImagePhotoGrid';
import ImageContainer from './components/ImageContainer';
import type { NextImageSize } from '@/platforms/next-image';
import { formatTag } from '@/tag';
-import { generateRecipeText, getPhotoWithRecipeFromPhotos } from '@/recipe';
+import { generateRecipeText, getRecipePropsFromPhotos } from '@/recipe';
import PhotoFilmIcon from '@/film/PhotoFilmIcon';
import {
isStringFujifilmSimulationLabel,
@@ -27,16 +27,10 @@ export default function RecipeImageResponse({
fontFamily: string
smallText?: boolean
}) {
- const {
- recipeData,
- film,
- } = getPhotoWithRecipeFromPhotos(photos) ?? {};
+ const { data, film } = getRecipePropsFromPhotos(photos) ?? {};
- let recipeLines = recipeData && film
- ? generateRecipeText({
- data: recipeData,
- film,
- }, true)
+ let recipeLines = data && film
+ ? generateRecipeText({ data, film }, true)
: [];
if (recipeLines && recipeLines.length > MAX_RECIPE_LINES) {
@@ -75,7 +69,7 @@ export default function RecipeImageResponse({
/>,
title: formatTag(recipe).toLocaleUpperCase(),
}}>
- {recipeData &&
+ {data &&
(
- photo?.recipeData &&
- photo?.film
- ) ? setRecipeModalProps?.({
- title: photo.recipeTitle,
- data: photo.recipeData,
- film: photo.film,
- iso: photo.isoFormatted,
- exposure: photo.exposureTimeFormatted,
- })
+ toggleRecipeOverlay={recipeProps
+ ? () => setRecipeModalProps?.(recipeProps)
: undefined}
/>}
entityDescription={descriptionForRecipePhotos(photos, undefined, count)}
diff --git a/src/recipe/index.ts b/src/recipe/index.ts
index d3735c92..a7448906 100644
--- a/src/recipe/index.ts
+++ b/src/recipe/index.ts
@@ -132,7 +132,7 @@ export const generateMetaForRecipe = (
const photoHasRecipe = (photo?: Photo) =>
photo?.film && photo?.recipeData;
-export const getPhotoWithRecipeFromPhotos = (
+const getPhotoWithRecipeFromPhotos = (
photos: Photo[],
preferredPhoto?: Photo,
) =>
@@ -140,6 +140,21 @@ export const getPhotoWithRecipeFromPhotos = (
? preferredPhoto
: photos.find(photoHasRecipe);
+export const getRecipePropsFromPhotos = (
+ ...args: Parameters
+): RecipeProps | undefined => {
+ const photo = getPhotoWithRecipeFromPhotos(...args);
+ return photo?.recipeData && photo?.film
+ ? {
+ title: photo.recipeTitle,
+ data: photo.recipeData,
+ film: photo.film,
+ iso: photo.isoFormatted,
+ exposure: photo.exposureTimeFormatted,
+ }
+ : undefined;
+};
+
export const sortRecipes = (recipes: Recipes = []) =>
recipes.sort((a, b) => a.recipe.localeCompare(b.recipe));
diff --git a/src/state/AppState.ts b/src/state/AppState.ts
index c3bae9a1..871ba518 100644
--- a/src/state/AppState.ts
+++ b/src/state/AppState.ts
@@ -1,3 +1,5 @@
+'use client';
+
import {
Dispatch,
SetStateAction,