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

@@ -217,7 +217,7 @@ let mut vec = Vec::with_capacity(12);
let doc = resjson.docs[i].clone(); let doc = resjson.docs[i].clone();
vec.push( vec.push(
BookUI{ BookUI{
id: (i+1) as i32, id: -((i+1) as i32),
open_library_key: Some(doc.key), open_library_key: Some(doc.key),
title: doc.title, title: doc.title,
edition_count: doc.edition_count, edition_count: doc.edition_count,

View File

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