package com.aistudio.bonjuteri.jwlry.model import com.google.firebase.Timestamp import com.google.firebase.firestore.DocumentId import com.google.firebase.firestore.IgnoreExtraProperties import com.google.firebase.firestore.ServerTimestamp enum class UserRole(val displayName: String) { SUPER_ADMIN("Süper Yönetici"), ADMIN("Yönetici"), EDITOR("Editör"), USER("Müşteri"); val isPrivileged: Boolean get() = this == SUPER_ADMIN || this == ADMIN || this == EDITOR val canManageEverything: Boolean get() = this == SUPER_ADMIN || this == ADMIN } @IgnoreExtraProperties data class UserProfile( @DocumentId val id: String = "", val email: String = "", val firstName: String = "", val lastName: String = "", val phone: String = "", val role: String = UserRole.USER.name, @ServerTimestamp val createdAt: Timestamp? = null, @ServerTimestamp val updatedAt: Timestamp? = null ) { val userRole: UserRole get() = try { UserRole.valueOf(role) } catch (_: Exception) { UserRole.USER } val fullName: String get() = listOf(firstName, lastName).filter { it.isNotBlank() }.joinToString(" ").ifBlank { email } }