diff --git a/src/components/category_today_task_list.rs b/src/components/category_today_task_list.rs index 772847c..b09982e 100644 --- a/src/components/category_today_task_list.rs +++ b/src/components/category_today_task_list.rs @@ -2,8 +2,9 @@ use crate::components::task_list::TaskList; use crate::hooks::use_tasks_with_subtasks_in_category; use crate::internationalization::LocaleFromLanguageIdentifier; use crate::models::category::Category; -use crate::models::task::TaskWithSubtasks; -use chrono::Local; +use crate::models::task::{Task, TaskWithSubtasks}; +use crate::route::Route; +use chrono::{Local, NaiveDateTime}; use dioxus::prelude::*; use dioxus_free_icons::Icon; use dioxus_free_icons::icons::fa_solid_icons::{FaCalendarCheck, FaCalendarXmark, FaWater}; @@ -42,6 +43,7 @@ pub(crate) fn CategoryTodayTaskList() -> Element { .cloned() .collect::>(); let long_term_tasks = use_tasks_with_subtasks_in_category(Category::LongTerm)?; + let inbox_tasks = use_tasks_with_subtasks_in_category(Category::Inbox)?; rsx! { div { @@ -116,8 +118,32 @@ pub(crate) fn CategoryTodayTaskList() -> Element { } } } - TaskList { - tasks: today_tasks + div { + TaskList { + tasks: today_tasks + } + if !inbox_tasks.is_empty() { + Link { + to: Route::CategoryInboxPage {}, + TaskList { + is_interactive: false, + tasks: vec![ + TaskWithSubtasks { + task: Task { + id: 0, + title: t!("empty-inbox")._upper_first(), + deadline: None, + category: Category::Inbox, + project_id: None, + created_at: NaiveDateTime::default(), + updated_at: NaiveDateTime::default() + }, + subtasks: Vec::new() + } + ] + } + } + } } } } diff --git a/src/components/task_list.rs b/src/components/task_list.rs index 1d1bc8d..008cf6d 100644 --- a/src/components/task_list.rs +++ b/src/components/task_list.rs @@ -9,7 +9,12 @@ use dioxus::dioxus_core::Element; use dioxus::prelude::*; #[component] -pub(crate) fn TaskList(tasks: Vec, class: Option<&'static str>) -> Element { +pub(crate) fn TaskList( + tasks: Vec, + /// Whether to open and complete tasks on clicks. + is_interactive: Option, + class: Option<&'static str>, +) -> Element { let navigator = use_navigator(); rsx! { div { @@ -34,6 +39,9 @@ pub(crate) fn TaskList(tasks: Vec, class: Option<&'static str> onclick: { let task = task.clone(); move |_| { + if let Some(false) = is_interactive { + return; + } *TASK_BEING_EDITED.write() = Some(task.task.clone()); navigator.push(Route::TaskFormPage); } @@ -49,6 +57,9 @@ pub(crate) fn TaskList(tasks: Vec, class: Option<&'static str> // To prevent editing the task. event.stop_propagation(); async move { + if let Some(false) = is_interactive { + return; + } let _ = complete_task(task.task.id).await; } } diff --git a/src/internationalization/cs_cz.ftl b/src/internationalization/cs_cz.ftl index 5053f6f..62385df 100644 --- a/src/internationalization/cs_cz.ftl +++ b/src/internationalization/cs_cz.ftl @@ -4,6 +4,7 @@ yesterday = včera today = dnes tomorrow = zítra overdue = zpožděné +empty-inbox = vyprázdnit schránku ## Date and time formats date-format = %-d. %B diff --git a/src/internationalization/en_us.ftl b/src/internationalization/en_us.ftl index ac823d4..e72dcd7 100644 --- a/src/internationalization/en_us.ftl +++ b/src/internationalization/en_us.ftl @@ -4,6 +4,7 @@ yesterday = yesterday today = today tomorrow = tomorrow overdue = overdue +empty-inbox = empty the inbox ## Date and time formats date-format = %B %-d