|
|
|
|
@ -1,25 +1,30 @@
|
|
|
|
|
use std::marker::PhantomData;
|
|
|
|
|
|
|
|
|
|
use perseus::{navigate, Html, RenderFnResult, RenderFnResultWithCause, SsrNode, Template};
|
|
|
|
|
use sycamore::prelude::*;
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
api::types::{company::Company, transaction::TransactionCompany},
|
|
|
|
|
api::{
|
|
|
|
|
routes::transaction::get_transactions,
|
|
|
|
|
types::{company::Company, transaction::TransactionCompany},
|
|
|
|
|
},
|
|
|
|
|
components::{
|
|
|
|
|
base_async_select::{AsyncSelectRx, BaseAsyncSelect},
|
|
|
|
|
base_button::{BaseButton, BaseButtonStateRx},
|
|
|
|
|
paginated_data_table::{PaginatedTable, PaginatedTableStateRx},
|
|
|
|
|
},
|
|
|
|
|
env::Config,
|
|
|
|
|
global_state::AppStateRx,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#[perseus::make_rx(IndexPageStateRx)]
|
|
|
|
|
pub struct IndexPageState {
|
|
|
|
|
pub req: String,
|
|
|
|
|
pub company_slug: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[perseus::template_rx]
|
|
|
|
|
pub fn index_page(IndexPageStateRx { req }: IndexPageStateRx, global_state: AppStateRx) -> View<G> {
|
|
|
|
|
pub fn index_page(
|
|
|
|
|
IndexPageStateRx { company_slug }: IndexPageStateRx,
|
|
|
|
|
global_state: AppStateRx,
|
|
|
|
|
) -> View<G> {
|
|
|
|
|
let dark_mode = global_state.dark_mode;
|
|
|
|
|
let dark_mode_2 = dark_mode.clone();
|
|
|
|
|
let dark_mode_3 = dark_mode.clone();
|
|
|
|
|
@ -40,12 +45,18 @@ pub fn index_page(IndexPageStateRx { req }: IndexPageStateRx, global_state: AppS
|
|
|
|
|
|
|
|
|
|
let toggle_dark_mode = cloned!(() => move |_| dark_mode_2.set(!*dark_mode.get()));
|
|
|
|
|
|
|
|
|
|
let paginated_table_state: PaginatedTableStateRx<TransactionCompany> = PaginatedTableStateRx {
|
|
|
|
|
req,
|
|
|
|
|
ph_data: Signal::new(PhantomData),
|
|
|
|
|
};
|
|
|
|
|
let paginated_table_state: PaginatedTableStateRx<TransactionCompany, _, _> =
|
|
|
|
|
PaginatedTableStateRx {
|
|
|
|
|
route: get_transactions,
|
|
|
|
|
filter: if (*company_slug.get()).is_empty() {
|
|
|
|
|
None
|
|
|
|
|
} else {
|
|
|
|
|
Some((*company_slug.get()).clone())
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let async_select_prop: AsyncSelectRx<Company> = AsyncSelectRx {
|
|
|
|
|
remote_list: Signal::new(format!("{}company/", global_state.config.get().api_url)).handle(),
|
|
|
|
|
selected_item: Signal::new(None),
|
|
|
|
|
};
|
|
|
|
|
let async_select_prop2 = async_select_prop.clone();
|
|
|
|
|
@ -67,7 +78,6 @@ pub fn index_page(IndexPageStateRx { req }: IndexPageStateRx, global_state: AppS
|
|
|
|
|
|
|
|
|
|
view! {
|
|
|
|
|
main (class=if *dark_mode_3.get() { "dark" } else { "" }) {
|
|
|
|
|
link (rel="stylesheet", href = "/.perseus/static/tailwind.css") {}
|
|
|
|
|
div (class="bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-100 font-sans") {
|
|
|
|
|
header (class="shadow-md h-12 p-2 align-middle w-full bg-gray-100 dark:bg-slate-500/30 backdrop-blur-lg") {
|
|
|
|
|
div (class="flex flex-row justify-between") {
|
|
|
|
|
@ -101,7 +111,7 @@ pub fn index_page(IndexPageStateRx { req }: IndexPageStateRx, global_state: AppS
|
|
|
|
|
div (class="w-80") {
|
|
|
|
|
p () {"Search for a company:"}
|
|
|
|
|
BaseAsyncSelect(async_select_prop)
|
|
|
|
|
BaseButton(search_button)
|
|
|
|
|
BaseButton(search_button)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PaginatedTable(paginated_table_state)
|
|
|
|
|
@ -134,8 +144,7 @@ pub async fn get_build_state(
|
|
|
|
|
_locale: String,
|
|
|
|
|
) -> RenderFnResultWithCause<IndexPageState> {
|
|
|
|
|
let company_slug: String = path.clone().drain("index".len()..).collect();
|
|
|
|
|
let req = format!("http://localhost:8000/v1/transaction{}", company_slug);
|
|
|
|
|
Ok(IndexPageState { req })
|
|
|
|
|
Ok(IndexPageState { company_slug })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn get_build_paths() -> RenderFnResult<Vec<String>> {
|
|
|
|
|
|