use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

/// Project member role. Stored as `"owner"`, `"admin"`, or `"member"` in the database.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
pub enum MemberRole {
    Owner,
    Admin,
    Member,
}

impl std::fmt::Display for MemberRole {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            MemberRole::Owner => write!(f, "owner"),
            MemberRole::Admin => write!(f, "admin"),
            MemberRole::Member => write!(f, "member"),
        }
    }
}

impl std::str::FromStr for MemberRole {
    type Err = &'static str;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "owner" => Ok(MemberRole::Owner),
            "admin" => Ok(MemberRole::Admin),
            "member" => Ok(MemberRole::Member),
            _ => Err("unknown member role"),
        }
    }
}

pub use project::Entity as Project;
pub use project_access_log::Entity as ProjectAccessLog;
pub use project_activity::Entity as ProjectActivity;
pub use project_audit_log::Entity as ProjectAuditLog;
pub use project_billing::Entity as ProjectBilling;
pub use project_billing_history::Entity as ProjectBillingHistory;
pub use project_board::Entity as ProjectBoard;
pub use project_board_card::Entity as ProjectBoardCard;
pub use project_board_column::Entity as ProjectBoardColumn;
pub use project_follow::Entity as ProjectFollow;
pub use project_history_name::Entity as ProjectHistoryName;
pub use project_label::Entity as ProjectLabel;
pub use project_skill::{Entity as ProjectSkill, SkillMetadata, SkillSource};
pub mod project_skill;
pub use project_member_invitations::Entity as ProjectMemberInvitations;
pub use project_member_join_answers::Entity as ProjectMemberJoinAnswers;
pub use project_member_join_request::Entity as ProjectMemberJoinRequest;
pub use project_member_join_settings::Entity as ProjectMemberJoinSettings;
pub use project_members::Entity as ProjectMember;
pub use project_watch::Entity as ProjectWatch;

pub mod project;
pub mod project_access_log;
pub mod project_activity;
pub mod project_audit_log;
pub mod project_billing;
pub mod project_billing_history;
pub mod project_board;
pub mod project_board_card;
pub mod project_board_column;
pub mod project_follow;
pub mod project_history_name;
pub mod project_label;
pub mod project_like;
pub mod project_member_invitations;
pub mod project_member_join_answers;
pub mod project_member_join_request;
pub mod project_member_join_settings;
pub mod project_members;
pub mod project_watch;
