fix(reviews): debug errors linked to the reviews

This commit is contained in:
Ryan Mwangi 2024-12-16 20:47:24 +03:00
parent ccd23654e3
commit a0978e30f9
3 changed files with 15 additions and 20 deletions

View File

@ -4,7 +4,6 @@ use leptos::*;
use leptos_meta::*; use leptos_meta::*;
use crate::components::{item_form::ItemForm, items_list::ItemsList, review_form::ReviewForm, reviews_list::ReviewsList }; use crate::components::{item_form::ItemForm, items_list::ItemsList, review_form::ReviewForm, reviews_list::ReviewsList };
use crate::models::item::Item; use crate::models::item::Item;
use crate::models::review::Review;
use crate::nostr::NostrClient; use crate::nostr::NostrClient;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use uuid::Uuid; use uuid::Uuid;
@ -64,7 +63,7 @@ pub fn App() -> impl IntoView {
// Component to display the list of items. // Component to display the list of items.
<ItemsList items=items_signal /> <ItemsList items=items_signal />
// Reviews form and list // Reviews form and list
<ReviewForm item_id={items_signal.get().first().unwrap().id.clone()} on_submit={submit_review} /> <ReviewForm item_id={items_signal.get().first().unwrap().id.clone()} on_submit={Box::new(submit_review)} />
<ReviewsList reviews={vec![]} /> <ReviewsList reviews={vec![]} />
</div> </div>
</> </>

View File

@ -7,11 +7,13 @@ pub fn ReviewsList(reviews: Vec<Review>) -> impl IntoView {
<div> <div>
<h3>{ "Reviews" }</h3> <h3>{ "Reviews" }</h3>
<ul> <ul>
{ for review in reviews { {
view! { reviews.into_iter().map(|review| {
<li>{ &review.content }</li> view! {
} <li>{ review.content }</li>
} } }
}).collect::<Vec<_>>()
}
</ul> </ul>
</div> </div>
} }

View File

@ -1,19 +1,13 @@
/// Represents an Item in CompareWare. /// Represents an Item in CompareWare.
/// Each item has metadata and key-value tags for categorization. /// Each item has metadata and key-value tags for categorization.
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::models::review::Review;
pub struct Review {
pub user_id: String,
pub title: String,
pub content: String,
pub timestamp: i64,
}
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Item { pub struct Item {
pub id: String, // Unique ID for the item pub id: String,
pub name: String, // Item name pub name: String,
pub description: String, // Short description of the item pub description: String,
pub tags: Vec<(String, String)>, // Key-value tags (e.g., "type" -> "software") pub tags: Vec<(String, String)>,
pub reviews: Vec<Review>, // Reviews pub reviews: Vec<Review>, // Add reviews field here
} }