|
|
|
|
@ -1,9 +1,17 @@
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
|
|
use perseus::prelude::*;
|
|
|
|
|
use sycamore::{prelude::*, rt::Event};
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
components::{
|
|
|
|
|
loading::Loading, main_content_container::MainContentContainer, the_header::TheHeader,
|
|
|
|
|
base_async_select::{AsyncSelectRx, BaseAsyncSelect},
|
|
|
|
|
base_button::{BaseButton, BaseButtonStateRx},
|
|
|
|
|
base_table::BaseTable,
|
|
|
|
|
loading::Loading,
|
|
|
|
|
main_content_container::MainContentContainer,
|
|
|
|
|
paginated_data_table::{PaginatedTable, PaginatedTableStateRx},
|
|
|
|
|
the_header::TheHeader,
|
|
|
|
|
},
|
|
|
|
|
global_state::AppStateRx,
|
|
|
|
|
};
|
|
|
|
|
@ -46,15 +54,53 @@ fn profile_page<G: Html>(cx: BoundedScope) -> View<G> {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let async_select_route_ref = create_ref(cx, |n, l| api_scope_ref.get_company_by_name(n, l));
|
|
|
|
|
let async_select_prop: AsyncSelectRx<_, _, _> = AsyncSelectRx {
|
|
|
|
|
route: async_select_route_ref,
|
|
|
|
|
selected_item: create_signal(cx, None),
|
|
|
|
|
clear: create_signal(cx, false),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let table_route_ref = create_ref(cx, move |_, p, s| {
|
|
|
|
|
api_scope_ref.get_followed_companies(p, s)
|
|
|
|
|
});
|
|
|
|
|
let paginated_table_state: PaginatedTableStateRx<_, _, _> = PaginatedTableStateRx {
|
|
|
|
|
record_label: "Companies".to_owned(),
|
|
|
|
|
route: table_route_ref,
|
|
|
|
|
filter: None,
|
|
|
|
|
table_class: create_ref(cx, "w-full".to_string()),
|
|
|
|
|
refresh: create_signal(cx, true),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let follow_button = BaseButtonStateRx {
|
|
|
|
|
label: create_signal(cx, "Follow".to_string()),
|
|
|
|
|
disabled: create_memo(cx, move || async_select_prop.selected_item.get().is_none()),
|
|
|
|
|
clicked: create_signal(cx, false),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
create_effect(cx, move || {
|
|
|
|
|
if *follow_button.clicked.get() && async_select_prop.selected_item.get_untracked().is_some()
|
|
|
|
|
{
|
|
|
|
|
follow_button.clicked.set(false);
|
|
|
|
|
if let Some(company) = (*async_select_prop.selected_item.get_untracked()).clone() {
|
|
|
|
|
spawn_local_scoped(cx, async move {
|
|
|
|
|
api_scope_ref.follow_company(company.id).await.unwrap();
|
|
|
|
|
paginated_table_state.refresh.set(true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
async_select_prop.clear.set(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
view! {cx,
|
|
|
|
|
main (class=format!("{} flex flex-1", dark_mode_class)) {
|
|
|
|
|
div (class="flex-1 font-sans bg-slate-200 text-slate-700 dark:bg-slate-700 dark:text-slate-100") {
|
|
|
|
|
TheHeader()
|
|
|
|
|
MainContentContainer(useless_prop=1) {
|
|
|
|
|
div(class="items-center m-auto w-2/5 min-w-70") {
|
|
|
|
|
h1(class="text-lg text-center") {
|
|
|
|
|
"Profile page"
|
|
|
|
|
}
|
|
|
|
|
div(class="m-auto w-full max-w-2xl") {
|
|
|
|
|
(if !*loading.get() {
|
|
|
|
|
view! {cx,
|
|
|
|
|
p() {
|
|
|
|
|
@ -83,6 +129,12 @@ fn profile_page<G: Html>(cx: BoundedScope) -> View<G> {
|
|
|
|
|
Loading()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
h2(class="mt-3 font-bold") {
|
|
|
|
|
"Follow companies"
|
|
|
|
|
}
|
|
|
|
|
BaseAsyncSelect(async_select_prop)
|
|
|
|
|
BaseButton(follow_button)
|
|
|
|
|
PaginatedTable(paginated_table_state)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|