Skip to content

Commit

Permalink
Merge pull request #64 from pknu-wap/feature/jaino/#59
Browse files Browse the repository at this point in the history
Feature/jaino/#59
  • Loading branch information
jeongjaino authored Dec 22, 2023
2 parents 787381e + 9c90d87 commit 0506617
Show file tree
Hide file tree
Showing 34 changed files with 1,043 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.wap.wapp.core.designresource.R.string
import com.wap.wapp.feature.management.navigation.managementNavigationRoute
import com.wap.wapp.feature.notice.navigation.noticeNavigationRoute
import com.wap.wapp.feature.profile.navigation.profileNavigationRoute
import com.wap.wapp.feature.survey.navigation.surveyNavigationRoute
import com.wap.wapp.feature.survey.navigation.SurveyRoute

enum class TopLevelDestination(
val route: String,
Expand All @@ -20,7 +20,7 @@ enum class TopLevelDestination(
labelTextId = string.notice,
),
SURVEY(
route = surveyNavigationRoute,
route = SurveyRoute.route,
iconDrawableId = R.drawable.ic_survey,
labelTextId = string.survey,
),
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import com.wap.wapp.feature.profile.navigation.profileScreen
import com.wap.wapp.feature.profile.profilesetting.navigation.navigateToProfileSetting
import com.wap.wapp.feature.splash.navigation.splashNavigationRoute
import com.wap.wapp.feature.splash.navigation.splashScreen
import com.wap.wapp.feature.survey.navigation.surveyScreen
import com.wap.wapp.feature.survey.navigation.navigateToSurvey
import com.wap.wapp.feature.survey.navigation.navigateToSurveyAnswer
import com.wap.wapp.feature.survey.navigation.surveyNavGraph

@Composable
fun WappNavHost(
Expand Down Expand Up @@ -58,7 +60,10 @@ fun WappNavHost(
navigateToSignIn = { navController.navigateToSignIn() },
)
noticeScreen()
surveyScreen()
surveyNavGraph(
navigateToSurvey = navController::navigateToSurvey ,
navigateToSurveyAnswer = navController::navigateToSurveyAnswer,
)
surveyCheckScreen(
navigateToManagement = { navController.navigateToManagement() },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class ManagementRepositoryImpl @Inject constructor(
override suspend fun postSurveyForm(surveyForm: SurveyForm): Result<Unit> {
return managementDataSource.postSurveyForm(
surveyFormRequest = SurveyFormRequest(
userId = surveyForm.userId,
eventId = surveyForm.eventId,
title = surveyForm.title,
content = surveyForm.content,
surveyQuestion = surveyForm.surveyQuestion,
surveyQuestionList = surveyForm.surveyQuestionList,
deadline = surveyForm.deadline.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME),
),
eventId = surveyForm.eventId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.wap.wapp.core.data.repository.survey

import com.wap.wapp.core.model.survey.Survey
import com.wap.wapp.core.model.survey.SurveyForm

interface SurveyRepository {
suspend fun getSurveyList(): Result<List<Survey>>

suspend fun getSurvey(surveyId: String): Result<Survey>

suspend fun getSurveyFormList(): Result<List<SurveyForm>>

suspend fun getSurveyForm(eventId: Int): Result<SurveyForm>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wap.wapp.core.data.repository.survey

import com.wap.wapp.core.model.survey.Survey
import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.network.source.survey.SurveyDataSource
import com.wap.wapp.core.network.source.user.UserDataSource
import javax.inject.Inject
Expand Down Expand Up @@ -45,4 +46,18 @@ class SurveyRepositoryImpl @Inject constructor(

// TODO 도메인 모델 구현을 위한 익스텐션, notice DataSource 구현 후 소거
private fun String.toDomain(): String = this

override suspend fun getSurveyFormList(): Result<List<SurveyForm>> {
return surveyDataSource.getSurveyFormList().mapCatching { surveyFormResponseList ->
surveyFormResponseList.map { surveyFormResponse ->
surveyFormResponse.toDomain()
}
}
}

override suspend fun getSurveyForm(eventId: Int): Result<SurveyForm> {
return surveyDataSource.getSurveyForm(eventId).mapCatching { surveyFormResponse ->
surveyFormResponse.toDomain()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.wap.designsystem.component

import androidx.annotation.StringRes
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.wap.designsystem.WappTheme

@Composable
Expand Down Expand Up @@ -42,3 +45,33 @@ fun WappTextField(
},
)
}

@Composable
fun WappRoundedTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
@StringRes placeholder: Int,
) {
TextField(
value = value,
onValueChange = onValueChange,
modifier = modifier,
colors = TextFieldDefaults.colors(
focusedTextColor = WappTheme.colors.white,
unfocusedTextColor = WappTheme.colors.white,
focusedContainerColor = WappTheme.colors.black25,
unfocusedContainerColor = WappTheme.colors.black25,
focusedIndicatorColor = WappTheme.colors.black25,
unfocusedIndicatorColor = WappTheme.colors.black25,
cursorColor = WappTheme.colors.yellow34,
),
placeholder = {
androidx.compose.material.Text(
text = stringResource(id = placeholder),
color = WappTheme.colors.gray82,
)
},
shape = RoundedCornerShape(10.dp),
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wap.wapp.core.domain.usecase.management

import com.wap.wapp.core.data.repository.management.ManagementRepository
import com.wap.wapp.core.data.repository.user.UserRepository
import com.wap.wapp.core.model.event.Event
import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.model.survey.SurveyQuestion
Expand All @@ -12,26 +11,22 @@ import javax.inject.Inject

class RegisterSurveyUseCase @Inject constructor(
private val managementRepository: ManagementRepository,
private val userRepository: UserRepository,
) {
suspend operator fun invoke(
event: Event,
title: String,
content: String,
surveyQuestion: List<SurveyQuestion>,
surveyQuestionList: List<SurveyQuestion>,
deadlineDate: LocalDate,
deadlineTime: LocalTime,
): Result<Unit> {
return runCatching {
val userId = userRepository.getUserId().getOrThrow()

managementRepository.postSurveyForm(
SurveyForm(
eventId = event.eventId,
userId = userId,
title = title,
content = content,
surveyQuestion = surveyQuestion,
surveyQuestionList = surveyQuestionList,
deadline = LocalDateTime.of(deadlineDate, deadlineTime),
),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.wap.wapp.core.domain.usecase.survey

import com.wap.wapp.core.data.repository.survey.SurveyRepository
import javax.inject.Inject

class GetSurveyFormListUseCase @Inject constructor(
private val surveyRepository: SurveyRepository,
) {
suspend operator fun invoke() = surveyRepository.getSurveyFormList()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.wap.wapp.core.domain.usecase.survey

import com.wap.wapp.core.data.repository.survey.SurveyRepository
import javax.inject.Inject

class GetSurveyFormUseCase @Inject constructor(
private val surveyRepository: SurveyRepository,
) {
suspend operator fun invoke(eventId: Int) = surveyRepository.getSurveyForm(eventId)
}
19 changes: 15 additions & 4 deletions core/model/src/main/java/com/wap/wapp/core/model/survey/Rating.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ enum class Rating {
GOOD, MEDIOCRE, BAD
}

fun Rating.toNaturalLanguage(): String = when (this) {
Rating.GOOD -> { "좋음" }
Rating.MEDIOCRE -> { "보통" }
Rating.BAD -> { "나쁨" }
data class RatingDescription(
val title: String,
val content: String,
)

fun Rating.toDescription(): RatingDescription = when (this) {
Rating.GOOD -> {
RatingDescription("좋음", "행사 진행이 완벽하고, \n행사 내용이 많았음.")
}
Rating.MEDIOCRE -> {
RatingDescription("보통", "행사 진행이 원활하고, \n행사 내용이 적당함.")
}
Rating.BAD -> {
RatingDescription("나쁨", "행사 진행이 아쉬웠고, \n행사 내용이 부족함.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ import java.time.LocalDateTime
// 운영진이 등록하는 설문 모델
data class SurveyForm(
val eventId: Int,
val userId: String,
val title: String,
val content: String,
val surveyQuestion: List<SurveyQuestion>,
val surveyQuestionList: List<SurveyQuestion>,
val deadline: LocalDateTime,
)
) {
constructor() : this(
-1,
"",
"",
emptyList(),
LocalDateTime.MIN,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ data class EventRequest(
val location: String = "",
val period: String = "",
val time: String = "",
val event_id: Int = 0,
val eventId: Int = 0,
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.wap.wapp.core.network.model.event

import com.google.firebase.firestore.PropertyName
import com.wap.wapp.core.model.event.Event
import java.time.LocalDate
import java.time.format.DateTimeFormatter

data class EventResponse(
val content: String = "",
@PropertyName("event_id") val eventId: Int = 0,
val eventId: Int = 0,
val location: String = "",
val period: String = "",
val title: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package com.wap.wapp.core.network.model.management
import com.wap.wapp.core.model.survey.SurveyQuestion

data class SurveyFormRequest(
val userId: String,
val eventId: Int,
val title: String,
val content: String,
val surveyQuestion: List<SurveyQuestion>,
val surveyQuestionList: List<SurveyQuestion>,
val deadline: String,
) {
constructor() : this(
"",
-1,
"",
"",
emptyList(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.wap.wapp.core.network.model.survey

import com.wap.wapp.core.model.survey.SurveyForm
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

data class SurveyFormResponse(
val eventId: Int,
val userId: String,
val title: String,
val content: String,
val surveyQuestionList: List<SurveyQuestionResponse>,
val deadline: String,
) {
constructor() : this(
-1,
"",
"",
"",
emptyList<SurveyQuestionResponse>(),
"",
)

fun toDomain(): SurveyForm = SurveyForm(
eventId = eventId,
title = title,
content = content,
surveyQuestionList = surveyQuestionList.map { it.toDomain() },
deadline = LocalDateTime.parse(deadline, DateTimeFormatter.ISO_LOCAL_DATE_TIME),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.wap.wapp.core.network.model.survey

import com.wap.wapp.core.model.survey.SurveyQuestion

data class SurveyQuestionResponse(
val questionTitle: String,
val questionType: QuestionTypeResponse,
) {
constructor() : this(
"",
QuestionTypeResponse.SUBJECTIVE,
)
fun toDomain() = SurveyQuestion(
questionTitle = questionTitle,
questionType = questionType.toDomain(),
)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.wap.wapp.core.network.source.survey

import com.wap.wapp.core.network.model.survey.SurveyFormResponse
import com.wap.wapp.core.network.model.survey.SurveyResponse

interface SurveyDataSource {
suspend fun getSurveyList(): Result<List<SurveyResponse>>

suspend fun getSurvey(surveyId: String): Result<SurveyResponse>

suspend fun getSurveyFormList(): Result<List<SurveyFormResponse>>

suspend fun getSurveyForm(eventId: Int): Result<SurveyFormResponse>
}
Loading

0 comments on commit 0506617

Please sign in to comment.