Skip to content

Commit

Permalink
Merge pull request #212 from TeamDATEROAD/chore-enroll
Browse files Browse the repository at this point in the history
[chore] 자체 QA - 코스 등록 + 일정 등록 (Enroll) 뷰
  • Loading branch information
jihyunniiii authored Aug 28, 2024
2 parents 0fd6b17 + 37e41f7 commit bd09c3f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -190,7 +192,7 @@ fun EnrollRoute(
EnrollScreenType.FIRST -> {
when (enrollType) {
EnrollType.COURSE -> enroll.images.isNotEmpty() && titleValidateState == TextFieldValidateResult.Success && dateValidateState == TextFieldValidateResult.Success && enroll.startAt.isNotEmpty() && enroll.tags.isNotEmpty() && enroll.country != null && enroll.city != null
EnrollType.TIMELINE -> titleValidateState == TextFieldValidateResult.Success && enroll.startAt.isNotEmpty() && enroll.tags.isNotEmpty() && enroll.country != null && enroll.city != null
EnrollType.TIMELINE -> titleValidateState == TextFieldValidateResult.Success && enroll.date.isNotEmpty() && enroll.startAt.isNotEmpty() && enroll.tags.isNotEmpty() && enroll.country != null && enroll.city != null
}
}

Expand Down Expand Up @@ -274,19 +276,22 @@ fun EnrollScreen(
leftIconResource = R.drawable.ic_top_bar_back_white,
onLeftIconClick = onTopBarBackButtonClick,
buttonContent = {
DateRoadFilledButton(
isEnabled = true,
textContent = stringResource(id = R.string.top_bar_button_text_load),
onClick = onTopBarLoadButtonClick,
textStyle = DateRoadTheme.typography.bodyMed13,
enabledBackgroundColor = DateRoadTheme.colors.purple600,
enabledTextColor = DateRoadTheme.colors.white,
disabledBackgroundColor = DateRoadTheme.colors.gray200,
disabledTextColor = DateRoadTheme.colors.gray400,
cornerRadius = 20.dp,
paddingHorizontal = 10.dp,
paddingVertical = 5.dp
)
Row {
DateRoadFilledButton(
isEnabled = true,
textContent = stringResource(id = R.string.top_bar_button_text_load),
onClick = onTopBarLoadButtonClick,
textStyle = DateRoadTheme.typography.bodyMed13,
enabledBackgroundColor = DateRoadTheme.colors.purple600,
enabledTextColor = DateRoadTheme.colors.white,
disabledBackgroundColor = DateRoadTheme.colors.gray200,
disabledTextColor = DateRoadTheme.colors.gray400,
cornerRadius = 20.dp,
paddingHorizontal = 10.dp,
paddingVertical = 5.dp
)
Spacer(modifier = Modifier.width(16.dp))
}
}
)
Spacer(modifier = Modifier.height(2.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.launch
import org.sopt.dateroad.data.dataremote.util.Date.NEAREST_DATE_START_OUTPUT_FORMAT
import org.sopt.dateroad.data.mapper.toEntity.toEnroll
import org.sopt.dateroad.domain.type.RegionType
import org.sopt.dateroad.domain.usecase.GetCourseDetailUseCase
Expand Down Expand Up @@ -45,6 +46,7 @@ class EnrollViewModel @Inject constructor(
}
}
}

is EnrollContract.EnrollEvent.OnEnrollButtonClick -> {
when (currentState.enrollType) {
EnrollType.COURSE -> {
Expand Down Expand Up @@ -120,7 +122,7 @@ class EnrollViewModel @Inject constructor(
viewModelScope.launch {
setEvent(EnrollContract.EnrollEvent.FetchCourseDetail(fetchEnrollState = LoadState.Loading, courseDetail = null))
getCourseDetailUseCase(courseId = courseId).onSuccess { courseDetail ->
setEvent(EnrollContract.EnrollEvent.FetchCourseDetail(fetchEnrollState = LoadState.Success, courseDetail = courseDetail))
setEvent(EnrollContract.EnrollEvent.FetchCourseDetail(fetchEnrollState = LoadState.Success, courseDetail = courseDetail.copy(startAt = courseDetail.startAt.substringBefore(NEAREST_DATE_START_OUTPUT_FORMAT))))
}
setEvent(EnrollContract.EnrollEvent.FetchCourseDetail(fetchEnrollState = LoadState.Error, courseDetail = null))
}
Expand All @@ -130,7 +132,7 @@ class EnrollViewModel @Inject constructor(
viewModelScope.launch {
setEvent(EnrollContract.EnrollEvent.FetchTimelineDetail(fetchEnrollState = LoadState.Loading, timelineDetail = null))
getTimelineDetailUseCase(timelineId = timelineId).onSuccess { timelineDetail ->
setEvent(EnrollContract.EnrollEvent.FetchTimelineDetail(fetchEnrollState = LoadState.Success, timelineDetail = timelineDetail))
setEvent(EnrollContract.EnrollEvent.FetchTimelineDetail(fetchEnrollState = LoadState.Success, timelineDetail = timelineDetail.copy(startAt = timelineDetail.startAt.substringBefore(NEAREST_DATE_START_OUTPUT_FORMAT))))
}.onFailure {
setEvent(EnrollContract.EnrollEvent.FetchTimelineDetail(fetchEnrollState = LoadState.Error, timelineDetail = null))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ProfileViewModel @Inject constructor(
setEvent(ProfileContract.ProfileEvent.PatchEditProfile(editProfileLoadState = LoadState.Loading))
patchEditProfileUseCase(editProfile = editProfile).onSuccess {
setEvent(ProfileContract.ProfileEvent.PatchEditProfile(editProfileLoadState = LoadState.Success))
}.onFailure { error ->
}.onFailure {
setEvent(ProfileContract.ProfileEvent.PatchEditProfile(editProfileLoadState = LoadState.Error))
}
}
Expand Down

0 comments on commit bd09c3f

Please sign in to comment.