2024-12-06 14:45:14 +03:00
|
|
|
use leptos::*;
|
|
|
|
use crate::components::{item_form::ItemForm, items_list::ItemsList};
|
|
|
|
use crate::models::item::Item;
|
|
|
|
|
|
|
|
#[component]
|
|
|
|
pub fn App() -> impl IntoView {
|
2024-12-09 13:56:39 +03:00
|
|
|
let (items_signal, set_items) = create_signal(Vec::<Item>::new());
|
2024-12-06 14:45:14 +03:00
|
|
|
|
|
|
|
let add_item = move |name: String, description: String, tags: Vec<(String, String)>| {
|
2024-12-09 13:56:39 +03:00
|
|
|
set_items;(|mut items: Vec<Item>| {
|
2024-12-06 14:45:14 +03:00
|
|
|
items.push(Item {
|
|
|
|
id: uuid::Uuid::new_v4().to_string(),
|
|
|
|
name,
|
|
|
|
description,
|
|
|
|
tags,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
view! {
|
|
|
|
<div>
|
|
|
|
<h1>CompareWare</h1>
|
2024-12-09 13:56:39 +03:00
|
|
|
<ItemForm on_submit=Box::new(add_item) />
|
|
|
|
<ItemsList items={items_signal.get().clone()} />
|
2024-12-06 14:45:14 +03:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|