bugfixing
This commit is contained in:
Binary file not shown.
@@ -39,7 +39,7 @@ data class SpielplanResponse(
|
||||
data class SeasonDto(val slug: String = "", val label: String = "")
|
||||
data class MannschaftenSeasonsResponse(
|
||||
val success: Boolean = false,
|
||||
val seasons: List<SeasonDto> = emptyList(),
|
||||
val seasons: List<String> = emptyList(),
|
||||
val currentSeason: String = "",
|
||||
val defaultSeason: String = "",
|
||||
)
|
||||
|
||||
@@ -278,6 +278,7 @@ fun NavGraph(
|
||||
de.harheimertc.ui.screens.memberarea.MemberAreaScreen(
|
||||
navController = navController,
|
||||
showBackNavigation = !persistentNavigation,
|
||||
navigationState = navigationState,
|
||||
)
|
||||
}
|
||||
composable(Destinations.Members.route) {
|
||||
|
||||
@@ -65,7 +65,7 @@ class NavigationViewModel @Inject constructor(
|
||||
teams = teams.await(),
|
||||
hasGalleryImages = gallery.await(),
|
||||
loggedIn = hasStoredSession || status.isLoggedIn,
|
||||
roles = (status.roles + status.user?.roles.orEmpty()).toSet(),
|
||||
roles = status.navigationRoles(),
|
||||
connectionNote = null,
|
||||
)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class NavigationViewModel @Inject constructor(
|
||||
val hasStoredSession = !authRepository.getToken().isNullOrBlank()
|
||||
_state.value = _state.value.copy(
|
||||
loggedIn = hasStoredSession || status.isLoggedIn,
|
||||
roles = (status.roles + status.user?.roles.orEmpty()).toSet(),
|
||||
roles = status.navigationRoles(),
|
||||
connectionNote = _state.value.connectionNote,
|
||||
)
|
||||
}
|
||||
@@ -95,3 +95,9 @@ class NavigationViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun de.harheimertc.data.AuthStatusResponse.navigationRoles(): Set<String> = buildSet {
|
||||
addAll(roles)
|
||||
role?.takeIf { it.isNotBlank() }?.let(::add)
|
||||
addAll(user?.roles.orEmpty())
|
||||
}
|
||||
|
||||
@@ -56,10 +56,17 @@ class MannschaftenViewModel @Inject constructor(
|
||||
repository.fetchSeasons()
|
||||
.onSuccess { response ->
|
||||
val currentSeason = getCurrentSeasonSlug()
|
||||
val seasons = response.seasons.ifEmpty { listOf(SeasonDto(slug = response.currentSeason.ifBlank { currentSeason }, label = formatSeasonLabel(response.currentSeason.ifBlank { currentSeason }))) }
|
||||
val seasons = response.seasons
|
||||
.map { season -> SeasonDto(slug = season, label = formatSeasonLabel(season)) }
|
||||
.ifEmpty {
|
||||
val fallbackSeason = response.currentSeason.ifBlank { currentSeason }
|
||||
listOf(SeasonDto(slug = fallbackSeason, label = formatSeasonLabel(fallbackSeason)))
|
||||
}
|
||||
val serverCurrentSeason = response.currentSeason.ifBlank { currentSeason }
|
||||
val selectedSeason = when {
|
||||
response.defaultSeason.isNotBlank() -> response.defaultSeason
|
||||
seasons.any { it.slug == currentSeason } -> currentSeason
|
||||
seasons.any { it.slug == serverCurrentSeason } -> serverCurrentSeason
|
||||
response.defaultSeason.isNotBlank() -> response.defaultSeason
|
||||
seasons.isNotEmpty() -> seasons.first().slug
|
||||
else -> currentSeason
|
||||
}
|
||||
|
||||
@@ -26,9 +26,11 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.navigation.NavController
|
||||
import de.harheimertc.BuildConfig
|
||||
import de.harheimertc.data.BirthdayDto
|
||||
import de.harheimertc.ui.components.LoadingState
|
||||
import de.harheimertc.ui.navigation.Destinations
|
||||
import de.harheimertc.ui.navigation.NavigationUiState
|
||||
import de.harheimertc.ui.theme.Accent100
|
||||
import de.harheimertc.ui.theme.Accent500
|
||||
import de.harheimertc.ui.theme.Accent700
|
||||
@@ -40,6 +42,7 @@ import de.harheimertc.ui.theme.Primary600
|
||||
fun MemberAreaScreen(
|
||||
navController: NavController,
|
||||
showBackNavigation: Boolean,
|
||||
navigationState: NavigationUiState = NavigationUiState(),
|
||||
viewModel: MemberAreaViewModel = hiltViewModel(),
|
||||
) {
|
||||
val state by viewModel.state.collectAsState()
|
||||
@@ -63,6 +66,12 @@ fun MemberAreaScreen(
|
||||
MemberAreaCardGrid(navController)
|
||||
}
|
||||
|
||||
if (navigationState.isAdmin) {
|
||||
item {
|
||||
ServerInfoCard()
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
BirthdayCard(
|
||||
birthdays = state.birthdays,
|
||||
@@ -74,6 +83,16 @@ fun MemberAreaScreen(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ServerInfoCard() {
|
||||
Surface(color = Primary100, shape = RoundedCornerShape(14.dp), shadowElevation = 2.dp) {
|
||||
Column(Modifier.fillMaxWidth().padding(18.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text("Serververbindung", style = MaterialTheme.typography.titleLarge, color = Accent900)
|
||||
Text(BuildConfig.API_BASE_URL.trimEnd('/'), color = Primary600, fontWeight = FontWeight.SemiBold)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MemberAreaCardGrid(navController: NavController) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
|
||||
Reference in New Issue
Block a user