home fragmentization

This commit is contained in:
Zynh0722 2023-11-04 02:11:30 -07:00
parent 3de7389500
commit 76fb971a24
3 changed files with 25 additions and 19 deletions

View file

@ -53,7 +53,7 @@ async fn open_shift(State(state): State<AppState>) -> impl IntoResponse {
.unwrap()
};
render!(crate::templates::home_html, shift)
render!(crate::templates::components::home_fragment_html, shift)
}
async fn close_shift(State(state): State<AppState>, Path(id): Path<u32>) -> impl IntoResponse {

View file

@ -0,0 +1,22 @@
@use super::shift_button_html;
@use cm_lib::models::Shift;
@(open_shift: Option<Shift>)
<main>
<div>
@:shift_button_html(open_shift.as_ref())
</div>
@if open_shift.is_some() {
<div hx-boost="true">
<a href="/shifts/@open_shift.unwrap().id/drinks">
<button>Drinks</button>
</a>
</div>
}
<div hx-boost="true">
<a href="/shift_reports">
<button>Shift Reports</button>
</a>
</div>
</main>

View file

@ -1,27 +1,11 @@
@use super::base_html;
@use super::components::shift_button_html;
@use super::components::home_fragment_html;
@use cm_lib::models::Shift;
@(open_shift: Option<Shift>)
@:base_html({
<main>
<div>
@:shift_button_html(open_shift.as_ref())
</div>
@if open_shift.is_some() {
<div hx-boost="true">
<a href="/shifts/@open_shift.unwrap().id/drinks">
<button>Drinks</button>
</a>
</div>
}
<div hx-boost="true">
<a href="/shift_reports">
<button>Shift Reports</button>
</a>
</div>
</main>
@:home_fragment_html(open_shift)
})