|
|
@ -1,18 +1,25 @@
|
|
|
|
use chrono::{Datelike, Local};
|
|
|
|
use chrono::{Datelike, Local};
|
|
|
|
use leptos::*;
|
|
|
|
use leptos::*;
|
|
|
|
use crate::backend::data::{ApiResponse, ResSumWithItems};
|
|
|
|
use crate::backend::data::{ApiResponse, ReservationState, ResSumWithItems};
|
|
|
|
use crate::backend::reservation::{month_chart, reservations_in_month, year_chart, years};
|
|
|
|
use crate::backend::reservation::{month_chart, reservations_in_month, year_chart, years};
|
|
|
|
use crate::components::modal_box::{DialogOpener, ModalBody, ModalDialog};
|
|
|
|
use crate::components::modal_box::{DialogOpener, ModalBody, ModalDialog};
|
|
|
|
|
|
|
|
use crate::components::user_menu::MenuOpener;
|
|
|
|
use crate::locales::{loc_date, show_day, trl};
|
|
|
|
use crate::locales::{loc_date, show_day, trl};
|
|
|
|
|
|
|
|
use crate::pages::new_reservations::CancelDialog;
|
|
|
|
|
|
|
|
|
|
|
|
#[component]
|
|
|
|
#[component]
|
|
|
|
fn booking_detail(reservation: ReadSignal<ResSumWithItems>, opener: DialogOpener) -> impl IntoView {
|
|
|
|
fn booking_detail(reservation: ReadSignal<ResSumWithItems>, opener: DialogOpener) -> impl IntoView {
|
|
|
|
|
|
|
|
let menu = MenuOpener::new();
|
|
|
|
|
|
|
|
let cancel_opener = DialogOpener::new();
|
|
|
|
|
|
|
|
let menu_visible = create_rw_signal(false);
|
|
|
|
view! {
|
|
|
|
view! {
|
|
|
|
|
|
|
|
<CancelDialog opener=cancel_opener reservation=reservation/>
|
|
|
|
<ModalDialog title="Booking detail" opener=opener>
|
|
|
|
<ModalDialog title="Booking detail" opener=opener>
|
|
|
|
<ModalBody>
|
|
|
|
<ModalBody>
|
|
|
|
<p>
|
|
|
|
<p>
|
|
|
|
{move || {
|
|
|
|
{move || {
|
|
|
|
let detail = reservation.get();
|
|
|
|
let detail = reservation.get();
|
|
|
|
|
|
|
|
menu_visible.set(detail.summary.state != ReservationState::Canceled);
|
|
|
|
view! {
|
|
|
|
view! {
|
|
|
|
<b>{show_day(&detail.summary.date.weekday())}" - "{loc_date(detail.summary.date)}</b><br/>
|
|
|
|
<b>{show_day(&detail.summary.date.weekday())}" - "{loc_date(detail.summary.date)}</b><br/>
|
|
|
|
<For each=move || detail.reservations.clone()
|
|
|
|
<For each=move || detail.reservations.clone()
|
|
|
@ -30,10 +37,33 @@ fn booking_detail(reservation: ReadSignal<ResSumWithItems>, opener: DialogOpener
|
|
|
|
</Show>
|
|
|
|
</Show>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{trl("Price: ")}{detail.summary.price.to_string()}<br/>
|
|
|
|
{trl("Price: ")}{detail.summary.price.to_string()}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<Show when=move || menu_visible.get()>
|
|
|
|
|
|
|
|
<table width="100%">
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
<td width="100%"></td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
|
|
|
|
<div class="dropdown">
|
|
|
|
|
|
|
|
<button type="button" class="btn p-0 dropdown-toggle hide-arrow"
|
|
|
|
|
|
|
|
on:click=move |_| menu.toggle()>
|
|
|
|
|
|
|
|
<i class="bx bx-dots-vertical-rounded"></i>
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<div class={move || if menu.visible() {"dropdown-menu show"} else {"dropdown-menu"} }
|
|
|
|
|
|
|
|
style="position: absolute; insert: 0px 0px auto; margin: 0px; transform: translate3d(-160px, 0px, 0px);"
|
|
|
|
|
|
|
|
on:mouseleave=move |_| menu.toggle()>
|
|
|
|
|
|
|
|
<a class="dropdown-item text-danger" href="javascript:void(0);" on:click=move |_| {
|
|
|
|
|
|
|
|
cancel_opener.show();
|
|
|
|
|
|
|
|
}>
|
|
|
|
|
|
|
|
<i class="bx bx-trash me-1"></i> {trl("Cancel")}</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
</Show>
|
|
|
|
</ModalBody>
|
|
|
|
</ModalBody>
|
|
|
|
</ModalDialog>
|
|
|
|
</ModalDialog>
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -46,10 +76,10 @@ pub fn bookings() -> impl IntoView {
|
|
|
|
let year = create_rw_signal(Local::now().year());
|
|
|
|
let year = create_rw_signal(Local::now().year());
|
|
|
|
let month = create_rw_signal(Local::now().month());
|
|
|
|
let month = create_rw_signal(Local::now().month());
|
|
|
|
let chart = create_blocking_resource(move || year.get(),move |y| month_chart(y));
|
|
|
|
let chart = create_blocking_resource(move || year.get(),move |y| month_chart(y));
|
|
|
|
let reservations = create_blocking_resource(move || (year.get(), month.get()), move |p| reservations_in_month(p.0, p.1));
|
|
|
|
let detail_dlg = DialogOpener::new();
|
|
|
|
|
|
|
|
let reservations = create_blocking_resource(move || (year.get(), month.get(), detail_dlg.visible()), move |p| reservations_in_month(p.0, p.1));
|
|
|
|
let all_months: Vec<u32> = vec![1,2,3,4,5,6,7,8,9,10,11,12];
|
|
|
|
let all_months: Vec<u32> = vec![1,2,3,4,5,6,7,8,9,10,11,12];
|
|
|
|
let res_detail = create_rw_signal(ResSumWithItems::default());
|
|
|
|
let res_detail = create_rw_signal(ResSumWithItems::default());
|
|
|
|
let detail_dlg = DialogOpener::new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view! {
|
|
|
|
view! {
|
|
|
|
<h1>{trl("Booking overview")}</h1>
|
|
|
|
<h1>{trl("Booking overview")}</h1>
|
|
|
|