Skip to content

Commit

Permalink
feat: finish description implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-pitblado committed Nov 6, 2024
1 parent 2987f2c commit a92eaa2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub async fn create_new_task(
instance_url: &str,
api_key: &str,
task_title: &str,
description: Option<&str>,
priority: Option<u8>,
) -> Result<(), Box<dyn Error>> {
let client = Client::new();
Expand All @@ -58,6 +59,10 @@ pub async fn create_new_task(
"title": task_title
});

if let Some(desc) = description {
task_data["description"] = json!(desc);
}

if let Some(priority_value) = priority {
task_data["priority"] = json!(priority_value);
}
Expand Down
3 changes: 1 addition & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,13 @@ impl App {
match key.code {
KeyCode::Enter => {
if !self.new_task_title.trim().is_empty() {
// Use the parser to extract the task title, priority, and label titles
let parsed_task = parse_task_input(&self.new_task_title);

// Create the new task with the parsed title, priority, and labels
if let Err(err) = create_new_task(
instance_url,
api_key,
&parsed_task.title,
parsed_task.description.as_deref(),
parsed_task.priority,
)
.await
Expand Down

0 comments on commit a92eaa2

Please sign in to comment.