Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] 자체 QA - 코스 등록 + 일정 등록 (Enroll) 뷰 #212

Merged
merged 4 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading