From a0978e30f92ba8b3287199470be4c0e3b750e395 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 16 Dec 2024 20:47:24 +0300 Subject: [PATCH] fix(reviews): debug errors linked to the reviews --- src/app.rs | 3 +-- src/components/reviews_list.rs | 12 +++++++----- src/models/item.rs | 20 +++++++------------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/app.rs b/src/app.rs index f883453..353ff68 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4,7 +4,6 @@ use leptos::*; use leptos_meta::*; use crate::components::{item_form::ItemForm, items_list::ItemsList, review_form::ReviewForm, reviews_list::ReviewsList }; use crate::models::item::Item; -use crate::models::review::Review; use crate::nostr::NostrClient; use tokio::sync::mpsc; use uuid::Uuid; @@ -64,7 +63,7 @@ pub fn App() -> impl IntoView { // Component to display the list of items. // Reviews form and list - + diff --git a/src/components/reviews_list.rs b/src/components/reviews_list.rs index 6916ae6..bbefa65 100644 --- a/src/components/reviews_list.rs +++ b/src/components/reviews_list.rs @@ -7,11 +7,13 @@ pub fn ReviewsList(reviews: Vec) -> impl IntoView {

{ "Reviews" }

    - { for review in reviews { - view! { -
  • { &review.content }
  • - } - } } + { + reviews.into_iter().map(|review| { + view! { +
  • { review.content }
  • + } + }).collect::>() + }
} diff --git a/src/models/item.rs b/src/models/item.rs index ddace10..337bfef 100644 --- a/src/models/item.rs +++ b/src/models/item.rs @@ -1,19 +1,13 @@ /// Represents an Item in CompareWare. /// Each item has metadata and key-value tags for categorization. use serde::{Deserialize, Serialize}; - -pub struct Review { - pub user_id: String, - pub title: String, - pub content: String, - pub timestamp: i64, -} +use crate::models::review::Review; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Item { - pub id: String, // Unique ID for the item - pub name: String, // Item name - pub description: String, // Short description of the item - pub tags: Vec<(String, String)>, // Key-value tags (e.g., "type" -> "software") - pub reviews: Vec, // Reviews -} + pub id: String, + pub name: String, + pub description: String, + pub tags: Vec<(String, String)>, + pub reviews: Vec, // Add reviews field here +} \ No newline at end of file