From 82589a4d4df4da172cdddffd9b9a114627499412 Mon Sep 17 00:00:00 2001 From: Franklin Date: Sun, 23 Apr 2023 11:07:15 -0400 Subject: [PATCH] Changed filters and added item for s3 image upload requests on backend --- src/domain/project_state/mod.rs | 8 ++++---- src/dto/filters.rs | 2 ++ src/dto/item.rs | 9 +++++++++ src/dto/mod.rs | 3 ++- src/dto/payloads/agent.rs | 8 ++++++++ 5 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 src/dto/item.rs diff --git a/src/domain/project_state/mod.rs b/src/domain/project_state/mod.rs index d60fddb..6c15378 100644 --- a/src/domain/project_state/mod.rs +++ b/src/domain/project_state/mod.rs @@ -16,8 +16,8 @@ pub enum ProjectState { impl Display for ProjectState { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - ProjectState::Finished => write!(f, "Finished"), - ProjectState::InConstruction => write!(f, "InConstruction"), + ProjectState::Finished => write!(f, "Terminado"), + ProjectState::InConstruction => write!(f, "En Construcción"), } } } @@ -27,8 +27,8 @@ impl FromStr for ProjectState { fn from_str(s: &str) -> Result { match s { - "Finished" => Ok(Self::Finished), - "InConstruction" => Ok(Self::InConstruction), + "Terminado" => Ok(Self::Finished), + "En Construcción" => Ok(Self::InConstruction), _ => Err(Error::Parsing), } } diff --git a/src/dto/filters.rs b/src/dto/filters.rs index 9467ff3..97672cf 100644 --- a/src/dto/filters.rs +++ b/src/dto/filters.rs @@ -8,6 +8,7 @@ pub enum Filter { InDistrict(String), Finished, + InConstruction, ByProjectType(ProjectType), ByProjectCondition(ProjectCondition), ByRoomCount(i32), @@ -19,6 +20,7 @@ impl Filter { Filter::InCity(city) => (String::from("incity"), city), Filter::InDistrict(district) => (String::from("indistrict"), district), Filter::Finished => (String::from("finished"), String::from("true")), + Filter::InConstruction => (String::from("inconstruction"), String::from("true")), Filter::ByProjectType(project_type) => (String::from("byprojecttype"), project_type.to_string()), Filter::ByProjectCondition(project_condition) => (String::from("byprojectcondition"), project_condition.to_string()), Filter::ByRoomCount(room_count) => (String::from("byroomcount"), room_count.to_string()), diff --git a/src/dto/item.rs b/src/dto/item.rs new file mode 100644 index 0000000..918c419 --- /dev/null +++ b/src/dto/item.rs @@ -0,0 +1,9 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Default)] +pub enum Item { + #[default] + Project, + Unit, + Agent, +} \ No newline at end of file diff --git a/src/dto/mod.rs b/src/dto/mod.rs index 5f2ec9c..d91646f 100644 --- a/src/dto/mod.rs +++ b/src/dto/mod.rs @@ -1,4 +1,5 @@ pub mod filters; pub mod payloads; pub mod listing; -pub mod project_card; \ No newline at end of file +pub mod project_card; +pub mod item; \ No newline at end of file diff --git a/src/dto/payloads/agent.rs b/src/dto/payloads/agent.rs index 7a07555..36bd21c 100644 --- a/src/dto/payloads/agent.rs +++ b/src/dto/payloads/agent.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + use chrono::Utc; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -63,3 +65,9 @@ impl UpdateAgentPayload { persisted_agent.last_updated = Utc::now(); } } + +impl Display for Agent { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.full_name) + } +} \ No newline at end of file