feat: hromadné editace
This commit is contained in:
1 parent
8fa7f601f2
commit
bc85a37fc0
18 files changed
+825
-18
No files matched your search
@@ -1,18 +1,20 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Button, Form, Modal } from "react-bootstrap";
|
||||
import {
|
||||
DayRecord, MealEntry, MealSuggestion, MealTemplate, MealType, Nutrients, UserSettings,
|
||||
DayRecord, MealEntry, MealSuggestion, MealTemplate, MealType, UserSettings,
|
||||
addMeal, getMealHistory, getMealTemplates, getSettings, updateMeal,
|
||||
} from "../../../../types";
|
||||
import { MEAL_TYPES_IN_ORDER, MEAL_TYPE_ICONS, MEAL_TYPE_NAMES, NUTRIENTS_IN_ORDER } from "../../enums";
|
||||
import {
|
||||
applyMultiplier, deriveAmounts, formatCalories, formatMultiplier, formatMultiplierInput, formatPriceInput,
|
||||
formatNutrientInput, formatWeight, normalizeSearch, parseIntInput, parseMultiplierInput, parseNutrientInput,
|
||||
formatWeight, normalizeSearch, parseIntInput, parseMultiplierInput, parseNutrientInput,
|
||||
parsePriceInput,
|
||||
} from "../../Utils";
|
||||
import CalorieLookup from "../CalorieLookup";
|
||||
import MealSuggestions from "../MealSuggestions";
|
||||
import NutrientsFieldset, { NutrientInputs, emptyNutrientInputs, toNutrients } from "../NutrientsFieldset";
|
||||
import NutrientsFieldset, {
|
||||
NutrientInputs, emptyNutrientInputs, toNutrientInputs, toNutrients,
|
||||
} from "../NutrientsFieldset";
|
||||
import SourceInput from "../SourceInput";
|
||||
|
||||
type Props = {
|
||||
@@ -65,10 +67,6 @@ const mergeSuggestion = (current: MealForm, values: Partial<MealForm>, onlyEmpty
|
||||
return result;
|
||||
};
|
||||
|
||||
/** Převede uložené živiny na text pro editační pole. */
|
||||
const toNutrientInputs = (nutrients?: Nutrients): NutrientInputs =>
|
||||
Object.fromEntries(NUTRIENTS_IN_ORDER.map(key => [key, formatNutrientInput(nutrients?.[key])])) as NutrientInputs;
|
||||
|
||||
/** Znormalizuje název zdroje pro porovnání se sazbami z nastavení. */
|
||||
function normalizeSource(source: string): string {
|
||||
return source.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase().trim();
|
||||
|
||||
Reference in new issue
Block a user