v0.10-frontend3

This commit is contained in:
2022-11-01 15:29:02 +05:30
parent ef128c6bb7
commit b64633bf53
2 changed files with 11 additions and 3 deletions

View File

@@ -173,6 +173,7 @@ async fn ListDB<G: Html>(cx: Scope<'_>) -> View<G> {
#[component(inline_props)]
pub fn BookDB<G: Html>(cx: Scope, bookitem: BookUIProp) -> View<G> {
let book = bookitem.bookitem.clone();
let coverurl = book.cover.clone().unwrap_or("http://localhost:8081/images/placeholder.jpg".to_string());
let handle_delete = move |_| {
spawn_local(async move {
let temp = delete_book(book.id).await.unwrap();
@@ -181,11 +182,16 @@ pub fn BookDB<G: Html>(cx: Scope, bookitem: BookUIProp) -> View<G> {
};
view! { cx,
li{
div(class="column"){
div(class="card"){
img(src=coverurl,width="100")
(format!("{:?}",book))
button(class="delete", on:click=handle_delete){ "-" }
}
}
}
}
#[component]
@@ -236,6 +242,7 @@ async fn ListOL<G: Html>(cx: Scope<'_>) -> View<G> {
pub fn BookOL<G: Html>(cx: Scope, bookitem: BookUIProp) -> View<G> {
let book = bookitem.bookitem.clone();
let bookdisp=book.clone();
let coverurl = book.cover.clone().unwrap_or("http://localhost:8081/images/placeholder.jpg".to_string());
let app_state = use_context::<AppState>(cx);
let handle_add = move |_| {
app_state.adding.set(true);
@@ -245,7 +252,8 @@ pub fn BookOL<G: Html>(cx: Scope, bookitem: BookUIProp) -> View<G> {
view! { cx,
div(class="column"){
div(class="card"){
(format!("{:?}",bookdisp))
img(src=coverurl,width="100")
(format!("{:?}",bookdisp))
button(class="add", on:click=handle_add){ "+" }
}
}