Skip to content
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 @@ -17,4 +17,6 @@ data class RegisterRoutineRequest(
val executionTime: String,
@SerialName("subRoutineName")
val subRoutineName: List<String>,
@SerialName("recommendedRoutineType")
val recommendedRoutineType: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class WriteRoutineRepositoryImpl @Inject constructor(
startDate: Date,
endDate: Date,
subRoutines: List<String>,
recommendedRoutineType: String?,
): Result<Unit> {
val request = RegisterRoutineRequest(
routineName = name,
Expand All @@ -32,6 +33,7 @@ class WriteRoutineRepositoryImpl @Inject constructor(
routineStartDate = startDate.toFormattedString(),
routineEndDate = endDate.toFormattedString(),
subRoutineName = subRoutines,
recommendedRoutineType = recommendedRoutineType,
)
return writeRoutineDataSource.registerRoutine(request).also {
if (it.isSuccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface WriteRoutineRepository {
startDate: Date,
endDate: Date,
subRoutines: List<String>,
recommendedRoutineType: String?,
): Result<Unit>

suspend fun editRoutine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RegisterRoutineUseCase @Inject constructor(
startDate: Date,
endDate: Date,
subRoutines: List<String>,
recommendedRoutineType: String?,
): Result<Unit> {
return writeRoutineRepository.registerRoutine(
name = name,
Expand All @@ -24,6 +25,7 @@ class RegisterRoutineUseCase @Inject constructor(
startDate = startDate,
endDate = endDate,
subRoutines = subRoutines,
recommendedRoutineType = recommendedRoutineType,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
),
startDate = Date.fromString(routine.startDate),
endDate = Date.fromString(routine.endDate),
recommendedRoutineType = null,
),
)
},
Expand Down Expand Up @@ -121,6 +122,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
),
startDate = Date.now(),
endDate = Date.now(),
recommendedRoutineType = routine.recommendedRoutineType.categoryName,
),
)
},
Expand All @@ -134,7 +136,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
override suspend fun SimpleSyntax<WriteRoutineState, WriteRoutineSideEffect>.reduceState(
intent: WriteRoutineIntent,
state: WriteRoutineState,
): WriteRoutineState {
): WriteRoutineState? {
when (intent) {
WriteRoutineIntent.SelectAllTime -> {
return state.copy(
Expand Down Expand Up @@ -221,9 +223,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
WriteRoutineIntent.RegisterRoutineSuccess -> {
sendSideEffect(WriteRoutineSideEffect.MoveToPreviousScreen)

return state.copy(
loading = false,
)
return null
}
WriteRoutineIntent.RegisterRoutineLoading -> {
return state.copy(
Expand Down Expand Up @@ -254,6 +254,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
endDate = intent.endDate,
subRoutineNames = intent.subRoutines,
loading = false,
recommendedRoutineType = intent.recommendedRoutineType,
)
}

Expand Down Expand Up @@ -449,6 +450,8 @@ class WriteRoutineViewModel @AssistedInject constructor(
viewModelScope.launch {
val currentState = stateFlow.value

if (currentState.loading) return@launch

val startTime = currentState.startTime ?: return@launch

val repeatDay = when (currentState.repeatType) {
Expand Down Expand Up @@ -483,6 +486,7 @@ class WriteRoutineViewModel @AssistedInject constructor(
startDate = if (noRepeatRoutine) Date.now().toDomainDate() else currentState.startDate.toDomainDate(),
endDate = if (noRepeatRoutine) Date.now().toDomainDate() else currentState.endDate.toDomainDate(),
subRoutines = subRoutines,
recommendedRoutineType = currentState.recommendedRoutineType,
)

if (registerRoutineResult.isSuccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sealed class WriteRoutineIntent : MviIntent {
val subRoutines: List<String>,
val startDate: Date,
val endDate: Date,
val recommendedRoutineType: String?,
) : WriteRoutineIntent()
data object SelectAllTime : WriteRoutineIntent()
data object ShowTimePickerBottomSheet : WriteRoutineIntent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ data class WriteRoutineState(
val repeatDaysUiExpanded: Boolean,
val periodUiExpanded: Boolean,
val startTimeUiExpanded: Boolean,
val recommendedRoutineType: String?,
) : MviState {
companion object {
val Init = WriteRoutineState(
Expand Down Expand Up @@ -79,6 +80,7 @@ data class WriteRoutineState(
startTimeUiExpanded = false,
startDate = Date.now(),
endDate = Date.now(),
recommendedRoutineType = null,
)
}

Expand Down