mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-11-03 18:53:17 -05:00 
			
		
		
		
	* generate types * use generated types * ui updates * init button link for common styles * add links * setup label views * add delete confirmation * reset when not saved * link label to foods and auto set when adding to shopping list * generate types * use inheritence to manage exception handling * fix schema generation and add test for open_api generation * add header to api docs * move list consilidation to service * split list and list items controller * shopping list/list item tests - PARTIAL * enable recipe add/remove in shopping lists * generate types * linting * init global utility components * update types and add list item api * fix import cycle and database error * add container and border classes * new recipe list component * fix tests * breakout item editor * refactor item editor * update bulk actions * update input / color contrast * type generation * refactor controller dependencies * include food/unit editor * remove console.logs * fix and update type generation * fix incorrect type for column * fix postgres error * fix delete by variable * auto remove refs * fix typo
		
			
				
	
	
		
			40 lines
		
	
	
		
			861 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			861 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
/**
 | 
						|
 * use-display-text module contains helpful utility functions to compute the display text when provided
 | 
						|
 * with the food, units, quantity, and notes.
 | 
						|
 */
 | 
						|
 | 
						|
import { IngredientFood, IngredientUnit } from "~/types/api-types/recipe";
 | 
						|
 | 
						|
export function getDisplayText(
 | 
						|
  notes = "",
 | 
						|
  quantity: number | null = null,
 | 
						|
  food: IngredientFood | null = null,
 | 
						|
  unit: IngredientUnit | null = null
 | 
						|
): string {
 | 
						|
  // Fallback to note only if no food or unit is provided
 | 
						|
  if (food === null && unit === null) {
 | 
						|
    return `${quantity || ""} ${notes}`.trim();
 | 
						|
  }
 | 
						|
 | 
						|
  // Otherwise build the display text
 | 
						|
  let displayText = "";
 | 
						|
 | 
						|
  if (quantity) {
 | 
						|
    displayText += quantity;
 | 
						|
  }
 | 
						|
 | 
						|
  if (unit) {
 | 
						|
    displayText += ` ${unit.name}`;
 | 
						|
  }
 | 
						|
 | 
						|
  if (food) {
 | 
						|
    displayText += ` ${food.name}`;
 | 
						|
  }
 | 
						|
 | 
						|
  if (notes) {
 | 
						|
    displayText += ` ${notes}`;
 | 
						|
  }
 | 
						|
 | 
						|
  return displayText.trim();
 | 
						|
}
 |