Skip to content

Commit

Permalink
[CHORE] #93 : 설문 형식 불러올 때 / EventId -> SurveyFormId로 인자 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Jan 8, 2024
1 parent a6b4a18 commit c4e2146
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import javax.inject.Inject
class GetSurveyFormUseCase @Inject constructor(
private val surveyFormRepository: SurveyFormRepository,
) {
suspend operator fun invoke(eventId: String) = surveyFormRepository.getSurveyForm(eventId)
suspend operator fun invoke(surveyFormId: String) =
surveyFormRepository.getSurveyForm(surveyFormId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.wap.wapp.core.domain.usecase.survey

import com.wap.wapp.core.data.repository.survey.SurveyFormRepository
import com.wap.wapp.core.model.event.Event
import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.model.survey.SurveyQuestion
import java.time.LocalDate
import java.time.LocalDateTime
Expand All @@ -21,13 +20,11 @@ class RegisterSurveyUseCase @Inject constructor(
deadlineTime: LocalTime,
): Result<Unit> = runCatching {
surveyFormRepository.postSurveyForm(
SurveyForm(
eventId = event.eventId,
title = title,
content = content,
surveyQuestionList = surveyQuestionList,
deadline = LocalDateTime.of(deadlineDate, deadlineTime),
),
eventId = event.eventId,
title = title,
content = content,
surveyQuestionList = surveyQuestionList,
deadline = LocalDateTime.of(deadlineDate, deadlineTime),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal fun SurveyAnswerScreen(
viewModel: SurveyAnswerViewModel,
onSubmitButtonClicked: () -> Unit,
onBackButtonClicked: () -> Unit,
eventId: String,
surveyFormId: String,
) {
val surveyFormUiState = viewModel.surveyFormUiState.collectAsStateWithLifecycle().value
val questionNumber = viewModel.questionNumber.collectAsStateWithLifecycle().value
Expand All @@ -48,7 +48,7 @@ internal fun SurveyAnswerScreen(
val snackBarHostState = remember { SnackbarHostState() }

LaunchedEffect(true) {
viewModel.getSurveyForm(eventId)
viewModel.getSurveyForm(surveyFormId)

viewModel.surveyAnswerEvent.collectLatest {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class SurveyAnswerViewModel @Inject constructor(
private val _objectiveAnswer: MutableStateFlow<Rating> = MutableStateFlow(Rating.GOOD)
val objectiveAnswer = _objectiveAnswer.asStateFlow()

fun getSurveyForm(eventId: String) {
fun getSurveyForm(surveyFormId: String) {
viewModelScope.launch {
getSurveyFormUseCase(eventId = eventId)
getSurveyFormUseCase(surveyFormId = surveyFormId)
.onSuccess { surveyForm ->
_surveyFormUiState.value = SurveyFormUiState.Success(surveyForm)
_surveyForm.value = surveyForm
Expand Down Expand Up @@ -91,6 +91,7 @@ class SurveyAnswerViewModel @Inject constructor(

viewModelScope.launch {
postSurveyUseCase(
surveyFormId = surveyForm.surveyFormId,
eventId = surveyForm.eventId,
title = surveyForm.title,
content = surveyForm.content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ fun NavGraphBuilder.surveyNavGraph(
SurveyScreen(
viewModel = hiltViewModel(),
navigateToSignIn = navigateToSignIn,
navigateToSurveyAnswer = { eventId ->
navigateToSurveyAnswer(eventId)
navigateToSurveyAnswer = { surveyFormId ->
navigateToSurveyAnswer(surveyFormId)
},
)
}
Expand All @@ -42,18 +42,18 @@ fun NavGraphBuilder.surveyNavGraph(
},
),
) { navBackStackEntry ->
val eventId = navBackStackEntry.arguments?.getString("id") ?: ""
val surveyFormId = navBackStackEntry.arguments?.getString("id") ?: ""
SurveyAnswerScreen(
viewModel = hiltViewModel(),
onSubmitButtonClicked = navigateToSurvey,
onBackButtonClicked = navigateToSurvey,
eventId = eventId,
surveyFormId = surveyFormId,
)
}
}

object SurveyRoute {
const val route: String = "survey"

fun answerRoute(eventId: String): String = "$route/$eventId"
fun answerRoute(surveyFormId: String): String = "$route/$surveyFormId"
}

0 comments on commit c4e2146

Please sign in to comment.