Cleanup
This commit is contained in:
@@ -156,7 +156,7 @@ fn day_counts(partials: &[TicketPartial]) -> [usize; 7] {
|
||||
chrono::Weekday::Sun => 6,
|
||||
};
|
||||
occ[idx] += 1;
|
||||
current = current + chrono::Duration::days(1);
|
||||
current += chrono::Duration::days(1);
|
||||
}
|
||||
|
||||
occ
|
||||
@@ -236,7 +236,7 @@ pub fn diagnostics_component() -> Html {
|
||||
/// ```
|
||||
#[component(TicketCount)]
|
||||
pub fn ticket_count_component() -> Html {
|
||||
let tickets = use_state(|| Vec::<Ticket>::new());
|
||||
let tickets = use_state(Vec::<Ticket>::new);
|
||||
let error = use_state(|| None::<String>);
|
||||
let loading = use_state(|| false);
|
||||
let user = use_state(|| ActiveUser {
|
||||
@@ -252,7 +252,7 @@ pub fn ticket_count_component() -> Html {
|
||||
use_effect_with((), move |_| {
|
||||
loading.set(true);
|
||||
spawn_local(async move {
|
||||
let url = format!("/api/tickets");
|
||||
let url = "/api/tickets".to_string();
|
||||
match Request::get(&url).send().await {
|
||||
Ok(response) if response.status() == 200 => {
|
||||
match response.json::<Vec<Ticket>>().await {
|
||||
@@ -284,9 +284,8 @@ pub fn ticket_count_component() -> Html {
|
||||
.credentials(web_sys::RequestCredentials::Include)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
if response.status() == 200 {
|
||||
if let Ok(json) = response.json::<serde_json::Value>().await {
|
||||
&& response.status() == 200
|
||||
&& let Ok(json) = response.json::<serde_json::Value>().await {
|
||||
let id = json
|
||||
.get("data")
|
||||
.and_then(|d| d.get("id"))
|
||||
@@ -299,8 +298,6 @@ pub fn ticket_count_component() -> Html {
|
||||
.unwrap_or(false);
|
||||
user.set(ActiveUser { id, is_admin });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|| ()
|
||||
});
|
||||
@@ -316,7 +313,7 @@ pub fn ticket_count_component() -> Html {
|
||||
.iter()
|
||||
.filter(|t| {
|
||||
status_conditions(t)
|
||||
&& (user.is_admin || user.id.map_or(false, |uid| t.user_id == uid))
|
||||
&& (user.is_admin || (user.id == Some(t.user_id)))
|
||||
})
|
||||
.count();
|
||||
html! {
|
||||
@@ -357,8 +354,8 @@ pub fn ticket_count_component() -> Html {
|
||||
/// ```
|
||||
#[component(SubmitStats)]
|
||||
pub fn submit_stats_component() -> Html {
|
||||
let tickets = use_state(|| Vec::<TicketPartial>::new());
|
||||
let users = use_state(|| Vec::<UserPartial>::new());
|
||||
let tickets = use_state(Vec::<TicketPartial>::new);
|
||||
let users = use_state(Vec::<UserPartial>::new);
|
||||
let error = use_state(|| None::<String>);
|
||||
let loading = use_state(|| false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user