Skip to content

Commit

Permalink
feat(entity/response): Add new hidden field from Entity of Location, …
Browse files Browse the repository at this point in the history
…Refill, Product
  • Loading branch information
flo-ride committed Nov 26, 2024
1 parent 2c7f5e7 commit 0aeafa8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions entity/src/response/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub struct LocationResponse {
/// The timestamp indicating when the location was created.
pub created_at: chrono::DateTime<chrono::Utc>,

/// Indicates whether the location is hidden.
pub hidden: Option<bool>,

/// Indicates whether the location is disabled.
pub disabled: bool,
}
Expand All @@ -58,6 +61,10 @@ impl From<crate::models::location::Model> for LocationResponse {
name: value.name,
category: value.category.map(Into::into),
created_at: value.created_at.into(),
hidden: match value.hidden {
true => Some(true),
false => None,
},
disabled: value.disabled,
}
}
Expand Down
21 changes: 14 additions & 7 deletions entity/src/response/product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ pub struct ProductResponse {
/// Represent the unit type of Product, if it's a liquid -> Liter, etc...
unit: UnitResponse,

/// Is the product purchasable
purchasable: bool,

/// Optional SMA code associated with the product.
sma_code: Option<String>,

Expand All @@ -87,8 +84,14 @@ pub struct ProductResponse {
/// Creation timestamp of the product.
created_at: chrono::DateTime<chrono::Utc>,

/// Optional flag indicating if the product is disabled.
disabled: Option<bool>,
/// Is the product purchasable
purchasable: Option<bool>,

/// Is the product can be seen by simple user
hidden: Option<bool>,

/// indicating if the product is disabled.
disabled: bool,
}

impl TryFrom<crate::models::product::Model> for ProductResponse {
Expand All @@ -115,15 +118,19 @@ impl TryFrom<crate::models::product::Model> for ProductResponse {
),
None => None,
},
purchasable: value.purchasable,
unit: value.unit.into(),
sma_code: value.sma_code,
inventree_code: value.inventree_code,
created_at: value.created_at.into(),
disabled: match value.disabled {
purchasable: match value.purchasable {
true => Some(true),
false => None,
},
hidden: match value.hidden {
true => Some(true),
false => None,
},
disabled: value.disabled,
})
}
}
Expand Down
7 changes: 7 additions & 0 deletions entity/src/response/refill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ pub struct RefillResponse {
/// The timestamp indicating when the refill was created.
pub created_at: chrono::DateTime<chrono::Utc>,

/// Indicates whether the refill is currently hidden.
pub hidden: Option<bool>,

/// Indicates whether the refill is currently disabled.
pub disabled: bool,
}
Expand Down Expand Up @@ -96,6 +99,10 @@ impl TryFrom<crate::models::refill::Model> for RefillResponse {
}
},
credit_currency: value.credit_currency.into(),
hidden: match value.hidden {
true => Some(true),
false => None,
},
disabled: value.disabled,
created_at: value.created_at.into(),
})
Expand Down

0 comments on commit 0aeafa8

Please sign in to comment.