package com.prodhack.moscow2025.data.data_providers.local_db.entities

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.prodhack.moscow2025.domain.models.User

@Entity(tableName = "users")
data class UserEntity(
	@PrimaryKey(autoGenerate = false)
	val id: String,
	val email: String,
	@ColumnInfo(name = "first_name")
	val firstName: String?,
	@ColumnInfo(name = "last_name")
	val lastName: String?,
	@ColumnInfo(name = "display_name")
	val displayName: String?,
	@ColumnInfo(name = "avatar_url")
	val avatarUrl: String?,
	val phone: String?
) {
	fun mapToDomain(): User {
		return User(
			id = id,
			firstName = firstName,
			lastName = lastName,
			displayName = displayName,
			email = email,
			avatarUrl = avatarUrl,
			phone = phone
		)
	}
}

fun User.mapToDB(): UserEntity = UserEntity(
	id = id,
	firstName = firstName,
	lastName = lastName,
	displayName = displayName,
	phone = phone,
	email = email,
	avatarUrl = avatarUrl
)