refactor(comments): add comments to files
This commit is contained in:
parent
82b8b447dc
commit
58e8faa11c
4 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
/// Main application entry point for CompareWare.
|
||||||
|
/// Combines the item management components (form and list) to provide a cohesive user interface.
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use crate::components::{item_form::ItemForm, items_list::ItemsList};
|
use crate::components::{item_form::ItemForm, items_list::ItemsList};
|
||||||
use crate::models::item::Item;
|
use crate::models::item::Item;
|
||||||
|
@ -5,8 +7,10 @@ use uuid::Uuid;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn App() -> impl IntoView {
|
pub fn App() -> impl IntoView {
|
||||||
|
// Signal to store and update the list of items.
|
||||||
let (items_signal, set_items) = create_signal(Vec::<Item>::new());
|
let (items_signal, set_items) = create_signal(Vec::<Item>::new());
|
||||||
|
|
||||||
|
// Function to handle adding a new item to the list.
|
||||||
let add_item = move |name: String, description: String, tags: Vec<(String, String)>| {
|
let add_item = move |name: String, description: String, tags: Vec<(String, String)>| {
|
||||||
set_items.update(|items| {
|
set_items.update(|items| {
|
||||||
items.push(Item {
|
items.push(Item {
|
||||||
|
@ -21,7 +25,9 @@ pub fn App() -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<div>
|
<div>
|
||||||
<h1>{ "CompareWare" }</h1>
|
<h1>{ "CompareWare" }</h1>
|
||||||
|
// Form component for adding new items.
|
||||||
<ItemForm on_submit=Box::new(add_item) />
|
<ItemForm on_submit=Box::new(add_item) />
|
||||||
|
// Component to display the list of items.
|
||||||
<ItemsList items=items_signal.get() />
|
<ItemsList items=items_signal.get() />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
/// Form component for adding a new item.
|
||||||
|
/// Handles user input for item name, description, and optional tags.
|
||||||
|
/// Calls `on_submit` when the form is submitted.
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_dom::ev::SubmitEvent;
|
use leptos_dom::ev::SubmitEvent;
|
||||||
|
|
||||||
|
@ -7,6 +10,7 @@ pub fn ItemForm(on_submit: Box<dyn Fn(String, String, Vec<(String, String)>)>) -
|
||||||
let (description, set_description) = create_signal(String::new());
|
let (description, set_description) = create_signal(String::new());
|
||||||
let (tags, set_tags) = create_signal(Vec::<(String, String)>::new());
|
let (tags, set_tags) = create_signal(Vec::<(String, String)>::new());
|
||||||
|
|
||||||
|
// Handle form submission.
|
||||||
let handle_submit = move |ev: SubmitEvent| {
|
let handle_submit = move |ev: SubmitEvent| {
|
||||||
ev.prevent_default();
|
ev.prevent_default();
|
||||||
on_submit(name.get(), description.get(), tags.get().clone());
|
on_submit(name.get(), description.get(), tags.get().clone());
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/// Component to display a list of items.
|
||||||
|
/// Iterates through the items and renders their name, description, and tags.
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
|
|
||||||
use crate::models::item::Item;
|
use crate::models::item::Item;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/// Represents an Item in CompareWare.
|
||||||
|
/// Each item has metadata and key-value tags for categorization.
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue