diff --git a/src/domain/project_condition/mod.rs b/src/domain/project_condition/mod.rs index 4d10527..2c0895d 100644 --- a/src/domain/project_condition/mod.rs +++ b/src/domain/project_condition/mod.rs @@ -28,6 +28,8 @@ impl FromStr for ProjectCondition { fn from_str(s: &str) -> Result { match s { + "Nuevo" => Ok(Self::New), + "Reventa" => Ok(Self::Resale), _ => Err(Error::Parsing), } } diff --git a/src/dto/filters.rs b/src/dto/filters.rs index 1f2461a..6f724c2 100644 --- a/src/dto/filters.rs +++ b/src/dto/filters.rs @@ -11,3 +11,15 @@ pub enum Filter { ByProjectType(ProjectType), ByProjectCondition(ProjectCondition), } + +impl Filter { + pub fn to_param(self) -> (String, String) { + match self { + Filter::InCity(city) => (String::from("incity"), city), + Filter::InDistrict(district) => (String::from("indistrict"), district), + Filter::Finished => (String::from("finished"), String::from("a")), + Filter::ByProjectType(project_type) => (String::from("byprojecttype"), project_type.to_string()), + Filter::ByProjectCondition(project_condition) => (String::from("byprojectcondition"), project_condition.to_string()), + } + } +} \ No newline at end of file diff --git a/src/dto/listing.rs b/src/dto/listing.rs new file mode 100644 index 0000000..40be237 --- /dev/null +++ b/src/dto/listing.rs @@ -0,0 +1,18 @@ +use serde::{Deserialize, Serialize}; + +use crate::domain::{project::Project, unit::Unit, location::Location, agent::Agent}; + + +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, PartialOrd)] +pub struct Listing { + pub project: Project, + pub units: Vec, + pub location: Location, + pub agent: Agent, +} + +impl Listing { + pub fn new(project: Project, units: Vec, location: Location, agent: Agent) -> Self { + Self { project, units, location, agent } + } +} \ No newline at end of file diff --git a/src/dto/mod.rs b/src/dto/mod.rs index 943d4c4..5f2ec9c 100644 --- a/src/dto/mod.rs +++ b/src/dto/mod.rs @@ -1,2 +1,4 @@ pub mod filters; pub mod payloads; +pub mod listing; +pub mod project_card; \ No newline at end of file diff --git a/src/dto/payloads/unit.rs b/src/dto/payloads/unit.rs index 8a3f56d..81801ed 100644 --- a/src/dto/payloads/unit.rs +++ b/src/dto/payloads/unit.rs @@ -26,6 +26,7 @@ pub struct NewUnitPayload { #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, PartialOrd)] pub struct UpdateUnitPayload { + pub id: Uuid, /// Let the client convert from usd to whatever currency #[serde(rename = "priceUsd")] pub price_usd: Option, diff --git a/src/dto/project_card.rs b/src/dto/project_card.rs new file mode 100644 index 0000000..e7332da --- /dev/null +++ b/src/dto/project_card.rs @@ -0,0 +1,22 @@ +use chrono::NaiveDateTime; +use serde::{Serialize, Deserialize}; +use uuid::Uuid; + +use crate::domain::{project_state::ProjectState, project_type::ProjectType, project_condition::ProjectCondition, media::MediaList}; + +/// A Dto with everything included in the card of the project list views in the frontend app. +#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub struct ProjectCardDto { + pub id: Uuid, + #[serde(rename = "projectState")] + pub project_state: Option, + #[serde(rename = "projectType")] + pub project_type: Option, + #[serde(rename = "projectCondition")] + pub project_condition: Option, + pub city: String, + pub district: String, + #[serde(rename = "finishDate")] + pub finish_date: NaiveDateTime, + pub media: Option, +} \ No newline at end of file