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

import kotlinx.serialization.Serializable

@Serializable
data class PredefinedActivityDto(
    val id: Int,
    val name: String? = null,
    val code: String? = null,
    val description: String? = null,
    val duration: Int? = null,
    val durationText: String? = null,
    val imageLink: String? = null,
    @Serializable(with = FlexibleNullableDrawingDataSerializer::class)
    val drawingData: String? = null,
    val excludeFromStats: Boolean? = null,
)

@Serializable
data class PredefinedActivityUpsertBody(
    val name: String? = null,
    val code: String? = null,
    val description: String? = null,
    val duration: Int? = null,
    val durationText: String? = null,
    val imageLink: String? = null,
    val drawingData: String? = null,
    val excludeFromStats: Boolean? = null,
)

fun PredefinedActivityDto.displayLabel(): String {
    val n = name?.trim().orEmpty()
    if (n.isNotEmpty()) return n
    val c = code?.trim().orEmpty()
    if (c.isNotEmpty()) return c
    return "Übung $id"
}
