Skip to content

Commit

Permalink
Display introduction rejection reason
Browse files Browse the repository at this point in the history
  • Loading branch information
Isti01 committed Sep 5, 2024
1 parent 5368366 commit 3723bf3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,21 @@ open class TeamService(
val members = if (teamComponent.showTeamMembersPublicly.isValueTrue() || ownTeam) mapMembers(team, user?.id) else null
val requests = if (user != null && user.role.value >= RoleType.PRIVILEGED.value && ownTeam) mapRequests(team) else null

val introduction = teamIntroductionRepository.findIntroductionsForGroup(team.id)
.firstOrNull { it.approved }
val introductions = teamIntroductionRepository.findIntroductionsForGroup(team.id)
val latestIntro = introductions.firstOrNull { it.approved }
val latestRejectedIntro = introductions.firstOrNull { it.rejected }

// if there is a newer introduction that is rejected than the latest accepted, we should display the reason
val descriptionRejected = (latestRejectedIntro?.creationDate ?: 0) > (latestIntro?.creationDate ?: 0)
val rejectionReason = if (descriptionRejected) latestRejectedIntro?.rejectionReason else null
return TeamView(
id = team.id,
name = team.name,
coverUrl = team.coverImageUrl,
description = introduction?.introduction ?: "",
logo = introduction?.logo ?: "",
description = latestIntro?.introduction ?: "",
descriptionRejected = if (ownTeam) descriptionRejected else false,
descriptionRejectionReason = if (ownTeam) rejectionReason else null,
logo = latestIntro?.logo ?: "",
points = score,
members = members,
applicants = requests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ data class TeamView(
var name: String = "",
val coverUrl: String = "",
val description: String = "",
var descriptionRejected: Boolean,
val descriptionRejectionReason: String?,
val logo: String? = null,
var points: Int? = null,
var members: List<TeamMemberView>? = null,
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/pages/teams/components/TeamDetailsCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ export function TeamDetailsCore({ team, isLoading, error, myTeam = false, refetc
</Box>
</Box>
</Box>
{team.descriptionRejected && (
<Box backgroundImage={team.coverUrl} mt={5} backgroundPosition="center" backgroundSize="cover" borderRadius="lg" overflow="hidden">
<Box p={4} bg={bannerBlanket}>
<Heading fontSize={25} my={0}>
A csapat leírása elutasításra került
</Heading>
<Text>Az adminisztrátor üzenete: {team.descriptionRejectionReason ?? ''}</Text>
</Box>
</Box>
)}
<Flex flex={1} gap={5} justify="space-between" flexDirection={['column', null, 'row']} align="flex-start">
<VStack align="flex-start" w="full">
<Grid mt={5} gridAutoRows="auto" w="full" gridTemplateColumns={['full', 'repeat(2, 1fr)', 'repeat(3, 1fr)']} gap={5}>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/util/views/team.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export enum TeamStatus {
export type TeamView = {
coverUrl: string
description: string
descriptionRejected: boolean
descriptionRejectionReason?: String
leaderNotes: string
points: number
members: TeamMemberView[]
Expand Down

0 comments on commit 3723bf3

Please sign in to comment.