Improved card with new reservations.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use leptos::*;
|
||||
use crate::backend::data::{ApiResponse, ResSumWithItems};
|
||||
use crate::backend::data::{ApiResponse, Page, ResSumWithItems};
|
||||
use crate::backend::reservation::{Approve, Cancel, get_new_reservations};
|
||||
use crate::components::data_form::QuestionDialog;
|
||||
use crate::components::modal_box::{DialogOpener, ModalBody, ModalDialog};
|
||||
@@ -56,8 +56,12 @@ fn create_dialog(opener: DialogOpener) -> impl IntoView {
|
||||
#[component]
|
||||
pub fn new_reservations(app_opener: DialogOpener, cancel_opener: DialogOpener) -> impl IntoView {
|
||||
let create = DialogOpener::new();
|
||||
let res = create_blocking_resource(move || app_opener.visible() || cancel_opener.visible() || create.visible(),
|
||||
move |_| get_new_reservations());
|
||||
let page = create_rw_signal(Page::new(5));
|
||||
let first = create_rw_signal(false);
|
||||
let last = create_rw_signal(false);
|
||||
let total_pages = create_rw_signal(0i32);
|
||||
let res = create_blocking_resource(move || (app_opener.visible() || cancel_opener.visible() || create.visible(), page),
|
||||
move |d| get_new_reservations(d.1.get()));
|
||||
let reservation = create_rw_signal(ResSumWithItems::default());
|
||||
|
||||
view! {
|
||||
@@ -74,9 +78,12 @@ pub fn new_reservations(app_opener: DialogOpener, cancel_opener: DialogOpener) -
|
||||
view! {<div>{trl("Something went wrong")}<br/>{e.to_string()}</div>}}
|
||||
Ok(r) => { match r {
|
||||
ApiResponse::Data(r) => {
|
||||
first.set(r.is_first());
|
||||
last.set(r.is_last());
|
||||
total_pages.set(r.total_pages());
|
||||
view! {
|
||||
<div>
|
||||
<For each=move || r.clone()
|
||||
<For each=move || r.data()
|
||||
key=|res| res.summary.id()
|
||||
let:data>
|
||||
{move || {
|
||||
@@ -144,6 +151,19 @@ pub fn new_reservations(app_opener: DialogOpener, cancel_opener: DialogOpener) -
|
||||
<a href="#" class="card-link" on:click=move |_| create.show()>
|
||||
<i class="bx bx-plus-circle fs-4 lh-0"></i>
|
||||
</a>
|
||||
<a href="#" class={move || {if first.get() {"card-link disabled"} else {"card-link"}}} on:click=move |_| page.update(move |p| p.first())>
|
||||
<i class="bx bx-first-page fs-4 lh-0"></i>
|
||||
</a>
|
||||
<a href="#" class={move || {if first.get() {"card-link disabled"} else {"card-link"}}} on:click=move |_| page.update(move |p| p.prev())>
|
||||
<i class="bx bx-chevron-left fs-4 lh-0"></i>
|
||||
</a>
|
||||
<span class="card-link">{move || page.get().page_num()}</span>
|
||||
<a href="#" class={move || {if last.get() {"card-link disabled"} else {"card-link"}}} on:click=move |_| page.update(move |p| p.next())>
|
||||
<i class="bx bx-chevron-right fs-4 lh-0"></i>
|
||||
</a>
|
||||
<a href="#" class={move || {if last.get() {"card-link disabled"} else {"card-link"}}} on:click=move |_| page.update(move |p| p.go_to(total_pages.get()))>
|
||||
<i class="bx bx-last-page fs-4 lh-0"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user