diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetSurveyFormUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetSurveyFormUseCase.kt index 4be91f12..424be5de 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetSurveyFormUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/GetSurveyFormUseCase.kt @@ -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) } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/RegisterSurveyUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/RegisterSurveyUseCase.kt index c403f5fb..4e5842b0 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/RegisterSurveyUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/survey/RegisterSurveyUseCase.kt @@ -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 @@ -21,13 +20,11 @@ class RegisterSurveyUseCase @Inject constructor( deadlineTime: LocalTime, ): Result = 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), ) } } diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerScreen.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerScreen.kt index 077c3874..f260d048 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerScreen.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerScreen.kt @@ -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 @@ -48,7 +48,7 @@ internal fun SurveyAnswerScreen( val snackBarHostState = remember { SnackbarHostState() } LaunchedEffect(true) { - viewModel.getSurveyForm(eventId) + viewModel.getSurveyForm(surveyFormId) viewModel.surveyAnswerEvent.collectLatest { when (it) { diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerViewModel.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerViewModel.kt index fea8100f..95a5ea7c 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerViewModel.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/answer/SurveyAnswerViewModel.kt @@ -43,9 +43,9 @@ class SurveyAnswerViewModel @Inject constructor( private val _objectiveAnswer: MutableStateFlow = 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 @@ -91,6 +91,7 @@ class SurveyAnswerViewModel @Inject constructor( viewModelScope.launch { postSurveyUseCase( + surveyFormId = surveyForm.surveyFormId, eventId = surveyForm.eventId, title = surveyForm.title, content = surveyForm.content, diff --git a/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt b/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt index 2a9394f4..0a664274 100644 --- a/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt +++ b/feature/survey/src/main/java/com/wap/wapp/feature/survey/navigation/SurveyNavigation.kt @@ -28,8 +28,8 @@ fun NavGraphBuilder.surveyNavGraph( SurveyScreen( viewModel = hiltViewModel(), navigateToSignIn = navigateToSignIn, - navigateToSurveyAnswer = { eventId -> - navigateToSurveyAnswer(eventId) + navigateToSurveyAnswer = { surveyFormId -> + navigateToSurveyAnswer(surveyFormId) }, ) } @@ -42,12 +42,12 @@ 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, ) } } @@ -55,5 +55,5 @@ fun NavGraphBuilder.surveyNavGraph( object SurveyRoute { const val route: String = "survey" - fun answerRoute(eventId: String): String = "$route/$eventId" + fun answerRoute(surveyFormId: String): String = "$route/$surveyFormId" }