All checks were successful
actionlint check / actionlint check (pull_request) Successful in 8s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 3s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 6s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 7s
GitLeaks check / GitLeaks check (pull_request) Successful in 13s
hadolint check / hadolint check (pull_request) Successful in 13s
markdownlint check / markdownlint check (pull_request) Successful in 31s
htmlhint check / htmlhint check (pull_request) Successful in 40s
Prettier check / Prettier check (pull_request) Successful in 30s
checkov check / checkov check (pull_request) Successful in 1m16s
Stylelint check / Stylelint check (pull_request) Successful in 22s
ShellCheck check / ShellCheck check (pull_request) Successful in 50s
yamllint check / yamllint check (pull_request) Successful in 44s
Rust check / Rust check (pull_request) Successful in 58m3s
113 lines
4.8 KiB
Rust
113 lines
4.8 KiB
Rust
use crate::internationalization::LocaleFromLanguageIdentifier;
|
|
use crate::models::category::Category;
|
|
use crate::models::task::TaskWithSubtasks;
|
|
use chrono::{Datelike, Local};
|
|
use dioxus::core_macro::rsx;
|
|
use dioxus::dioxus_core::Element;
|
|
use dioxus::prelude::*;
|
|
use dioxus_free_icons::Icon;
|
|
use dioxus_free_icons::icons::fa_solid_icons::{FaBomb, FaClock, FaListCheck};
|
|
use dioxus_i18n::prelude::i18n;
|
|
use dioxus_i18n::t;
|
|
use voca_rs::Voca;
|
|
|
|
#[component]
|
|
pub(crate) fn TaskListItem(task: TaskWithSubtasks) -> Element {
|
|
let today_date = Local::now().date_naive();
|
|
rsx! {
|
|
div {
|
|
class: "pt-0.75 flex flex-col",
|
|
div {
|
|
class: "grow font-medium text-pretty wrap-anywhere",
|
|
{task.task.title}
|
|
},
|
|
div {
|
|
class: "flex flex-row gap-4",
|
|
if let Some(deadline) = task.task.deadline {
|
|
div {
|
|
class: "flex flex-row items-center gap-1 text-sm text-gray-500",
|
|
Icon {
|
|
icon: FaBomb,
|
|
height: 14,
|
|
width: 14
|
|
}
|
|
{
|
|
format!(
|
|
" {}",
|
|
if deadline == today_date - chrono::Days::new(1) {
|
|
t!("yesterday")
|
|
} else if deadline == today_date {
|
|
t!("today")
|
|
} else if deadline == today_date + chrono::Days::new(1) {
|
|
t!("tomorrow")
|
|
} else if deadline > today_date
|
|
&& deadline <= today_date + chrono::Days::new(7) {
|
|
let deadline = deadline.format_localized(
|
|
"%A",
|
|
LocaleFromLanguageIdentifier::from(
|
|
&i18n().language()
|
|
).into()
|
|
).to_string();
|
|
if t!("weekday-lowercase-first")
|
|
.parse().unwrap() {
|
|
deadline._lower_first()
|
|
} else {
|
|
deadline
|
|
}
|
|
} else {
|
|
let format = t!(
|
|
if deadline.year() == today_date.year() {
|
|
"date-format"
|
|
} else {
|
|
"date-year-format"
|
|
}
|
|
);
|
|
deadline.format_localized(
|
|
format.as_str(),
|
|
LocaleFromLanguageIdentifier::from(
|
|
&i18n().language()
|
|
).into()
|
|
).to_string()
|
|
}
|
|
)
|
|
}
|
|
}
|
|
}
|
|
if let Category::Calendar { time, .. } = task.task.category {
|
|
if let Some(calendar_time) = time {
|
|
div {
|
|
class: "flex flex-row items-center gap-1 text-sm text-gray-500",
|
|
Icon {
|
|
icon: FaClock,
|
|
height: 14,
|
|
width: 14
|
|
}
|
|
{
|
|
let format = t!("time-format");
|
|
format!(" {}", calendar_time.time.format(format.as_str()))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if !task.subtasks.is_empty() {
|
|
div {
|
|
class: "flex flex-row items-center gap-1 text-sm text-gray-500",
|
|
Icon {
|
|
icon: FaListCheck,
|
|
height: 14,
|
|
width: 14
|
|
}
|
|
{format!(
|
|
" {}/{}",
|
|
task.subtasks.iter()
|
|
.filter(|subtask| subtask.is_completed)
|
|
.count(),
|
|
task.subtasks.len()
|
|
)}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|