import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faClock, faFilePdf, faPenToSquare, faTrash } from "@fortawesome/free-solid-svg-icons"; import { MealTemplate } from "../../../types"; import { RECIPE_FLAVOR_NAMES } from "../enums"; import { deriveRecipe, formatCalories, formatCount, formatIngredientAmount, formatPrepTime, formatPrice, formatWeight, getIngredientCalories, } from "../Utils"; import RecipeNote from "./RecipeNote"; import RecipeLinks from "./RecipeLinks"; type Props = { template: MealTemplate, busy?: boolean, /** Všechny recepty — bez nich se vazby na jiné recepty nezobrazí. */ recipeList?: MealTemplate[], onOpenRecipe?: (recipe: MealTemplate) => void, /** Bez úpravy a smazání je karta jen k nahlédnutí (kolo štěstí). */ onEdit?: () => void, onDelete?: () => void, onExport?: () => void, }; /** * Karta receptu uvnitř jídla v seznamu jídel — suroviny, hodnoty celého hrnce * i jedné porce a postup. Název a zdroj neopakuje, nese je jídlo. */ const MealTemplateCard = ({ template, busy, recipeList, onOpenRecipe, onEdit, onDelete, onExport }: Readonly) => { const recipe = deriveRecipe(template.ingredients, template.servings, template.cookedWeight); return (
Recept {template.category && {template.category}} {RECIPE_FLAVOR_NAMES[template.flavor].toLowerCase()} {template.prepMinutes != null && ( {formatPrepTime(template.prepMinutes)} )} {template.weight != null && porce {formatWeight(template.weight)}} {(template.servings ?? 1) > 1 && ( {formatCount(template.servings ?? 1, 'porce', 'porce', 'porcí')} )}
{template.calories != null && ( {formatCalories(template.calories)} )} {template.price != null && ( {formatPrice(template.price)} )} {onExport && ( )} {onEdit && ( )} {onDelete && ( )}
{!!template.ingredients.length && ( )}
Celkem {formatCalories(recipe.totalCalories)} {recipe.totalWeight != null && <> · {formatWeight(recipe.totalWeight)}} {recipe.caloriesPer100g != null && <> · {recipe.caloriesPer100g} kcal/100 g} {recipe.totalPrice != null && <> · {formatPrice(recipe.totalPrice)}}
{recipeList && } {template.note && }
); }; export default MealTemplateCard;