From 6f7237098a21387aed8b802a8439c1d3229b7fee Mon Sep 17 00:00:00 2001 From: Franklin Date: Sun, 16 Oct 2022 19:26:53 -0400 Subject: [PATCH] Added status type --- src/domain/enums/league_player_status.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/domain/enums/league_player_status.rs b/src/domain/enums/league_player_status.rs index 80da788..64c3e1e 100644 --- a/src/domain/enums/league_player_status.rs +++ b/src/domain/enums/league_player_status.rs @@ -49,7 +49,28 @@ impl FromStr for LeaguePlayerStatus { "Left" => Ok(Self::Requested), "Invited" => Ok(Self::Invited), "Canceled" => Ok(Self::Canceled), - _ => Err(Error::Unspecified) //TODO: Create ParseStr error in actix_web_utils + _ => Err(Error::Unspecified), + } + } +} + +pub enum StatusType { + /// Inside a league + Active, + /// Either outside of a league, or attempting to join + Inactive, +} + +impl LeaguePlayerStatus { + pub fn get_status_type(&self) -> StatusType { + match self { + LeaguePlayerStatus::Denied => StatusType::Inactive, + LeaguePlayerStatus::Joined => StatusType::Active, + LeaguePlayerStatus::Requested => StatusType::Inactive, + LeaguePlayerStatus::Kicked => StatusType::Inactive, + LeaguePlayerStatus::Left => StatusType::Inactive, + LeaguePlayerStatus::Invited => StatusType::Inactive, + LeaguePlayerStatus::Canceled => StatusType::Inactive, } } } \ No newline at end of file