| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#![allow(clippy::needless_pass_by_value)] |
| 28 |
|
| 29 |
use chrono::{Datelike, NaiveDate}; |
| 30 |
use goingson_core::monthly_review::{self, MonthlyReviewData, ProjectPulse}; |
| 31 |
use goingson_core::{MonthlyGoal, MonthlyGoalStatus, Task}; |
| 32 |
use makeover_layout::Tone; |
| 33 |
use quasi_declare::declare; |
| 34 |
use quasi_router::screen::{Figure, Tag}; |
| 35 |
use quasi_router::{Action, Response, RouteError, Router}; |
| 36 |
|
| 37 |
use crate::commands::gather_monthly_review; |
| 38 |
use crate::state::{AppState, DESKTOP_USER_ID}; |
| 39 |
|
| 40 |
#[cfg(test)] |
| 41 |
mod tests; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
const GOAL_SLOTS: i32 = 3; |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
fn month_of(request: &quasi_router::Request) -> NaiveDate { |
| 60 |
request |
| 61 |
.carried |
| 62 |
.get("month") |
| 63 |
.and_then(monthly_review::parse_month) |
| 64 |
.unwrap_or_else(monthly_review::current_month_start) |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
fn in_month(action: Action, month: NaiveDate) -> Action { |
| 69 |
action.carrying("month", month.format("%Y-%m").to_string()) |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
fn step(month: NaiveDate, forward: bool) -> NaiveDate { |
| 78 |
let (year, number) = match (month.month(), forward) { |
| 79 |
(12, true) => (month.year() + 1, 1), |
| 80 |
(1, false) => (month.year() - 1, 12), |
| 81 |
(m, true) => (month.year(), m + 1), |
| 82 |
(m, false) => (month.year(), m - 1), |
| 83 |
}; |
| 84 |
NaiveDate::from_ymd_opt(year, number, 1).unwrap_or(month) |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
fn load(state: &AppState, month: NaiveDate) -> Result<MonthlyReviewData, RouteError> { |
| 89 |
gather_monthly_review(state, month).map_err(|error| RouteError::internal(error.to_string())) |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
fn health_tone(status: &str) -> makeover_layout::Tone { |
| 100 |
match status { |
| 101 |
"healthy" => makeover_layout::Tone::Success, |
| 102 |
"warning" => makeover_layout::Tone::Warning, |
| 103 |
"danger" => makeover_layout::Tone::Danger, |
| 104 |
_ => makeover_layout::Tone::Neutral, |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
declare! { |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
shape task_row(task: &Task) -> Row; |
| 115 |
|
| 116 |
row &task.title { |
| 117 |
for project in task.project_name.iter() { |
| 118 |
meta project; |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
struct Marked { |
| 125 |
number: u32, |
| 126 |
is_today: bool, |
| 127 |
is_vacation: bool, |
| 128 |
|
| 129 |
counts: String, |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
fn has_counts(day: &Marked) -> bool { |
| 134 |
!day.counts.is_empty() |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
struct Goal { |
| 158 |
stored: MonthlyGoal, |
| 159 |
|
| 160 |
move_label: &'static str, |
| 161 |
|
| 162 |
next: MonthlyGoalStatus, |
| 163 |
|
| 164 |
status_label: &'static str, |
| 165 |
status_tone: makeover_layout::Tone, |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
struct Review { |
| 170 |
data: MonthlyReviewData, |
| 171 |
month: NaiveDate, |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
days: Vec<Marked>, |
| 179 |
goals: Vec<Goal>, |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
fn read(state: &AppState, month: NaiveDate) -> Result<Review, RouteError> { |
| 184 |
let data = load(state, month)?; |
| 185 |
|
| 186 |
let days = data |
| 187 |
.days |
| 188 |
.iter() |
| 189 |
.filter(|day| day.completed_count > 0 || day.event_count > 0 || day.is_vacation) |
| 190 |
.map(|day| { |
| 191 |
let mut counts = Vec::new(); |
| 192 |
if day.completed_count > 0 { |
| 193 |
counts.push(format!("{} done", day.completed_count)); |
| 194 |
} |
| 195 |
if day.event_count > 0 { |
| 196 |
counts.push(format!("{} events", day.event_count)); |
| 197 |
} |
| 198 |
Marked { |
| 199 |
number: day.day_number, |
| 200 |
is_today: day.is_today, |
| 201 |
is_vacation: day.is_vacation, |
| 202 |
counts: counts.join(", "), |
| 203 |
} |
| 204 |
}) |
| 205 |
.collect(); |
| 206 |
|
| 207 |
let goals = data |
| 208 |
.goals |
| 209 |
.iter() |
| 210 |
.map(|goal| { |
| 211 |
let (move_label, next) = match goal.status { |
| 212 |
MonthlyGoalStatus::Active => ("Mark done", MonthlyGoalStatus::Done), |
| 213 |
MonthlyGoalStatus::Done => ("Give up on it", MonthlyGoalStatus::Abandoned), |
| 214 |
MonthlyGoalStatus::Abandoned => ("Make it active again", MonthlyGoalStatus::Active), |
| 215 |
}; |
| 216 |
let (status_label, status_tone) = match goal.status { |
| 217 |
MonthlyGoalStatus::Active => ("Active", makeover_layout::Tone::Info), |
| 218 |
MonthlyGoalStatus::Done => ("Done", makeover_layout::Tone::Success), |
| 219 |
MonthlyGoalStatus::Abandoned => ("Abandoned", makeover_layout::Tone::Neutral), |
| 220 |
}; |
| 221 |
Goal { |
| 222 |
stored: goal.clone(), |
| 223 |
move_label, |
| 224 |
next, |
| 225 |
status_label, |
| 226 |
status_tone, |
| 227 |
} |
| 228 |
}) |
| 229 |
.collect(); |
| 230 |
|
| 231 |
Ok(Review { |
| 232 |
data, |
| 233 |
month, |
| 234 |
days, |
| 235 |
goals, |
| 236 |
}) |
| 237 |
} |
| 238 |
|
| 239 |
declare! { |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
shape heat_map(review: &Review) -> Vec<Node>; |
| 259 |
|
| 260 |
section "The Month"; |
| 261 |
|
| 262 |
empty "Nothing recorded this month yet." when review.days.is_empty(); |
| 263 |
|
| 264 |
list { |
| 265 |
for day in review.days.iter() { |
| 266 |
row day.number.to_string() { |
| 267 |
token Tag::badge("Today").tone(Tone::Info) when day.is_today; |
| 268 |
token Tag::badge("Day off") when day.is_vacation; |
| 269 |
meta &day.counts when has_counts(day); |
| 270 |
} |
| 271 |
} |
| 272 |
} unless review.days.is_empty(); |
| 273 |
} |
| 274 |
|
| 275 |
declare! { |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
shape numbers(review: &Review) -> Vec<Node>; |
| 284 |
|
| 285 |
section "The Numbers"; |
| 286 |
|
| 287 |
stats [] { |
| 288 |
figure Figure::new(review.data.tasks_completed_count.to_string(), "Tasks Completed"); |
| 289 |
figure Figure::new(review.data.tasks_created_count.to_string(), "Tasks Created"); |
| 290 |
figure Figure::new(review.data.events_count.to_string(), "Events"); |
| 291 |
figure Figure::new(review.data.completion_streak.to_string(), "Longest Streak"); |
| 292 |
|
| 293 |
for busiest in review.data.busiest_day.iter() { |
| 294 |
figure Figure::new(busiest, "Busiest Day"); |
| 295 |
} |
| 296 |
for quietest in review.data.quietest_day.iter() { |
| 297 |
figure Figure::new(quietest, "Quietest Day"); |
| 298 |
} |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
declare! { |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
shape accomplished(review: &Review) -> Vec<Node>; |
| 310 |
|
| 311 |
section "Accomplished" unless review.data.tasks_completed_top.is_empty(); |
| 312 |
|
| 313 |
list { |
| 314 |
for task in review.data.tasks_completed_top.iter() { |
| 315 |
include task_row(task); |
| 316 |
} |
| 317 |
} unless review.data.tasks_completed_top.is_empty(); |
| 318 |
} |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
fn pulse_label(project: &ProjectPulse) -> &'static str { |
| 327 |
match project.direction.as_str() { |
| 328 |
"shrinking" => "Shrinking", |
| 329 |
"growing" => "Growing", |
| 330 |
_ => "Stable", |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
fn pulse_tone(project: &ProjectPulse) -> makeover_layout::Tone { |
| 336 |
match project.direction.as_str() { |
| 337 |
"shrinking" => makeover_layout::Tone::Success, |
| 338 |
"growing" => makeover_layout::Tone::Warning, |
| 339 |
_ => makeover_layout::Tone::Neutral, |
| 340 |
} |
| 341 |
} |
| 342 |
|
| 343 |
declare! { |
| 344 |
|
| 345 |
shape project_pulse(review: &Review) -> Vec<Node>; |
| 346 |
|
| 347 |
section "Project Pulse" unless review.data.project_pulse.is_empty(); |
| 348 |
|
| 349 |
list { |
| 350 |
for project in review.data.project_pulse.iter() { |
| 351 |
row &project.name { |
| 352 |
token Tag::badge(pulse_label(project)).tone(pulse_tone(project)); |
| 353 |
meta "{project.completed} done, {project.created} added"; |
| 354 |
} |
| 355 |
} |
| 356 |
} unless review.data.project_pulse.is_empty(); |
| 357 |
} |
| 358 |
|
| 359 |
declare! { |
| 360 |
|
| 361 |
|
| 362 |
shape projects_health(review: &Review) -> Vec<Node>; |
| 363 |
|
| 364 |
section "Project Health" unless review.data.project_health.is_empty(); |
| 365 |
|
| 366 |
list { |
| 367 |
for project in review.data.project_health.iter() { |
| 368 |
row &project.name { |
| 369 |
token Tag::badge(&project.status).tone(health_tone(&project.status)); |
| 370 |
} |
| 371 |
} |
| 372 |
} unless review.data.project_health.is_empty(); |
| 373 |
} |
| 374 |
|
| 375 |
declare! { |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
shape patterns(review: &Review) -> Vec<Node>; |
| 382 |
|
| 383 |
section "Patterns" unless review.data.patterns.is_empty(); |
| 384 |
|
| 385 |
list { |
| 386 |
for pattern in review.data.patterns.iter() { |
| 387 |
row pattern; |
| 388 |
} |
| 389 |
} unless review.data.patterns.is_empty(); |
| 390 |
} |
| 391 |
|
| 392 |
declare! { |
| 393 |
|
| 394 |
shape goal_row(review: &Review, goal: &Goal) -> Row; |
| 395 |
|
| 396 |
row &goal.stored.text { |
| 397 |
token Tag::badge(goal.status_label).tone(goal.status_tone); |
| 398 |
|
| 399 |
act goal.move_label |
| 400 |
to doing in_month( |
| 401 |
Action::post("/monthly-review/goals/{goal.stored.id}/status") |
| 402 |
.with("status", goal.next.as_str()), |
| 403 |
review.month |
| 404 |
); |
| 405 |
|
| 406 |
act "Delete" |
| 407 |
to doing in_month( |
| 408 |
Action::post("/monthly-review/goals/{goal.stored.id}/delete"), |
| 409 |
review.month |
| 410 |
) { |
| 411 |
tone Danger; |
| 412 |
confirm "Are you sure you want to delete this goal?"; |
| 413 |
} |
| 414 |
} |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
fn has_room(review: &Review) -> bool { |
| 419 |
i32::try_from(review.goals.len()).unwrap_or(GOAL_SLOTS) < GOAL_SLOTS |
| 420 |
} |
| 421 |
|
| 422 |
declare! { |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
shape goals(review: &Review) -> Vec<Node>; |
| 433 |
|
| 434 |
section "Goals"; |
| 435 |
|
| 436 |
for goal in review.goals.iter() { |
| 437 |
list { |
| 438 |
include goal_row(review, goal); |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
form doing in_month(Action::post("/monthly-review/goals"), review.month) |
| 443 |
when has_room(review) { |
| 444 |
submit "Add goal"; |
| 445 |
|
| 446 |
field Text "text" "Goal" { |
| 447 |
placeholder "What do you want to achieve this month?"; |
| 448 |
required; |
| 449 |
} |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
fn reflection_submit(review: &Review) -> &'static str { |
| 457 |
if review.data.reflection.is_some() { |
| 458 |
"Save notes" |
| 459 |
} else { |
| 460 |
"Complete review" |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
|
| 465 |
fn reviewed(review: &Review) -> bool { |
| 466 |
review.data.reflection.is_some() |
| 467 |
} |
| 468 |
|
| 469 |
|
| 470 |
fn highlight(review: &Review) -> String { |
| 471 |
review |
| 472 |
.data |
| 473 |
.reflection |
| 474 |
.as_ref() |
| 475 |
.map(|saved| saved.highlight_text.clone()) |
| 476 |
.unwrap_or_default() |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
fn changed(review: &Review) -> String { |
| 481 |
review |
| 482 |
.data |
| 483 |
.reflection |
| 484 |
.as_ref() |
| 485 |
.map(|saved| saved.change_text.clone()) |
| 486 |
.unwrap_or_default() |
| 487 |
} |
| 488 |
|
| 489 |
declare! { |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
shape reflection(review: &Review) -> Vec<Node>; |
| 503 |
|
| 504 |
section "Reflection"; |
| 505 |
|
| 506 |
form doing in_month(Action::post("/monthly-review/complete"), review.month) { |
| 507 |
submit reflection_submit(review); |
| 508 |
|
| 509 |
field Textarea "highlight" "What was the highlight of this month?" { |
| 510 |
placeholder "Shipped the thing I had been putting off..."; |
| 511 |
value highlight(review); |
| 512 |
} |
| 513 |
|
| 514 |
field Textarea "change" "What would you change?" { |
| 515 |
placeholder "Too many small tasks, not enough deep work..."; |
| 516 |
value changed(review); |
| 517 |
} |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
declare! { |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
shape screen(review: &Review) -> Screen; |
| 532 |
|
| 533 |
screen sidebar_content "Monthly Review" { |
| 534 |
at_place super::shell::MONTH; |
| 535 |
|
| 536 |
region "month-band" as Band { |
| 537 |
page &review.data.month_display; |
| 538 |
|
| 539 |
act "Previous month" |
| 540 |
to doing in_month(Action::get("/monthly-review"), step(review.month, false)); |
| 541 |
act "Next month" |
| 542 |
to doing in_month(Action::get("/monthly-review"), step(review.month, true)); |
| 543 |
act "This month" to get "/monthly-review"; |
| 544 |
} |
| 545 |
|
| 546 |
region "monthly-review" as Pane { |
| 547 |
banner Tone::Info "This month is already reviewed. Your notes stay editable." |
| 548 |
when reviewed(review); |
| 549 |
|
| 550 |
extend heat_map(review); |
| 551 |
extend numbers(review); |
| 552 |
extend accomplished(review); |
| 553 |
extend project_pulse(review); |
| 554 |
extend projects_health(review); |
| 555 |
extend goals(review); |
| 556 |
extend patterns(review); |
| 557 |
extend reflection(review); |
| 558 |
} |
| 559 |
} |
| 560 |
} |
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
fn wrote(state: &AppState, month: NaiveDate) -> Result<Response, RouteError> { |
| 569 |
Ok(screen(&read(state, month)?).into()) |
| 570 |
} |
| 571 |
|
| 572 |
|
| 573 |
fn review(state: &AppState, request: quasi_router::Request) -> Result<Response, RouteError> { |
| 574 |
wrote(state, month_of(&request)) |
| 575 |
} |
| 576 |
|
| 577 |
|
| 578 |
fn month_key(month: NaiveDate) -> String { |
| 579 |
month.format("%Y-%m").to_string() |
| 580 |
} |
| 581 |
|
| 582 |
|
| 583 |
fn goal_id(request: &quasi_router::Request) -> Result<goingson_core::MonthlyGoalId, RouteError> { |
| 584 |
let raw = request |
| 585 |
.captures |
| 586 |
.get("id") |
| 587 |
.ok_or_else(|| RouteError::not_found("no goal id"))?; |
| 588 |
Ok(goingson_core::MonthlyGoalId::from( |
| 589 |
uuid::Uuid::parse_str(raw).map_err(|_| RouteError::not_found("not a goal id"))?, |
| 590 |
)) |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
fn add_goal(state: &AppState, request: quasi_router::Request) -> Result<Response, RouteError> { |
| 600 |
let month = month_of(&request); |
| 601 |
let text = request.payload.get("text").unwrap_or_default().trim(); |
| 602 |
if text.is_empty() { |
| 603 |
return Err(RouteError::conflict("A goal needs some text")); |
| 604 |
} |
| 605 |
|
| 606 |
let key = month_key(month); |
| 607 |
let taken = state |
| 608 |
.monthly_reviews |
| 609 |
.list_goals(DESKTOP_USER_ID, &key) |
| 610 |
.map_err(|error| RouteError::internal(error.to_string()))?; |
| 611 |
if i32::try_from(taken.len()).unwrap_or(GOAL_SLOTS) >= GOAL_SLOTS { |
| 612 |
return Err(RouteError::conflict("This month already has three goals")); |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
let position = (1..=GOAL_SLOTS) |
| 619 |
.find(|slot| !taken.iter().any(|goal| goal.position == *slot)) |
| 620 |
.ok_or_else(|| RouteError::conflict("This month already has three goals"))?; |
| 621 |
|
| 622 |
state |
| 623 |
.monthly_reviews |
| 624 |
.upsert_goal(DESKTOP_USER_ID, &key, text, position) |
| 625 |
.map_err(|error| RouteError::internal(error.to_string()))?; |
| 626 |
wrote(state, month) |
| 627 |
} |
| 628 |
|
| 629 |
|
| 630 |
fn set_goal_status( |
| 631 |
state: &AppState, |
| 632 |
request: quasi_router::Request, |
| 633 |
) -> Result<Response, RouteError> { |
| 634 |
let month = month_of(&request); |
| 635 |
let id = goal_id(&request)?; |
| 636 |
let status: MonthlyGoalStatus = request |
| 637 |
.payload |
| 638 |
.get("status") |
| 639 |
.ok_or_else(|| RouteError::not_found("no status"))? |
| 640 |
.parse() |
| 641 |
.map_err(|_| RouteError::not_found("not a goal status"))?; |
| 642 |
|
| 643 |
state |
| 644 |
.monthly_reviews |
| 645 |
.update_goal_status(id, DESKTOP_USER_ID, &status) |
| 646 |
.map_err(|error| RouteError::internal(error.to_string()))? |
| 647 |
.ok_or_else(|| RouteError::not_found("no such goal"))?; |
| 648 |
wrote(state, month) |
| 649 |
} |
| 650 |
|
| 651 |
|
| 652 |
fn delete_goal(state: &AppState, request: quasi_router::Request) -> Result<Response, RouteError> { |
| 653 |
let month = month_of(&request); |
| 654 |
let id = goal_id(&request)?; |
| 655 |
|
| 656 |
if !state |
| 657 |
.monthly_reviews |
| 658 |
.delete_goal(id, DESKTOP_USER_ID) |
| 659 |
.map_err(|error| RouteError::internal(error.to_string()))? |
| 660 |
{ |
| 661 |
return Err(RouteError::not_found("no such goal")); |
| 662 |
} |
| 663 |
wrote(state, month) |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
fn complete(state: &AppState, request: quasi_router::Request) -> Result<Response, RouteError> { |
| 672 |
let month = month_of(&request); |
| 673 |
let highlight = request.payload.get("highlight").unwrap_or_default().trim(); |
| 674 |
let change = request.payload.get("change").unwrap_or_default().trim(); |
| 675 |
|
| 676 |
state |
| 677 |
.monthly_reviews |
| 678 |
.upsert_reflection(DESKTOP_USER_ID, &month_key(month), highlight, change) |
| 679 |
.map_err(|error| RouteError::internal(error.to_string()))?; |
| 680 |
Ok(wrote(state, month)?.toast(Tone::Success, "Month reviewed")) |
| 681 |
} |
| 682 |
|
| 683 |
|
| 684 |
#[must_use] |
| 685 |
pub fn routes(router: Router<AppState>) -> Router<AppState> { |
| 686 |
router |
| 687 |
.get("/monthly-review", review) |
| 688 |
.post("/monthly-review/goals", add_goal) |
| 689 |
.post("/monthly-review/goals/{id}/status", set_goal_status) |
| 690 |
.post("/monthly-review/goals/{id}/delete", delete_goal) |
| 691 |
.post("/monthly-review/complete", complete) |
| 692 |
} |
| 693 |
|