Add a RON API to search recipes by title + a bit of refactoring

This commit is contained in:
Greg Burri 2025-05-21 19:58:31 +02:00
parent a3f61e3711
commit 084f7ef445
26 changed files with 499 additions and 333 deletions

View file

@ -1,16 +1,16 @@
use chrono::{Datelike, Days, Months, NaiveDate};
use common::ron_api;
use common::web_api;
use gloo::storage::{LocalStorage, Storage};
use ron::ser::{PrettyConfig, to_string_pretty};
use serde::{Deserialize, Serialize};
use thiserror::Error;
use crate::{calendar, request};
use crate::{calendar, ron_request};
#[derive(Error, Debug)]
pub enum Error {
#[error("Request error: {0}")]
Request(#[from] request::Error),
Request(#[from] ron_request::Error),
}
type Result<T> = std::result::Result<T, Error>;
@ -25,11 +25,11 @@ impl ShoppingList {
Self { is_local }
}
pub async fn get_items(&self) -> Result<Vec<ron_api::ShoppingListItem>> {
pub async fn get_items(&self) -> Result<Vec<web_api::ShoppingListItem>> {
if self.is_local {
Ok(vec![]) // TODO
} else {
Ok(request::get("shopping_list").await?)
Ok(ron_request::get("/ron-api/shopping_list").await?)
}
}
@ -37,9 +37,9 @@ impl ShoppingList {
if self.is_local {
todo!();
} else {
request::patch(
"shopping_list/checked",
ron_api::KeyValue {
ron_request::patch(
"/ron-api/shopping_list/checked",
web_api::KeyValue {
id: item_id,
value: is_checked,
},