diff --git a/Cargo.lock b/Cargo.lock
index 7b3b057..6b389be 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -730,6 +730,7 @@ dependencies = [
"leptos_router",
"nostr-sdk",
"serde",
+ "serde_json",
"tokio",
"uuid",
"wasm-bindgen",
diff --git a/Cargo.toml b/Cargo.toml
index ebc0942..b809cf5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,6 +24,7 @@ tokio = "1"
gloo-net = "0.5"
futures = "0.3"
wasm-bindgen-futures = "0.4"
+serde_json="1.0.133"
[features]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"]
diff --git a/src/app.rs b/src/app.rs
index 210d358..56c4c2a 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,7 +1,7 @@
use leptos::*;
use leptos_meta::*;
-use crate::components::{item_form::ItemForm, items_list::ItemsList};
-use crate::models::item::{Item, ReviewWithRating};
+use crate::components::items_list::ItemsList;
+use crate::models::item::Item;
use crate::nostr::NostrClient;
use tokio::sync::mpsc;
use uuid::Uuid;
@@ -28,36 +28,28 @@ pub fn App() -> impl IntoView {
}
});
- // Add a new item and review using the unified form
- let add_item = move |name: String, description: String, tags: Vec<(String, String)>, review: String, rating: u8| {
+ // Function to add a new item from the grid
+ let add_item_from_grid = move || {
let new_id = Uuid::new_v4().to_string();
set_items.update(|items| {
let item = Item {
id: new_id.clone(),
- name,
- description,
- tags,
- reviews: vec![ReviewWithRating { content: review.clone(), rating }],
+ name: String::new(),
+ description: String::new(),
+ tags: vec![],
+ reviews: vec![],
wikidata_id: None,
};
items.push(item);
});
-
- spawn_local(async move {
- let nostr_client = NostrClient::new("wss://relay.example.com").await.unwrap();
- nostr_client.publish_item("New item added!".to_string(), "".to_string(), vec![]).await.unwrap();
- });
};
view! {
{ "CompareWare" }
- // Unified form for adding an item and its first review
-
- // Display all items, including reviews
-
+
}
}
diff --git a/src/components/items_list.rs b/src/components/items_list.rs
index 025de27..53940a6 100644
--- a/src/components/items_list.rs
+++ b/src/components/items_list.rs
@@ -1,22 +1,20 @@
-/// Component to display a list of items.
-/// Iterates through the items and renders their name, description, tags, and reviews.
-use leptos::*;
use crate::models::item::Item;
-use serde::Deserialize;
-use futures::future;
use gloo_net::http::Request;
+use leptos::logging::log;
+use leptos::*;
+use serde::Deserialize;
+use std::collections::HashMap;
use wasm_bindgen_futures::spawn_local;
-use std::sync::Arc;
-// Define the structure for Wikidata API response
#[derive(Deserialize, Clone, Debug)]
struct WikidataResponse {
- entities: std::collections::HashMap,
+ entities: HashMap,
}
+
#[derive(Deserialize, Clone, Debug)]
struct WikidataEntity {
- labels: Option>,
- descriptions: Option>,
+ labels: Option>,
+ descriptions: Option>,
}
#[derive(Deserialize, Clone, Debug)]
@@ -25,144 +23,115 @@ struct WikidataLabel {
}
#[component]
-pub fn ItemsList(items: ReadSignal>) -> impl IntoView {
- // Create a signal for selected items
- let (selected_items_signal, set_selected_items) = create_signal(Vec::::new());
+pub fn ItemsList(items: ReadSignal>, set_items: WriteSignal>, on_add_item: impl Fn() + 'static, ) -> impl IntoView {
let (wikidata_data, set_wikidata_data) = create_signal(Vec::