Skip to content

Commit

Permalink
Add ChallengeStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Nov 8, 2023
1 parent 220b898 commit b9b8a84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ data class Challenge(
val finishDate: LocalDate,
@SerialName("current_interval")
val currentInterval: Int?
)
) {
val status: ChallengeStatus?
get() = ChallengeStatus.getByValue(statusValue)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.hyperskill.app.challenges.domain.model

enum class ChallengeStatus(val value: String) {
NOT_STARTED("not started"),
STARTED("started"),
NOT_COMPLETED("not completed"),
PARTIAL_COMPLETED("partial completed"),
COMPLETED("completed");

companion object {
private val VALUES: Array<ChallengeStatus> = values()

fun getByValue(value: String): ChallengeStatus? =
VALUES.firstOrNull { it.value == value }
}
}

0 comments on commit b9b8a84

Please sign in to comment.