added theme toggle,

fixed create entityies in API
This commit is contained in:
2026-02-14 08:01:07 +01:00
parent 9b2f2c4e91
commit 276cc21c5a
13 changed files with 141 additions and 46 deletions

View File

@ -46,7 +46,7 @@ class API extends APIlite {
if (is_array($existing)) {
throw new \Exception('User with this email already exists');
}
$userId = $this->users()->userSave(array(
$userId = $this->users()->user(null, array(
'email' => $email,
'password_hash' => $this->users()->hashString($password),
'token' => null,
@ -192,7 +192,7 @@ class API extends APIlite {
if ($kcal_100 == 0) {
$kcal_100 = $this->computeKcal100($protein_g_100, $carbs_g_100, $fat_g_100);
}
$ingredientId = $this->ingredients()->ingredientSave(array(
$ingredientId = $this->ingredients()->ingredient(null, array(
'user_id' => $user_id,
'name' => $name,
'protein_g_100' => $this->round2($protein_g_100),
@ -326,7 +326,7 @@ class API extends APIlite {
$user_id = $this->requireUserIDbyToken($token);
$name = $this->normalizeName($name);
$this->assertMealType($meal_type);
$mealId = $this->meals()->mealSave(array(
$mealId = $this->meals()->meal(null, array(
'user_id' => $user_id,
'name' => $name,
'meal_type' => $meal_type,
@ -387,7 +387,7 @@ class API extends APIlite {
throw new \Exception('position must be >= 1');
}
$this->getIngredientAccessible($user_id, $ingredient_id);
$mealItemId = $this->mealItems()->mealItemSave(array(
$mealItemId = $this->mealItems()->mealItem(null, array(
'meal_id' => $meal_id,
'ingredient_id' => $ingredient_id,
'grams' => $this->round2($grams),
@ -508,7 +508,7 @@ class API extends APIlite {
throw new \Exception('Failed to update diary entry');
}
} else {
$inserted = $this->diaryEntries()->diaryEntrySave(array(
$inserted = $this->diaryEntries()->diaryEntry(null, array(
'diary_day_id' => (int) $day['diary_day_id'],
'meal_type' => $meal_type,
'meal_id' => $meal_id,
@ -890,7 +890,7 @@ class API extends APIlite {
if (is_array($day)) {
return $this->mapDiaryDay($day);
}
$dayId = $this->diaryDays()->diaryDaySave(array(
$dayId = $this->diaryDays()->diaryDay(null, array(
'user_id' => $user_id,
'day_date' => $day_date,
'created_at' => '`NOW`'