package de.tsschulz.tt_tagebuch.shared.api.models

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject

@Serializable
data class PendingUserDto(
    val id: Int = 0,
    val email: String = "",
    val firstName: String? = null,
    val lastName: String? = null,
)

@Serializable
data class PendingUserClubJoinDto(
    val id: Int? = null,
    val userId: Int = 0,
    val clubId: Int? = null,
    val user: PendingUserDto? = null,
)

@Serializable
data class ClubAccessDecisionBody(
    val clubid: Int,
    val userid: Int,
)

@Serializable
data class AvailableRoleDto(
    val value: String,
    val label: String,
    val description: String = "",
)

@Serializable
data class PermissionResourceDto(
    val label: String = "",
    val actions: List<String> = emptyList(),
)

@Serializable
data class PermissionUserRefDto(
    val id: Int = 0,
    val email: String = "",
)

@Serializable
data class ClubPermissionMemberDto(
    val userId: Int,
    val user: PermissionUserRefDto? = null,
    val role: String = "",
    val isOwner: Boolean = false,
    val approved: Boolean? = true,
    val permissions: JsonObject? = null,
    val effectivePermissions: JsonObject? = null,
)

@Serializable
data class UpdateUserRoleBody(
    val role: String,
)

@Serializable
data class UpdateUserApprovedBody(
    val approved: Boolean,
)

@Serializable
data class UpdateUserCustomPermissionsBody(
    val permissions: JsonObject,
)

@Serializable
data class ApiLogListRowDto(
    val id: Int,
    val userId: Int? = null,
    val method: String? = null,
    val path: String? = null,
    val statusCode: Int? = null,
    val executionTime: Int? = null,
    val errorMessage: String? = null,
    val logType: String? = null,
    val schedulerJobType: String? = null,
    val createdAt: String? = null,
)

@Serializable
data class ApiLogsListPageDto(
    val logs: List<ApiLogListRowDto> = emptyList(),
    val total: Int = 0,
    val limit: Int = 0,
    val offset: Int = 0,
)

@Serializable
data class ApiLogsListEnvelopeDto(
    val success: Boolean = false,
    val data: ApiLogsListPageDto? = null,
)

@Serializable
data class ApiLogDetailEnvelopeDto(
    val success: Boolean = false,
    val data: ApiLogDetailDto? = null,
)

@Serializable
data class ApiLogDetailDto(
    val id: Int = 0,
    val userId: Int? = null,
    val method: String? = null,
    val path: String? = null,
    val statusCode: Int? = null,
    val executionTime: Int? = null,
    val errorMessage: String? = null,
    val logType: String? = null,
    val schedulerJobType: String? = null,
    val createdAt: String? = null,
    val ipAddress: String? = null,
    val userAgent: String? = null,
)
