Skip to content

Commit

Permalink
Merge branch 'develop' into feature/jaino/#95
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino authored Feb 6, 2024
2 parents dccd38c + 7c41c14 commit b7b9a2e
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 68 deletions.
8 changes: 5 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## 1. 📄 관련된 이슈 및 소개

## 2. 🔥변경된 점
## 2. 🔥 변경된 점

## 3. 📸 스크린샷(선택)
## 3. ✅ 꼭 확인해줬으면 하는 부분

## 4. 💡알게된 혹은 궁금한 사항들
## 4. 📸 스크린샷(선택)

## 5. 💡알게된 혹은 궁금한 사항들
3 changes: 2 additions & 1 deletion .idea/misc.xml

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

4 changes: 3 additions & 1 deletion app/src/main/java/com/wap/wapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.wap.wapp.feature.management.event.navigation.eventRegistrationNavigat
import com.wap.wapp.feature.management.survey.navigation.ManagementSurveyRoute
import com.wap.wapp.feature.profile.profilesetting.navigation.profileSettingNavigationRoute
import com.wap.wapp.feature.splash.navigation.splashNavigationRoute
import com.wap.wapp.feature.survey.navigation.SurveyRoute
import com.wap.wapp.navigation.TopLevelDestination
import com.wap.wapp.navigation.WappNavHost
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -115,8 +116,9 @@ private fun handleBottomBarState(
profileSettingNavigationRoute -> setBottomBarState(false)
attendanceManagementNavigationRoute -> setBottomBarState(false)
ManagementSurveyRoute.surveyFormRegistrationRoute -> setBottomBarState(false)
eventRegistrationNavigationRoute -> setBottomBarState(false)
ManagementSurveyRoute.surveyFormEditRoute("{id}") -> setBottomBarState(false)
eventRegistrationNavigationRoute -> setBottomBarState(false)
SurveyRoute.answerRoute("{id}") ->setBottomBarState(false)
else -> setBottomBarState(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import com.wap.wapp.core.network.constant.EVENT_COLLECTION
import com.wap.wapp.core.network.model.attendancestatus.AttendanceStatusRequest
import com.wap.wapp.core.network.model.attendancestatus.AttendanceStatusResponse
import com.wap.wapp.core.network.utils.await
import com.wap.wapp.core.network.utils.getSeoulDateTimeNow
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import com.wap.wapp.core.network.utils.generateNowDateTime
import com.wap.wapp.core.network.utils.toISOLocalDateTimeString
import javax.inject.Inject

class AttendanceStatusDataSourceImpl @Inject constructor(
Expand All @@ -34,7 +33,7 @@ class AttendanceStatusDataSourceImpl @Inject constructor(
override suspend fun postAttendanceStatus(eventId: String, userId: String): Result<Unit> =
runCatching {
val attendanceStatusRequest =
AttendanceStatusRequest(getSeoulDateTimeNow().toISOLocalDateTimeString())
AttendanceStatusRequest(generateNowDateTime().toISOLocalDateTimeString())

firebaseFirestore.collection(ATTENDANCE_STATUS_COLLECTION)
.document(userId)
Expand All @@ -43,7 +42,4 @@ class AttendanceStatusDataSourceImpl @Inject constructor(
.set(attendanceStatusRequest)
.await()
}

private fun LocalDateTime.toISOLocalDateTimeString(): String =
this.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import com.wap.wapp.core.network.constant.EVENT_COLLECTION
import com.wap.wapp.core.network.model.event.EventRequest
import com.wap.wapp.core.network.model.event.EventResponse
import com.wap.wapp.core.network.utils.await
import com.wap.wapp.core.network.utils.getSeoulDateTimeNow
import com.wap.wapp.core.network.utils.generateNowDateTime
import com.wap.wapp.core.network.utils.toISOLocalDateTimeString
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.format.DateTimeFormatter
import javax.inject.Inject

class EventDataSourceImpl @Inject constructor(
Expand Down Expand Up @@ -38,7 +37,7 @@ class EventDataSourceImpl @Inject constructor(

// 선택된 날짜 1일 00시 00분 00초
val startDateTime = date.atStartOfDay().toISOLocalDateTimeString()
val currentDateTime = getSeoulDateTimeNow().toISOLocalDateTimeString()
val currentDateTime = generateNowDateTime().toISOLocalDateTimeString()
val task = firebaseFirestore.collection(EVENT_COLLECTION)
.whereGreaterThanOrEqualTo("startDateTime", startDateTime)
.whereLessThanOrEqualTo("startDateTime", currentDateTime)
Expand Down Expand Up @@ -167,6 +166,3 @@ class EventDataSourceImpl @Inject constructor(
.await()
}
}

private fun LocalDateTime.toISOLocalDateTimeString(): String =
this.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ internal fun String.toISOLocalDateTime(): LocalDateTime = LocalDateTime.parse(
DateTimeFormatter.ISO_LOCAL_DATE_TIME,
)

internal fun getSeoulDateTimeNow() = LocalDateTime.now(ZoneId.of("Asia/Seoul"))
internal fun LocalDateTime.toISOLocalDateTimeString(): String =
this.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)

internal fun generateNowDateTime(zoneId: ZoneId = ZoneId.of("Asia/Seoul")): LocalDateTime =
LocalDateTime.now(zoneId)
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ class ManagementViewModel @Inject constructor(
private val _eventList: MutableStateFlow<EventsState> = MutableStateFlow(EventsState.Init)
val eventList: StateFlow<EventsState> = _eventList.asStateFlow()

fun getUserRole() {
viewModelScope.launch {
getUserRoleUseCase()
.onSuccess { userRole ->
_userRole.value = UserRoleUiState.Success(userRole)
}
.onFailure { exception ->
_errorFlow.emit(exception)
}
}
fun getUserRole() = viewModelScope.launch {
getUserRoleUseCase()
.onSuccess { userRole ->
_userRole.value = UserRoleUiState.Success(userRole)
}
.onFailure { exception ->
_errorFlow.emit(exception)
}
}

fun getEventSurveyList() = viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.wap.wapp.feature.profile.profilesetting
internal const val PRIVACY_POLICY_URL =
"https://www.notion.so/46beb7c4f3c2417bbec20eafd610d580?pvs=11"
internal const val FAQ_URL = "https://www.notion.so/46beb7c4f3c2417bbec20eafd610d580?pvs=11"
internal const val INQUIRY_URL = "https://www.notion.so/4fcb60f346c041248fd0d97d202a8a9a"
internal const val INQUIRY_URL = "https://forms.gle/DhVoqtEPkLJJrHa28"
internal const val TERMS_AND_POLICIES_URL = "https://www.notion.so/042dc914a6a34093a51658693e009411"
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,6 @@ internal fun ProfileSettingScreen(

Divider(color = dividerColor)

WappRowBar(
title = stringResource(id = string.faq),
onClicked = { navigateToUri(context, FAQ_URL) },
)

Divider(color = dividerColor)

WappRowBar(
title = stringResource(id = string.terms_and_policies),
onClicked = { navigateToUri(context, TERMS_AND_POLICIES_URL) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,23 @@ internal fun SurveyAnswerForm(
}
}

val isFirstQuestion = questionNumber > 0
val isGreaterThanFirstQuestion = questionNumber > 0
val isLastQuestion = questionNumber == lastQuestionNumber // 마지막 응답일 경우, 완료로 변경
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
WappButton(
textRes = R.string.previous,
onClick = onPreviousQuestionButtonClicked,
isEnabled = isFirstQuestion,
isEnabled = isGreaterThanFirstQuestion,
modifier = Modifier.weight(1f),
)

SurveyAnswerButton(
isLastQuestion = isLastQuestion,
onButtonClicked = onNextQuestionButtonClicked,
isEnabled = isButtonEnabled(surveyQuestion.questionType, subjectiveAnswer),
isEnabled = checkQuestionTypeAndSubjectiveAnswer(
questionType = surveyQuestion.questionType,
subjectiveAnswer = subjectiveAnswer,
),
modifier = Modifier.weight(1f),
)
}
Expand All @@ -79,8 +82,8 @@ internal fun SurveyAnswerForm(
@Composable
private fun SurveyAnswerButton(
isLastQuestion: Boolean,
onButtonClicked: () -> Unit,
isEnabled: Boolean,
onButtonClicked: () -> Unit,
modifier: Modifier,
) {
if (isLastQuestion) {
Expand All @@ -100,11 +103,12 @@ private fun SurveyAnswerButton(
}
}

private fun isButtonEnabled(
private fun checkQuestionTypeAndSubjectiveAnswer(
questionType: QuestionType,
subjectiveAnswer: String,
): Boolean {
if (questionType == QuestionType.SUBJECTIVE) return subjectiveAnswer.length >= 10

return true
if (questionType == QuestionType.OBJECTIVE) {
return true
}
return subjectiveAnswer.length >= 10
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal fun SurveyAnswerScreen(
},
onNextQuestionButtonClicked = {
if (questionNumber < surveyAnswerList.size) { // 작성한 답변을 수정하는 경우
viewModel.modifySurveyAnswer()
viewModel.editSurveyAnswer()
} else {
viewModel.addSurveyAnswer()
}
Expand All @@ -102,9 +102,15 @@ internal fun SurveyAnswerScreen(
return@SurveyAnswerContent
}

viewModel.setNextQuestionNumber() // 다음 질문 불러오기
viewModel.setNextQuestionAndAnswer() // 다음 질문 불러오기
},
onPreviousQuestionButtonClicked = {
// 응답의 갯수가 질문의 갯수보다 작은 경우
if (questionNumber >= surveyAnswerList.size) {
viewModel.addSurveyAnswer()
}
viewModel.setPreviousQuestionAndAnswer()
},
onPreviousQuestionButtonClicked = { viewModel.setPreviousQuestion() },
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@ class SurveyAnswerViewModel @Inject constructor(
}
}

private fun getEvent() {
viewModelScope.launch {
getEventUseCase(eventId = _surveyForm.value.eventId)
.onSuccess { event ->
_eventName.value = event.title
}
.onFailure { throwable ->
_surveyAnswerEvent.emit(SurveyAnswerUiEvent.Failure(throwable))
}
}
private fun getEvent() = viewModelScope.launch {
getEventUseCase(eventId = _surveyForm.value.eventId)
.onSuccess { event ->
_eventName.value = event.title
}
.onFailure { throwable ->
_surveyAnswerEvent.emit(SurveyAnswerUiEvent.Failure(throwable))
}
}

fun addSurveyAnswer() {
Expand Down Expand Up @@ -110,7 +108,7 @@ class SurveyAnswerViewModel @Inject constructor(
}
}

fun modifySurveyAnswer() {
fun editSurveyAnswer() {
val questionNumber = _questionNumber.value
val surveyQuestion = _surveyForm.value.surveyQuestionList[questionNumber]
val surveyAnswerList = _surveyAnswerList.value
Expand Down Expand Up @@ -159,20 +157,27 @@ class SurveyAnswerViewModel @Inject constructor(

fun setObjectiveAnswer(answer: Rating) { _objectiveAnswer.value = answer }

fun setNextQuestionNumber() { _questionNumber.value += 1 }
fun setNextQuestionAndAnswer() {
_questionNumber.value += 1
if (_questionNumber.value < _surveyAnswerList.value.size) { // 다음 질문이 아미 작성된 질문인 경우
setSurveyAnswer()
}
}

fun setPreviousQuestion() {
val questionNumber = --_questionNumber.value
fun setPreviousQuestionAndAnswer() {
_questionNumber.value -= 1
setSurveyAnswer()
}

// 이전 질문 정보 불러오기
val previousQuestion = _surveyAnswerList.value[questionNumber]
when (previousQuestion.questionType) {
private fun setSurveyAnswer() {
val surveyAnswer = _surveyAnswerList.value[_questionNumber.value]
when (surveyAnswer.questionType) {
QuestionType.SUBJECTIVE -> {
setSubjectiveAnswer(previousQuestion.questionAnswer)
setSubjectiveAnswer(surveyAnswer.questionAnswer)
}

QuestionType.OBJECTIVE -> {
when (previousQuestion.questionAnswer) {
when (surveyAnswer.questionAnswer) {
"GOOD" -> setObjectiveAnswer(Rating.GOOD)
"MEDIOCRE" -> setObjectiveAnswer(Rating.MEDIOCRE)
"BAD" -> setObjectiveAnswer(Rating.BAD)
Expand Down

0 comments on commit b7b9a2e

Please sign in to comment.