From ccd23654e37078f9270e79d3220621edc89eda9a Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 16 Dec 2024 19:06:33 +0300 Subject: [PATCH] feat(reviews): add reviews section --- src/app.rs | 12 +++++++++++- src/components/mod.rs | 2 ++ src/components/review_form.rs | 25 +++++++++++++++++++++++++ src/components/reviews_list.rs | 18 ++++++++++++++++++ src/models/item.rs | 8 ++++++++ src/models/mod.rs | 1 + src/models/review.rs | 9 +++++++++ 7 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/components/review_form.rs create mode 100644 src/components/reviews_list.rs create mode 100644 src/models/review.rs diff --git a/src/app.rs b/src/app.rs index f45dc8b..f883453 100644 --- a/src/app.rs +++ b/src/app.rs @@ -2,8 +2,9 @@ /// Combines the item management components (form and list) to provide a cohesive user interface. use leptos::*; use leptos_meta::*; -use crate::components::{item_form::ItemForm, items_list::ItemsList}; +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; @@ -37,6 +38,7 @@ pub fn App() -> impl IntoView { name: name.clone(), description: description.clone(), tags: tags.clone(), + reviews: vec![], }; items.push(item); }); @@ -47,6 +49,11 @@ pub fn App() -> impl IntoView { }); }; + // Handle review submission + let submit_review = move |content: String| { + // Handle the review submission logic + }; + view! { <> @@ -56,6 +63,9 @@ pub fn App() -> impl IntoView { // Component to display the list of items. + // Reviews form and list + + } diff --git a/src/components/mod.rs b/src/components/mod.rs index 6d4b027..7ac9a5a 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,2 +1,4 @@ pub mod item_form; pub mod items_list; +pub mod review_form; +pub mod reviews_list; diff --git a/src/components/review_form.rs b/src/components/review_form.rs new file mode 100644 index 0000000..83be251 --- /dev/null +++ b/src/components/review_form.rs @@ -0,0 +1,25 @@ +use leptos::*; +use crate::models::item::Item; +use leptos::ev::Event; + + +#[component] +pub fn ReviewForm(item_id: String, on_submit: impl Fn(String) + 'static) -> impl IntoView { + let (review_content, set_review_content) = create_signal(String::new()); + + let submit_review = move |e| { + on_submit(review_content.get()); + }; + + view! { +
+

{ "Submit Review" }

+